Fix standalone builds adjusting to new relative path.
authorSimo Sorce <idra@samba.org>
Fri, 19 Sep 2008 19:12:28 +0000 (15:12 -0400)
committerSimo Sorce <idra@samba.org>
Fri, 19 Sep 2008 22:06:46 +0000 (18:06 -0400)
Add shared-build target to libreplace.
Useful to build multiple standalone libraries that depend on each other
without having to install them to the final install dir during the build.

lib/replace/Makefile.in
lib/replace/build_macros.m4 [new file with mode: 0644]
lib/replace/configure.ac
lib/replace/libreplace.m4
lib/replace/test/testsuite.c

index c989835a8d37b29cee7e63451be470f2a4dd6194..c889a0e45793c3198ceeef024706c339d6afb8d5 100644 (file)
@@ -9,7 +9,8 @@ libdir = @libdir@
 VPATH = @libreplacedir@
 srcdir = @srcdir@
 builddir = @builddir@
-INSTALL = @INSTALL@
+sharedbuilddir = @sharedbuilddir@
+INSTALLCMD = @INSTALL@
 LIBS = @LIBS@
 
 .PHONY: test all showflags install installcheck clean distclean realdistclean
@@ -29,8 +30,14 @@ showflags:
        @echo '  LIBS   = $(LIBS)'
 
 install: all
-       mkdir -p $(libdir)
-       $(INSTALL) libreplace.a $(libdir)
+       ${INSTALLCMD} -d $(libdir)
+       ${INSTALLCMD} -m 644 libreplace.a $(libdir)
+
+shared-build: all
+       ${INSTALLCMD} -d $(sharedbuilddir)/include
+       ${INSTALLCMD} -m 644 replace.h $(sharedbuilddir)/include
+       ${INSTALLCMD} -d $(sharedbuilddir)/lib
+       ${INSTALLCMD} -m 644 libreplace.a $(sharedbuilddir)/lib
 
 libreplace.a: $(OBJS)
        ar -rcsv $@ $(OBJS)
diff --git a/lib/replace/build_macros.m4 b/lib/replace/build_macros.m4
new file mode 100644 (file)
index 0000000..c036668
--- /dev/null
@@ -0,0 +1,14 @@
+AC_DEFUN(BUILD_WITH_SHARED_BUILD_DIR,
+  [ AC_ARG_WITH([shared-build-dir],
+                [AC_HELP_STRING([--with-shared-build-dir=DIR],
+                                [temporary build directory where libraries are installed [$srcdir/sharedbuild]])])
+
+    sharedbuilddir="$srcdir/sharedbuild"
+    if test x"$with_shared_build_dir" != x; then
+        sharedbuilddir=$with_shared_build_dir
+        CFLAGS="$CFLAGS -I$with_shared_build_dir/include"
+        LDFLAGS="$LDFLAGS -L$with_shared_build_dir/lib"
+    fi
+    AC_SUBST(sharedbuilddir)
+  ])
+
index 81997e09b7d00f46de3433a3031ffce32a025f2f..0361825a022d992992da4c2998596c3397b32edb 100644 (file)
@@ -22,6 +22,9 @@ if test "$ac_cv_prog_gcc" = yes; then
    CFLAGS="$CFLAGS -Wno-format-y2k"
 fi
 
+m4_include(build_macros.m4)
+BUILD_WITH_SHARED_BUILD_DIR
+
 LIBS="${LIBREPLACE_NETWORK_LIBS}"
 AC_SUBST(LIBS)
 
index dc7d88e6e183b02f01486683a8466fca3f17cbd4..e563acfd794c2aee249a41ee1beb3a3d79f916ff 100644 (file)
@@ -5,7 +5,7 @@ echo "LIBREPLACE_LOCATION_CHECKS: START"
 dnl find the libreplace sources. This is meant to work both for 
 dnl libreplace standalone builds, and builds of packages using libreplace
 libreplacedir=""
-libreplacepaths="$srcdir $srcdir/lib/replace $srcdir/libreplace $srcdir/../libreplace $srcdir/../replace $srcdir/../lib/replace"
+libreplacepaths="$srcdir $srcdir/lib/replace $srcdir/libreplace $srcdir/../libreplace $srcdir/../replace $srcdir/../lib/replace $srcdir/../../../lib/replace"
 for d in $libreplacepaths; do
        if test -f "$d/replace.c"; then
                libreplacedir="$d"              
@@ -34,7 +34,7 @@ echo "LIBREPLACE_BROKEN_CHECKS: START"
 dnl find the libreplace sources. This is meant to work both for 
 dnl libreplace standalone builds, and builds of packages using libreplace
 libreplacedir=""
-libreplacepaths="$srcdir $srcdir/lib/replace $srcdir/libreplace $srcdir/../libreplace $srcdir/../replace $srcdir/../lib/replace"
+libreplacepaths="$srcdir $srcdir/lib/replace $srcdir/libreplace $srcdir/../libreplace $srcdir/../replace $srcdir/../lib/replace $srcdir/../../../lib/replace"
 for d in $libreplacepaths; do
        if test -f "$d/replace.c"; then
                libreplacedir="$d"              
index 1e8290906e18b039505582769b3e59b4495649a3..dcb05fbbf4ead2d522e1b44550548f04a5237e7e 100644 (file)
@@ -1069,7 +1069,8 @@ bool torture_local_replace(struct torture_context *ctx)
        return ret;
 }
 
-#if _SAMBA_BUILD_<4
+#if _SAMBA_BUILD_>3
+#else
 int main(void)
 {
        bool ret = torture_local_replace(NULL);