summaryrefslogtreecommitdiff
path: root/source4/lib/replace/replace.m4
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2006-09-04 12:21:42 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:17:05 -0500
commit38fdde5d9bf15b10caa60ee216d278ba8d870c2e (patch)
treef5da0712c3bd704a0af17aa6d12d8c616a2d6e1b /source4/lib/replace/replace.m4
parentf6f4d868ea7d3a01ec28c6855240882911cae039 (diff)
downloadsamba-38fdde5d9bf15b10caa60ee216d278ba8d870c2e.tar.gz
samba-38fdde5d9bf15b10caa60ee216d278ba8d870c2e.tar.bz2
samba-38fdde5d9bf15b10caa60ee216d278ba8d870c2e.zip
r18031: Merge my replace fixes:
* libreplace can now build stand-alone * add stub testsuite for libreplace * make talloc/tdb/ldb use libreplace (This used to be commit fe7ca4b1454e01a33ed0d53791ebffdd349298b4)
Diffstat (limited to 'source4/lib/replace/replace.m4')
-rw-r--r--source4/lib/replace/replace.m458
1 files changed, 58 insertions, 0 deletions
diff --git a/source4/lib/replace/replace.m4 b/source4/lib/replace/replace.m4
new file mode 100644
index 0000000000..829f4db6f6
--- /dev/null
+++ b/source4/lib/replace/replace.m4
@@ -0,0 +1,58 @@
+dnl Try to find a replacement library
+dnl Will define HAVE_REPLACE_H if replace.h can be found
+AC_DEFUN([SMB_LIBREPLACE], [
+AC_ARG_WITH(libreplace,
+[ --with-libreplace Specify location to libreplace],
+[
+ # Check whether libreplace can actually be found in this location
+ if ! test -f "$withval/replace.h"
+ then
+ AC_MSG_ERROR([Unable to find replace.h in $withval])
+ fi
+ replacedir=$withval
+],
+[
+ # Check if we can find libreplace in a common location
+ for dir in . replace ../replace
+ do
+ AC_MSG_CHECKING([for libreplace in $dir])
+ if test -f "$dir/replace.h"
+ then
+ replacedir="$dir"
+ AC_MSG_RESULT(yes)
+ break
+ fi
+ AC_MSG_RESULT(no)
+ done
+])
+
+AC_SUBST(REPLACE_LIBS)
+
+if test "$replacedir" != ""
+then
+ REPLACE_LIBS="$replacedir/libreplace.a"
+ CFLAGS="$CFLAGS -I$replacedir"
+ AC_DEFINE(HAVE_REPLACE_H, 1,
+ [Whether replace.h is present and should be used])
+fi
+])
+
+dnl Try to find the specified functions in the system, or
+dnl in Samba's replacement library. In the future, this may also
+dnl try to find these functions in libroken or GNUlib if libreplace can't be
+dnl found.
+AC_DEFUN(SMB_REPLACE_FUNCS, [
+ AC_REQUIRE([SMB_LIBREPLACE])dnl
+
+ if test -z "$replacedir" || test -f "$replacedir/libreplace.a"
+ then
+ LIBS="$LIBS $REPLACE_LIBS"
+ for f in $1
+ do
+ AC_CHECK_FUNC($f, [], [
+ AC_MSG_ERROR([Unable to find $f in the system. Consider
+ specifying the path to the replacement library])
+ ])
+ done
+ fi
+])