]> git.cworth.org Git - glaze/commitdiff
Use "gcc --print-multiarch" to determine directory names for library installs
authorCarl Worth <cworth@cworth.org>
Thu, 22 Aug 2013 00:28:49 +0000 (17:28 -0700)
committerCarl Worth <cworth@cworth.org>
Thu, 22 Aug 2013 00:32:13 +0000 (17:32 -0700)
Previously, we had hardcoded names of lib32 and lib64. Instead, we now
ask gcc for the actual triple being targeted, (such as, for example,
lib/i386-linux-gnu or lib/x86_64-linux-gnu).

Using these correct names means that the user of Glaze can put a
literal $LIB into LD_PRELOAD or LD_LIBRARY_PATH and the run-time
linker will expand that to the correct name based on the architecture
of the program being linked

.gitignore
Makefile
configure

index 4b1f0179ec7bbf40bbaf5e1450b33a9b382b026e..7a82f8e22766693b467e55de2c02addc14e5f21b 100644 (file)
@@ -1,6 +1,5 @@
 glaze.pc
 glaze.pc
-lib32
-lib64
+lib
 libglaze.so*
 Makefile.config
 *~
 libglaze.so*
 Makefile.config
 *~
index f13fa877014873e702595377520cf90bd714c649..147dcd5416988c9b26fa89363fce214261680d5f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -27,11 +27,11 @@ LIBGLAZE_LIBNAME = $(LIBGLAZE_SONAME).$(MINOR).$(RELEASE)
 TARGETS = $(LIBGLAZE_LIBNAME)
 
 ifeq ($(COMPILER_SUPPORTS_32),Yes)
 TARGETS = $(LIBGLAZE_LIBNAME)
 
 ifeq ($(COMPILER_SUPPORTS_32),Yes)
-TARGETS += lib32/libGL.so.1
+TARGETS += $(LIB32_DIR)/libGL.so.1
 endif
 
 ifeq ($(COMPILER_SUPPORTS_64),Yes)
 endif
 
 ifeq ($(COMPILER_SUPPORTS_64),Yes)
-TARGETS += lib64/libGL.so.1
+TARGETS += $(LIB64_DIR)/libGL.so.1
 endif
 
 all: $(TARGETS)
 endif
 
 all: $(TARGETS)
@@ -41,20 +41,20 @@ GLAZE_CFLAGS = $(CFLAGS) $(WARN_CFLAGS)
 $(LIBGLAZE_LIBNAME): glaze.c
        $(CC) $(GLAZE_CFLAGS) -fPIC -shared -Wl,-Bsymbolic,-soname=$(LIBGLAZE_SONAME) -ldl -o $@ $<
 
 $(LIBGLAZE_LIBNAME): glaze.c
        $(CC) $(GLAZE_CFLAGS) -fPIC -shared -Wl,-Bsymbolic,-soname=$(LIBGLAZE_SONAME) -ldl -o $@ $<
 
-lib64/libGL.so.1: glaze-gl.c glapi.def
-       mkdir -p lib64
+$(LIB64_DIR)/libGL.so.1: glaze-gl.c glapi.def
+       mkdir -p $(LIB64_DIR)
        $(CC) $(GLAZE_CFLAGS) -m64 -fPIC -shared -Wl,-Bsymbolic -o $@ $<
 
        $(CC) $(GLAZE_CFLAGS) -m64 -fPIC -shared -Wl,-Bsymbolic -o $@ $<
 
-lib32/libGL.so.1: glaze-gl.c specs/gl.def
-       mkdir -p lib32
+$(LIB32_DIR)/libGL.so.1: glaze-gl.c specs/gl.def
+       mkdir -p $(LIB32_DIR)
        $(CC) $(GLAZE_CFLAGS) -m32 -fPIC -shared -Wl,-Bsymbolic -o $@ $<
 
 .PHONY: install
 install: all
        $(CC) $(GLAZE_CFLAGS) -m32 -fPIC -shared -Wl,-Bsymbolic -o $@ $<
 
 .PHONY: install
 install: all
