r25877: Add libreplace macro for soname flags.
authorJelmer Vernooij <jelmer@samba.org>
Tue, 6 Nov 2007 15:23:18 +0000 (16:23 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 21 Dec 2007 04:44:36 +0000 (05:44 +0100)
source/build/m4/check_ld.m4
source/lib/ldb/Makefile.in
source/lib/ldb/configure.ac
source/lib/replace/libreplace_ld.m4

index de80394b083bdf2ebc4fbe4e5066f58ae161fd36..15af978dc97e36281cdf7fab99be0f238526b528 100644 (file)
@@ -19,7 +19,6 @@ AC_SUBST(LD)
 AC_SUBST(LDFLAGS)
 AC_SUBST(SHLD)
 AC_SUBST(SHLD_UNDEF_FLAGS)
-AC_SUBST(SONAMEFLAG)
 
 # Assume non-shared by default and override below
 # these are the defaults, good for lots of systems
@@ -28,7 +27,6 @@ STLD_FLAGS="-rcs"
 BLDSHARED="false"
 LD="${CC}"
 SHLD="${CC}"
-SONAMEFLAG=""
 PICFLAG=""
 
 # allow for --with-hostld=gcc
@@ -50,13 +48,10 @@ case "$host_os" in
                BLDSHARED="true"
                SHLD_UNDEF_FLAGS="-Wl,--allow-shlib-undefined"
                LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
-               SONAMEFLAG="-Wl,-soname="
                ;;
        *solaris*)
                BLDSHARED="true"
-               SONAMEFLAG="-h "
                if test "${GCC}" = "yes"; then
-                       SONAMEFLAG="-Wl,-soname="
                        if test "${ac_cv_prog_gnu_ld}" = "yes"; then
                                LDFLAGS="$LDFLAGS -Wl,-E"
                        fi
@@ -64,21 +59,17 @@ case "$host_os" in
                ;;
        *sunos*)
                BLDSHARED="true"
-               SONAMEFLAG="-Wl,-h,"
                ;;
        *netbsd* | *freebsd* | *dragonfly* )  
                BLDSHARED="true"
                LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
-               SONAMEFLAG="-Wl,-soname,"
                ;;
        *openbsd*)
                BLDSHARED="true"
                LDFLAGS="$LDFLAGS -Wl,-Bdynamic"
-               SONAMEFLAG="-Wl,-soname,"
                ;;
        *irix*)
                BLDSHARED="true"
-               SONAMEFLAG="-soname "
                SHLD="${PROG_LD}"
                ;;
        *aix*)
@@ -88,8 +79,6 @@ case "$host_os" in
        *hpux*)
                # Use special PIC flags for the native HP-UX compiler.
                if test $ac_cv_prog_cc_Ae = yes; then
-                       SONAMEFLAG="-Wl,+h "
-               elif test "${GCC}" = "yes"; then
                fi
                BLDSHARED="true" # I hope this is correct
                if test "$host_cpu" = "ia64"; then
@@ -100,11 +89,9 @@ case "$host_os" in
                ;;
        *osf*)
                BLDSHARED="true"
-               SONAMEFLAG="-Wl,-soname,"
                ;;
        *unixware*)
                BLDSHARED="true"
-               SONAMEFLAG="-Wl,-soname,"
                ;;
        *darwin*)
                BLDSHARED="true"
@@ -129,6 +116,7 @@ AC_LD_PICFLAG
 AC_LD_EXPORT_DYNAMIC
 AC_LD_SHLDFLAGS
 AC_LD_SHLIBEXT
