[PATCH] Make versioned shared library suffix configurable
Mike Hommey
mh+jemalloc at glandium.org
Mon Apr 16 23:58:49 PDT 2012
From: Mike Hommey <mh at glandium.org>
This allows for different patterns for file names:
- lib.so.version for e.g. Linux
- lib.version.dylib for OSX (which is much more common than
lib.dylib.version)
- lib.dll for Windows (no version at all).
---
Makefile.in | 21 ++++++++++++++-------
bin/jemalloc.sh.in | 2 +-
configure.ac | 3 +++
3 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index 0dfddea..d426cbd 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -47,6 +47,7 @@ cfgoutputs_out := @cfgoutputs_out@
enable_autogen := @enable_autogen@
enable_experimental := @enable_experimental@
DSO_LDFLAGS = @DSO_LDFLAGS@
+SOREV = @SOREV@
ifeq (macho, $(ABI))
TEST_LIBRARY_PATH := DYLD_FALLBACK_LIBRARY_PATH=$(objroot)lib
@@ -72,9 +73,11 @@ ifeq (macho, $(ABI))
CSRCS += $(srcroot)src/zone.c
endif
STATIC_LIBS := $(objroot)lib/$(LIBJEMALLOC).$(A)
-DSOS := $(objroot)lib/$(LIBJEMALLOC).$(SO).$(REV) \
- $(objroot)lib/$(LIBJEMALLOC).$(SO) \
- $(objroot)lib/$(LIBJEMALLOC)_pic.$(A)
+DSOS := $(objroot)lib/$(LIBJEMALLOC)_pic.$(A) \
+ $(objroot)lib/$(LIBJEMALLOC).$(SOREV)
+ifneq ($(SOREV),$(SO))
+DSOS += $(objroot)lib/$(LIBJEMALLOC).$(SO)
+endif
MAN3 := $(objroot)doc/jemalloc$(install_suffix).3
DOCS_XML := $(objroot)doc/jemalloc$(install_suffix).xml
DOCS_HTML := $(DOCS_XML:$(objroot)%.xml=$(srcroot)%.html)
@@ -127,11 +130,13 @@ $(objroot)src/%.pic.$(O): $(srcroot)src/%.c
$(CC) $(CFLAGS) -fPIC -DPIC -c $(CPPFLAGS) -o $@ $<
@$(CC) -MM $(CPPFLAGS) -MT $@ -o $(@:%.$(O)=%.d) $<
-%.$(SO) : %.$(SO).$(REV)
+ifneq ($(SOREV),$(SO))
+%.$(SO) : %.$(SOREV)
@mkdir -p $(@D)
ln -sf $(<F) $@
+endif
-$(objroot)lib/$(LIBJEMALLOC).$(SO).$(REV) : $(CSRCS:$(srcroot)%.c=$(objroot)%.pic.$(O))
+$(objroot)lib/$(LIBJEMALLOC).$(SOREV) : $(CSRCS:$(srcroot)%.c=$(objroot)%.pic.$(O))
@mkdir -p $(@D)
$(CC) $(DSO_LDFLAGS) $(call RPATH,$(RPATH_EXTRA)) -o $@ $+ $(LDFLAGS) $(LIBS)
@@ -175,8 +180,10 @@ done
install_lib_shared: $(DSOS)
install -d $(LIBDIR)
- install -m 755 $(objroot)lib/$(LIBJEMALLOC).$(SO).$(REV) $(LIBDIR)
- ln -sf $(LIBJEMALLOC).$(SO).$(REV) $(LIBDIR)/$(LIBJEMALLOC).$(SO)
+ install -m 755 $(objroot)lib/$(LIBJEMALLOC).$(SOREV) $(LIBDIR)
+ifneq ($(SOREV),$(SO))
+ ln -sf $(LIBJEMALLOC).$(SOREV) $(LIBDIR)/$(LIBJEMALLOC).$(SO)
+endif
install_lib_static: $(DSOS) $(STATIC_LIBS)
install -d $(LIBDIR)
diff --git a/bin/jemalloc.sh.in b/bin/jemalloc.sh.in
index 56cdfaf..cdf3673 100644
--- a/bin/jemalloc.sh.in
+++ b/bin/jemalloc.sh.in
@@ -4,6 +4,6 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
- at LD_PRELOAD_VAR@=${libdir}/libjemalloc. at so@. at rev@
+ at LD_PRELOAD_VAR@=${libdir}/libjemalloc. at SOREV@
export @LD_PRELOAD_VAR@
exec "$@"
diff --git a/configure.ac b/configure.ac
index 3a7a245..0f78c61 100644
--- a/configure.ac
+++ b/configure.ac
@@ -201,6 +201,7 @@ exe=
lib="lib"
DSO_LDFLAGS='-shared -Wl,-soname,$(@F)'
RPATH='-Wl,-rpath,$(1)'
+SOREV='$(SO).$(REV)'
dnl Heap profiling uses the log(3) function.
LIBS="$LIBS -lm"
@@ -223,6 +224,7 @@ case "${host}" in
so="dylib"
force_tls="0"
DSO_LDFLAGS='-shared -Wl,-dylib_install_name,$(@F)'
+ SOREV='$(REV).$(SO)'
;;
*-*-freebsd*)
CFLAGS="$CFLAGS"
@@ -284,6 +286,7 @@ AC_SUBST([a])
AC_SUBST([exe])
AC_SUBST([lib])
AC_SUBST([DSO_LDFLAGS])
+AC_SUBST([SOREV])
JE_COMPILABLE([__attribute__ syntax],
[static __attribute__((unused)) void foo(void){}],
--
1.7.10
More information about the jemalloc-discuss
mailing list