From 553d330d06573b6bc951e3c00672a1abfe29b7aa Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 21 Aug 2013 17:28:49 -0700 Subject: [PATCH] Use "gcc --print-multiarch" to determine directory names for library installs 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 | 3 +-- Makefile | 20 ++++++++++---------- configure | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 4b1f017..7a82f8e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ glaze.pc -lib32 -lib64 +lib libglaze.so* Makefile.config *~ diff --git a/Makefile b/Makefile index f13fa87..147dcd5 100644 --- a/Makefile +++ b/Makefile @@ -27,11 +27,11 @@ LIBGLAZE_LIBNAME = $(LIBGLAZE_SONAME).$(MINOR).$(RELEASE) 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) -TARGETS += lib64/libGL.so.1 +TARGETS += $(LIB64_DIR)/libGL.so.1 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 $@ $< -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 $@ $< -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 - 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) diff --git a/configure b/configure index d115790..d25e22a 100755 --- 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" + + printf " Target directory for 32-bit targets... " + + lib32_dir=$(gcc -m32 --print-multiarch) + printf "${lib32_dir}\n" + 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" + + printf " Target directory for 64-bit targets... " + + lib64_dir=$(gcc -m64 --print-multiarch) + printf "${lib64_dir}\n" + 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} +LIB32_DIR = lib/${lib32_dir} COMPILER_SUPPORTS_64 = ${have_m64} +LIB64_DIR = lib/${lib64_dir} # Version information for glaze library MAJOR = ${MAJOR} -- 2.43.0