-       mkdir -p $(DESTDIR)$(LIBDIR)/glaze/lib64
-       install -m0644 lib64/libGL.so.1 $(DESTDIR)$(LIBDIR)/glaze/lib64
-       mkdir -p $(DESTDIR)$(LIBDIR)/glaze/lib32
-       install -m0644 lib32/libGL.so.1 $(DESTDIR)$(LIBDIR)/glaze/lib32
+       mkdir -p $(DESTDIR)$(LIBDIR)/glaze/$(LIB64_DIR)
+       install -m0644 $(LIB64_DIR)/libGL.so.1 $(DESTDIR)$(LIBDIR)/glaze/$(LIB64_DIR)
+       mkdir -p $(DESTDIR)$(LIBDIR)/glaze/$(LIB32_DIR)
+       install -m0644 $(LIB32_DIR)/libGL.so.1 $(DESTDIR)$(LIBDIR)/glaze/$(LIB32_DIR)
        install -m0644 $(LIBGLAZE_LIBNAME) $(DESTDIR)$(LIBDIR)
        ln -sf $(LIBGLAZE_LIBNAME) $(DESTDIR)$(LIBDIR)/$(LIBGLAZE_SONAME)
        ln -sf $(LIBGLAZE_LIBNAME) $(DESTDIR)$(LIBDIR)/$(LIBGLAZE_LINKER_NAME)
        install -m0644 $(LIBGLAZE_LIBNAME) $(DESTDIR)$(LIBDIR)
        ln -sf $(LIBGLAZE_LIBNAME) $(DESTDIR)$(LIBDIR)/$(LIBGLAZE_SONAME)
        ln -sf $(LIBGLAZE_LIBNAME) $(DESTDIR)$(LIBDIR)/$(LIBGLAZE_LINKER_NAME)
index d115790d56296b6d99f9d732b525f226cf6c04fa..d25e22a4b3820951164753053d173fb93e92860e 100755 (executable)
--- a/configure
+++ b/configure
@@ -176,6 +176,12 @@ have_m32=Yes
 if ${CC} -m32 -o arch-minimal arch-minimal.c > /dev/null 2>&1
 then
     printf "Yes.\n"
 if ${CC} -m32 -o arch-minimal arch-minimal.c > /dev/null 2>&1
 then
     printf "Yes.\n"
+
+    printf "   Target directory for 32-bit targets... "
+
+    lib32_dir=$(gcc -m32 --print-multiarch)
+    printf "${lib32_dir}\n"
+
 else
     printf "No.\n"
     have_m32=No
 else
     printf "No.\n"
     have_m32=No
@@ -186,6 +192,12 @@ have_m64=Yes
 if ${CC} -m64 -o arch-minimal arch-minimal.c > /dev/null 2>&1
 then
     printf "Yes.\n"
 if ${CC} -m64 -o arch-minimal arch-minimal.c > /dev/null 2>&1
 then
     printf "Yes.\n"
+
+    printf "   Target directory for 64-bit targets... "
+
+    lib64_dir=$(gcc -m64 --print-multiarch)
+    printf "${lib64_dir}\n"
+
 else
     printf "No.\n"
     have_m64=No
 else
     printf "No.\n"
     have_m64=No
@@ -261,7 +273,9 @@ INCLUDEDIR = ${INCLUDEDIR:-\$(PREFIX)/include}
 
 # Whether compiler can create 32 or 64-bit binaries
 COMPILER_SUPPORTS_32 = ${have_m32}
 
 # Whether compiler can create 32 or 64-bit binaries
 COMPILER_SUPPORTS_32 = ${have_m32}
+LIB32_DIR = lib/${lib32_dir}
 COMPILER_SUPPORTS_64 = ${have_m64}
 COMPILER_SUPPORTS_64 = ${have_m64}
+LIB64_DIR = lib/${lib64_dir}
 
 # Version information for glaze library
 MAJOR   = ${MAJOR}
 
 # Version information for glaze library
 MAJOR   = ${MAJOR}