summaryrefslogtreecommitdiff
path: root/source4/lib/replace
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/replace')
-rw-r--r--source4/lib/replace/Makefile.in6
-rw-r--r--source4/lib/replace/config.m430
-rw-r--r--source4/lib/replace/configure.ac40
3 files changed, 20 insertions, 56 deletions
diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in
index baadbc5d5c..502dacbd2a 100644
--- a/source4/lib/replace/Makefile.in
+++ b/source4/lib/replace/Makefile.in
@@ -6,16 +6,16 @@ exec_prefix = @exec_prefix@
bindir = @bindir@
includedir = @includedir@
libdir = @libdir@
-VPATH = @srcdir@
+VPATH = @libreplacedir@
srcdir = @srcdir@
builddir = @builddir@
INSTALL = @INSTALL@
.PHONY: test
-CFLAGS=-I. -I$(srcdir) @CFLAGS@
+CFLAGS=-I. -I@libreplacedir@ @CFLAGS@
-OBJS = dlfcn.o getpass.o replace.o snprintf.o timegm.o
+OBJS = @LIBREPLACEOBJ@
all: libreplace.a testsuite
diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4
index a846f5168f..382da639fc 100644
--- a/source4/lib/replace/config.m4
+++ b/source4/lib/replace/config.m4
@@ -1,3 +1,16 @@
+dnl find the libreplace sources. This is meant to work both for
+dnl libreplace standalone builds, and builds of packages using libreplace
+libreplacedir=""
+for d in "$srcdir" "$srcdir/lib/replace" "$srcdir/libreplace" "$srcdir/../libreplace"; do
+ if test -f "$d/replace.c"; then
+ libreplacedir="$d"
+ AC_SUBST(libreplacedir)
+ break;
+ fi
+done
+LIBREPLACEOBJ="dlfcn.o getpass.o replace.o snprintf.o timegm.o"
+AC_SUBST(LIBREPLACEOBJ)
+
AC_CHECK_HEADERS([stdint.h inttypes.h])
AC_CHECK_TYPE(uint_t, unsigned int)
AC_CHECK_TYPE(uint8_t, unsigned char)
@@ -56,9 +69,7 @@ AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror)
AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename)
AC_CHECK_FUNCS(waitpid strlcpy strlcat innetgr initgroups memmove strdup)
AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp)
-AC_HAVE_DECL(setresuid, [#include <unistd.h>])
-AC_HAVE_DECL(setresgid, [#include <unistd.h>])
-AC_HAVE_DECL(errno, [#include <errno.h>])
+AC_CHECK_DECLS([setresuid, setresgid, errno])
AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
AC_TRY_RUN([#include <stdlib.h>
@@ -83,10 +94,7 @@ if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
fi
dnl Provided by snprintf.c:
-AC_HAVE_DECL(asprintf, [#include <stdio.h>])
-AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
-AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
-AC_HAVE_DECL(snprintf, [#include <stdio.h>])
+AC_CHECK_DECLS([asprintf, vasprintf, snprintf])
AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
AC_CHECK_HEADERS(strings.h)
@@ -129,14 +137,10 @@ if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
fi
-dnl Provided by dlfcn.c:
-AC_SEARCH_LIBS_EXT(dlopen, [dl], DL_LIBS)
-SMB_EXT_LIB(DL,[${DL_LIBS}],[${DL_CFLAGS}],[${DL_CPPFLAGS}],[${DL_LDFLAGS}])
-SAVE_LIBS="$LIBS"
-LIBS="$LIBS $DL_LIBS"
+dnl dummies provided by dlfcn.c if not available
+AC_SEARCH_LIBS(dlopen, dl)
AC_CHECK_HEADERS(dlfcn.h)
AC_CHECK_FUNCS(dlopen dlsym dlerror dlclose)
-LIBS="$SAVE_LIBS"
AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],,
[AC_MSG_ERROR([Required function not found])])
diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac
index 3d56c8d934..2b5fbf1c18 100644
--- a/source4/lib/replace/configure.ac
+++ b/source4/lib/replace/configure.ac
@@ -1,46 +1,6 @@
AC_DEFUN([SMB_EXT_LIB], [echo -n ""])
AC_DEFUN([SMB_ENABLE], [echo -n ""])
-dnl see if a declaration exists for a function or variable
-dnl defines HAVE_function_DECL if it exists
-dnl AC_HAVE_DECL(var, includes)
-AC_DEFUN(AC_HAVE_DECL,
-[
- AC_CACHE_CHECK([for $1 declaration],ac_cv_have_$1_decl,[
- AC_TRY_COMPILE([$2],[int i = (int)$1],
- ac_cv_have_$1_decl=yes,ac_cv_have_$1_decl=no)])
- if test x"$ac_cv_have_$1_decl" = x"yes"; then
- AC_DEFINE([HAVE_]translit([$1], [a-z], [A-Z])[_DECL],1,[Whether $1() is available])
- fi
-])
-
-dnl AC_SEARCH_LIBS_EXT(FUNCTION, SEARCH-LIBS, EXT_LIBS,
-dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
-dnl [OTHER-LIBRARIES])
-dnl --------------------------------------------------------
-dnl Search for a library defining FUNC, if it's not already available.
-AC_DEFUN([AC_SEARCH_LIBS_EXT],
-[AC_CACHE_CHECK([for library containing $1], [ac_cv_search_ext_$1],
-[
-ac_func_search_ext_save_LIBS=$LIBS
-ac_cv_search_ext_$1=no
-AC_LINK_IFELSE([AC_LANG_CALL([], [$1])],
- [ac_cv_search_ext_$1="none required"])
-if test "$ac_cv_search_ext_$1" = no; then
- for ac_lib in $2; do
- LIBS="-l$ac_lib $$3 $6 $ac_func_search_save_ext_LIBS"
- AC_LINK_IFELSE([AC_LANG_CALL([], [$1])],
- [ac_cv_search_ext_$1="-l$ac_lib"
-break])
- done
-fi
-LIBS=$ac_func_search_ext_save_LIBS])
-AS_IF([test "$ac_cv_search_ext_$1" != no],
- [test "$ac_cv_search_ext_$1" = "none required" || $3="$ac_cv_search_ext_$1 $$3"
- $4],
- [$5])dnl
-])
-
AC_PREREQ(2.50)
AC_INIT(dlfcn.c)
AC_CONFIG_SRCDIR([dlfcn.c])