1 # acx_nlnetlabs.m4 - common macros for configure checks
2 # Copyright 2009, Wouter Wijngaards, NLnet Labs.
6 # 2013-09-19 FLTO help text improved.
7 # 2013-07-18 Enable ACX_CHECK_COMPILER_FLAG to test for -Wstrict-prototypes
8 # 2013-06-25 FLTO has --disable-flto option.
9 # 2013-05-03 Update W32_SLEEP for newer mingw that links but not defines it.
10 # 2013-03-22 Fix ACX_RSRC_VERSION for long version numbers.
11 # 2012-02-09 Fix AHX_MEMCMP_BROKEN with undef in compat/memcmp.h.
12 # 2012-01-20 Fix COMPILER_FLAGS_UNBOUND for gcc 4.6.2 assigned-not-used-warns.
13 # 2011-12-05 Fix getaddrinfowithincludes on windows with fedora16 mingw32-gcc.
14 # Fix ACX_MALLOC for redefined malloc error.
15 # Fix GETADDRINFO_WITH_INCLUDES to add -lws2_32
16 # 2011-11-10 Fix FLTO test to not drop a.out in current directory.
17 # 2011-11-01 Fix FLTO test for llvm on Lion.
18 # 2011-08-01 Fix nonblock test (broken at v13).
19 # 2011-08-01 Fix autoconf 2.68 warnings
20 # 2011-06-23 Add ACX_CHECK_FLTO to check -flto.
21 # 2010-08-16 Fix FLAG_OMITTED for AS_TR_CPP changes in autoconf-2.66.
22 # 2010-07-02 Add check for ss_family (for minix).
23 # 2010-04-26 Fix to use CPPFLAGS for CHECK_COMPILER_FLAGS.
24 # 2010-03-01 Fix RPATH using CONFIG_COMMANDS to run at the very end.
25 # 2010-02-18 WITH_SSL outputs the LIBSSL_LDFLAGS, LIBS, CPPFLAGS seperate, -ldl
26 # 2010-02-01 added ACX_CHECK_MEMCMP_SIGNED, AHX_MEMCMP_BROKEN
27 # 2010-01-20 added AHX_COONFIG_STRLCAT
28 # 2009-07-14 U_CHAR detection improved for windows crosscompile.
29 # added ACX_FUNC_MALLOC
30 # fixup some #if to #ifdef
31 # NONBLOCKING test for mingw crosscompile.
32 # 2009-07-13 added ACX_WITH_SSL_OPTIONAL
33 # 2009-07-03 fixup LDFLAGS for empty ssl dir.
35 # Automates some of the checking constructs. Aims at portability for POSIX.
36 # Documentation for functions is below.
38 # the following macro's are provided in this file:
39 # (see below for details on each macro).
41 # ACX_ESCAPE_BACKSLASH - escape backslashes in var for C-preproc.
42 # ACX_RSRC_VERSION - create windows resource version number.
43 # ACX_CHECK_COMPILER_FLAG - see if cc supports a flag.
44 # ACX_CHECK_ERROR_FLAGS - see which flag is -werror (used below).
45 # ACX_CHECK_COMPILER_FLAG_NEEDED - see if flags make the code compile cleanly.
46 # ACX_DEPFLAG - find cc dependency flags.
47 # ACX_DETERMINE_EXT_FLAGS_UNBOUND - find out which flags enable BSD and POSIX.
48 # ACX_CHECK_FORMAT_ATTRIBUTE - find cc printf format syntax.
49 # ACX_CHECK_UNUSED_ATTRIBUTE - find cc variable unused syntax.
50 # ACX_CHECK_FLTO - see if cc supports -flto and use it if so.
51 # ACX_LIBTOOL_C_ONLY - create libtool for C only, improved.
52 # ACX_TYPE_U_CHAR - u_char type.
53 # ACX_TYPE_RLIM_T - rlim_t type.
54 # ACX_TYPE_SOCKLEN_T - socklen_t type.
55 # ACX_TYPE_IN_ADDR_T - in_addr_t type.
56 # ACX_TYPE_IN_PORT_T - in_port_t type.
57 # ACX_ARG_RPATH - add --disable-rpath option.
58 # ACX_WITH_SSL - add --with-ssl option, link -lcrypto.
59 # ACX_WITH_SSL_OPTIONAL - add --with-ssl option, link -lcrypto,
60 # where --without-ssl is also accepted
61 # ACX_LIB_SSL - setup to link -lssl.
62 # ACX_SYS_LARGEFILE - improved sys_largefile, fseeko, >2G files.
63 # ACX_CHECK_GETADDRINFO_WITH_INCLUDES - find getaddrinfo, portably.
64 # ACX_FUNC_DEPRECATED - see if func is deprecated.
65 # ACX_CHECK_NONBLOCKING_BROKEN - see if nonblocking sockets really work.
66 # ACX_MKDIR_ONE_ARG - determine mkdir(2) number of arguments.
67 # ACX_FUNC_IOCTLSOCKET - find ioctlsocket, portably.
68 # ACX_FUNC_MALLOC - check malloc, define replacement .
69 # AHX_CONFIG_FORMAT_ATTRIBUTE - config.h text for format.
70 # AHX_CONFIG_UNUSED_ATTRIBUTE - config.h text for unused.
71 # AHX_CONFIG_FSEEKO - define fseeko, ftello fallback.
72 # AHX_CONFIG_RAND_MAX - define RAND_MAX if needed.
73 # AHX_CONFIG_MAXHOSTNAMELEN - define MAXHOSTNAMELEN if needed.
74 # AHX_CONFIG_IPV6_MIN_MTU - define IPV6_MIN_MTU if needed.
75 # AHX_CONFIG_SNPRINTF - snprintf compat prototype
76 # AHX_CONFIG_INET_PTON - inet_pton compat prototype
77 # AHX_CONFIG_INET_NTOP - inet_ntop compat prototype
78 # AHX_CONFIG_INET_ATON - inet_aton compat prototype
79 # AHX_CONFIG_MEMMOVE - memmove compat prototype
80 # AHX_CONFIG_STRLCAT - strlcat compat prototype
81 # AHX_CONFIG_STRLCPY - strlcpy compat prototype
82 # AHX_CONFIG_GMTIME_R - gmtime_r compat prototype
83 # AHX_CONFIG_W32_SLEEP - w32 compat for sleep
84 # AHX_CONFIG_W32_USLEEP - w32 compat for usleep
85 # AHX_CONFIG_W32_RANDOM - w32 compat for random
86 # AHX_CONFIG_W32_SRANDOM - w32 compat for srandom
87 # AHX_CONFIG_W32_FD_SET_T - w32 detection of FD_SET_T.
88 # ACX_CFLAGS_STRIP - strip one flag from CFLAGS
89 # ACX_STRIP_EXT_FLAGS - strip extension flags from CFLAGS
90 # AHX_CONFIG_FLAG_OMITTED - define omitted flag
91 # AHX_CONFIG_FLAG_EXT - define omitted extension flag
92 # AHX_CONFIG_EXT_FLAGS - define the stripped extension flags
93 # ACX_CHECK_MEMCMP_SIGNED - check if memcmp uses signed characters.
94 # AHX_MEMCMP_BROKEN - replace memcmp func for CHECK_MEMCMP_SIGNED.
95 # ACX_CHECK_SS_FAMILY - check for sockaddr_storage.ss_family
98 dnl Escape backslashes as \\, for C:\ paths, for the C preprocessor defines.
99 dnl for example, ACX_ESCAPE_BACKSLASH($from_var, to_var)
100 dnl $1: the text to change.
102 AC_DEFUN([ACX_ESCAPE_BACKSLASH], [$2="`echo $1 | sed -e 's/\\\\/\\\\\\\\/g'`"
105 dnl Calculate comma separated windows-resource numbers from package version.
106 dnl Picks the first three(,0) or four numbers out of the name.
107 dnl $1: variable for the result
108 AC_DEFUN([ACX_RSRC_VERSION],
109 [$1=[`echo $PACKAGE_VERSION | sed -e 's/^[^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\).*$/\1,\2,\3,\4/' -e 's/^[^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\)[^0-9]*$/\1,\2,\3,0/' `]
112 dnl Routine to help check for compiler flags.
113 dnl Checks if the compiler will accept the flag.
114 dnl $1: the flag without a - in front, so g to check -g.
115 dnl $2: executed if yes
116 dnl $3: executed if no
117 AC_DEFUN([ACX_CHECK_COMPILER_FLAG],
119 AC_REQUIRE([AC_PROG_CC])
120 AC_MSG_CHECKING(whether $CC supports -$1)
121 cache=`echo $1 | sed 'y%.=/+-%___p_%'`
122 AC_CACHE_VAL(cv_prog_cc_flag_$cache,
124 echo 'void f(void){}' >conftest.c
125 if test -z "`$CC $CPPFLAGS $CFLAGS -$1 -c conftest.c 2>&1`"; then
126 eval "cv_prog_cc_flag_$cache=yes"
128 eval "cv_prog_cc_flag_$cache=no"
130 rm -f conftest conftest.o conftest.c
132 if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then
143 dnl setup flags for ACX_CHECK_COMPILER_FLAG_NEEDED
144 dnl ERRFLAG: result, compiler flag to turn warnings into errors
145 AC_DEFUN([ACX_CHECK_ERROR_FLAGS],
147 ACX_CHECK_COMPILER_FLAG(Werror, [ERRFLAG="-Werror"], [ERRFLAG="-errwarn"])
148 ACX_CHECK_COMPILER_FLAG(Wall, [ERRFLAG="$ERRFLAG -Wall"],
149 [ERRFLAG="$ERRFLAG -errfmt"])
152 dnl Routine to help check for needed compiler flags.
154 dnl $2: the includes and code
155 dnl $3: if the given code only compiles with the flag, execute argument 3
156 dnl $4: if the given code compiles without the flag, execute argument 4
157 dnl $5: with and without flag the compile fails, execute argument 5.
158 AC_DEFUN([ACX_CHECK_COMPILER_FLAG_NEEDED],
160 AC_REQUIRE([AC_PROG_CC])
161 AC_REQUIRE([ACX_CHECK_ERROR_FLAGS])
162 AC_MSG_CHECKING(whether we need $1 as a flag for $CC)
164 dnl cache=`echo $1 | sed 'y%.=/+- %___p__%'`
165 AC_CACHE_VAL(cv_prog_cc_flag_needed_$cache,
167 echo '$2' > conftest.c
168 echo 'void f(){}' >>conftest.c
169 if test -z "`$CC $CPPFLAGS $CFLAGS $ERRFLAG -c conftest.c 2>&1`"; then
170 eval "cv_prog_cc_flag_needed_$cache=no"
173 if test -z "`$CC $CPPFLAGS $CFLAGS $1 $ERRFLAG -c conftest.c 2>&1`"; then
174 eval "cv_prog_cc_flag_needed_$cache=yes"
176 eval "cv_prog_cc_flag_needed_$cache=fail"
177 #echo 'Test with flag fails too!'
179 #echo "$CC $CPPFLAGS $CFLAGS $1 $ERRFLAG -c conftest.c 2>&1"
180 #echo `$CC $CPPFLAGS $CFLAGS $1 $ERRFLAG -c conftest.c 2>&1`
185 rm -f conftest conftest.c conftest.o
187 if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = yes"; then
192 if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = no"; then
194 #echo 'Test with flag is no!'
196 #echo "$CC $CPPFLAGS $CFLAGS $1 $ERRFLAG -c conftest.c 2>&1"
197 #echo `$CC $CPPFLAGS $CFLAGS $1 $ERRFLAG -c conftest.c 2>&1`
202 AC_MSG_RESULT(failed)
209 dnl Check for CC dependency flag
210 dnl DEPFLAG: set to flag that generates dependencies.
211 AC_DEFUN([ACX_DEPFLAG],
213 AC_MSG_CHECKING([$CC dependency flag])
214 echo 'void f(){}' >conftest.c
215 if test "`$CC -MM conftest.c 2>&1`" = "conftest.o: conftest.c"; then
218 if test "`$CC -xM1 conftest.c 2>&1`" = "conftest.o: conftest.c"; then
221 DEPFLAG="-MM" # dunno do something
224 AC_MSG_RESULT($DEPFLAG)
229 dnl Determine flags that gives POSIX and BSD functionality.
230 dnl CFLAGS is modified for the result.
231 AC_DEFUN([ACX_DETERMINE_EXT_FLAGS_UNBOUND],
233 ACX_CHECK_COMPILER_FLAG(std=c99, [C99FLAG="-std=c99"])
234 ACX_CHECK_COMPILER_FLAG(xc99, [C99FLAG="-xc99"])
236 AC_CHECK_HEADERS([getopt.h time.h],,, [AC_INCLUDES_DEFAULT])
238 ACX_CHECK_COMPILER_FLAG_NEEDED($C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_ALL_SOURCE,
240 #include "confdefs.h"
243 #include <sys/time.h>
260 const char* str = NULL;
263 t = ctime_r(&time, buf);
266 a = getopt(2, opts, "a");
268 str = gai_strerror(0);
269 if(str && t && tv.tv_usec && msg.msg_control)
273 ], [CFLAGS="$CFLAGS $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_ALL_SOURCE"])
275 ACX_CHECK_COMPILER_FLAG_NEEDED($C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_ALL_SOURCE,
277 #include "confdefs.h"
280 #include <sys/time.h>
297 const char* str = NULL;
300 t = ctime_r(&time, buf);
303 a = getopt(2, opts, "a");
305 str = gai_strerror(0);
306 if(str && t && tv.tv_usec && msg.msg_control)
310 ], [CFLAGS="$CFLAGS $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_ALL_SOURCE"])
312 ACX_CHECK_COMPILER_FLAG_NEEDED($C99FLAG,
320 ], [CFLAGS="$CFLAGS $C99FLAG"])
322 ACX_CHECK_COMPILER_FLAG_NEEDED(-D_BSD_SOURCE,
331 ], [CFLAGS="$CFLAGS -D_BSD_SOURCE"])
333 ACX_CHECK_COMPILER_FLAG_NEEDED(-D_GNU_SOURCE,
335 #include <netinet/in.h>
338 struct in6_pktinfo inf;
339 int a = (int)sizeof(inf);
342 ], [CFLAGS="$CFLAGS -D_GNU_SOURCE"])
344 # check again for GNU_SOURCE for setresgid. May fail if setresgid
345 # is not available at all. -D_FRSRESGID is to make this check unique.
346 # otherwise we would get the previous cached result.
347 ACX_CHECK_COMPILER_FLAG_NEEDED(-D_GNU_SOURCE -D_FRSRESGID,
352 int a = setresgid(0,0,0);
353 a = setresuid(0,0,0);
356 ], [CFLAGS="$CFLAGS -D_GNU_SOURCE"])
358 ACX_CHECK_COMPILER_FLAG_NEEDED(-D_POSIX_C_SOURCE=200112,
360 #include "confdefs.h"
371 const char* str = NULL;
372 t = ctime_r(&time, buf);
373 str = gai_strerror(0);
378 ], [CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200112"])
380 ACX_CHECK_COMPILER_FLAG_NEEDED(-D__EXTENSIONS__,
382 #include "confdefs.h"
385 #include <sys/time.h>
400 a = getopt(2, opts, "a");
406 ], [CFLAGS="$CFLAGS -D__EXTENSIONS__"])
408 ])dnl End of ACX_DETERMINE_EXT_FLAGS_UNBOUND
410 dnl Check if CC supports -flto.
411 dnl in a way that supports clang and suncc (that flag does something else,
412 dnl but fails to link). It sets it in CFLAGS if it works.
413 AC_DEFUN([ACX_CHECK_FLTO], [
414 AC_ARG_ENABLE([flto], AS_HELP_STRING([--disable-flto], [Disable link-time optimization (gcc specific option)]))
415 AS_IF([test "x$enable_flto" != "xno"], [
416 AC_MSG_CHECKING([if $CC supports -flto])
418 CFLAGS="$CFLAGS -flto"
419 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [
420 if $CC $CFLAGS -o conftest conftest.c 2>&1 | grep "warning: no debug symbols in executable" >/dev/null; then
426 rm -f conftest conftest.c conftest.o
427 ], [CFLAGS="$BAKCFLAGS" ; AC_MSG_RESULT(no)])
431 dnl Check the printf-format attribute (if any)
432 dnl result in HAVE_ATTR_FORMAT.
433 dnl Make sure you also include the AHX_CONFIG_FORMAT_ATTRIBUTE.
434 AC_DEFUN([ACX_CHECK_FORMAT_ATTRIBUTE],
435 [AC_REQUIRE([AC_PROG_CC])
436 AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "format" attribute)
437 AC_CACHE_VAL(ac_cv_c_format_attribute,
438 [ac_cv_c_format_attribute=no
441 void f (char *format, ...) __attribute__ ((format (printf, 1, 2)));
442 void (*pf) (char *format, ...) __attribute__ ((format (printf, 1, 2)));
446 [ac_cv_c_format_attribute="yes"],
447 [ac_cv_c_format_attribute="no"])
450 AC_MSG_RESULT($ac_cv_c_format_attribute)
451 if test $ac_cv_c_format_attribute = yes; then
452 AC_DEFINE(HAVE_ATTR_FORMAT, 1, [Whether the C compiler accepts the "format" attribute])
454 ])dnl End of ACX_CHECK_FORMAT_ATTRIBUTE
456 dnl Setup ATTR_FORMAT config.h parts.
457 dnl make sure you call ACX_CHECK_FORMAT_ATTRIBUTE also.
458 AC_DEFUN([AHX_CONFIG_FORMAT_ATTRIBUTE],
460 #ifdef HAVE_ATTR_FORMAT
461 # define ATTR_FORMAT(archetype, string_index, first_to_check) \
462 __attribute__ ((format (archetype, string_index, first_to_check)))
463 #else /* !HAVE_ATTR_FORMAT */
464 # define ATTR_FORMAT(archetype, string_index, first_to_check) /* empty */
465 #endif /* !HAVE_ATTR_FORMAT */
468 dnl Check how to mark function arguments as unused.
469 dnl result in HAVE_ATTR_UNUSED.
470 dnl Make sure you include AHX_CONFIG_UNUSED_ATTRIBUTE also.
471 AC_DEFUN([ACX_CHECK_UNUSED_ATTRIBUTE],
472 [AC_REQUIRE([AC_PROG_CC])
473 AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "unused" attribute)
474 AC_CACHE_VAL(ac_cv_c_unused_attribute,
475 [ac_cv_c_unused_attribute=no
478 void f (char *u __attribute__((unused)));
482 [ac_cv_c_unused_attribute="yes"],
483 [ac_cv_c_unused_attribute="no"])
486 dnl Setup ATTR_UNUSED config.h parts.
487 dnl make sure you call ACX_CHECK_UNUSED_ATTRIBUTE also.
488 AC_DEFUN([AHX_CONFIG_UNUSED_ATTRIBUTE],
491 # define ATTR_UNUSED(x) x
492 #elif defined(__cplusplus)
493 # define ATTR_UNUSED(x)
494 #elif defined(HAVE_ATTR_UNUSED)
495 # define ATTR_UNUSED(x) x __attribute__((unused))
496 #else /* !HAVE_ATTR_UNUSED */
497 # define ATTR_UNUSED(x) x
498 #endif /* !HAVE_ATTR_UNUSED */
501 AC_MSG_RESULT($ac_cv_c_unused_attribute)
502 if test $ac_cv_c_unused_attribute = yes; then
503 AC_DEFINE(HAVE_ATTR_UNUSED, 1, [Whether the C compiler accepts the "unused" attribute])
507 dnl Pre-fun for ACX_LIBTOOL_C_ONLY
508 AC_DEFUN([ACX_LIBTOOL_C_PRE], [
509 # skip these tests, we do not need them.
510 AC_DEFUN([AC_PROG_F77], [:])
511 AC_DEFUN([AC_PROG_FC], [:])
512 AC_DEFUN([AC_PROG_CXX], [:])
513 AC_DEFUN([AC_PROG_CXXCPP], [:])
514 AC_DEFUN([AC_PROG_OBJC], [:])
515 AC_DEFUN([AC_PROG_OBJCCPP], [:])
516 AC_DEFUN([AC_LIBTOOL_CXX], [:])
517 AC_DEFUN([AC_LIBTOOL_F77], [:])
518 # always use ./libtool unless override from commandline (libtool=mylibtool)
519 if test -z "$libtool"; then
523 # avoid libtool max commandline length test on systems that fork slowly.
525 if echo "$host_os" | grep "sunos4" >/dev/null; then
526 lt_cv_sys_max_cmd_len=32750;
528 AC_PATH_TOOL(AR, ar, [false])
529 if test $AR = false; then
530 AC_MSG_ERROR([Cannot find 'ar', please extend PATH to include it])
534 dnl Perform libtool check, portably, only for C
535 AC_DEFUN([ACX_LIBTOOL_C_ONLY], [
536 dnl as a requirement so that is gets called before LIBTOOL
537 dnl because libtools 'AC_REQUIRE' names are right after this one, before
538 dnl this function contents.
539 AC_REQUIRE([ACX_LIBTOOL_C_PRE])
543 dnl Detect if u_char type is defined, otherwise define it.
544 AC_DEFUN([ACX_TYPE_U_CHAR],
545 [AC_CHECK_TYPE([u_char], ,
546 [AC_DEFINE([u_char], [unsigned char], [Define to 'unsigned char if not defined])], [
548 #ifdef HAVE_WINSOCK2_H
549 # include <winsock2.h>
553 dnl Detect if rlim_t type is defined, otherwise define it.
554 AC_DEFUN([ACX_TYPE_RLIM_T],
555 [AC_CHECK_TYPE(rlim_t, ,
556 [AC_DEFINE([rlim_t], [unsigned long], [Define to 'int' if not defined])], [
558 #ifdef HAVE_SYS_RESOURCE_H
559 # include <sys/resource.h>
563 dnl Detect if socklen_t type is defined, otherwise define it.
564 AC_DEFUN([ACX_TYPE_SOCKLEN_T],
566 AC_CHECK_TYPE(socklen_t, ,
567 [AC_DEFINE([socklen_t], [int], [Define to 'int' if not defined])], [
569 #ifdef HAVE_SYS_SOCKET_H
570 # include <sys/socket.h>
572 #ifdef HAVE_WS2TCPIP_H
573 # include <ws2tcpip.h>
577 dnl Detect if in_addr_t type is defined, otherwise define it.
578 AC_DEFUN([ACX_TYPE_IN_ADDR_T],
579 [ AC_CHECK_TYPE(in_addr_t, [], [AC_DEFINE([in_addr_t], [uint32_t], [in_addr_t])], [
581 #ifdef HAVE_SYS_TYPES_H
582 # include <sys/types.h>
584 #ifdef HAVE_NETINET_IN_H
585 # include <netinet/in.h>
589 dnl Detect if in_port_t type is defined, otherwise define it.
590 AC_DEFUN([ACX_TYPE_IN_PORT_T],
591 [ AC_CHECK_TYPE(in_port_t, [], [AC_DEFINE([in_port_t], [uint16_t], [in_port_t])], [
593 #ifdef HAVE_SYS_TYPES_H
594 # include <sys/types.h>
596 #ifdef HAVE_NETINET_IN_H
597 # include <netinet/in.h>
601 dnl Add option to disable the evil rpath. Check whether to use rpath or not.
602 dnl Adds the --disable-rpath option. Uses trick to edit the ./libtool.
603 AC_DEFUN([ACX_ARG_RPATH],
606 [ --disable-rpath disable hardcoded rpath (default=enabled)],
607 enable_rpath=$enableval, enable_rpath=yes)
608 if test "x$enable_rpath" = xno; then
609 dnl AC_MSG_RESULT([Fixing libtool for -rpath problems.])
610 AC_CONFIG_COMMANDS([disable-rpath], [
611 sed < libtool > libtool-2 \
612 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_RPATH_SED__ "/'
620 dnl Add a -R to the RUNTIME_PATH. Only if rpath is enabled and it is
621 dnl an absolute path.
622 dnl $1: the pathname to add.
623 AC_DEFUN([ACX_RUNTIME_PATH_ADD], [
624 if test "x$enable_rpath" = xyes; then
625 if echo "$1" | grep "^/" >/dev/null; then
626 RUNTIME_PATH="$RUNTIME_PATH -R$1"
631 dnl Common code for both ACX_WITH_SSL and ACX_WITH_SSL_OPTIONAL
632 dnl Takes one argument; the withval checked in those 2 functions
633 dnl sets up the environment for the given openssl path
634 AC_DEFUN([ACX_SSL_CHECKS], [
636 if test x_$withval != x_no; then
637 AC_MSG_CHECKING(for SSL)
638 if test x_$withval = x_ -o x_$withval = x_yes; then
639 withval="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /opt/local /usr/sfw /usr"
641 for dir in $withval; do
643 if test -f "$dir/include/openssl/ssl.h"; then
645 AC_DEFINE_UNQUOTED([HAVE_SSL], [], [Define if you have the SSL libraries installed.])
646 dnl assume /usr/include is already in the include-path.
647 if test "$ssldir" != "/usr"; then
648 CPPFLAGS="$CPPFLAGS -I$ssldir/include"
649 LIBSSL_CPPFLAGS="$LIBSSL_CPPFLAGS -I$ssldir/include"
654 if test x_$found_ssl != x_yes; then
655 AC_MSG_ERROR(Cannot find the SSL libraries in $withval)
657 AC_MSG_RESULT(found in $ssldir)
659 dnl assume /usr is already in the lib and dynlib paths.
660 if test "$ssldir" != "/usr" -a "$ssldir" != ""; then
661 LDFLAGS="$LDFLAGS -L$ssldir/lib"
662 LIBSSL_LDFLAGS="$LIBSSL_LDFLAGS -L$ssldir/lib"
663 ACX_RUNTIME_PATH_ADD([$ssldir/lib])
666 AC_MSG_CHECKING([for HMAC_CTX_init in -lcrypto])
667 LIBS="$LIBS -lcrypto"
668 LIBSSL_LIBS="$LIBSSL_LIBS -lcrypto"
670 int HMAC_CTX_init(void);
671 (void)HMAC_CTX_init();
674 AC_DEFINE([HAVE_HMAC_CTX_INIT], 1,
675 [If you have HMAC_CTX_init])
678 # check if -lwsock32 or -lgdi32 are needed.
680 BAKSSLLIBS="$LIBSSL_LIBS"
682 LIBSSL_LIBS="$LIBSSL_LIBS -lgdi32"
683 AC_MSG_CHECKING([if -lcrypto needs -lgdi32])
685 int HMAC_CTX_init(void);
686 (void)HMAC_CTX_init();
688 AC_DEFINE([HAVE_HMAC_CTX_INIT], 1,
689 [If you have HMAC_CTX_init])
694 LIBSSL_LIBS="$BAKSSLLIBS"
696 LIBSSL_LIBS="$LIBSSL_LIBS -ldl"
697 AC_MSG_CHECKING([if -lcrypto needs -ldl])
699 int HMAC_CTX_init(void);
700 (void)HMAC_CTX_init();
702 AC_DEFINE([HAVE_HMAC_CTX_INIT], 1,
703 [If you have HMAC_CTX_init])
707 AC_MSG_ERROR([OpenSSL found in $ssldir, but version 0.9.7 or higher is required])
713 AC_SUBST(RUNTIME_PATH)
714 # openssl engine functionality needs dlopen().
716 AC_SEARCH_LIBS([dlopen], [dl])
717 if test "$LIBS" != "$BAKLIBS"; then
718 LIBSSL_LIBS="$LIBSSL_LIBS -ldl"
721 AC_CHECK_HEADERS([openssl/ssl.h],,, [AC_INCLUDES_DEFAULT])
722 AC_CHECK_HEADERS([openssl/err.h],,, [AC_INCLUDES_DEFAULT])
723 AC_CHECK_HEADERS([openssl/rand.h],,, [AC_INCLUDES_DEFAULT])
724 ])dnl End of ACX_SSL_CHECKS
726 dnl Check for SSL, where SSL is mandatory
727 dnl Adds --with-ssl option, searches for openssl and defines HAVE_SSL if found
728 dnl Setup of CPPFLAGS, CFLAGS. Adds -lcrypto to LIBS.
729 dnl Checks main header files of SSL.
731 AC_DEFUN([ACX_WITH_SSL],
733 AC_ARG_WITH(ssl, AC_HELP_STRING([--with-ssl=pathname],
734 [enable SSL (will check /usr/local/ssl
735 /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /opt/local /usr/sfw /usr)]),[
739 if test x_$withval = x_no; then
740 AC_MSG_ERROR([Need SSL library to do digital signature cryptography])
742 ACX_SSL_CHECKS($withval)
743 ])dnl End of ACX_WITH_SSL
745 dnl Check for SSL, where ssl is optional (--without-ssl is allowed)
746 dnl Adds --with-ssl option, searches for openssl and defines HAVE_SSL if found
747 dnl Setup of CPPFLAGS, CFLAGS. Adds -lcrypto to LIBS.
748 dnl Checks main header files of SSL.
750 AC_DEFUN([ACX_WITH_SSL_OPTIONAL],
752 AC_ARG_WITH(ssl, AC_HELP_STRING([--with-ssl=pathname],
753 [enable SSL (will check /usr/local/ssl
754 /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /opt/local /usr/sfw /usr)]),[
758 ACX_SSL_CHECKS($withval)
759 ])dnl End of ACX_WITH_SSL_OPTIONAL
761 dnl Setup to use -lssl
762 dnl To use -lcrypto, use the ACX_WITH_SSL setup (before this one).
763 AC_DEFUN([ACX_LIB_SSL],
765 # check if libssl needs libdl
768 AC_MSG_CHECKING([if libssl needs libdl])
769 AC_TRY_LINK_FUNC([SSL_CTX_new], [
775 AC_SEARCH_LIBS([dlopen], [dl])
776 ]) ])dnl End of ACX_LIB_SSL
778 dnl Setup to use very large files (>2Gb).
779 dnl setups fseeko and its own
780 AC_DEFUN([ACX_SYS_LARGEFILE],
783 dnl try to see if an additional _LARGEFILE_SOURCE 1 is needed to get fseeko
784 ACX_CHECK_COMPILER_FLAG_NEEDED(-D_LARGEFILE_SOURCE=1,
788 int a = fseeko(stdin, 0, 0);
791 ], [CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE=1"])
794 dnl Check getaddrinfo.
795 dnl Works on linux, solaris, bsd and windows(links winsock).
796 dnl defines HAVE_GETADDRINFO, USE_WINSOCK.
797 AC_DEFUN([ACX_CHECK_GETADDRINFO_WITH_INCLUDES],
798 [AC_REQUIRE([AC_PROG_CC])
799 AC_MSG_CHECKING(for getaddrinfo)
800 ac_cv_func_getaddrinfo=no
808 char* (*f) () = getaddrinfo;
817 dnl this case on linux, solaris, bsd
818 [ac_cv_func_getaddrinfo="yes"
819 dnl see if on windows
820 if test "$ac_cv_header_windows_h" = "yes"; then
821 AC_DEFINE(USE_WINSOCK, 1, [Whether the windows socket API is used])
823 LIBS="$LIBS -lws2_32"
826 dnl no quick getaddrinfo, try mingw32 and winsock2 library.
828 LIBS="$LIBS -lws2_32"
832 #ifdef HAVE_WS2TCPIP_H
833 #include <ws2tcpip.h>
837 (void)getaddrinfo(NULL, NULL, NULL, NULL);
841 ac_cv_func_getaddrinfo="yes"
842 dnl already: LIBS="$LIBS -lws2_32"
843 AC_DEFINE(USE_WINSOCK, 1, [Whether the windows socket API is used])
847 ac_cv_func_getaddrinfo="no"
852 AC_MSG_RESULT($ac_cv_func_getaddrinfo)
853 if test $ac_cv_func_getaddrinfo = yes; then
854 AC_DEFINE(HAVE_GETADDRINFO, 1, [Whether getaddrinfo is available])
856 ])dnl Endof AC_CHECK_GETADDRINFO_WITH_INCLUDES
858 dnl check if a function is deprecated. defines DEPRECATED_func in config.h.
859 dnl $1: function name
860 dnl $2: C-statement that calls the function.
861 dnl $3: includes for the program.
862 dnl $4: executes if yes
863 dnl $5: executes if no
864 AC_DEFUN([ACX_FUNC_DEPRECATED],
866 AC_REQUIRE([AC_PROG_CC])
867 AC_MSG_CHECKING(if $1 is deprecated)
868 cache=`echo $1 | sed 'y%.=/+-%___p_%'`
869 AC_CACHE_VAL(cv_cc_deprecated_$cache,
871 echo '$3' >conftest.c
872 echo 'void f(){ $2 }' >>conftest.c
873 if test -z "`$CC -c conftest.c 2>&1 | grep deprecated`"; then
874 eval "cv_cc_deprecated_$cache=no"
876 eval "cv_cc_deprecated_$cache=yes"
878 rm -f conftest conftest.o conftest.c
880 if eval "test \"`echo '$cv_cc_deprecated_'$cache`\" = yes"; then
882 AC_DEFINE_UNQUOTED(AS_TR_CPP([DEPRECATED_$1]), 1, [Whether $1 is deprecated])
890 ])dnl end of ACX_FUNC_DEPRECATED
892 dnl check if select and nonblocking sockets actually work.
893 dnl Needs fork(2) and select(2).
894 dnl defines NONBLOCKING_IS_BROKEN, and if that is true multiple reads from
895 dnl a nonblocking socket do not work, a new call to select is necessary.
896 AC_DEFUN([ACX_CHECK_NONBLOCKING_BROKEN],
898 AC_MSG_CHECKING([if nonblocking sockets work])
899 if echo $target | grep mingw32 >/dev/null; then
900 AC_MSG_RESULT([no (windows)])
901 AC_DEFINE([NONBLOCKING_IS_BROKEN], 1, [Define if the network stack does not fully support nonblocking io (causes lower performance).])
910 #ifdef HAVE_SYS_TYPES_H
911 #include <sys/types.h>
913 #ifdef HAVE_SYS_SOCKET_H
914 #include <sys/socket.h>
916 #ifdef HAVE_NETINET_IN_H
917 #include <netinet/in.h>
919 #ifdef HAVE_ARPA_INET_H
920 #include <arpa/inet.h>
935 struct sockaddr_in a;
936 /* test if select and nonblocking reads work well together */
938 fork child to send 10 messages.
940 then try to nonblocking read the 10 messages
941 then, nonblocking read must give EAGAIN
944 port = 12345 + (time(0)%32);
945 sfd = socket(PF_INET, SOCK_DGRAM, 0);
950 memset(&a, 0, sizeof(a));
951 a.sin_family = AF_INET;
952 a.sin_port = htons(port);
953 a.sin_addr.s_addr = inet_addr("127.0.0.1");
954 if(bind(sfd, (struct sockaddr*)&a, sizeof(a)) < 0) {
958 if(fcntl(sfd, F_SETFL, O_NONBLOCK) == -1) {
963 cfd = socket(PF_INET, SOCK_DGRAM, 0);
965 perror("client socket");
969 if(bind(cfd, (struct sockaddr*)&a, sizeof(a)) < 0) {
970 perror("client bind");
973 a.sin_port = htons(port);
975 /* no handler, causes exit in 10 seconds */
978 /* send and receive on the socket */
979 if((p=fork()) == 0) {
980 for(i=0; i<num; i++) {
981 if(sendto(cfd, &i, sizeof(i), 0,
982 (struct sockaddr*)&a, sizeof(a)) < 0) {
997 if(select(sfd+1, &rset, NULL, NULL, NULL) < 1) {
1003 if(recv(sfd, &x, sizeof(x), 0) != sizeof(x)) {
1011 /* now we want to get EAGAIN: nonblocking goodness */
1013 recv(sfd, &x, sizeof(x), 0);
1014 if(errno != EAGAIN) {
1015 perror("trying to recv again");
1018 /* EAGAIN encountered */
1026 AC_MSG_RESULT([yes])
1029 AC_DEFINE([NONBLOCKING_IS_BROKEN], 1, [Define if the network stack does not fully support nonblocking io (causes lower performance).])
1031 AC_MSG_RESULT([crosscompile(yes)])
1034 ])dnl End of ACX_CHECK_NONBLOCKING_BROKEN
1036 dnl Check if mkdir has one or two arguments.
1037 dnl defines MKDIR_HAS_ONE_ARG
1038 AC_DEFUN([ACX_MKDIR_ONE_ARG],
1040 AC_MSG_CHECKING([whether mkdir has one arg])
1044 #ifdef HAVE_WINSOCK2_H
1045 #include <winsock2.h>
1047 #ifdef HAVE_SYS_STAT_H
1048 #include <sys/stat.h>
1051 (void)mkdir("directory");
1054 AC_DEFINE(MKDIR_HAS_ONE_ARG, 1, [Define if mkdir has one argument.])
1058 ])dnl end of ACX_MKDIR_ONE_ARG
1060 dnl Check for ioctlsocket function. works on mingw32 too.
1061 AC_DEFUN([ACX_FUNC_IOCTLSOCKET],
1064 AC_MSG_CHECKING(for ioctlsocket)
1065 AC_LINK_IFELSE([AC_LANG_PROGRAM([
1066 #ifdef HAVE_WINSOCK2_H
1067 #include <winsock2.h>
1070 (void)ioctlsocket(0, 0, NULL);
1073 AC_DEFINE(HAVE_IOCTLSOCKET, 1, [if the function 'ioctlsocket' is available])
1074 ],[AC_MSG_RESULT(no)])
1075 ])dnl end of ACX_FUNC_IOCTLSOCKET
1077 dnl detect malloc and provide malloc compat prototype.
1078 dnl $1: unique name for compat code
1079 AC_DEFUN([ACX_FUNC_MALLOC],
1081 AC_MSG_CHECKING([for GNU libc compatible malloc])
1082 AC_RUN_IFELSE([AC_LANG_PROGRAM(
1083 [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
1088 ]], [ if(malloc(0) != 0) return 1;])
1090 [AC_MSG_RESULT([no])
1092 AC_DEFINE_UNQUOTED([malloc], [rpl_malloc_$1], [Define if replacement function should be used.])] ,
1093 [AC_MSG_RESULT([yes])
1094 AC_DEFINE([HAVE_MALLOC], 1, [If have GNU libc compatible malloc])],
1095 [AC_MSG_RESULT([no (crosscompile)])
1097 AC_DEFINE_UNQUOTED([malloc], [rpl_malloc_$1], [Define if replacement function should be used.])] )
1100 dnl Define fallback for fseeko and ftello if needed.
1101 AC_DEFUN([AHX_CONFIG_FSEEKO],
1104 #define fseeko fseek
1105 #define ftello ftell
1106 #endif /* HAVE_FSEEKO */
1109 dnl Define RAND_MAX if not defined
1110 AC_DEFUN([AHX_CONFIG_RAND_MAX],
1113 #define RAND_MAX 2147483647
1117 dnl Define MAXHOSTNAMELEN if not defined
1118 AC_DEFUN([AHX_CONFIG_MAXHOSTNAMELEN],
1120 #ifndef MAXHOSTNAMELEN
1121 #define MAXHOSTNAMELEN 256
1125 dnl Define IPV6_MIN_MTU if not defined
1126 AC_DEFUN([AHX_CONFIG_IPV6_MIN_MTU],
1128 #ifndef IPV6_MIN_MTU
1129 #define IPV6_MIN_MTU 1280
1130 #endif /* IPV6_MIN_MTU */
1133 dnl provide snprintf, vsnprintf compat prototype
1134 dnl $1: unique name for compat code
1135 AC_DEFUN([AHX_CONFIG_SNPRINTF],
1137 #ifndef HAVE_SNPRINTF
1138 #define snprintf snprintf_$1
1139 #define vsnprintf vsnprintf_$1
1141 int snprintf (char *str, size_t count, const char *fmt, ...);
1142 int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
1143 #endif /* HAVE_SNPRINTF */
1146 dnl provide inet_pton compat prototype.
1147 dnl $1: unique name for compat code
1148 AC_DEFUN([AHX_CONFIG_INET_PTON],
1150 #ifndef HAVE_INET_PTON
1151 #define inet_pton inet_pton_$1
1152 int inet_pton(int af, const char* src, void* dst);
1153 #endif /* HAVE_INET_PTON */
1156 dnl provide inet_ntop compat prototype.
1157 dnl $1: unique name for compat code
1158 AC_DEFUN([AHX_CONFIG_INET_NTOP],
1160 #ifndef HAVE_INET_NTOP
1161 #define inet_ntop inet_ntop_$1
1162 const char *inet_ntop(int af, const void *src, char *dst, size_t size);
1166 dnl provide inet_aton compat prototype.
1167 dnl $1: unique name for compat code
1168 AC_DEFUN([AHX_CONFIG_INET_ATON],
1170 #ifndef HAVE_INET_ATON
1171 #define inet_aton inet_aton_$1
1172 int inet_aton(const char *cp, struct in_addr *addr);
1176 dnl provide memmove compat prototype.
1177 dnl $1: unique name for compat code
1178 AC_DEFUN([AHX_CONFIG_MEMMOVE],
1180 #ifndef HAVE_MEMMOVE
1181 #define memmove memmove_$1
1182 void *memmove(void *dest, const void *src, size_t n);
1186 dnl provide strlcat compat prototype.
1187 dnl $1: unique name for compat code
1188 AC_DEFUN([AHX_CONFIG_STRLCAT],
1190 #ifndef HAVE_STRLCAT
1191 #define strlcat strlcat_$1
1192 size_t strlcat(char *dst, const char *src, size_t siz);
1196 dnl provide strlcpy compat prototype.
1197 dnl $1: unique name for compat code
1198 AC_DEFUN([AHX_CONFIG_STRLCPY],
1200 #ifndef HAVE_STRLCPY
1201 #define strlcpy strlcpy_$1
1202 size_t strlcpy(char *dst, const char *src, size_t siz);
1206 dnl provide gmtime_r compat prototype.
1207 dnl $1: unique name for compat code
1208 AC_DEFUN([AHX_CONFIG_GMTIME_R],
1210 #ifndef HAVE_GMTIME_R
1211 #define gmtime_r gmtime_r_$1
1212 struct tm *gmtime_r(const time_t *timep, struct tm *result);
1216 dnl provide w32 compat definition for sleep
1217 AC_DEFUN([AHX_CONFIG_W32_SLEEP],
1219 #if !defined(HAVE_SLEEP) || defined(HAVE_WINDOWS_H)
1220 #define sleep(x) Sleep((x)*1000) /* on win32 */
1221 #endif /* HAVE_SLEEP */
1224 dnl provide w32 compat definition for usleep
1225 AC_DEFUN([AHX_CONFIG_W32_USLEEP],
1228 #define usleep(x) Sleep((x)/1000 + 1) /* on win32 */
1229 #endif /* HAVE_USLEEP */
1232 dnl provide w32 compat definition for random
1233 AC_DEFUN([AHX_CONFIG_W32_RANDOM],
1236 #define random rand /* on win32, for tests only (bad random) */
1237 #endif /* HAVE_RANDOM */
1240 dnl provide w32 compat definition for srandom
1241 AC_DEFUN([AHX_CONFIG_W32_SRANDOM],
1243 #ifndef HAVE_SRANDOM
1244 #define srandom(x) srand(x) /* on win32, for tests only (bad random) */
1245 #endif /* HAVE_SRANDOM */
1248 dnl provide w32 compat definition for FD_SET_T
1249 AC_DEFUN([AHX_CONFIG_W32_FD_SET_T],
1251 /* detect if we need to cast to unsigned int for FD_SET to avoid warnings */
1252 #ifdef HAVE_WINSOCK2_H
1253 #define FD_SET_T (u_int)
1259 dnl Remove an extension flag from CFLAGS, define replacement to be made.
1260 dnl Used by ACX_STRIP_EXT_FLAGS.
1261 dnl $1: the name of the flag, for example -D_GNU_SOURCE.
1262 AC_DEFUN([ACX_CFLAGS_STRIP],
1264 if echo $CFLAGS | grep " $1" >/dev/null 2>&1; then
1265 CFLAGS="`echo $CFLAGS | sed -e 's/ $1//g'`"
1266 AC_DEFINE(m4_bpatsubst(OMITTED_$1,[[-=]],_), 1, Put $1 define in config.h)
1270 dnl Remove EXT flags from the CFLAGS and set them to be defined in config.h
1271 dnl use with ACX_DETERMINE_EXT_FLAGS.
1272 AC_DEFUN([ACX_STRIP_EXT_FLAGS],
1274 AC_MSG_NOTICE([Stripping extension flags...])
1275 ACX_CFLAGS_STRIP(-D_GNU_SOURCE)
1276 ACX_CFLAGS_STRIP(-D_BSD_SOURCE)
1277 ACX_CFLAGS_STRIP(-D__EXTENSIONS__)
1278 ACX_CFLAGS_STRIP(-D_POSIX_C_SOURCE=200112)
1279 ACX_CFLAGS_STRIP(-D_XOPEN_SOURCE=600)
1280 ACX_CFLAGS_STRIP(-D_XOPEN_SOURCE_EXTENDED=1)
1281 ACX_CFLAGS_STRIP(-D_ALL_SOURCE)
1282 ACX_CFLAGS_STRIP(-D_LARGEFILE_SOURCE=1)
1283 ]) dnl End of ACX_STRIP_EXT_FLAGS
1285 dnl define one omitted flag for config.h
1286 dnl $1: flag name. -D_GNU_SOURCE
1287 dnl $2: replacement define. _GNU_SOURCE
1288 dnl $3: define value, 1
1289 AC_DEFUN([AHX_CONFIG_FLAG_OMITTED],
1290 [#if defined($1) && !defined($2)
1294 dnl Wrapper for AHX_CONFIG_FLAG_OMITTED for -D style flags
1295 dnl $1: the -DNAME or -DNAME=value string.
1296 AC_DEFUN([AHX_CONFIG_FLAG_EXT],
1297 [AHX_CONFIG_FLAG_OMITTED(m4_bpatsubst(OMITTED_$1,[[-=]],_),m4_bpatsubst(m4_bpatsubst($1,-D,),=.*$,),m4_if(m4_bregexp($1,=),-1,1,m4_bpatsubst($1,^.*=,)))
1300 dnl config.h part to define omitted cflags, use with ACX_STRIP_EXT_FLAGS.
1301 AC_DEFUN([AHX_CONFIG_EXT_FLAGS],
1302 [AHX_CONFIG_FLAG_EXT(-D_GNU_SOURCE)
1303 AHX_CONFIG_FLAG_EXT(-D_BSD_SOURCE)
1304 AHX_CONFIG_FLAG_EXT(-D__EXTENSIONS__)
1305 AHX_CONFIG_FLAG_EXT(-D_POSIX_C_SOURCE=200112)
1306 AHX_CONFIG_FLAG_EXT(-D_XOPEN_SOURCE=600)
1307 AHX_CONFIG_FLAG_EXT(-D_XOPEN_SOURCE_EXTENDED=1)
1308 AHX_CONFIG_FLAG_EXT(-D_ALL_SOURCE)
1309 AHX_CONFIG_FLAG_EXT(-D_LARGEFILE_SOURCE=1)
1312 dnl check if memcmp is using signed characters and replace if so.
1313 AC_DEFUN([ACX_CHECK_MEMCMP_SIGNED],
1314 [AC_MSG_CHECKING([if memcmp compares unsigned])
1315 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1321 char a = 255, b = 0;
1322 if(memcmp(&a, &b, 1) < 0)
1326 ]])], [AC_MSG_RESULT([yes]) ],
1327 [ AC_MSG_RESULT([no])
1328 AC_DEFINE([MEMCMP_IS_BROKEN], [1], [Define if memcmp() does not compare unsigned bytes])
1330 ], [ AC_MSG_RESULT([cross-compile no])
1331 AC_DEFINE([MEMCMP_IS_BROKEN], [1], [Define if memcmp() does not compare unsigned bytes])
1335 dnl define memcmp to its replacement, pass unique id for program as arg
1336 AC_DEFUN([AHX_MEMCMP_BROKEN], [
1337 #ifdef MEMCMP_IS_BROKEN
1338 #include "compat/memcmp.h"
1339 #define memcmp memcmp_$1
1340 int memcmp(const void *x, const void *y, size_t n);
1344 dnl ACX_CHECK_SS_FAMILY - check for sockaddr_storage.ss_family
1345 AC_DEFUN([ACX_CHECK_SS_FAMILY],
1346 [AC_CHECK_MEMBER([struct sockaddr_storage.ss_family], [], [
1347 AC_CHECK_MEMBER([struct sockaddr_storage.__ss_family], [
1348 AC_DEFINE([ss_family], [__ss_family], [Fallback member name for socket family in struct sockaddr_storage])
1349 ],, [AC_INCLUDES_DEFAULT
1350 #ifdef HAVE_NETINET_IN_H
1351 #include <netinet/in.h>
1353 #ifdef HAVE_SYS_SOCKET_H
1354 #include <sys/socket.h>
1359 #ifdef HAVE_ARPA_INET_H
1360 #include <arpa/inet.h>
1363 ], [AC_INCLUDES_DEFAULT
1364 #ifdef HAVE_NETINET_IN_H
1365 #include <netinet/in.h>
1367 #ifdef HAVE_SYS_SOCKET_H
1368 #include <sys/socket.h>
1373 #ifdef HAVE_ARPA_INET_H
1374 #include <arpa/inet.h>