Make versioned shared library suffix configurable

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).
This commit is contained in:
Mike Hommey 2012-04-18 18:29:40 +02:00 committed by Jason Evans
parent 78f7352259
commit 85221d5d75
3 changed files with 18 additions and 8 deletions

View File

@ -47,6 +47,7 @@ cfgoutputs_out := @cfgoutputs_out@
enable_autogen := @enable_autogen@ enable_autogen := @enable_autogen@
enable_experimental := @enable_experimental@ enable_experimental := @enable_experimental@
DSO_LDFLAGS = @DSO_LDFLAGS@ DSO_LDFLAGS = @DSO_LDFLAGS@
SOREV = @SOREV@
ifeq (macho, $(ABI)) ifeq (macho, $(ABI))
TEST_LIBRARY_PATH := DYLD_FALLBACK_LIBRARY_PATH=$(objroot)lib TEST_LIBRARY_PATH := DYLD_FALLBACK_LIBRARY_PATH=$(objroot)lib
@ -72,9 +73,11 @@ ifeq (macho, $(ABI))
CSRCS += $(srcroot)src/zone.c CSRCS += $(srcroot)src/zone.c
endif endif
STATIC_LIBS := $(objroot)lib/$(LIBJEMALLOC).$(A) STATIC_LIBS := $(objroot)lib/$(LIBJEMALLOC).$(A)
DSOS := $(objroot)lib/$(LIBJEMALLOC).$(SO).$(REV) \ DSOS := $(objroot)lib/$(LIBJEMALLOC)_pic.$(A) \
$(objroot)lib/$(LIBJEMALLOC).$(SO) \ $(objroot)lib/$(LIBJEMALLOC).$(SOREV)
$(objroot)lib/$(LIBJEMALLOC)_pic.$(A) ifneq ($(SOREV),$(SO))
DSOS += $(objroot)lib/$(LIBJEMALLOC).$(SO)
endif
MAN3 := $(objroot)doc/jemalloc$(install_suffix).3 MAN3 := $(objroot)doc/jemalloc$(install_suffix).3
DOCS_XML := $(objroot)doc/jemalloc$(install_suffix).xml DOCS_XML := $(objroot)doc/jemalloc$(install_suffix).xml
DOCS_HTML := $(DOCS_XML:$(objroot)%.xml=$(srcroot)%.html) 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) $(CFLAGS) -fPIC -DPIC -c $(CPPFLAGS) -o $@ $<
@$(CC) -MM $(CPPFLAGS) -MT $@ -o $(@:%.$(O)=%.d) $< @$(CC) -MM $(CPPFLAGS) -MT $@ -o $(@:%.$(O)=%.d) $<
%.$(SO) : %.$(SO).$(REV) ifneq ($(SOREV),$(SO))
%.$(SO) : %.$(SOREV)
@mkdir -p $(@D) @mkdir -p $(@D)
ln -sf $(<F) $@ 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) @mkdir -p $(@D)
$(CC) $(DSO_LDFLAGS) $(call RPATH,$(RPATH_EXTRA)) -o $@ $+ $(LDFLAGS) $(LIBS) $(CC) $(DSO_LDFLAGS) $(call RPATH,$(RPATH_EXTRA)) -o $@ $+ $(LDFLAGS) $(LIBS)
@ -175,8 +180,10 @@ done
install_lib_shared: $(DSOS) install_lib_shared: $(DSOS)
install -d $(LIBDIR) install -d $(LIBDIR)
install -m 755 $(objroot)lib/$(LIBJEMALLOC).$(SO).$(REV) $(LIBDIR) install -m 755 $(objroot)lib/$(LIBJEMALLOC).$(SOREV) $(LIBDIR)
ln -sf $(LIBJEMALLOC).$(SO).$(REV) $(LIBDIR)/$(LIBJEMALLOC).$(SO) ifneq ($(SOREV),$(SO))
ln -sf $(LIBJEMALLOC).$(SOREV) $(LIBDIR)/$(LIBJEMALLOC).$(SO)
endif
install_lib_static: $(DSOS) $(STATIC_LIBS) install_lib_static: $(DSOS) $(STATIC_LIBS)
install -d $(LIBDIR) install -d $(LIBDIR)

View File

@ -4,6 +4,6 @@ prefix=@prefix@
exec_prefix=@exec_prefix@ exec_prefix=@exec_prefix@
libdir=@libdir@ libdir=@libdir@
@LD_PRELOAD_VAR@=${libdir}/libjemalloc.@so@.@rev@ @LD_PRELOAD_VAR@=${libdir}/libjemalloc.@SOREV@
export @LD_PRELOAD_VAR@ export @LD_PRELOAD_VAR@
exec "$@" exec "$@"

View File

@ -201,6 +201,7 @@ exe=
lib="lib" lib="lib"
DSO_LDFLAGS='-shared -Wl,-soname,$(@F)' DSO_LDFLAGS='-shared -Wl,-soname,$(@F)'
RPATH='-Wl,-rpath,$(1)' RPATH='-Wl,-rpath,$(1)'
SOREV='$(SO).$(REV)'
dnl Heap profiling uses the log(3) function. dnl Heap profiling uses the log(3) function.
LIBS="$LIBS -lm" LIBS="$LIBS -lm"
@ -223,6 +224,7 @@ case "${host}" in
so="dylib" so="dylib"
force_tls="0" force_tls="0"
DSO_LDFLAGS='-shared -Wl,-dylib_install_name,$(@F)' DSO_LDFLAGS='-shared -Wl,-dylib_install_name,$(@F)'
SOREV='$(REV).$(SO)'
;; ;;
*-*-freebsd*) *-*-freebsd*)
CFLAGS="$CFLAGS" CFLAGS="$CFLAGS"
@ -284,6 +286,7 @@ AC_SUBST([a])
AC_SUBST([exe]) AC_SUBST([exe])
AC_SUBST([lib]) AC_SUBST([lib])
AC_SUBST([DSO_LDFLAGS]) AC_SUBST([DSO_LDFLAGS])
AC_SUBST([SOREV])
JE_COMPILABLE([__attribute__ syntax], JE_COMPILABLE([__attribute__ syntax],
[static __attribute__((unused)) void foo(void){}], [static __attribute__((unused)) void foo(void){}],