2006-09-05 11:21:16 +00:00
dnl find the libreplace sources. This is meant to work both for
dnl libreplace standalone builds, and builds of packages using libreplace
libreplacedir=""
2006-09-05 11:45:55 +00:00
for d in "$srcdir" "$srcdir/lib/replace" "$srcdir/libreplace" "$srcdir/../libreplace" "$srcdir/../replace"; do
2006-09-05 11:21:16 +00:00
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)
2006-03-31 23:28:18 +00:00
AC_CHECK_HEADERS([stdint.h inttypes.h])
2005-09-24 14:58:18 +00:00
AC_CHECK_TYPE(uint_t, unsigned int)
2006-09-04 12:21:42 +00:00
AC_CHECK_TYPE(uint8_t, unsigned char)
AC_CHECK_TYPE(int8_t, char)
2005-09-24 14:58:18 +00:00
AC_CHECK_TYPE(int16_t, short)
AC_CHECK_TYPE(uint16_t, unsigned short)
AC_CHECK_TYPE(int32_t, long)
2006-09-04 12:21:42 +00:00
AC_CHECK_TYPE(intptr_t, unsigned long long)
2005-09-24 14:58:18 +00:00
AC_CHECK_TYPE(uint32_t, unsigned long)
2005-09-26 15:59:43 +00:00
AC_CHECK_TYPE(ssize_t, int)
2005-09-24 14:58:18 +00:00
2006-06-02 20:55:17 +00:00
AC_CHECK_HEADERS(stdbool.h)
AC_CHECK_TYPE(bool,
[AC_DEFINE(HAVE_BOOL, 1, [Whether the bool type is available])],,
[
AC_INCLUDES_DEFAULT
#ifdef HAVE_STDBOOL_H
#include <stdbool.h>
#endif]
)
2005-08-04 16:49:17 +00:00
AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
AC_TRY_RUN([
#include <stdio.h>
#include <sys/types.h>
#include <netinet/in.h>
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
main() { struct in_addr ip; ip.s_addr = 0x12345678;
if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); }
exit(1);}],
samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
fi
2005-08-18 00:20:40 +00:00
2005-09-23 00:38:22 +00:00
dnl Provided by replace.c:
2005-09-27 00:11:21 +00:00
AC_TRY_COMPILE([
#include <sys/types.h>
#if STDC_HEADERS
#include <stdlib.h>
#include <stddef.h>
#endif
#include <sys/socket.h>],
[socklen_t foo;],,
[AC_DEFINE(socklen_t, int,[Socket length type])])
2005-09-23 00:38:22 +00:00
AC_CHECK_HEADERS(sys/syslog.h syslog.h)
2006-09-05 02:03:22 +00:00
AC_CHECK_HEADERS(sys/time.h time.h)
2006-09-05 04:58:23 +00:00
AC_CHECK_HEADERS(sys/socket.h netinet/in.h)
2006-09-05 11:42:20 +00:00
AC_CHECK_HEADERS(stdarg.h vararg.h)
2005-09-23 00:38:22 +00:00
AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror)
2006-08-23 23:21:29 +00:00
AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename)
2006-08-23 11:32:29 +00:00
AC_CHECK_FUNCS(waitpid strlcpy strlcat innetgr initgroups memmove strdup)
2006-09-01 12:37:17 +00:00
AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp)
2006-09-05 11:21:16 +00:00
AC_CHECK_DECLS([setresuid, setresgid, errno])
2005-09-23 00:38:22 +00:00
AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
AC_TRY_RUN([#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
main() {
struct stat st;
char tpl[20]="/tmp/test.XXXXXX";
int fd = mkstemp(tpl);
if (fd == -1) exit(1);
unlink(tpl);
if (fstat(fd, &st) != 0) exit(1);
if ((st.st_mode & 0777) != 0600) exit(1);
exit(0);
}],
samba_cv_HAVE_SECURE_MKSTEMP=yes,
samba_cv_HAVE_SECURE_MKSTEMP=no,
samba_cv_HAVE_SECURE_MKSTEMP=cross)])
if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
fi
dnl Provided by snprintf.c:
2006-09-05 11:21:16 +00:00
AC_CHECK_DECLS([asprintf, vasprintf, snprintf])
2005-09-23 00:38:22 +00:00
AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
2006-04-29 12:39:19 +00:00
AC_CHECK_HEADERS(strings.h)
2005-09-23 00:38:22 +00:00
AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
AC_TRY_RUN([
#include <sys/types.h>
2006-09-04 16:30:40 +00:00
#include <stdio.h>
2005-09-23 00:38:22 +00:00
#include <stdarg.h>
2006-09-04 16:30:40 +00:00
#include <stdlib.h>
2005-09-23 00:38:22 +00:00
void foo(const char *format, ...) {
va_list ap;
int len;
char buf[20];
long long l = 1234567890;
l *= 100;
va_start(ap, format);
len = vsnprintf(buf, 0, format, ap);
va_end(ap);
if (len != 5) exit(1);
va_start(ap, format);
len = vsnprintf(0, 0, format, ap);
va_end(ap);
2006-09-04 16:30:40 +00:00
if (len != 5) exit(2);
2005-09-23 00:38:22 +00:00
2006-09-04 16:30:40 +00:00
if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(3);
2005-09-23 00:38:22 +00:00
2006-09-04 16:30:40 +00:00
if (snprintf(buf, 20, "%lld", l) != 12 || strcmp(buf, "123456789000") != 0) exit(4);
if (snprintf(buf, 20, "%zu", 123456789) != 9 || strcmp(buf, "123456789") != 0) exit(5);
if (snprintf(buf, 20, "%2\$d %1\$d", 3, 4) != 3 || strcmp(buf, "4 3") != 0) exit(6);
if (snprintf(buf, 20, "%s", 0) < 3) exit(7);
2005-09-23 00:38:22 +00:00
exit(0);
}
main() { foo("hello"); }
],
samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
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
2006-09-05 11:21:16 +00:00
dnl dummies provided by dlfcn.c if not available
AC_SEARCH_LIBS(dlopen, dl)
2005-09-23 00:38:22 +00:00
AC_CHECK_HEADERS(dlfcn.h)
AC_CHECK_FUNCS(dlopen dlsym dlerror dlclose)
2005-09-24 14:58:18 +00:00
AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],,
[AC_MSG_ERROR([Required function not found])])
2005-12-29 23:14:33 +00:00
2006-09-05 12:13:15 +00:00
m4_include(getpass.m4)
m4_include(cc_features.m4)
2006-09-05 07:58:26 +00:00
LIBREPLACE_C99_STRUCT_INIT(c99_struct_initialization=yes,
c99_struct_initialization=no)
2006-04-08 15:26:59 +00:00
dnl VA_COPY
AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[
AC_TRY_LINK([#include <stdarg.h>
va_list ap1,ap2;], [va_copy(ap1,ap2);],
samba_cv_HAVE_VA_COPY=yes,samba_cv_HAVE_VA_COPY=no)])
if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then
AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
fi
if test x"$samba_cv_HAVE_VA_COPY" != x"yes"; then
AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE___VA_COPY,[
AC_TRY_LINK([#include <stdarg.h>
va_list ap1,ap2;], [__va_copy(ap1,ap2);],
samba_cv_HAVE___VA_COPY=yes,samba_cv_HAVE___VA_COPY=no)])
if test x"$samba_cv_HAVE___VA_COPY" = x"yes"; then
AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
fi
fi
2006-04-08 16:25:53 +00:00
dnl __FUNCTION__ macro
AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
2006-04-26 14:20:46 +00:00
else
dnl __func__ macro
AC_CACHE_CHECK([for __func__ macro],samba_cv_HAVE_func_MACRO,[
AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __func__);],
samba_cv_HAVE_func_MACRO=yes,samba_cv_HAVE_func_MACRO=no)])
if test x"$samba_cv_HAVE_func_MACRO" = x"yes"; then
AC_DEFINE(HAVE_func_MACRO,1,[Whether there is a __func__ macro])
fi
2006-04-08 16:25:53 +00:00
fi
2006-04-24 14:09:07 +00:00
2006-04-29 12:39:19 +00:00
AC_CHECK_HEADERS([sys/param.h limits.h])
2006-09-04 12:21:42 +00:00
AC_CHECK_TYPE(comparison_fn_t,
[AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])])
AC_CHECK_FUNCS(timegm strnlen setenv)
AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq)
2006-09-05 04:23:11 +00:00
# this test disabled as we don't actually need __VA_ARGS__ yet
# AC_TRY_CPP([
# #define eprintf(...) fprintf(stderr, __VA_ARGS__)
# eprintf("bla", "bar");
# ], [], [AC_MSG_ERROR([__VA_ARGS__ is required])])
2006-09-04 12:21:42 +00:00
# Check prerequisites
AC_CHECK_FUNCS([memset printf syslog], [],
[ AC_MSG_ERROR([Required function not found])])
2006-09-05 01:50:52 +00:00
AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
AC_TRY_COMPILE([
#include <sys/types.h>
#if STDC_HEADERS
#include <stdlib.h>
#include <stddef.h>
#endif
#include <signal.h>],[sig_atomic_t i = 0],
samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)])
if test x"$samba_cv_sig_atomic_t" = x"yes"; then
AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type])
fi
2006-09-05 11:42:20 +00:00