summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/replace/test/snprintf.c29
-rw-r--r--lib/replace/wscript69
-rw-r--r--lib/util/wscript_configure2
3 files changed, 57 insertions, 43 deletions
diff --git a/lib/replace/test/snprintf.c b/lib/replace/test/snprintf.c
new file mode 100644
index 0000000000..d06630bcc9
--- /dev/null
+++ b/lib/replace/test/snprintf.c
@@ -0,0 +1,29 @@
+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);
+ if (len != 5) exit(2);
+
+ if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(3);
+
+ 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);
+
+ printf("1");
+ exit(0);
+}
+main() { foo("hello"); }
diff --git a/lib/replace/wscript b/lib/replace/wscript
index 399654cceb..e40626788a 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -119,7 +119,7 @@ def configure(conf):
conf.CHECK_FUNCS('connect gethostbyname if_nametoindex socketpair')
conf.CHECK_FUNCS('inet_ntoa inet_aton inet_ntop inet_pton')
conf.CHECK_FUNCS('dirfd getdirentries getdents syslog getaddrinfo freeaddrinfo')
- conf.CHECK_FUNCS('gai_strerror')
+ conf.CHECK_FUNCS('gai_strerror get_current_dir_name')
conf.CHECK_FUNCS('timegm getifaddrs freeifaddrs mmap setgroups setsid')
conf.CHECK_FUNCS('getgrent_r getgrgid_r getgrnam_r getgrouplist getpagesize')
conf.CHECK_FUNCS('getpwent_r getpwnam_r getpwuid_r epoll_create')
@@ -161,47 +161,11 @@ def configure(conf):
msg="Checking for va_copy")
- # we could also put code fragments like this in separate files,
- # for example in test/snprintf.c
- conf.check_cc(fragment='''
-#include <sys/types.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-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);
- if (len != 5) exit(2);
-
- if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(3);
-
- 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);
-
- printf("1");
- exit(0);
-}
-main() { foo("hello"); }
-''',
- define_name="HAVE_C99_VSNPRINTF",
- execute=1,
- define_ret=1,
- quote=0,
- msg="Checking for C99 vsnprintf")
+ conf.CHECK_CODE('#include "test/snprintf.c"',
+ define="HAVE_C99_VSNPRINTF",
+ execute=1,
+ addmain=False,
+ msg="Checking for C99 vsnprintf")
if Options.options.developer:
conf.ADD_CFLAGS('-Wall -g -Wfatal-errors -DDEVELOPER -W -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Werror-implicit-function-declaration -Wformat=2 -Wno-format-y2k')
@@ -209,6 +173,27 @@ main() { foo("hello"); }
conf.SAMBA_CONFIG_H()
conf.SAMBA_BUILD_ENV()
+ # look for a method of finding the list of network interfaces
+ for method in ['HAVE_IFACE_GETIFADDRS', 'HAVE_IFACE_AIX', 'HAVE_IFACE_IFCONF', 'HAVE_IFACE_IFREQ']:
+ if conf.CHECK_CODE('''
+ #define %s 1
+ #define NO_CONFIG_H 1
+ #define AUTOCONF_TEST 1
+ #define SOCKET_WRAPPER_NOT_REPLACE
+ #include "replace.c"
+ #include "inet_ntop.c"
+ #include "snprintf.c"
+ #include "getifaddrs.c"
+ #define getifaddrs_test main
+ #include "test/getifaddrs.c"
+ ''' % method,
+ method,
+ addmain=False,
+ execute=True):
+ break
+
+
+
def build(bld):
bld.set_rpath()
diff --git a/lib/util/wscript_configure b/lib/util/wscript_configure
index a2f1c256a3..8c819e378a 100644
--- a/lib/util/wscript_configure
+++ b/lib/util/wscript_configure
@@ -11,4 +11,4 @@ conf.CHECK_FUNCS_IN('flistxattr', 'attr', checklibc=True)
conf.CHECK_STRUCTURE_MEMBER('struct statvfs', 'f_frsize', define='HAVE_FRSIZE')
-conf.CHECK_CODE_COMPILES('gettimeofday(NULL, NULL)', 'HAVE_GETTIMEOFDAY_TZ')
+conf.CHECK_CODE('gettimeofday(NULL, NULL)', 'HAVE_GETTIMEOFDAY_TZ', execute=False)