+AC_LD_SONAMEFLAG
 
 AC_ARG_ENABLE(shared,
 [  --disable-shared        Disable testing for building shared libraries],
index a1f89fe626a1e0d77dca3d4261bc58feb0f143a0..5deb9b3b9078b9d90c037468f72f79c369bcd651 100644 (file)
@@ -35,6 +35,7 @@ LDAP_LIBS = @LDAP_LIBS@
 LIBDL = @LIBDL@
 
 SHLIBEXT = @SHLIBEXT@
+SONAMEFLAG = @SONAMEFLAG@
 
 LD_EXPORT_DYNAMIC = @LD_EXPORT_DYNAMIC@
 SHLD_FLAGS = @SHLD_FLAGS@
@@ -47,7 +48,7 @@ CFLAGS=-g -I$(srcdir)/include -Iinclude -I$(srcdir) -I$(srcdir)/.. \
        $(POPT_CFLAGS) $(TALLOC_CFLAGS) $(TDB_CFLAGS) \
        -DLIBDIR=\"$(libdir)\" -DSHLIBEXT=\"$(SHLIBEXT)\" -DUSE_MMAP=1 @CFLAGS@
 
-LIB_FLAGS=$(LDFLAGS) -Llib -lldb $(LIBS) $(POPT_LIBS) $(TALLOC_LIBS) \
+LIB_FLAGS=$(LDFLAGS) -Llib $(SOLIB) $(LIBS) $(POPT_LIBS) $(TALLOC_LIBS) \
                  $(TDB_LIBS) $(LDAP_LIBS) $(LIBDL)
 
 LDB_TDB_DIR=ldb_tdb
@@ -80,7 +81,7 @@ LDB_LIB = lib/libldb.a
 
 BINS = bin/ldbadd bin/ldbsearch bin/ldbdel bin/ldbmodify bin/ldbedit bin/ldbrename bin/ldbtest bin/oLschema2ldif
 
-LIBS = $(LDB_LIB)
+LIBS = $(SOLIB)
 
 EXAMPLES = examples/ldbreader examples/ldifreader
 
@@ -93,7 +94,13 @@ nss: nssdir all $(NSS_LIB)
 nssdir:
        @mkdir -p $(NSSDIR)
 
-all: showflags dirs $(OBJS) $(LDB_LIB) $(BINS) $(EXAMPLES) manpages
+SONAME = libldb.so.0
+SOLIB = lib/libldb.so.0.9.0
+
+$(SOLIB): $(OBJS)
+       $(CC) $(SHLD_FLAGS) $(SONAMEFLAG)$(SONAME) -o $@ $^ @LDFLAGS@ @LIBS@ $(TALLOC_LIBS) $(TDB_LIBS)
+
+all: showflags dirs $(OBJS) $(LDB_LIB) $(SOLIB) $(BINS) $(EXAMPLES) manpages
 
 showflags:
        @echo 'ldb will be compiled with flags:'
@@ -105,6 +112,11 @@ showflags:
        @mkdir -p `dirname $@`
        @$(CC) $(CFLAGS) $(PICFLAG) -c $< -o $@
 
+.c.po:
+       @echo Compiling $*.c
+       @mkdir -p `dirname $@`
+       @$(CC) -fPIC $(CFLAGS) -c $< -o $@
+
 dirs:
        @mkdir -p $(DIRS)
 
@@ -148,7 +160,7 @@ examples/ldbreader: examples/ldbreader.o $(LIBS)
 examples/ldifreader: examples/ldifreader.o $(LIBS)
        $(CC) -o examples/ldifreader examples/ldifreader.o $(LIB_FLAGS)
 
-.SUFFIXES: .1 .1.xml .3 .3.xml .xml .html
+.SUFFIXES: .1 .1.xml .3 .3.xml .xml .html .c .o
 
 manpages:
        @$(srcdir)/docs/builddocs.sh "$(XSLTPROC)" "$(srcdir)"
@@ -190,7 +202,7 @@ installcheck: install test
 install: all
        mkdir -p $(DESTDIR)$(includedir) $(DESTDIR)$(libdir)/pkgconfig $(DESTDIR)$(libdir) $(bindir)
        cp $(srcdir)/include/ldb.h $(srcdir)/include/ldb_errors.h $(DESTDIR)$(includedir)
-       cp $(LDB_LIB) $(DESTDIR)$(libdir)
+       cp $(LDB_LIB) $(SOLIB) $(DESTDIR)$(libdir)
        cp $(BINS) $(DESTDIR)$(bindir)
        cp ldb.pc $(DESTDIR)$(libdir)/pkgconfig
        $(srcdir)/docs/installdocs.sh $(DESTDIR)$(mandir)
index ff100bb2e07691b24759d1e5a77088b837691535..bf7b5b05a98412106cd4eb1ea632d44702ae8147 100644 (file)
@@ -71,6 +71,7 @@ AC_LD_EXPORT_DYNAMIC
 AC_LD_PICFLAG
 AC_LD_SHLDFLAGS
 AC_LD_SHLIBEXT
+AC_LD_SONAMEFLAG
 
 m4_include(libldb.m4)
 AC_OUTPUT(Makefile ldb.pc)
index 183c302aaea8ddbf8d1cf7db4781570f1f8f0227..c276a7a86455b521ce5c8c6bb05f9c43e002bb58 100644 (file)
@@ -125,3 +125,44 @@ AC_DEFUN([AC_LD_SHLIBEXT],
        esac
        AC_SUBST(SHLIBEXT)
 ])
+
+AC_DEFUN([AC_LD_SONAMEFLAG],
+[
+       AC_SUBST(SONAMEFLAG)
+       SONAMEFLAG=""
+       case "$host_os" in 
+               *linux*)
+                       SONAMEFLAG="-Wl,-soname="
+                       ;;
+               *solaris*)
+                       SONAMEFLAG="-h "
+                       if test "${GCC}" = "yes"; then
+                               SONAMEFLAG="-Wl,-soname="
+                       fi
+                       ;;
+               *sunos*)
+                       SONAMEFLAG="-Wl,-h,"
+                       ;;
+               *netbsd* | *freebsd* | *dragonfly* )
+                       SONAMEFLAG="-Wl,-soname,"
+                       ;;
+               *openbsd*)
+                       SONAMEFLAG="-Wl,-soname,"
+                       ;;
+               *irix*)
+                       SONAMEFLAG="-soname "
+                       ;;
+               *hpux*)
+                       SONAMEFLAG="-Wl,+h "
+                       ;;
+               *osf*)
+                       SONAMEFLAG="-Wl,-soname,"
+                       ;;
+               *unixware*)
+                       SONAMEFLAG="-Wl,-soname,"
+                       ;;
+               *darwin*)
+                       SONAMEFLAG="-Wl,-soname,"
+                       ;;
+               esac
+])