acx_nlnetlabs.m4 revision 287917
1238106Sdes# acx_nlnetlabs.m4 - common macros for configure checks 2238106Sdes# Copyright 2009, Wouter Wijngaards, NLnet Labs. 3238106Sdes# BSD licensed. 4238106Sdes# 5287917Sdes# Version 27 6287917Sdes# 2015-03-17 AHX_CONFIG_REALLOCARRAY added 7266114Sdes# 2013-09-19 FLTO help text improved. 8266114Sdes# 2013-07-18 Enable ACX_CHECK_COMPILER_FLAG to test for -Wstrict-prototypes 9266114Sdes# 2013-06-25 FLTO has --disable-flto option. 10266114Sdes# 2013-05-03 Update W32_SLEEP for newer mingw that links but not defines it. 11266114Sdes# 2013-03-22 Fix ACX_RSRC_VERSION for long version numbers. 12238106Sdes# 2012-02-09 Fix AHX_MEMCMP_BROKEN with undef in compat/memcmp.h. 13238106Sdes# 2012-01-20 Fix COMPILER_FLAGS_UNBOUND for gcc 4.6.2 assigned-not-used-warns. 14238106Sdes# 2011-12-05 Fix getaddrinfowithincludes on windows with fedora16 mingw32-gcc. 15238106Sdes# Fix ACX_MALLOC for redefined malloc error. 16238106Sdes# Fix GETADDRINFO_WITH_INCLUDES to add -lws2_32 17238106Sdes# 2011-11-10 Fix FLTO test to not drop a.out in current directory. 18238106Sdes# 2011-11-01 Fix FLTO test for llvm on Lion. 19238106Sdes# 2011-08-01 Fix nonblock test (broken at v13). 20238106Sdes# 2011-08-01 Fix autoconf 2.68 warnings 21238106Sdes# 2011-06-23 Add ACX_CHECK_FLTO to check -flto. 22238106Sdes# 2010-08-16 Fix FLAG_OMITTED for AS_TR_CPP changes in autoconf-2.66. 23238106Sdes# 2010-07-02 Add check for ss_family (for minix). 24238106Sdes# 2010-04-26 Fix to use CPPFLAGS for CHECK_COMPILER_FLAGS. 25238106Sdes# 2010-03-01 Fix RPATH using CONFIG_COMMANDS to run at the very end. 26238106Sdes# 2010-02-18 WITH_SSL outputs the LIBSSL_LDFLAGS, LIBS, CPPFLAGS seperate, -ldl 27238106Sdes# 2010-02-01 added ACX_CHECK_MEMCMP_SIGNED, AHX_MEMCMP_BROKEN 28238106Sdes# 2010-01-20 added AHX_COONFIG_STRLCAT 29238106Sdes# 2009-07-14 U_CHAR detection improved for windows crosscompile. 30238106Sdes# added ACX_FUNC_MALLOC 31238106Sdes# fixup some #if to #ifdef 32238106Sdes# NONBLOCKING test for mingw crosscompile. 33238106Sdes# 2009-07-13 added ACX_WITH_SSL_OPTIONAL 34238106Sdes# 2009-07-03 fixup LDFLAGS for empty ssl dir. 35238106Sdes# 36238106Sdes# Automates some of the checking constructs. Aims at portability for POSIX. 37238106Sdes# Documentation for functions is below. 38238106Sdes# 39238106Sdes# the following macro's are provided in this file: 40238106Sdes# (see below for details on each macro). 41238106Sdes# 42238106Sdes# ACX_ESCAPE_BACKSLASH - escape backslashes in var for C-preproc. 43238106Sdes# ACX_RSRC_VERSION - create windows resource version number. 44238106Sdes# ACX_CHECK_COMPILER_FLAG - see if cc supports a flag. 45238106Sdes# ACX_CHECK_ERROR_FLAGS - see which flag is -werror (used below). 46238106Sdes# ACX_CHECK_COMPILER_FLAG_NEEDED - see if flags make the code compile cleanly. 47238106Sdes# ACX_DEPFLAG - find cc dependency flags. 48238106Sdes# ACX_DETERMINE_EXT_FLAGS_UNBOUND - find out which flags enable BSD and POSIX. 49238106Sdes# ACX_CHECK_FORMAT_ATTRIBUTE - find cc printf format syntax. 50238106Sdes# ACX_CHECK_UNUSED_ATTRIBUTE - find cc variable unused syntax. 51238106Sdes# ACX_CHECK_FLTO - see if cc supports -flto and use it if so. 52238106Sdes# ACX_LIBTOOL_C_ONLY - create libtool for C only, improved. 53238106Sdes# ACX_TYPE_U_CHAR - u_char type. 54238106Sdes# ACX_TYPE_RLIM_T - rlim_t type. 55238106Sdes# ACX_TYPE_SOCKLEN_T - socklen_t type. 56238106Sdes# ACX_TYPE_IN_ADDR_T - in_addr_t type. 57238106Sdes# ACX_TYPE_IN_PORT_T - in_port_t type. 58238106Sdes# ACX_ARG_RPATH - add --disable-rpath option. 59238106Sdes# ACX_WITH_SSL - add --with-ssl option, link -lcrypto. 60238106Sdes# ACX_WITH_SSL_OPTIONAL - add --with-ssl option, link -lcrypto, 61238106Sdes# where --without-ssl is also accepted 62238106Sdes# ACX_LIB_SSL - setup to link -lssl. 63238106Sdes# ACX_SYS_LARGEFILE - improved sys_largefile, fseeko, >2G files. 64238106Sdes# ACX_CHECK_GETADDRINFO_WITH_INCLUDES - find getaddrinfo, portably. 65238106Sdes# ACX_FUNC_DEPRECATED - see if func is deprecated. 66238106Sdes# ACX_CHECK_NONBLOCKING_BROKEN - see if nonblocking sockets really work. 67238106Sdes# ACX_MKDIR_ONE_ARG - determine mkdir(2) number of arguments. 68238106Sdes# ACX_FUNC_IOCTLSOCKET - find ioctlsocket, portably. 69238106Sdes# ACX_FUNC_MALLOC - check malloc, define replacement . 70238106Sdes# AHX_CONFIG_FORMAT_ATTRIBUTE - config.h text for format. 71238106Sdes# AHX_CONFIG_UNUSED_ATTRIBUTE - config.h text for unused. 72238106Sdes# AHX_CONFIG_FSEEKO - define fseeko, ftello fallback. 73238106Sdes# AHX_CONFIG_RAND_MAX - define RAND_MAX if needed. 74238106Sdes# AHX_CONFIG_MAXHOSTNAMELEN - define MAXHOSTNAMELEN if needed. 75238106Sdes# AHX_CONFIG_IPV6_MIN_MTU - define IPV6_MIN_MTU if needed. 76238106Sdes# AHX_CONFIG_SNPRINTF - snprintf compat prototype 77238106Sdes# AHX_CONFIG_INET_PTON - inet_pton compat prototype 78238106Sdes# AHX_CONFIG_INET_NTOP - inet_ntop compat prototype 79238106Sdes# AHX_CONFIG_INET_ATON - inet_aton compat prototype 80238106Sdes# AHX_CONFIG_MEMMOVE - memmove compat prototype 81238106Sdes# AHX_CONFIG_STRLCAT - strlcat compat prototype 82238106Sdes# AHX_CONFIG_STRLCPY - strlcpy compat prototype 83238106Sdes# AHX_CONFIG_GMTIME_R - gmtime_r compat prototype 84238106Sdes# AHX_CONFIG_W32_SLEEP - w32 compat for sleep 85238106Sdes# AHX_CONFIG_W32_USLEEP - w32 compat for usleep 86238106Sdes# AHX_CONFIG_W32_RANDOM - w32 compat for random 87238106Sdes# AHX_CONFIG_W32_SRANDOM - w32 compat for srandom 88238106Sdes# AHX_CONFIG_W32_FD_SET_T - w32 detection of FD_SET_T. 89238106Sdes# ACX_CFLAGS_STRIP - strip one flag from CFLAGS 90238106Sdes# ACX_STRIP_EXT_FLAGS - strip extension flags from CFLAGS 91238106Sdes# AHX_CONFIG_FLAG_OMITTED - define omitted flag 92238106Sdes# AHX_CONFIG_FLAG_EXT - define omitted extension flag 93238106Sdes# AHX_CONFIG_EXT_FLAGS - define the stripped extension flags 94238106Sdes# ACX_CHECK_MEMCMP_SIGNED - check if memcmp uses signed characters. 95238106Sdes# AHX_MEMCMP_BROKEN - replace memcmp func for CHECK_MEMCMP_SIGNED. 96238106Sdes# ACX_CHECK_SS_FAMILY - check for sockaddr_storage.ss_family 97238106Sdes# 98238106Sdes 99238106Sdesdnl Escape backslashes as \\, for C:\ paths, for the C preprocessor defines. 100238106Sdesdnl for example, ACX_ESCAPE_BACKSLASH($from_var, to_var) 101238106Sdesdnl $1: the text to change. 102238106Sdesdnl $2: the result. 103238106SdesAC_DEFUN([ACX_ESCAPE_BACKSLASH], [$2="`echo $1 | sed -e 's/\\\\/\\\\\\\\/g'`" 104238106Sdes]) 105238106Sdes 106238106Sdesdnl Calculate comma separated windows-resource numbers from package version. 107238106Sdesdnl Picks the first three(,0) or four numbers out of the name. 108238106Sdesdnl $1: variable for the result 109238106SdesAC_DEFUN([ACX_RSRC_VERSION], 110266114Sdes[$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/' `] 111238106Sdes]) 112238106Sdes 113238106Sdesdnl Routine to help check for compiler flags. 114238106Sdesdnl Checks if the compiler will accept the flag. 115238106Sdesdnl $1: the flag without a - in front, so g to check -g. 116238106Sdesdnl $2: executed if yes 117238106Sdesdnl $3: executed if no 118238106SdesAC_DEFUN([ACX_CHECK_COMPILER_FLAG], 119238106Sdes[ 120238106SdesAC_REQUIRE([AC_PROG_CC]) 121238106SdesAC_MSG_CHECKING(whether $CC supports -$1) 122238106Sdescache=`echo $1 | sed 'y%.=/+-%___p_%'` 123238106SdesAC_CACHE_VAL(cv_prog_cc_flag_$cache, 124238106Sdes[ 125266114Sdesecho 'void f(void){}' >conftest.c 126238106Sdesif test -z "`$CC $CPPFLAGS $CFLAGS -$1 -c conftest.c 2>&1`"; then 127238106Sdeseval "cv_prog_cc_flag_$cache=yes" 128238106Sdeselse 129238106Sdeseval "cv_prog_cc_flag_$cache=no" 130238106Sdesfi 131238106Sdesrm -f conftest conftest.o conftest.c 132238106Sdes]) 133238106Sdesif eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then 134238106SdesAC_MSG_RESULT(yes) 135238106Sdes: 136238106Sdes$2 137238106Sdeselse 138238106SdesAC_MSG_RESULT(no) 139238106Sdes: 140238106Sdes$3 141238106Sdesfi 142238106Sdes]) 143238106Sdes 144238106Sdesdnl setup flags for ACX_CHECK_COMPILER_FLAG_NEEDED 145238106Sdesdnl ERRFLAG: result, compiler flag to turn warnings into errors 146238106SdesAC_DEFUN([ACX_CHECK_ERROR_FLAGS], 147238106Sdes[ 148238106SdesACX_CHECK_COMPILER_FLAG(Werror, [ERRFLAG="-Werror"], [ERRFLAG="-errwarn"]) 149238106SdesACX_CHECK_COMPILER_FLAG(Wall, [ERRFLAG="$ERRFLAG -Wall"], 150238106Sdes [ERRFLAG="$ERRFLAG -errfmt"]) 151238106Sdes]) 152238106Sdes 153238106Sdesdnl Routine to help check for needed compiler flags. 154238106Sdesdnl $1: flags for CC 155238106Sdesdnl $2: the includes and code 156238106Sdesdnl $3: if the given code only compiles with the flag, execute argument 3 157238106Sdesdnl $4: if the given code compiles without the flag, execute argument 4 158238106Sdesdnl $5: with and without flag the compile fails, execute argument 5. 159238106SdesAC_DEFUN([ACX_CHECK_COMPILER_FLAG_NEEDED], 160238106Sdes[ 161238106SdesAC_REQUIRE([AC_PROG_CC]) 162238106SdesAC_REQUIRE([ACX_CHECK_ERROR_FLAGS]) 163238106SdesAC_MSG_CHECKING(whether we need $1 as a flag for $CC) 164238106Sdescache=AS_TR_SH($1) 165238106Sdesdnl cache=`echo $1 | sed 'y%.=/+- %___p__%'` 166238106SdesAC_CACHE_VAL(cv_prog_cc_flag_needed_$cache, 167238106Sdes[ 168238106Sdesecho '$2' > conftest.c 169238106Sdesecho 'void f(){}' >>conftest.c 170238106Sdesif test -z "`$CC $CPPFLAGS $CFLAGS $ERRFLAG -c conftest.c 2>&1`"; then 171238106Sdeseval "cv_prog_cc_flag_needed_$cache=no" 172238106Sdeselse 173238106Sdes[ 174238106Sdesif test -z "`$CC $CPPFLAGS $CFLAGS $1 $ERRFLAG -c conftest.c 2>&1`"; then 175238106Sdeseval "cv_prog_cc_flag_needed_$cache=yes" 176238106Sdeselse 177238106Sdeseval "cv_prog_cc_flag_needed_$cache=fail" 178238106Sdes#echo 'Test with flag fails too!' 179238106Sdes#cat conftest.c 180238106Sdes#echo "$CC $CPPFLAGS $CFLAGS $1 $ERRFLAG -c conftest.c 2>&1" 181238106Sdes#echo `$CC $CPPFLAGS $CFLAGS $1 $ERRFLAG -c conftest.c 2>&1` 182238106Sdes#exit 1 183238106Sdesfi 184238106Sdes] 185238106Sdesfi 186238106Sdesrm -f conftest conftest.c conftest.o 187238106Sdes]) 188238106Sdesif eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = yes"; then 189238106SdesAC_MSG_RESULT(yes) 190238106Sdes: 191238106Sdes$3 192238106Sdeselse 193238106Sdesif eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = no"; then 194238106SdesAC_MSG_RESULT(no) 195238106Sdes#echo 'Test with flag is no!' 196238106Sdes#cat conftest.c 197238106Sdes#echo "$CC $CPPFLAGS $CFLAGS $1 $ERRFLAG -c conftest.c 2>&1" 198238106Sdes#echo `$CC $CPPFLAGS $CFLAGS $1 $ERRFLAG -c conftest.c 2>&1` 199238106Sdes#exit 1 200238106Sdes: 201238106Sdes$4 202238106Sdeselse 203238106SdesAC_MSG_RESULT(failed) 204238106Sdes: 205238106Sdes$5 206238106Sdesfi 207238106Sdesfi 208238106Sdes]) 209238106Sdes 210238106Sdesdnl Check for CC dependency flag 211238106Sdesdnl DEPFLAG: set to flag that generates dependencies. 212238106SdesAC_DEFUN([ACX_DEPFLAG], 213238106Sdes[ 214238106SdesAC_MSG_CHECKING([$CC dependency flag]) 215238106Sdesecho 'void f(){}' >conftest.c 216238106Sdesif test "`$CC -MM conftest.c 2>&1`" = "conftest.o: conftest.c"; then 217238106Sdes DEPFLAG="-MM" 218238106Sdeselse 219238106Sdes if test "`$CC -xM1 conftest.c 2>&1`" = "conftest.o: conftest.c"; then 220238106Sdes DEPFLAG="-xM1" 221238106Sdes else 222238106Sdes DEPFLAG="-MM" # dunno do something 223238106Sdes fi 224238106Sdesfi 225238106SdesAC_MSG_RESULT($DEPFLAG) 226238106Sdesrm -f conftest.c 227238106SdesAC_SUBST(DEPFLAG) 228238106Sdes]) 229238106Sdes 230238106Sdesdnl Determine flags that gives POSIX and BSD functionality. 231238106Sdesdnl CFLAGS is modified for the result. 232238106SdesAC_DEFUN([ACX_DETERMINE_EXT_FLAGS_UNBOUND], 233238106Sdes[ 234238106SdesACX_CHECK_COMPILER_FLAG(std=c99, [C99FLAG="-std=c99"]) 235238106SdesACX_CHECK_COMPILER_FLAG(xc99, [C99FLAG="-xc99"]) 236238106Sdes 237238106SdesAC_CHECK_HEADERS([getopt.h time.h],,, [AC_INCLUDES_DEFAULT]) 238238106Sdes 239238106SdesACX_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, 240238106Sdes[ 241238106Sdes#include "confdefs.h" 242238106Sdes#include <stdlib.h> 243238106Sdes#include <ctype.h> 244238106Sdes#include <sys/time.h> 245238106Sdes#ifdef HAVE_TIME_H 246238106Sdes#include <time.h> 247238106Sdes#endif 248238106Sdes#include <unistd.h> 249238106Sdes#include <netdb.h> 250238106Sdes#ifdef HAVE_GETOPT_H 251238106Sdes#include <getopt.h> 252238106Sdes#endif 253238106Sdes 254238106Sdesint test() { 255238106Sdes int a; 256238106Sdes char **opts = NULL; 257238106Sdes struct timeval tv; 258238106Sdes char *t; 259238106Sdes time_t time = 0; 260238106Sdes char *buf = NULL; 261238106Sdes const char* str = NULL; 262238106Sdes struct msghdr msg; 263238106Sdes msg.msg_control = 0; 264238106Sdes t = ctime_r(&time, buf); 265238106Sdes tv.tv_usec = 10; 266238106Sdes srandom(32); 267238106Sdes a = getopt(2, opts, "a"); 268238106Sdes a = isascii(32); 269238106Sdes str = gai_strerror(0); 270238106Sdes if(str && t && tv.tv_usec && msg.msg_control) 271238106Sdes a = 0; 272238106Sdes return a; 273238106Sdes} 274238106Sdes], [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"]) 275238106Sdes 276238106SdesACX_CHECK_COMPILER_FLAG_NEEDED($C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_ALL_SOURCE, 277238106Sdes[ 278238106Sdes#include "confdefs.h" 279238106Sdes#include <stdlib.h> 280238106Sdes#include <ctype.h> 281238106Sdes#include <sys/time.h> 282238106Sdes#ifdef HAVE_TIME_H 283238106Sdes#include <time.h> 284238106Sdes#endif 285238106Sdes#include <unistd.h> 286238106Sdes#include <netdb.h> 287238106Sdes#ifdef HAVE_GETOPT_H 288238106Sdes#include <getopt.h> 289238106Sdes#endif 290238106Sdes 291238106Sdesint test() { 292238106Sdes int a; 293238106Sdes char **opts = NULL; 294238106Sdes struct timeval tv; 295238106Sdes char *t; 296238106Sdes time_t time = 0; 297238106Sdes char *buf = NULL; 298238106Sdes const char* str = NULL; 299238106Sdes struct msghdr msg; 300238106Sdes msg.msg_control = 0; 301238106Sdes t = ctime_r(&time, buf); 302238106Sdes tv.tv_usec = 10; 303238106Sdes srandom(32); 304238106Sdes a = getopt(2, opts, "a"); 305238106Sdes a = isascii(32); 306238106Sdes str = gai_strerror(0); 307238106Sdes if(str && t && tv.tv_usec && msg.msg_control) 308238106Sdes a = 0; 309238106Sdes return a; 310238106Sdes} 311238106Sdes], [CFLAGS="$CFLAGS $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_ALL_SOURCE"]) 312238106Sdes 313238106SdesACX_CHECK_COMPILER_FLAG_NEEDED($C99FLAG, 314238106Sdes[ 315238106Sdes#include <stdbool.h> 316238106Sdes#include <ctype.h> 317238106Sdesint test() { 318238106Sdes int a = 0; 319238106Sdes return a; 320238106Sdes} 321238106Sdes], [CFLAGS="$CFLAGS $C99FLAG"]) 322238106Sdes 323238106SdesACX_CHECK_COMPILER_FLAG_NEEDED(-D_BSD_SOURCE, 324238106Sdes[ 325238106Sdes#include <ctype.h> 326238106Sdes 327238106Sdesint test() { 328238106Sdes int a; 329238106Sdes a = isascii(32); 330238106Sdes return a; 331238106Sdes} 332238106Sdes], [CFLAGS="$CFLAGS -D_BSD_SOURCE"]) 333238106Sdes 334238106SdesACX_CHECK_COMPILER_FLAG_NEEDED(-D_GNU_SOURCE, 335238106Sdes[ 336238106Sdes#include <netinet/in.h> 337238106Sdes 338238106Sdesint test() { 339238106Sdes struct in6_pktinfo inf; 340238106Sdes int a = (int)sizeof(inf); 341238106Sdes return a; 342238106Sdes} 343238106Sdes], [CFLAGS="$CFLAGS -D_GNU_SOURCE"]) 344238106Sdes 345238106Sdes# check again for GNU_SOURCE for setresgid. May fail if setresgid 346238106Sdes# is not available at all. -D_FRSRESGID is to make this check unique. 347238106Sdes# otherwise we would get the previous cached result. 348238106SdesACX_CHECK_COMPILER_FLAG_NEEDED(-D_GNU_SOURCE -D_FRSRESGID, 349238106Sdes[ 350238106Sdes#include <unistd.h> 351238106Sdes 352238106Sdesint test() { 353238106Sdes int a = setresgid(0,0,0); 354238106Sdes a = setresuid(0,0,0); 355238106Sdes return a; 356238106Sdes} 357238106Sdes], [CFLAGS="$CFLAGS -D_GNU_SOURCE"]) 358238106Sdes 359238106SdesACX_CHECK_COMPILER_FLAG_NEEDED(-D_POSIX_C_SOURCE=200112, 360238106Sdes[ 361238106Sdes#include "confdefs.h" 362238106Sdes#ifdef HAVE_TIME_H 363238106Sdes#include <time.h> 364238106Sdes#endif 365238106Sdes#include <netdb.h> 366238106Sdes 367238106Sdesint test() { 368238106Sdes int a = 0; 369238106Sdes char *t; 370238106Sdes time_t time = 0; 371238106Sdes char *buf = NULL; 372238106Sdes const char* str = NULL; 373238106Sdes t = ctime_r(&time, buf); 374238106Sdes str = gai_strerror(0); 375238106Sdes if(t && str) 376238106Sdes a = 0; 377238106Sdes return a; 378238106Sdes} 379238106Sdes], [CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200112"]) 380238106Sdes 381238106SdesACX_CHECK_COMPILER_FLAG_NEEDED(-D__EXTENSIONS__, 382238106Sdes[ 383238106Sdes#include "confdefs.h" 384238106Sdes#include <stdlib.h> 385238106Sdes#include <ctype.h> 386238106Sdes#include <sys/time.h> 387238106Sdes#ifdef HAVE_TIME_H 388238106Sdes#include <time.h> 389238106Sdes#endif 390238106Sdes#include <unistd.h> 391238106Sdes#ifdef HAVE_GETOPT_H 392238106Sdes#include <getopt.h> 393238106Sdes#endif 394238106Sdes 395238106Sdesint test() { 396238106Sdes int a; 397238106Sdes char **opts = NULL; 398238106Sdes struct timeval tv; 399238106Sdes tv.tv_usec = 10; 400238106Sdes srandom(32); 401238106Sdes a = getopt(2, opts, "a"); 402238106Sdes a = isascii(32); 403238106Sdes if(tv.tv_usec) 404238106Sdes a = 0; 405238106Sdes return a; 406238106Sdes} 407238106Sdes], [CFLAGS="$CFLAGS -D__EXTENSIONS__"]) 408238106Sdes 409238106Sdes])dnl End of ACX_DETERMINE_EXT_FLAGS_UNBOUND 410238106Sdes 411238106Sdesdnl Check if CC supports -flto. 412238106Sdesdnl in a way that supports clang and suncc (that flag does something else, 413238106Sdesdnl but fails to link). It sets it in CFLAGS if it works. 414266114SdesAC_DEFUN([ACX_CHECK_FLTO], [ 415266114Sdes AC_ARG_ENABLE([flto], AS_HELP_STRING([--disable-flto], [Disable link-time optimization (gcc specific option)])) 416266114Sdes AS_IF([test "x$enable_flto" != "xno"], [ 417266114Sdes AC_MSG_CHECKING([if $CC supports -flto]) 418266114Sdes BAKCFLAGS="$CFLAGS" 419266114Sdes CFLAGS="$CFLAGS -flto" 420266114Sdes AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [ 421266114Sdes if $CC $CFLAGS -o conftest conftest.c 2>&1 | grep "warning: no debug symbols in executable" >/dev/null; then 422266114Sdes CFLAGS="$BAKCFLAGS" 423266114Sdes AC_MSG_RESULT(no) 424266114Sdes else 425266114Sdes AC_MSG_RESULT(yes) 426266114Sdes fi 427266114Sdes rm -f conftest conftest.c conftest.o 428266114Sdes ], [CFLAGS="$BAKCFLAGS" ; AC_MSG_RESULT(no)]) 429266114Sdes ]) 430238106Sdes]) 431238106Sdes 432238106Sdesdnl Check the printf-format attribute (if any) 433238106Sdesdnl result in HAVE_ATTR_FORMAT. 434238106Sdesdnl Make sure you also include the AHX_CONFIG_FORMAT_ATTRIBUTE. 435238106SdesAC_DEFUN([ACX_CHECK_FORMAT_ATTRIBUTE], 436238106Sdes[AC_REQUIRE([AC_PROG_CC]) 437238106SdesAC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "format" attribute) 438238106SdesAC_CACHE_VAL(ac_cv_c_format_attribute, 439238106Sdes[ac_cv_c_format_attribute=no 440238106SdesAC_TRY_COMPILE( 441238106Sdes[#include <stdio.h> 442238106Sdesvoid f (char *format, ...) __attribute__ ((format (printf, 1, 2))); 443238106Sdesvoid (*pf) (char *format, ...) __attribute__ ((format (printf, 1, 2))); 444238106Sdes], [ 445238106Sdes f ("%s", "str"); 446238106Sdes], 447238106Sdes[ac_cv_c_format_attribute="yes"], 448238106Sdes[ac_cv_c_format_attribute="no"]) 449238106Sdes]) 450238106Sdes 451238106SdesAC_MSG_RESULT($ac_cv_c_format_attribute) 452238106Sdesif test $ac_cv_c_format_attribute = yes; then 453238106Sdes AC_DEFINE(HAVE_ATTR_FORMAT, 1, [Whether the C compiler accepts the "format" attribute]) 454238106Sdesfi 455238106Sdes])dnl End of ACX_CHECK_FORMAT_ATTRIBUTE 456238106Sdes 457238106Sdesdnl Setup ATTR_FORMAT config.h parts. 458238106Sdesdnl make sure you call ACX_CHECK_FORMAT_ATTRIBUTE also. 459238106SdesAC_DEFUN([AHX_CONFIG_FORMAT_ATTRIBUTE], 460238106Sdes[ 461238106Sdes#ifdef HAVE_ATTR_FORMAT 462238106Sdes# define ATTR_FORMAT(archetype, string_index, first_to_check) \ 463238106Sdes __attribute__ ((format (archetype, string_index, first_to_check))) 464238106Sdes#else /* !HAVE_ATTR_FORMAT */ 465238106Sdes# define ATTR_FORMAT(archetype, string_index, first_to_check) /* empty */ 466238106Sdes#endif /* !HAVE_ATTR_FORMAT */ 467238106Sdes]) 468238106Sdes 469238106Sdesdnl Check how to mark function arguments as unused. 470238106Sdesdnl result in HAVE_ATTR_UNUSED. 471238106Sdesdnl Make sure you include AHX_CONFIG_UNUSED_ATTRIBUTE also. 472238106SdesAC_DEFUN([ACX_CHECK_UNUSED_ATTRIBUTE], 473238106Sdes[AC_REQUIRE([AC_PROG_CC]) 474238106SdesAC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "unused" attribute) 475238106SdesAC_CACHE_VAL(ac_cv_c_unused_attribute, 476238106Sdes[ac_cv_c_unused_attribute=no 477238106SdesAC_TRY_COMPILE( 478238106Sdes[#include <stdio.h> 479238106Sdesvoid f (char *u __attribute__((unused))); 480238106Sdes], [ 481238106Sdes f ("x"); 482238106Sdes], 483238106Sdes[ac_cv_c_unused_attribute="yes"], 484238106Sdes[ac_cv_c_unused_attribute="no"]) 485238106Sdes]) 486238106Sdes 487238106Sdesdnl Setup ATTR_UNUSED config.h parts. 488238106Sdesdnl make sure you call ACX_CHECK_UNUSED_ATTRIBUTE also. 489238106SdesAC_DEFUN([AHX_CONFIG_UNUSED_ATTRIBUTE], 490238106Sdes[ 491238106Sdes#if defined(DOXYGEN) 492238106Sdes# define ATTR_UNUSED(x) x 493238106Sdes#elif defined(__cplusplus) 494238106Sdes# define ATTR_UNUSED(x) 495238106Sdes#elif defined(HAVE_ATTR_UNUSED) 496238106Sdes# define ATTR_UNUSED(x) x __attribute__((unused)) 497238106Sdes#else /* !HAVE_ATTR_UNUSED */ 498238106Sdes# define ATTR_UNUSED(x) x 499238106Sdes#endif /* !HAVE_ATTR_UNUSED */ 500238106Sdes]) 501238106Sdes 502238106SdesAC_MSG_RESULT($ac_cv_c_unused_attribute) 503238106Sdesif test $ac_cv_c_unused_attribute = yes; then 504238106Sdes AC_DEFINE(HAVE_ATTR_UNUSED, 1, [Whether the C compiler accepts the "unused" attribute]) 505238106Sdesfi 506238106Sdes])dnl 507238106Sdes 508238106Sdesdnl Pre-fun for ACX_LIBTOOL_C_ONLY 509238106SdesAC_DEFUN([ACX_LIBTOOL_C_PRE], [ 510238106Sdes# skip these tests, we do not need them. 511238106SdesAC_DEFUN([AC_PROG_F77], [:]) 512238106SdesAC_DEFUN([AC_PROG_FC], [:]) 513238106SdesAC_DEFUN([AC_PROG_CXX], [:]) 514238106SdesAC_DEFUN([AC_PROG_CXXCPP], [:]) 515238106SdesAC_DEFUN([AC_PROG_OBJC], [:]) 516238106SdesAC_DEFUN([AC_PROG_OBJCCPP], [:]) 517238106SdesAC_DEFUN([AC_LIBTOOL_CXX], [:]) 518238106SdesAC_DEFUN([AC_LIBTOOL_F77], [:]) 519238106Sdes# always use ./libtool unless override from commandline (libtool=mylibtool) 520238106Sdesif test -z "$libtool"; then 521238106Sdes libtool="./libtool" 522238106Sdesfi 523238106SdesAC_SUBST(libtool) 524238106Sdes# avoid libtool max commandline length test on systems that fork slowly. 525238106SdesAC_CANONICAL_HOST 526238106Sdesif echo "$host_os" | grep "sunos4" >/dev/null; then 527238106Sdes lt_cv_sys_max_cmd_len=32750; 528238106Sdesfi 529238106SdesAC_PATH_TOOL(AR, ar, [false]) 530238106Sdesif test $AR = false; then 531238106Sdes AC_MSG_ERROR([Cannot find 'ar', please extend PATH to include it]) 532238106Sdesfi 533238106Sdes]) 534238106Sdes 535238106Sdesdnl Perform libtool check, portably, only for C 536238106SdesAC_DEFUN([ACX_LIBTOOL_C_ONLY], [ 537238106Sdesdnl as a requirement so that is gets called before LIBTOOL 538238106Sdesdnl because libtools 'AC_REQUIRE' names are right after this one, before 539238106Sdesdnl this function contents. 540238106SdesAC_REQUIRE([ACX_LIBTOOL_C_PRE]) 541238106SdesAC_PROG_LIBTOOL 542238106Sdes]) 543238106Sdes 544238106Sdesdnl Detect if u_char type is defined, otherwise define it. 545238106SdesAC_DEFUN([ACX_TYPE_U_CHAR], 546238106Sdes[AC_CHECK_TYPE([u_char], , 547238106Sdes [AC_DEFINE([u_char], [unsigned char], [Define to 'unsigned char if not defined])], [ 548238106SdesAC_INCLUDES_DEFAULT 549238106Sdes#ifdef HAVE_WINSOCK2_H 550238106Sdes# include <winsock2.h> 551238106Sdes#endif 552238106Sdes]) ]) 553238106Sdes 554238106Sdesdnl Detect if rlim_t type is defined, otherwise define it. 555238106SdesAC_DEFUN([ACX_TYPE_RLIM_T], 556238106Sdes[AC_CHECK_TYPE(rlim_t, , 557238106Sdes [AC_DEFINE([rlim_t], [unsigned long], [Define to 'int' if not defined])], [ 558238106SdesAC_INCLUDES_DEFAULT 559238106Sdes#ifdef HAVE_SYS_RESOURCE_H 560238106Sdes# include <sys/resource.h> 561238106Sdes#endif 562238106Sdes]) ]) 563238106Sdes 564238106Sdesdnl Detect if socklen_t type is defined, otherwise define it. 565238106SdesAC_DEFUN([ACX_TYPE_SOCKLEN_T], 566238106Sdes[ 567238106SdesAC_CHECK_TYPE(socklen_t, , 568238106Sdes [AC_DEFINE([socklen_t], [int], [Define to 'int' if not defined])], [ 569238106SdesAC_INCLUDES_DEFAULT 570238106Sdes#ifdef HAVE_SYS_SOCKET_H 571238106Sdes# include <sys/socket.h> 572238106Sdes#endif 573238106Sdes#ifdef HAVE_WS2TCPIP_H 574238106Sdes# include <ws2tcpip.h> 575238106Sdes#endif 576238106Sdes]) ]) 577238106Sdes 578238106Sdesdnl Detect if in_addr_t type is defined, otherwise define it. 579238106SdesAC_DEFUN([ACX_TYPE_IN_ADDR_T], 580238106Sdes[ AC_CHECK_TYPE(in_addr_t, [], [AC_DEFINE([in_addr_t], [uint32_t], [in_addr_t])], [ 581238106SdesAC_INCLUDES_DEFAULT 582238106Sdes#ifdef HAVE_SYS_TYPES_H 583238106Sdes# include <sys/types.h> 584238106Sdes#endif 585238106Sdes#ifdef HAVE_NETINET_IN_H 586238106Sdes# include <netinet/in.h> 587238106Sdes#endif 588238106Sdes]) ]) 589238106Sdes 590238106Sdesdnl Detect if in_port_t type is defined, otherwise define it. 591238106SdesAC_DEFUN([ACX_TYPE_IN_PORT_T], 592238106Sdes[ AC_CHECK_TYPE(in_port_t, [], [AC_DEFINE([in_port_t], [uint16_t], [in_port_t])], [ 593238106SdesAC_INCLUDES_DEFAULT 594238106Sdes#ifdef HAVE_SYS_TYPES_H 595238106Sdes# include <sys/types.h> 596238106Sdes#endif 597238106Sdes#ifdef HAVE_NETINET_IN_H 598238106Sdes# include <netinet/in.h> 599238106Sdes#endif 600238106Sdes]) ]) 601238106Sdes 602238106Sdesdnl Add option to disable the evil rpath. Check whether to use rpath or not. 603238106Sdesdnl Adds the --disable-rpath option. Uses trick to edit the ./libtool. 604238106SdesAC_DEFUN([ACX_ARG_RPATH], 605238106Sdes[ 606238106SdesAC_ARG_ENABLE(rpath, 607238106Sdes [ --disable-rpath disable hardcoded rpath (default=enabled)], 608238106Sdes enable_rpath=$enableval, enable_rpath=yes) 609238106Sdesif test "x$enable_rpath" = xno; then 610238106Sdes dnl AC_MSG_RESULT([Fixing libtool for -rpath problems.]) 611238106Sdes AC_CONFIG_COMMANDS([disable-rpath], [ 612238106Sdes sed < libtool > libtool-2 \ 613238106Sdes 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_RPATH_SED__ "/' 614238106Sdes mv libtool-2 libtool 615238106Sdes chmod 755 libtool 616238106Sdes libtool="./libtool" 617238106Sdes ]) 618238106Sdesfi 619238106Sdes]) 620238106Sdes 621238106Sdesdnl Add a -R to the RUNTIME_PATH. Only if rpath is enabled and it is 622238106Sdesdnl an absolute path. 623238106Sdesdnl $1: the pathname to add. 624238106SdesAC_DEFUN([ACX_RUNTIME_PATH_ADD], [ 625238106Sdes if test "x$enable_rpath" = xyes; then 626238106Sdes if echo "$1" | grep "^/" >/dev/null; then 627238106Sdes RUNTIME_PATH="$RUNTIME_PATH -R$1" 628238106Sdes fi 629238106Sdes fi 630238106Sdes]) 631238106Sdes 632238106Sdesdnl Common code for both ACX_WITH_SSL and ACX_WITH_SSL_OPTIONAL 633238106Sdesdnl Takes one argument; the withval checked in those 2 functions 634238106Sdesdnl sets up the environment for the given openssl path 635238106SdesAC_DEFUN([ACX_SSL_CHECKS], [ 636238106Sdes withval=$1 637238106Sdes if test x_$withval != x_no; then 638238106Sdes AC_MSG_CHECKING(for SSL) 639238106Sdes if test x_$withval = x_ -o x_$withval = x_yes; then 640238106Sdes withval="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /opt/local /usr/sfw /usr" 641238106Sdes fi 642238106Sdes for dir in $withval; do 643238106Sdes ssldir="$dir" 644238106Sdes if test -f "$dir/include/openssl/ssl.h"; then 645238106Sdes found_ssl="yes" 646238106Sdes AC_DEFINE_UNQUOTED([HAVE_SSL], [], [Define if you have the SSL libraries installed.]) 647238106Sdes dnl assume /usr/include is already in the include-path. 648238106Sdes if test "$ssldir" != "/usr"; then 649238106Sdes CPPFLAGS="$CPPFLAGS -I$ssldir/include" 650238106Sdes LIBSSL_CPPFLAGS="$LIBSSL_CPPFLAGS -I$ssldir/include" 651238106Sdes fi 652238106Sdes break; 653238106Sdes fi 654238106Sdes done 655238106Sdes if test x_$found_ssl != x_yes; then 656238106Sdes AC_MSG_ERROR(Cannot find the SSL libraries in $withval) 657238106Sdes else 658238106Sdes AC_MSG_RESULT(found in $ssldir) 659238106Sdes HAVE_SSL=yes 660238106Sdes dnl assume /usr is already in the lib and dynlib paths. 661238106Sdes if test "$ssldir" != "/usr" -a "$ssldir" != ""; then 662238106Sdes LDFLAGS="$LDFLAGS -L$ssldir/lib" 663238106Sdes LIBSSL_LDFLAGS="$LIBSSL_LDFLAGS -L$ssldir/lib" 664238106Sdes ACX_RUNTIME_PATH_ADD([$ssldir/lib]) 665238106Sdes fi 666238106Sdes 667238106Sdes AC_MSG_CHECKING([for HMAC_CTX_init in -lcrypto]) 668238106Sdes LIBS="$LIBS -lcrypto" 669238106Sdes LIBSSL_LIBS="$LIBSSL_LIBS -lcrypto" 670238106Sdes AC_TRY_LINK(, [ 671238106Sdes int HMAC_CTX_init(void); 672238106Sdes (void)HMAC_CTX_init(); 673238106Sdes ], [ 674238106Sdes AC_MSG_RESULT(yes) 675238106Sdes AC_DEFINE([HAVE_HMAC_CTX_INIT], 1, 676238106Sdes [If you have HMAC_CTX_init]) 677238106Sdes ], [ 678238106Sdes AC_MSG_RESULT(no) 679238106Sdes # check if -lwsock32 or -lgdi32 are needed. 680238106Sdes BAKLIBS="$LIBS" 681238106Sdes BAKSSLLIBS="$LIBSSL_LIBS" 682238106Sdes LIBS="$LIBS -lgdi32" 683238106Sdes LIBSSL_LIBS="$LIBSSL_LIBS -lgdi32" 684238106Sdes AC_MSG_CHECKING([if -lcrypto needs -lgdi32]) 685238106Sdes AC_TRY_LINK([], [ 686238106Sdes int HMAC_CTX_init(void); 687238106Sdes (void)HMAC_CTX_init(); 688238106Sdes ],[ 689238106Sdes AC_DEFINE([HAVE_HMAC_CTX_INIT], 1, 690238106Sdes [If you have HMAC_CTX_init]) 691238106Sdes AC_MSG_RESULT(yes) 692238106Sdes ],[ 693238106Sdes AC_MSG_RESULT(no) 694238106Sdes LIBS="$BAKLIBS" 695238106Sdes LIBSSL_LIBS="$BAKSSLLIBS" 696238106Sdes LIBS="$LIBS -ldl" 697238106Sdes LIBSSL_LIBS="$LIBSSL_LIBS -ldl" 698238106Sdes AC_MSG_CHECKING([if -lcrypto needs -ldl]) 699238106Sdes AC_TRY_LINK([], [ 700238106Sdes int HMAC_CTX_init(void); 701238106Sdes (void)HMAC_CTX_init(); 702238106Sdes ],[ 703238106Sdes AC_DEFINE([HAVE_HMAC_CTX_INIT], 1, 704238106Sdes [If you have HMAC_CTX_init]) 705238106Sdes AC_MSG_RESULT(yes) 706238106Sdes ],[ 707238106Sdes AC_MSG_RESULT(no) 708238106Sdes AC_MSG_ERROR([OpenSSL found in $ssldir, but version 0.9.7 or higher is required]) 709238106Sdes ]) 710238106Sdes ]) 711238106Sdes ]) 712238106Sdes fi 713238106Sdes AC_SUBST(HAVE_SSL) 714238106Sdes AC_SUBST(RUNTIME_PATH) 715238106Sdes # openssl engine functionality needs dlopen(). 716238106Sdes BAKLIBS="$LIBS" 717238106Sdes AC_SEARCH_LIBS([dlopen], [dl]) 718238106Sdes if test "$LIBS" != "$BAKLIBS"; then 719238106Sdes LIBSSL_LIBS="$LIBSSL_LIBS -ldl" 720238106Sdes fi 721238106Sdes fi 722238106SdesAC_CHECK_HEADERS([openssl/ssl.h],,, [AC_INCLUDES_DEFAULT]) 723238106SdesAC_CHECK_HEADERS([openssl/err.h],,, [AC_INCLUDES_DEFAULT]) 724238106SdesAC_CHECK_HEADERS([openssl/rand.h],,, [AC_INCLUDES_DEFAULT]) 725238106Sdes])dnl End of ACX_SSL_CHECKS 726238106Sdes 727238106Sdesdnl Check for SSL, where SSL is mandatory 728238106Sdesdnl Adds --with-ssl option, searches for openssl and defines HAVE_SSL if found 729238106Sdesdnl Setup of CPPFLAGS, CFLAGS. Adds -lcrypto to LIBS. 730238106Sdesdnl Checks main header files of SSL. 731238106Sdesdnl 732238106SdesAC_DEFUN([ACX_WITH_SSL], 733238106Sdes[ 734238106SdesAC_ARG_WITH(ssl, AC_HELP_STRING([--with-ssl=pathname], 735238106Sdes [enable SSL (will check /usr/local/ssl 736238106Sdes /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /opt/local /usr/sfw /usr)]),[ 737238106Sdes ],[ 738238106Sdes withval="yes" 739238106Sdes ]) 740238106Sdes if test x_$withval = x_no; then 741238106Sdes AC_MSG_ERROR([Need SSL library to do digital signature cryptography]) 742238106Sdes fi 743238106Sdes ACX_SSL_CHECKS($withval) 744238106Sdes])dnl End of ACX_WITH_SSL 745238106Sdes 746238106Sdesdnl Check for SSL, where ssl is optional (--without-ssl is allowed) 747238106Sdesdnl Adds --with-ssl option, searches for openssl and defines HAVE_SSL if found 748238106Sdesdnl Setup of CPPFLAGS, CFLAGS. Adds -lcrypto to LIBS. 749238106Sdesdnl Checks main header files of SSL. 750238106Sdesdnl 751238106SdesAC_DEFUN([ACX_WITH_SSL_OPTIONAL], 752238106Sdes[ 753238106SdesAC_ARG_WITH(ssl, AC_HELP_STRING([--with-ssl=pathname], 754238106Sdes [enable SSL (will check /usr/local/ssl 755238106Sdes /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /opt/local /usr/sfw /usr)]),[ 756238106Sdes ],[ 757238106Sdes withval="yes" 758238106Sdes ]) 759238106Sdes ACX_SSL_CHECKS($withval) 760238106Sdes])dnl End of ACX_WITH_SSL_OPTIONAL 761238106Sdes 762238106Sdesdnl Setup to use -lssl 763238106Sdesdnl To use -lcrypto, use the ACX_WITH_SSL setup (before this one). 764238106SdesAC_DEFUN([ACX_LIB_SSL], 765238106Sdes[ 766238106Sdes# check if libssl needs libdl 767238106SdesBAKLIBS="$LIBS" 768238106SdesLIBS="-lssl $LIBS" 769238106SdesAC_MSG_CHECKING([if libssl needs libdl]) 770238106SdesAC_TRY_LINK_FUNC([SSL_CTX_new], [ 771238106Sdes AC_MSG_RESULT([no]) 772238106Sdes LIBS="$BAKLIBS" 773238106Sdes] , [ 774238106Sdes AC_MSG_RESULT([yes]) 775238106Sdes LIBS="$BAKLIBS" 776238106Sdes AC_SEARCH_LIBS([dlopen], [dl]) 777238106Sdes]) ])dnl End of ACX_LIB_SSL 778238106Sdes 779238106Sdesdnl Setup to use very large files (>2Gb). 780238106Sdesdnl setups fseeko and its own 781238106SdesAC_DEFUN([ACX_SYS_LARGEFILE], 782238106Sdes[ 783238106SdesAC_SYS_LARGEFILE 784238106Sdesdnl try to see if an additional _LARGEFILE_SOURCE 1 is needed to get fseeko 785238106SdesACX_CHECK_COMPILER_FLAG_NEEDED(-D_LARGEFILE_SOURCE=1, 786238106Sdes[ 787238106Sdes#include <stdio.h> 788238106Sdesint test() { 789238106Sdes int a = fseeko(stdin, 0, 0); 790238106Sdes return a; 791238106Sdes} 792238106Sdes], [CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE=1"]) 793238106Sdes]) 794238106Sdes 795238106Sdesdnl Check getaddrinfo. 796238106Sdesdnl Works on linux, solaris, bsd and windows(links winsock). 797238106Sdesdnl defines HAVE_GETADDRINFO, USE_WINSOCK. 798238106SdesAC_DEFUN([ACX_CHECK_GETADDRINFO_WITH_INCLUDES], 799238106Sdes[AC_REQUIRE([AC_PROG_CC]) 800238106SdesAC_MSG_CHECKING(for getaddrinfo) 801238106Sdesac_cv_func_getaddrinfo=no 802238106SdesAC_LINK_IFELSE( 803238106Sdes[AC_LANG_SOURCE([[ 804238106Sdes#ifdef __cplusplus 805238106Sdesextern "C" 806238106Sdes{ 807238106Sdes#endif 808238106Sdeschar* getaddrinfo(); 809238106Sdeschar* (*f) () = getaddrinfo; 810238106Sdes#ifdef __cplusplus 811238106Sdes} 812238106Sdes#endif 813238106Sdesint main() { 814238106Sdes ; 815238106Sdes return 0; 816238106Sdes} 817238106Sdes]])], 818238106Sdesdnl this case on linux, solaris, bsd 819238106Sdes[ac_cv_func_getaddrinfo="yes" 820238106Sdesdnl see if on windows 821238106Sdesif test "$ac_cv_header_windows_h" = "yes"; then 822238106Sdes AC_DEFINE(USE_WINSOCK, 1, [Whether the windows socket API is used]) 823238106Sdes USE_WINSOCK="1" 824238106Sdes LIBS="$LIBS -lws2_32" 825238106Sdesfi 826238106Sdes], 827238106Sdesdnl no quick getaddrinfo, try mingw32 and winsock2 library. 828238106SdesORIGLIBS="$LIBS" 829238106SdesLIBS="$LIBS -lws2_32" 830238106SdesAC_LINK_IFELSE( 831238106Sdes[AC_LANG_PROGRAM( 832238106Sdes[ 833238106Sdes#ifdef HAVE_WS2TCPIP_H 834238106Sdes#include <ws2tcpip.h> 835238106Sdes#endif 836238106Sdes], 837238106Sdes[ 838238106Sdes (void)getaddrinfo(NULL, NULL, NULL, NULL); 839238106Sdes] 840238106Sdes)], 841238106Sdes[ 842238106Sdesac_cv_func_getaddrinfo="yes" 843238106Sdesdnl already: LIBS="$LIBS -lws2_32" 844238106SdesAC_DEFINE(USE_WINSOCK, 1, [Whether the windows socket API is used]) 845238106SdesUSE_WINSOCK="1" 846238106Sdes], 847238106Sdes[ 848238106Sdesac_cv_func_getaddrinfo="no" 849238106SdesLIBS="$ORIGLIBS" 850238106Sdes]) 851238106Sdes) 852238106Sdes 853238106SdesAC_MSG_RESULT($ac_cv_func_getaddrinfo) 854238106Sdesif test $ac_cv_func_getaddrinfo = yes; then 855238106Sdes AC_DEFINE(HAVE_GETADDRINFO, 1, [Whether getaddrinfo is available]) 856238106Sdesfi 857238106Sdes])dnl Endof AC_CHECK_GETADDRINFO_WITH_INCLUDES 858238106Sdes 859238106Sdesdnl check if a function is deprecated. defines DEPRECATED_func in config.h. 860238106Sdesdnl $1: function name 861238106Sdesdnl $2: C-statement that calls the function. 862238106Sdesdnl $3: includes for the program. 863238106Sdesdnl $4: executes if yes 864238106Sdesdnl $5: executes if no 865238106SdesAC_DEFUN([ACX_FUNC_DEPRECATED], 866238106Sdes[ 867238106SdesAC_REQUIRE([AC_PROG_CC]) 868238106SdesAC_MSG_CHECKING(if $1 is deprecated) 869238106Sdescache=`echo $1 | sed 'y%.=/+-%___p_%'` 870238106SdesAC_CACHE_VAL(cv_cc_deprecated_$cache, 871238106Sdes[ 872238106Sdesecho '$3' >conftest.c 873238106Sdesecho 'void f(){ $2 }' >>conftest.c 874238106Sdesif test -z "`$CC -c conftest.c 2>&1 | grep deprecated`"; then 875238106Sdeseval "cv_cc_deprecated_$cache=no" 876238106Sdeselse 877238106Sdeseval "cv_cc_deprecated_$cache=yes" 878238106Sdesfi 879238106Sdesrm -f conftest conftest.o conftest.c 880238106Sdes]) 881238106Sdesif eval "test \"`echo '$cv_cc_deprecated_'$cache`\" = yes"; then 882238106SdesAC_MSG_RESULT(yes) 883238106SdesAC_DEFINE_UNQUOTED(AS_TR_CPP([DEPRECATED_$1]), 1, [Whether $1 is deprecated]) 884238106Sdes: 885238106Sdes$4 886238106Sdeselse 887238106SdesAC_MSG_RESULT(no) 888238106Sdes: 889238106Sdes$5 890238106Sdesfi 891238106Sdes])dnl end of ACX_FUNC_DEPRECATED 892238106Sdes 893238106Sdesdnl check if select and nonblocking sockets actually work. 894238106Sdesdnl Needs fork(2) and select(2). 895238106Sdesdnl defines NONBLOCKING_IS_BROKEN, and if that is true multiple reads from 896238106Sdesdnl a nonblocking socket do not work, a new call to select is necessary. 897238106SdesAC_DEFUN([ACX_CHECK_NONBLOCKING_BROKEN], 898238106Sdes[ 899238106SdesAC_MSG_CHECKING([if nonblocking sockets work]) 900238106Sdesif echo $target | grep mingw32 >/dev/null; then 901238106Sdes AC_MSG_RESULT([no (windows)]) 902238106Sdes AC_DEFINE([NONBLOCKING_IS_BROKEN], 1, [Define if the network stack does not fully support nonblocking io (causes lower performance).]) 903238106Sdeselse 904238106SdesAC_RUN_IFELSE([ 905238106SdesAC_LANG_SOURCE([[ 906238106Sdes#include <stdio.h> 907238106Sdes#include <string.h> 908238106Sdes#include <stdlib.h> 909238106Sdes#include <fcntl.h> 910238106Sdes#include <errno.h> 911238106Sdes#ifdef HAVE_SYS_TYPES_H 912238106Sdes#include <sys/types.h> 913238106Sdes#endif 914238106Sdes#ifdef HAVE_SYS_SOCKET_H 915238106Sdes#include <sys/socket.h> 916238106Sdes#endif 917238106Sdes#ifdef HAVE_NETINET_IN_H 918238106Sdes#include <netinet/in.h> 919238106Sdes#endif 920238106Sdes#ifdef HAVE_ARPA_INET_H 921238106Sdes#include <arpa/inet.h> 922238106Sdes#endif 923238106Sdes#ifdef HAVE_UNISTD_H 924238106Sdes#include <unistd.h> 925238106Sdes#endif 926238106Sdes#ifdef HAVE_TIME_H 927238106Sdes#include <time.h> 928238106Sdes#endif 929238106Sdes 930238106Sdesint main(void) 931238106Sdes{ 932238106Sdes int port; 933238106Sdes int sfd, cfd; 934238106Sdes int num = 10; 935238106Sdes int i, p; 936238106Sdes struct sockaddr_in a; 937238106Sdes /* test if select and nonblocking reads work well together */ 938238106Sdes /* open port. 939238106Sdes fork child to send 10 messages. 940238106Sdes select to read. 941238106Sdes then try to nonblocking read the 10 messages 942238106Sdes then, nonblocking read must give EAGAIN 943238106Sdes */ 944238106Sdes 945238106Sdes port = 12345 + (time(0)%32); 946238106Sdes sfd = socket(PF_INET, SOCK_DGRAM, 0); 947238106Sdes if(sfd == -1) { 948238106Sdes perror("socket"); 949238106Sdes return 1; 950238106Sdes } 951238106Sdes memset(&a, 0, sizeof(a)); 952238106Sdes a.sin_family = AF_INET; 953238106Sdes a.sin_port = htons(port); 954238106Sdes a.sin_addr.s_addr = inet_addr("127.0.0.1"); 955238106Sdes if(bind(sfd, (struct sockaddr*)&a, sizeof(a)) < 0) { 956238106Sdes perror("bind"); 957238106Sdes return 1; 958238106Sdes } 959238106Sdes if(fcntl(sfd, F_SETFL, O_NONBLOCK) == -1) { 960238106Sdes perror("fcntl"); 961238106Sdes return 1; 962238106Sdes } 963238106Sdes 964238106Sdes cfd = socket(PF_INET, SOCK_DGRAM, 0); 965238106Sdes if(cfd == -1) { 966238106Sdes perror("client socket"); 967238106Sdes return 1; 968238106Sdes } 969238106Sdes a.sin_port = 0; 970238106Sdes if(bind(cfd, (struct sockaddr*)&a, sizeof(a)) < 0) { 971238106Sdes perror("client bind"); 972238106Sdes return 1; 973238106Sdes } 974238106Sdes a.sin_port = htons(port); 975238106Sdes 976238106Sdes /* no handler, causes exit in 10 seconds */ 977238106Sdes alarm(10); 978238106Sdes 979238106Sdes /* send and receive on the socket */ 980238106Sdes if((p=fork()) == 0) { 981238106Sdes for(i=0; i<num; i++) { 982238106Sdes if(sendto(cfd, &i, sizeof(i), 0, 983238106Sdes (struct sockaddr*)&a, sizeof(a)) < 0) { 984238106Sdes perror("sendto"); 985238106Sdes return 1; 986238106Sdes } 987238106Sdes } 988238106Sdes } else { 989238106Sdes /* parent */ 990238106Sdes fd_set rset; 991238106Sdes int x; 992238106Sdes if(p == -1) { 993238106Sdes perror("fork"); 994238106Sdes return 1; 995238106Sdes } 996238106Sdes FD_ZERO(&rset); 997238106Sdes FD_SET(sfd, &rset); 998238106Sdes if(select(sfd+1, &rset, NULL, NULL, NULL) < 1) { 999238106Sdes perror("select"); 1000238106Sdes return 1; 1001238106Sdes } 1002238106Sdes i = 0; 1003238106Sdes while(i < num) { 1004238106Sdes if(recv(sfd, &x, sizeof(x), 0) != sizeof(x)) { 1005238106Sdes if(errno == EAGAIN) 1006238106Sdes continue; 1007238106Sdes perror("recv"); 1008238106Sdes return 1; 1009238106Sdes } 1010238106Sdes i++; 1011238106Sdes } 1012238106Sdes /* now we want to get EAGAIN: nonblocking goodness */ 1013238106Sdes errno = 0; 1014238106Sdes recv(sfd, &x, sizeof(x), 0); 1015238106Sdes if(errno != EAGAIN) { 1016238106Sdes perror("trying to recv again"); 1017238106Sdes return 1; 1018238106Sdes } 1019238106Sdes /* EAGAIN encountered */ 1020238106Sdes } 1021238106Sdes 1022238106Sdes close(sfd); 1023238106Sdes close(cfd); 1024238106Sdes return 0; 1025238106Sdes} 1026238106Sdes]])], [ 1027238106Sdes AC_MSG_RESULT([yes]) 1028238106Sdes], [ 1029238106Sdes AC_MSG_RESULT([no]) 1030238106Sdes AC_DEFINE([NONBLOCKING_IS_BROKEN], 1, [Define if the network stack does not fully support nonblocking io (causes lower performance).]) 1031238106Sdes], [ 1032238106Sdes AC_MSG_RESULT([crosscompile(yes)]) 1033238106Sdes]) 1034238106Sdesfi 1035238106Sdes])dnl End of ACX_CHECK_NONBLOCKING_BROKEN 1036238106Sdes 1037238106Sdesdnl Check if mkdir has one or two arguments. 1038238106Sdesdnl defines MKDIR_HAS_ONE_ARG 1039238106SdesAC_DEFUN([ACX_MKDIR_ONE_ARG], 1040238106Sdes[ 1041238106SdesAC_MSG_CHECKING([whether mkdir has one arg]) 1042238106SdesAC_TRY_COMPILE([ 1043238106Sdes#include <stdio.h> 1044238106Sdes#include <unistd.h> 1045238106Sdes#ifdef HAVE_WINSOCK2_H 1046238106Sdes#include <winsock2.h> 1047238106Sdes#endif 1048238106Sdes#ifdef HAVE_SYS_STAT_H 1049238106Sdes#include <sys/stat.h> 1050238106Sdes#endif 1051238106Sdes], [ 1052238106Sdes (void)mkdir("directory"); 1053238106Sdes], 1054238106SdesAC_MSG_RESULT(yes) 1055238106SdesAC_DEFINE(MKDIR_HAS_ONE_ARG, 1, [Define if mkdir has one argument.]) 1056238106Sdes, 1057238106SdesAC_MSG_RESULT(no) 1058238106Sdes) 1059238106Sdes])dnl end of ACX_MKDIR_ONE_ARG 1060238106Sdes 1061238106Sdesdnl Check for ioctlsocket function. works on mingw32 too. 1062238106SdesAC_DEFUN([ACX_FUNC_IOCTLSOCKET], 1063238106Sdes[ 1064238106Sdes# check ioctlsocket 1065238106SdesAC_MSG_CHECKING(for ioctlsocket) 1066238106SdesAC_LINK_IFELSE([AC_LANG_PROGRAM([ 1067238106Sdes#ifdef HAVE_WINSOCK2_H 1068238106Sdes#include <winsock2.h> 1069238106Sdes#endif 1070238106Sdes], [ 1071238106Sdes (void)ioctlsocket(0, 0, NULL); 1072238106Sdes])], [ 1073238106SdesAC_MSG_RESULT(yes) 1074238106SdesAC_DEFINE(HAVE_IOCTLSOCKET, 1, [if the function 'ioctlsocket' is available]) 1075238106Sdes],[AC_MSG_RESULT(no)]) 1076238106Sdes])dnl end of ACX_FUNC_IOCTLSOCKET 1077238106Sdes 1078238106Sdesdnl detect malloc and provide malloc compat prototype. 1079238106Sdesdnl $1: unique name for compat code 1080238106SdesAC_DEFUN([ACX_FUNC_MALLOC], 1081238106Sdes[ 1082238106Sdes AC_MSG_CHECKING([for GNU libc compatible malloc]) 1083238106Sdes AC_RUN_IFELSE([AC_LANG_PROGRAM( 1084238106Sdes[[#if defined STDC_HEADERS || defined HAVE_STDLIB_H 1085238106Sdes#include <stdlib.h> 1086238106Sdes#else 1087238106Sdeschar *malloc (); 1088238106Sdes#endif 1089238106Sdes]], [ if(malloc(0) != 0) return 1;]) 1090238106Sdes], 1091238106Sdes [AC_MSG_RESULT([no]) 1092238106Sdes AC_LIBOBJ(malloc) 1093238106Sdes AC_DEFINE_UNQUOTED([malloc], [rpl_malloc_$1], [Define if replacement function should be used.])] , 1094238106Sdes [AC_MSG_RESULT([yes]) 1095238106Sdes AC_DEFINE([HAVE_MALLOC], 1, [If have GNU libc compatible malloc])], 1096238106Sdes [AC_MSG_RESULT([no (crosscompile)]) 1097238106Sdes AC_LIBOBJ(malloc) 1098238106Sdes AC_DEFINE_UNQUOTED([malloc], [rpl_malloc_$1], [Define if replacement function should be used.])] ) 1099238106Sdes]) 1100238106Sdes 1101238106Sdesdnl Define fallback for fseeko and ftello if needed. 1102238106SdesAC_DEFUN([AHX_CONFIG_FSEEKO], 1103238106Sdes[ 1104238106Sdes#ifndef HAVE_FSEEKO 1105238106Sdes#define fseeko fseek 1106238106Sdes#define ftello ftell 1107238106Sdes#endif /* HAVE_FSEEKO */ 1108238106Sdes]) 1109238106Sdes 1110238106Sdesdnl Define RAND_MAX if not defined 1111238106SdesAC_DEFUN([AHX_CONFIG_RAND_MAX], 1112238106Sdes[ 1113238106Sdes#ifndef RAND_MAX 1114238106Sdes#define RAND_MAX 2147483647 1115238106Sdes#endif 1116238106Sdes]) 1117238106Sdes 1118238106Sdesdnl Define MAXHOSTNAMELEN if not defined 1119238106SdesAC_DEFUN([AHX_CONFIG_MAXHOSTNAMELEN], 1120238106Sdes[ 1121238106Sdes#ifndef MAXHOSTNAMELEN 1122238106Sdes#define MAXHOSTNAMELEN 256 1123238106Sdes#endif 1124238106Sdes]) 1125238106Sdes 1126238106Sdesdnl Define IPV6_MIN_MTU if not defined 1127238106SdesAC_DEFUN([AHX_CONFIG_IPV6_MIN_MTU], 1128238106Sdes[ 1129238106Sdes#ifndef IPV6_MIN_MTU 1130238106Sdes#define IPV6_MIN_MTU 1280 1131238106Sdes#endif /* IPV6_MIN_MTU */ 1132238106Sdes]) 1133238106Sdes 1134238106Sdesdnl provide snprintf, vsnprintf compat prototype 1135238106Sdesdnl $1: unique name for compat code 1136238106SdesAC_DEFUN([AHX_CONFIG_SNPRINTF], 1137238106Sdes[ 1138238106Sdes#ifndef HAVE_SNPRINTF 1139238106Sdes#define snprintf snprintf_$1 1140238106Sdes#define vsnprintf vsnprintf_$1 1141238106Sdes#include <stdarg.h> 1142238106Sdesint snprintf (char *str, size_t count, const char *fmt, ...); 1143238106Sdesint vsnprintf (char *str, size_t count, const char *fmt, va_list arg); 1144238106Sdes#endif /* HAVE_SNPRINTF */ 1145238106Sdes]) 1146238106Sdes 1147238106Sdesdnl provide inet_pton compat prototype. 1148238106Sdesdnl $1: unique name for compat code 1149238106SdesAC_DEFUN([AHX_CONFIG_INET_PTON], 1150238106Sdes[ 1151238106Sdes#ifndef HAVE_INET_PTON 1152238106Sdes#define inet_pton inet_pton_$1 1153238106Sdesint inet_pton(int af, const char* src, void* dst); 1154238106Sdes#endif /* HAVE_INET_PTON */ 1155238106Sdes]) 1156238106Sdes 1157238106Sdesdnl provide inet_ntop compat prototype. 1158238106Sdesdnl $1: unique name for compat code 1159238106SdesAC_DEFUN([AHX_CONFIG_INET_NTOP], 1160238106Sdes[ 1161238106Sdes#ifndef HAVE_INET_NTOP 1162238106Sdes#define inet_ntop inet_ntop_$1 1163238106Sdesconst char *inet_ntop(int af, const void *src, char *dst, size_t size); 1164238106Sdes#endif 1165238106Sdes]) 1166238106Sdes 1167238106Sdesdnl provide inet_aton compat prototype. 1168238106Sdesdnl $1: unique name for compat code 1169238106SdesAC_DEFUN([AHX_CONFIG_INET_ATON], 1170238106Sdes[ 1171238106Sdes#ifndef HAVE_INET_ATON 1172238106Sdes#define inet_aton inet_aton_$1 1173238106Sdesint inet_aton(const char *cp, struct in_addr *addr); 1174238106Sdes#endif 1175238106Sdes]) 1176238106Sdes 1177238106Sdesdnl provide memmove compat prototype. 1178238106Sdesdnl $1: unique name for compat code 1179238106SdesAC_DEFUN([AHX_CONFIG_MEMMOVE], 1180238106Sdes[ 1181238106Sdes#ifndef HAVE_MEMMOVE 1182238106Sdes#define memmove memmove_$1 1183238106Sdesvoid *memmove(void *dest, const void *src, size_t n); 1184238106Sdes#endif 1185238106Sdes]) 1186238106Sdes 1187238106Sdesdnl provide strlcat compat prototype. 1188238106Sdesdnl $1: unique name for compat code 1189238106SdesAC_DEFUN([AHX_CONFIG_STRLCAT], 1190238106Sdes[ 1191238106Sdes#ifndef HAVE_STRLCAT 1192238106Sdes#define strlcat strlcat_$1 1193238106Sdessize_t strlcat(char *dst, const char *src, size_t siz); 1194238106Sdes#endif 1195238106Sdes]) 1196238106Sdes 1197238106Sdesdnl provide strlcpy compat prototype. 1198238106Sdesdnl $1: unique name for compat code 1199238106SdesAC_DEFUN([AHX_CONFIG_STRLCPY], 1200238106Sdes[ 1201238106Sdes#ifndef HAVE_STRLCPY 1202238106Sdes#define strlcpy strlcpy_$1 1203238106Sdessize_t strlcpy(char *dst, const char *src, size_t siz); 1204238106Sdes#endif 1205238106Sdes]) 1206238106Sdes 1207238106Sdesdnl provide gmtime_r compat prototype. 1208238106Sdesdnl $1: unique name for compat code 1209238106SdesAC_DEFUN([AHX_CONFIG_GMTIME_R], 1210238106Sdes[ 1211238106Sdes#ifndef HAVE_GMTIME_R 1212238106Sdes#define gmtime_r gmtime_r_$1 1213238106Sdesstruct tm *gmtime_r(const time_t *timep, struct tm *result); 1214238106Sdes#endif 1215238106Sdes]) 1216238106Sdes 1217287917Sdesdnl provide reallocarray compat prototype. 1218287917Sdesdnl $1: unique name for compat code 1219287917SdesAC_DEFUN([AHX_CONFIG_REALLOCARRAY], 1220287917Sdes[ 1221287917Sdes#ifndef HAVE_REALLOCARRAY 1222287917Sdes#define reallocarray reallocarray$1 1223287917Sdesvoid* reallocarray(void *ptr, size_t nmemb, size_t size); 1224287917Sdes#endif 1225287917Sdes]) 1226287917Sdes 1227238106Sdesdnl provide w32 compat definition for sleep 1228238106SdesAC_DEFUN([AHX_CONFIG_W32_SLEEP], 1229238106Sdes[ 1230266114Sdes#if !defined(HAVE_SLEEP) || defined(HAVE_WINDOWS_H) 1231238106Sdes#define sleep(x) Sleep((x)*1000) /* on win32 */ 1232238106Sdes#endif /* HAVE_SLEEP */ 1233238106Sdes]) 1234238106Sdes 1235238106Sdesdnl provide w32 compat definition for usleep 1236238106SdesAC_DEFUN([AHX_CONFIG_W32_USLEEP], 1237238106Sdes[ 1238238106Sdes#ifndef HAVE_USLEEP 1239238106Sdes#define usleep(x) Sleep((x)/1000 + 1) /* on win32 */ 1240238106Sdes#endif /* HAVE_USLEEP */ 1241238106Sdes]) 1242238106Sdes 1243238106Sdesdnl provide w32 compat definition for random 1244238106SdesAC_DEFUN([AHX_CONFIG_W32_RANDOM], 1245238106Sdes[ 1246238106Sdes#ifndef HAVE_RANDOM 1247238106Sdes#define random rand /* on win32, for tests only (bad random) */ 1248238106Sdes#endif /* HAVE_RANDOM */ 1249238106Sdes]) 1250238106Sdes 1251238106Sdesdnl provide w32 compat definition for srandom 1252238106SdesAC_DEFUN([AHX_CONFIG_W32_SRANDOM], 1253238106Sdes[ 1254238106Sdes#ifndef HAVE_SRANDOM 1255238106Sdes#define srandom(x) srand(x) /* on win32, for tests only (bad random) */ 1256238106Sdes#endif /* HAVE_SRANDOM */ 1257238106Sdes]) 1258238106Sdes 1259238106Sdesdnl provide w32 compat definition for FD_SET_T 1260238106SdesAC_DEFUN([AHX_CONFIG_W32_FD_SET_T], 1261238106Sdes[ 1262238106Sdes/* detect if we need to cast to unsigned int for FD_SET to avoid warnings */ 1263238106Sdes#ifdef HAVE_WINSOCK2_H 1264238106Sdes#define FD_SET_T (u_int) 1265238106Sdes#else 1266238106Sdes#define FD_SET_T 1267238106Sdes#endif 1268238106Sdes]) 1269238106Sdes 1270238106Sdesdnl Remove an extension flag from CFLAGS, define replacement to be made. 1271238106Sdesdnl Used by ACX_STRIP_EXT_FLAGS. 1272238106Sdesdnl $1: the name of the flag, for example -D_GNU_SOURCE. 1273238106SdesAC_DEFUN([ACX_CFLAGS_STRIP], 1274238106Sdes[ 1275238106Sdes if echo $CFLAGS | grep " $1" >/dev/null 2>&1; then 1276238106Sdes CFLAGS="`echo $CFLAGS | sed -e 's/ $1//g'`" 1277238106Sdes AC_DEFINE(m4_bpatsubst(OMITTED_$1,[[-=]],_), 1, Put $1 define in config.h) 1278238106Sdes fi 1279238106Sdes]) 1280238106Sdes 1281238106Sdesdnl Remove EXT flags from the CFLAGS and set them to be defined in config.h 1282238106Sdesdnl use with ACX_DETERMINE_EXT_FLAGS. 1283238106SdesAC_DEFUN([ACX_STRIP_EXT_FLAGS], 1284238106Sdes[ 1285238106Sdes AC_MSG_NOTICE([Stripping extension flags...]) 1286238106Sdes ACX_CFLAGS_STRIP(-D_GNU_SOURCE) 1287238106Sdes ACX_CFLAGS_STRIP(-D_BSD_SOURCE) 1288238106Sdes ACX_CFLAGS_STRIP(-D__EXTENSIONS__) 1289238106Sdes ACX_CFLAGS_STRIP(-D_POSIX_C_SOURCE=200112) 1290238106Sdes ACX_CFLAGS_STRIP(-D_XOPEN_SOURCE=600) 1291238106Sdes ACX_CFLAGS_STRIP(-D_XOPEN_SOURCE_EXTENDED=1) 1292238106Sdes ACX_CFLAGS_STRIP(-D_ALL_SOURCE) 1293238106Sdes ACX_CFLAGS_STRIP(-D_LARGEFILE_SOURCE=1) 1294238106Sdes]) dnl End of ACX_STRIP_EXT_FLAGS 1295238106Sdes 1296238106Sdesdnl define one omitted flag for config.h 1297238106Sdesdnl $1: flag name. -D_GNU_SOURCE 1298238106Sdesdnl $2: replacement define. _GNU_SOURCE 1299238106Sdesdnl $3: define value, 1 1300238106SdesAC_DEFUN([AHX_CONFIG_FLAG_OMITTED], 1301238106Sdes[#if defined($1) && !defined($2) 1302238106Sdes#define $2 $3 1303238106Sdes[#]endif ]) 1304238106Sdes 1305238106Sdesdnl Wrapper for AHX_CONFIG_FLAG_OMITTED for -D style flags 1306238106Sdesdnl $1: the -DNAME or -DNAME=value string. 1307238106SdesAC_DEFUN([AHX_CONFIG_FLAG_EXT], 1308238106Sdes[AHX_CONFIG_FLAG_OMITTED(m4_bpatsubst(OMITTED_$1,[[-=]],_),m4_bpatsubst(m4_bpatsubst($1,-D,),=.*$,),m4_if(m4_bregexp($1,=),-1,1,m4_bpatsubst($1,^.*=,))) 1309238106Sdes]) 1310238106Sdes 1311238106Sdesdnl config.h part to define omitted cflags, use with ACX_STRIP_EXT_FLAGS. 1312238106SdesAC_DEFUN([AHX_CONFIG_EXT_FLAGS], 1313238106Sdes[AHX_CONFIG_FLAG_EXT(-D_GNU_SOURCE) 1314238106SdesAHX_CONFIG_FLAG_EXT(-D_BSD_SOURCE) 1315238106SdesAHX_CONFIG_FLAG_EXT(-D__EXTENSIONS__) 1316238106SdesAHX_CONFIG_FLAG_EXT(-D_POSIX_C_SOURCE=200112) 1317238106SdesAHX_CONFIG_FLAG_EXT(-D_XOPEN_SOURCE=600) 1318238106SdesAHX_CONFIG_FLAG_EXT(-D_XOPEN_SOURCE_EXTENDED=1) 1319238106SdesAHX_CONFIG_FLAG_EXT(-D_ALL_SOURCE) 1320238106SdesAHX_CONFIG_FLAG_EXT(-D_LARGEFILE_SOURCE=1) 1321238106Sdes]) 1322238106Sdes 1323238106Sdesdnl check if memcmp is using signed characters and replace if so. 1324238106SdesAC_DEFUN([ACX_CHECK_MEMCMP_SIGNED], 1325238106Sdes[AC_MSG_CHECKING([if memcmp compares unsigned]) 1326238106SdesAC_RUN_IFELSE([AC_LANG_SOURCE([[ 1327238106Sdes#include <stdio.h> 1328238106Sdes#include <stdlib.h> 1329238106Sdes#include <string.h> 1330238106Sdesint main(void) 1331238106Sdes{ 1332238106Sdes char a = 255, b = 0; 1333238106Sdes if(memcmp(&a, &b, 1) < 0) 1334238106Sdes return 1; 1335238106Sdes return 0; 1336238106Sdes} 1337238106Sdes]])], [AC_MSG_RESULT([yes]) ], 1338238106Sdes[ AC_MSG_RESULT([no]) 1339238106Sdes AC_DEFINE([MEMCMP_IS_BROKEN], [1], [Define if memcmp() does not compare unsigned bytes]) 1340238106Sdes AC_LIBOBJ([memcmp]) 1341238106Sdes], [ AC_MSG_RESULT([cross-compile no]) 1342238106Sdes AC_DEFINE([MEMCMP_IS_BROKEN], [1], [Define if memcmp() does not compare unsigned bytes]) 1343238106Sdes AC_LIBOBJ([memcmp]) 1344238106Sdes]) ]) 1345238106Sdes 1346238106Sdesdnl define memcmp to its replacement, pass unique id for program as arg 1347238106SdesAC_DEFUN([AHX_MEMCMP_BROKEN], [ 1348238106Sdes#ifdef MEMCMP_IS_BROKEN 1349238106Sdes#include "compat/memcmp.h" 1350238106Sdes#define memcmp memcmp_$1 1351238106Sdesint memcmp(const void *x, const void *y, size_t n); 1352238106Sdes#endif 1353238106Sdes]) 1354238106Sdes 1355238106Sdesdnl ACX_CHECK_SS_FAMILY - check for sockaddr_storage.ss_family 1356238106SdesAC_DEFUN([ACX_CHECK_SS_FAMILY], 1357238106Sdes[AC_CHECK_MEMBER([struct sockaddr_storage.ss_family], [], [ 1358238106Sdes AC_CHECK_MEMBER([struct sockaddr_storage.__ss_family], [ 1359238106Sdes AC_DEFINE([ss_family], [__ss_family], [Fallback member name for socket family in struct sockaddr_storage]) 1360238106Sdes ],, [AC_INCLUDES_DEFAULT 1361238106Sdes#ifdef HAVE_NETINET_IN_H 1362238106Sdes#include <netinet/in.h> 1363238106Sdes#endif 1364238106Sdes#ifdef HAVE_SYS_SOCKET_H 1365238106Sdes#include <sys/socket.h> 1366238106Sdes#endif 1367238106Sdes#ifdef HAVE_NETDB_H 1368238106Sdes#include <netdb.h> 1369238106Sdes#endif 1370238106Sdes#ifdef HAVE_ARPA_INET_H 1371238106Sdes#include <arpa/inet.h> 1372238106Sdes#endif 1373238106Sdes ]) 1374238106Sdes], [AC_INCLUDES_DEFAULT 1375238106Sdes#ifdef HAVE_NETINET_IN_H 1376238106Sdes#include <netinet/in.h> 1377238106Sdes#endif 1378238106Sdes#ifdef HAVE_SYS_SOCKET_H 1379238106Sdes#include <sys/socket.h> 1380238106Sdes#endif 1381238106Sdes#ifdef HAVE_NETDB_H 1382238106Sdes#include <netdb.h> 1383238106Sdes#endif 1384238106Sdes#ifdef HAVE_ARPA_INET_H 1385238106Sdes#include <arpa/inet.h> 1386238106Sdes#endif 1387238106Sdes]) ]) 1388238106Sdes 1389238106Sdesdnl End of file 1390