dnl ##define([AC_CACHE_LOAD], )dnl dnl--------------------------------------------------------------------------- dnl configure-script template dnl dnl--------------------------------------------------------------------------- dnl TODO: allow the use of hosts//machine.h.in resp Makefile.in dnl TODO:: when existing instead of the normal ones. dnl dnl some helper macros dnl AC_DEFUN([AC_UPDATE_VAR], [if test "x$[$1]" = "x" && test "x$DEFAULT[$1]" != "x"; then [$1]=$DEFAULT[$1] fi] ) AC_DEFUN([AC_CDEF_FROM_ENABLE], [AC_UPDATE_VAR(enable_[$1]) if test "x$enable_[$1]" = "xyes"; then cdef_[$1]="#define" else cdef_[$1]="#undef" fi ]) AC_DEFUN([AC_INT_VAL_FROM_WITH], [if test "x$with_[$1]" != "x"; then with_[$1]=`echo $with_[$1]| changequote(, )dnl sed -e 's/^\(-\?\(0x[0-9a-fA-F]\+\)\?[0-9]*\)[^0-9]\?.*$/\1/'` changequote([, ])dnl fi AC_UPDATE_VAR(with_[$1]) val_[$1]=$with_[$1]] ) AC_DEFUN([AC_STRING_VAL_FROM_WITH], [if test "x$with_[$1]" != "x"; then with_[$1]=`echo $with_[$1]| changequote(, )dnl sed -e 's/^\([^"]*\)\?.*$/\1/'` changequote([, ])dnl fi AC_UPDATE_VAR(with_[$1]) val_[$1]="\"$with_[$1]\""] ) AC_DEFUN([AC_TEXT_VAL_FROM_WITH], [if test "x$with_[$1]" != "x"; then with_[$1]=`echo $with_[$1]| changequote(, )dnl sed -e 's/^\([^"]*\)\?.*$/\1/'` changequote([, ])dnl fi AC_UPDATE_VAR(with_[$1]) val_[$1]="$with_[$1]"] ) AC_DEFUN([AC_FORM_HELP],[ --$1[]dnl ifelse([$2],,,dnl builtin(format,%[.]builtin(eval,(len([$1])<50)*(50-len([$1])))s,) [default=$2])[]dnl ifelse([$3],,,[ ]patsubst([$3],[^],[ ]))[]dnl ]) AC_DEFUN([AC_MY_ARG_ENABLE], [DEFAULTenable_[]translit([$1],[-],[_])=ifelse($2,,no,[$2]) AC_ARG_ENABLE([$1],AC_FORM_HELP([enable-$1]ifelse($3,,,[=($3)]), ifelse([$2],,[disabled],[$2],no,[disabled],[$2],yes,[enabled],[enabled($2)]), [$4]),[$5],[$6]) ]) AC_DEFUN([AC_MY_ARG_WITH], [DEFAULTwith_[]translit([$1],[-],[_])=ifelse($2,,no,[$2]) AC_ARG_WITH([$1],AC_FORM_HELP([with-$1]ifelse($3,,[=VALUE],[=$3]), [$2], [$4]),[$5],[$6]) ]) AC_DEFUN([AC_NOT_AVAILABLE], [if test "x$not_available" = "x"; then not_available="$1" else not_available="[$not_available], $1" fi]) dnl dnl let's start AC_INIT(prolang.y) dnl set the default prefix AC_PREFIX_DEFAULT(/opt/psyclpc) dnl dnl This variable collects those requested features for which the system dnl doesn't offer the right support. not_available="" dnl dnl define default values for package arguments dnl and declare the package arguments dnl AC_MY_ARG_ENABLE(erq,erq,[no/erq],[Enables and or selects ERQ demon]) AC_MY_ARG_ENABLE(access-control,yes,,) AC_MY_ARG_ENABLE(access-log,no,,) AC_MY_ARG_ENABLE(align-functions,yes,,) AC_MY_ARG_ENABLE(compat-mode,no,,) AC_MY_ARG_ENABLE(strict-euids,no,,) AC_MY_ARG_ENABLE(filename-spaces,no,,[Allow space characters in filenames]) AC_MY_ARG_ENABLE(share-variables,no,,[Enable clone initialization from blueprint variable values]) AC_MY_ARG_ENABLE(use-system-crypt,yes,,) AC_MY_ARG_ENABLE(udp-send,yes,,) AC_MY_ARG_ENABLE(use-ipv6,no,,[Enables support for IPv6]) AC_MY_ARG_ENABLE(use-alists,no,,[Enables alist support]) AC_MY_ARG_ENABLE(use-gnunet,no,,[Enables GNUnet support]) AC_MY_ARG_ENABLE(use-psyc,no,,[Enables libpsyc support]) AC_MY_ARG_ENABLE(use-mccp,no,,[Enables MCCP support]) AC_MY_ARG_ENABLE(use-mysql,no,,[Enables mySQL support]) AC_MY_ARG_ENABLE(use-pgsql,no,,[Enables PostgreSQL support]) AC_MY_ARG_ENABLE(use-sqlite,no,,[Enables SQLite support]) AC_MY_ARG_ENABLE(use-json,no,,[Enables JSON-C Support]) AC_MY_ARG_ENABLE(use-expat,no,,[Enables Expat XML Support]) AC_MY_ARG_ENABLE(use-iksemel,no,,[Enables Iksemel XML Support]) AC_MY_ARG_ENABLE(use-srv,no,,[Enables DNS SRV Support]) AC_MY_ARG_ENABLE(use-actions,yes,,[Enables regular MUD command parser]) AC_MY_ARG_ENABLE(use-builtin-editor,yes,,[Enables built-in text editor 'ed']) AC_MY_ARG_ENABLE(use-debug-log,yes,,[Enables built-in text editor 'ed']) AC_MY_ARG_ENABLE(use-experimental,no,,[Enables recent experimental features]) AC_MY_ARG_ENABLE(use-inventories,yes,,[Enables all inventory-related functions]) AC_MY_ARG_ENABLE(use-paranoia,no,,[Enables paranoid reference checking]) AC_MY_ARG_ENABLE(use-restored-objects,no,,[Enables serializing object pointers as name strings]) AC_MY_ARG_ENABLE(use-shadowing,yes,,[Enables all shadowing-related functions]) AC_MY_ARG_ENABLE(use-snooping,yes,,[Enables all snooping-related functions]) AC_MY_ARG_ENABLE(use-socket-limits,yes,,[Enables socket lines per second limits]) AC_MY_ARG_ENABLE(use-swap,no,,[Enables support for LPC memory swapping]) #AC_MY_ARG_ENABLE(backtrace-always,no,,[Always output error backtraces on the console]) AC_MY_ARG_ENABLE(use-ldmud-compatibility,yes,,[Makes psyclpc behave more like LDMUD than you will want]) AC_MY_ARG_ENABLE(use-pthreads,no,,[Enables using of threads for socket writes]) AC_MY_ARG_ENABLE(use-pcre,yes,,[Enables PCRE: yes/no]) AC_MY_ARG_ENABLE(use-iksemel,no,,[Enables use of iksemel for XML parsing]) AC_MY_ARG_ENABLE(use-deprecated,yes,,[Enables obsolete and deprecated efuns]) AC_MY_ARG_ENABLE(use-structs,yes,,[Enables structs]) AC_MY_ARG_ENABLE(use-tls,no,,[Enables Transport Layer Security over Telnet: no/gnu/ssl/yes]) AC_MY_ARG_WITH(tls-path,,,[Optional location of the TLS include/ and lib/ directory]) AC_MY_ARG_ENABLE(use-new-inlines,yes,,[Enables new inline syntax]) AC_MY_ARG_ENABLE(use-set-light,yes,,[Enables efun set_light()]) AC_MY_ARG_ENABLE(use-set-is-wizard,yes,,[Enables efun set_is_wizard()]) AC_MY_ARG_ENABLE(use-parse-command,yes,,[Enables efun parse_command()]) AC_MY_ARG_ENABLE(use-process-string,yes,,[Enables efun process_string()]) AC_MY_ARG_ENABLE(lpc-array-calls,yes,,[Enables call_others on arrays of objects]) AC_MY_ARG_ENABLE(comm-stat,yes,,) AC_MY_ARG_ENABLE(apply-cache_stat,yes,,) AC_MY_ARG_ENABLE(malloc-sbrk,yes,,[Use sbrk() if possible (smalloc,slaballoc)]) AC_MY_ARG_ENABLE(malloc-check,yes,,[Enable simple malloc checks (smalloc,slaballoc)]) AC_MY_ARG_ENABLE(malloc-trace,no,,[Annotate allocations with source file:line]) AC_MY_ARG_ENABLE(malloc-lpc-trace,no,,[Annotate allocations with LPC object info]) AC_MY_ARG_ENABLE(malloc-sbrk-trace,no,,[Log all esbrk() calls (smalloc,slaballoc)]) AC_MY_ARG_ENABLE(dynamic-costs,no,,) AC_MY_ARG_ENABLE(eval-cost-trace,no,,[Writes the evaluation costs in the stracktrace]) AC_MY_ARG_ENABLE(trace-code,yes,,[trace the most recently executed bytecode]) AC_MY_ARG_ENABLE(rxcache_table,yes,,) AC_MY_ARG_ENABLE(synchronous-heart-beat,yes,,[Do all heart beats at once.]) AC_MY_ARG_ENABLE(opcprof,no,,[create VM instruction usage statistics]) AC_MY_ARG_ENABLE(verbose-opcprof,no,,[with opcprof: include instruction names]) AC_MY_ARG_ENABLE(debug,yes,,[enable sanity checks]) AC_MY_ARG_ENABLE(yydebug,no,,[enable LPC compiler debug output]) AC_MY_ARG_ENABLE(no-inlines,no,,[disable inlining]) AC_MY_ARG_ENABLE(debug-telnet,no,,[enable telnet machine diagnostics]) AC_MY_ARG_ENABLE(debug-malloc-allocs,no,,[enable small block diagnostics]) AC_MY_ARG_ENABLE(check-object-stat,no,,[trace changes to the object statistics]) AC_MY_ARG_ENABLE(check-mapping-total,no,,[check the mapping statistic]) AC_MY_ARG_ENABLE(check-object-ref,no,,[check object references]) AC_MY_ARG_ENABLE(check-object-gc-ref,yes,,[check object references in GC]) AC_MY_ARG_ENABLE(dump-gc-refs,no,,[trace GC references]) AC_MY_ARG_WITH(optimize,med,,[Optimization level: no/low/med/high]) AC_MY_ARG_WITH(access-file,ACCESS.ALLOW,,[access permissions file]) AC_MY_ARG_WITH(access-log,access.allow.log,,[access log file]) AC_MY_ARG_WITH(pthreads-write-max-size,100000,,[max size of write buffer per thread]) AC_MY_ARG_WITH(erq-max-reply,1024,,) AC_MY_ARG_WITH(erq-max-send,1024,,) AC_MY_ARG_WITH(erq-debug,0,,[ERQ debug level]) AC_MY_ARG_WITH(read-file-max-size,50000,[BYTES], [maximum size of a file allowed to be read by 'read_file()']) AC_MY_ARG_WITH(master-name,secure/master,,[name of the master object]) AC_MY_ARG_WITH(input-escape,"!",,[input escape character]) AC_MY_ARG_WITH(time-to-clean_up,3600,[SECONDS],) AC_MY_ARG_WITH(time-to-swap,900,[SECONDS],) AC_MY_ARG_WITH(time-to-swap-variables,1800,[SECONDS],) AC_MY_ARG_WITH(time-to-reset,1800,[SECONDS],) AC_MY_ARG_WITH(alarm-time,2,[SECONDS],) AC_MY_ARG_WITH(heart-beat-interval,2,[SECONDS],) AC_MY_ARG_WITH(evaluator-stack-size,2000,,) AC_MY_ARG_WITH(max-user-trace,60,,) AC_MY_ARG_WITH(max-trace,65,,) AC_MY_ARG_WITH(compiler-stack-size,400,,) AC_MY_ARG_WITH(max-bits,6144,,) AC_MY_ARG_WITH(portno,4404,,) AC_MY_ARG_WITH(udp-port,4404,,) AC_MY_ARG_WITH(maxnumports,20,,) AC_MY_ARG_WITH(max_net_connects,20,,) AC_MY_ARG_WITH(size_socket_buffer,16384,,) AC_MY_ARG_WITH(max-cost,1000000,,) AC_MY_ARG_WITH(catch-reserved-cost,2000,,) AC_MY_ARG_WITH(master-reserved-cost,0x200,,) AC_MY_ARG_WITH(swap-file,LP_SWAP,,[name of the swap file]) AC_MY_ARG_WITH(max-array-size,5000,,[max number of array elements]) AC_MY_ARG_WITH(max-mapping-keys,5000,,[max number of mapping entries]) AC_MY_ARG_WITH(max-mapping-size,15000,,[max number of mapping elements]) AC_MY_ARG_WITH(max-callouts,0,,) AC_MY_ARG_WITH(max-players,50,,) AC_MY_ARG_WITH(max-local,50,,) AC_MY_ARG_WITH(allowed-ed-cmds,20,,[number of ed commands per backend cycle]) AC_MY_ARG_WITH(reserved-user-size,700000,,) AC_MY_ARG_WITH(reserved-master-size,100000,,) AC_MY_ARG_WITH(reserved-system-size,200000,,) AC_MY_ARG_WITH(htable-size,4096,,) AC_MY_ARG_WITH(itable-size,256,,) AC_MY_ARG_WITH(otable-size,1024,,) AC_MY_ARG_WITH(defmax,65000,,) AC_MY_ARG_WITH(apply-cache-bits,12,,) AC_MY_ARG_WITH(rxcache-table,8192,,) AC_MY_ARG_WITH(max-byte-transfer,50000,,) AC_MY_ARG_WITH(catch-udp-port,4246,,) AC_MY_ARG_WITH(set-buffer-size-max,65536,,) AC_MY_ARG_WITH(malloc,default,[default/smalloc/slaballoc/sysmalloc/ptmalloc],[memory manager to use]) AC_MY_ARG_WITH(min-malloced,0,,) AC_MY_ARG_WITH(min-small-malloced,0,,) AC_MY_ARG_WITH(max-malloced,0x4000000,,) AC_MY_ARG_WITH(total-trace-length,0x1000,,) AC_MY_ARG_WITH(pcre-recursion-limit,3000,,[maximum number of recursions in PCRE package]) AC_MY_ARG_WITH(wizlist-file,WIZLIST,,[name of the wizlist file]) AC_MY_ARG_WITH(max_net_connects,10,,[maximum number of concurrent connection attempts]) AC_MY_ARG_WITH(random-period-length,19937,[607 / 1279 / 2281 / 4253 / 11213 / 19937 / 44497 / 86243 / 132049 / 216091],[period length of the random number generator]) AC_ARG_WITH(setting,[ --with-setting=SETTING include a predefined setting],[ if test -f "settings/$withval" ; then cat >conftest.sed <<\EOF /^#.*/ d /^[[ \t]]*$/ d s/#.*$// s/disable_\([[^= \t]]*\)/enable_\1=no/ /^enable_/ s/^/DEFAULT/p /^with_/ s/^/DEFAULT/p [] EOF eval `sed -n -f conftest.sed 1) { x1000 } else foo(); return bar(); } int foo(){ return 0; } int bar(){ return 0; } int foobar(){ return 0; } double d = 4.5;], [double e = 1.3; e/= 0.2;], lp_cv_sys_float_branch_incompatible=no, lp_cv_sys_float_branch_incompatible=yes )) if test $lp_cv_sys_float_branch_incompatible = yes ; then CC="cc" GCC="" AC_MSG_WARN(falling back to cc) fi # Restore the CFLAGS CFLAGS=$save_cflags # check for ANSI-C (for compiling LDMUD project) AC_PROG_CC_STDC if test "${ac_cv_prog_cc_stdc}" = no; then AC_MSG_ERROR(You need an ANSI-C89 or ISO-C (C99) compiler! sorry..) fi # does the compile have an inline keyword? AC_C_INLINE if test "x$ac_cv_c_inline" != "xno"; then AC_DEFINE(HAS_INLINE, 1, [Does the compiler provide inline functions?]) fi # does the compile have an restrict keyword? # temporarily deactivated because it introduces an #if defined x into # machine.h and mkfunc.c can't deal with 'defined' without parentheses. #AC_C_RESTRICT # does the compile have an typeof keyword? AC_C_TYPEOF # does the preprocessor support the stringenizing operator? AC_C_STRINGIZE # check for some types AC_TYPE_INT8_T AC_TYPE_INT16_T AC_TYPE_INT32_T AC_TYPE_INT64_T AC_TYPE_INTMAX_T AC_TYPE_INTPTR_T AC_TYPE_UINT8_T AC_TYPE_UINT16_T AC_TYPE_UINT32_T AC_TYPE_UINT64_T AC_TYPE_UINTMAX_T AC_TYPE_UINTPTR_T AC_TYPE_LONG_LONG_INT AC_TYPE_UNSIGNED_LONG_LONG_INT AC_TYPE_LONG_DOUBLE AC_TYPE_LONG_DOUBLE_WIDER AC_TYPE_SSIZE_T AC_TYPE_SIZE_T AC_TYPE_OFF_T AC_TYPE_MODE_T AC_TYPE_PID_T AC_TYPE_SIGNAL # Check some sizes AC_CHECK_SIZEOF(char *) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(long long) AC_CHECK_SIZEOF(intptr_t) AC_CHECK_SIZEOF(intmax_t) # Checking for programs AC_PROG_INSTALL AC_CONFIG_HEADERS(machine.h) AC_CHECK_PROGS(YACC, byacc "bison -y", yacc) AC_PROG_CPP AH_TOP([ #ifndef MACHINE_H #define MACHINE_H]) AH_BOTTOM([ #endif]) dnl Recognize some unusual systems. dnl Not all checks happen here - the check for solaris for example requires dnl some library checks first. AC_EGREP_CPP(yes,[ #if defined(__EMX__) yes #endif ], [ EXTRA_CFLAGS="${EXTRA_CFLAGS} -DOS2" ]) AC_EGREP_CPP(yes,[ #if defined(__CYGWIN32__) || defined(__CYGWIN__) yes #endif ], [ EXTRA_CFLAGS="${EXTRA_CFLAGS} -DMSWIN" ]) dnl Checking for headers AC_HEADER_STDBOOL AC_CHECK_HEADERS(sys/rusage.h sys/time.h unistd.h stdlib.h libc.h memory.h) AC_CHECK_HEADERS(string.h bstring.h netdb.h crypt.h sys/param.h sys/termios.h) dnl extra check for ; must be there! AC_CHECK_HEADERS(limits.h) AC_HEADER_DIRENT dnl check for some functions AC_FUNC_MKTIME AC_FUNC_ALLOCA AC_CHECK_FUNCS(fchmod getrusage bzero memset memcpy memmem strdup strcspn) AC_CHECK_FUNCS(strchr strrchr getcwd memmove sysconf gettimeofday wait3 waitpid) AC_CHECK_FUNCS(fcntl getdomainname poll strtoul trunc) AC_CACHE_CHECK(for needed malloc() alignment,lp_cv_sys_malloc_align, AC_TRY_COMPILE([struct ts {double d; char *p; double e;}; int i = 96/(sizeof(struct ts)-20); ],, lp_cv_sys_malloc_align=8, lp_cv_sys_malloc_align=4)) AC_DEFINE_UNQUOTED(MALLOC_ALIGN,$lp_cv_sys_malloc_align,[word alignment]) if test "x$ac_cv_type_signal" = "xvoid"; then AC_DEFINE(RETSIGTYPE_VOID, 1, [Set in response to the signal handler return type, since not all compilers understand direct definition comparisons. ]) fi # --- Check for common system libraries --- AC_CHECK_LIB(m,main) AC_CHECK_LIB(socket,main) AC_CHECK_LIB(nsl,main) ERQ_LIBS="$LIBS" AC_CHECK_LIB(ucb,main, LIBS="$LIBS -lc -lucb") if test $ac_cv_lib_socket_main = "yes" || test $ac_cv_lib_ucb_main = "yes"; then AC_CHECK_LIB(nsl,main) fi # man herror says herror is obsolete.. but we use it in comm.c anyway... AC_CACHE_CHECK(if -lresolv is needed, lp_cv_need_lib_resolv, AC_TRY_RUN([ #include void t (void) { herror("foo"); } int main(void) { return 0; } ], lp_cv_need_lib_resolv=no, lp_cv_need_lib_resolv=yes )) if test "$lp_cv_need_lib_resolv" = "yes"; then AC_CHECK_LIB(resolv,main, LIBS="$LIBS -lresolv"; ERQ_LIBS="$LIBS") else AC_CHECK_LIB(resolv,main, ERQ_LIBS="$LIBS -lresolv") fi # --- Check if we need the crypto libraries --- if test "x$enable_use_system_crypt" = "x" || test "x$enable_use_system_crypt" = "xyes"; then AC_CHECK_FUNCS(crypt _crypt) for lp_lib in crypt crypto; do if test "$ac_cv_func_crypt" != "yes" -a "$ac_cv_func__crypt" != "yes"; then # Try linking with lib$lp_lib unset ac_cv_func_crypt unset ac_cv_func__crypt lp_save_libs="$LIBS" AC_CHECK_LIB($lp_lib,main, LIBS="$LIBS -l$lp_lib") if test "$SAVE_LIBS" != "$LIBS" ; then AC_CHECK_FUNCS(crypt _crypt) if test "$ac_cv_func_crypt" != "yes" -a "$ac_cv_func__crypt" != "yes"; then # They are not in this library LIBS="$lp_save_libs" else eval "lp_cv_need_lib_${lp_lib}=yes" fi fi fi done fi AC_CACHE_CHECK(if inet_ntoa() ok,lp_cv_func_inet_ntoa_ok, AC_TRY_RUN([ #include /* needed for netinet/in.h */ #include #include main() { char addr1[[]] = "176.88.1.16"; char addr2[[]] = "88.176.128.2"; struct in_addr tmp; #if SIZEOF_INT == 4 #define ADDR_TYPE unsigned int #else #define ADDR_TYPE unsigned long #endif *((ADDR_TYPE *)&tmp) = inet_addr(addr1); if (strcmp(addr1, inet_ntoa(tmp))) exit(1); *((ADDR_TYPE *)&tmp) = inet_addr(addr2); if (strcmp(addr2, inet_ntoa(tmp))) exit(1); exit(0); } ],lp_cv_func_inet_ntoa_ok=yes, lp_cv_func_inet_ntoa_ok=no, AC_TRY_COMPILE([ #if defined(sun) && !defined(__svr4__) #include /* needed for netinet/in.h */ #include #include char *inet_ntoa(ad) struct in_addr ad; { static char addr[[[20]]]; return addr; } #else use inet_ntoa() from the library. #endif ],,lp_cv_func_inet_ntoa_ok=no, lp_cv_func_inet_ntoa_ok=yes ))) if test $lp_cv_func_inet_ntoa_ok = yes ; then dnl TODO: Is there any platform where this is not the case? AC_DEFINE(INET_NTOA_OK, 1, [Is the library function inet_ntoa() compatible with the compiler?]) fi # --- IPV6 --- AC_CACHE_CHECK(for IPv6 support,lp_cv_has_ipv6, saveflags="$CFLAGS" CFLAGS="$CFLAGS -I/usr/inet6/include" AC_TRY_COMPILE([ #include #include struct sockaddr_in6 foo(void) { static struct sockaddr_in6 ad; return ad; } ],,lp_cv_has_ipv6=yes, lp_cv_has_ipv6=no CFLAGS="$saveflags" )) if test $lp_cv_has_ipv6 = yes; then AC_DEFINE(HAS_IPV6, 1, [Does the machine offer IPv6?]) if test $enable_use_ipv6 = yes; then AC_CACHE_CHECK(if -linet6 is needed, lp_cv_need_lib_inet6, AC_TRY_RUN([ #include #include void t (void) { struct sockaddr_in6 ad; inet6_ntoa(ad.sin_addr); } int main(void) { return 0; } ], lp_cv_need_lib_inet6=no, lp_cv_need_lib_inet6=yes )) if test "$lp_cv_need_lib_inet6" = "yes"; then AC_CHECK_LIB(inet6,main, LIBS="$LIBS -linet6") fi fi else if test $enable_use_ipv6 = yes; then echo "IPV6 not supported - disabling IPV6 support." AC_NOT_AVAILABLE(use-ipv6) fi cdef_use_ipv6="#undef" enable_use_ipv6=no fi # --- TLS --- has_tls=no saveflags="$CFLAGS" saveeflags="$EXTRA_CFLAGS" savelibs="$LIBS" savepkglibs="$PKGLIBS" # Check for OpenSSL unless not desired # Check for the libraries only if tls is actually enabled. if test ! "x${tls_include_path}" = "x"; then CFLAGS="$CFLAGS -I${tls_include_path}" EXTRA_CFLAGS="$EXTRA_CFLAGS -I${tls_include_path}" fi if test ! "x${tls_lib_path}" = "x"; then LIBS="$LIBS -L${tls_lib_path}" PKGLIBS="$PKGLIBS -L${tls_lib_path}" fi if test "$tls_package" = "any" -o "$tls_package" = "ssl"; then AC_CACHE_CHECK(for OpenSSL support,lp_cv_has_openssl, AC_TRY_COMPILE([ #include void foo(void) { int i = SSL_MAX_SSL_SESSION_ID_LENGTH; } ],,lp_cv_has_openssl=yes, lp_cv_has_openssl=no )) if test $lp_cv_has_openssl = yes; then has_tls=yes tls_package=ssl AC_DEFINE(HAS_OPENSSL, 1, [Does the machine offer OpenSSL/SSL?]) if test "$enable_use_tls" = "yes"; then AC_CACHE_CHECK(if -lssl or similar is needed, lp_cv_need_lib_ssl, AC_TRY_RUN([ #include void t (void) { SSL_library_init(); } int main(void) { return 0; } ], lp_cv_need_lib_ssl=no, lp_cv_need_lib_ssl=yes )) if test "$lp_cv_need_lib_ssl" = "yes"; then lp_cv_has_lib_ssl=no AC_CHECK_LIB(ssl,SSL_library_init, PKGLIBS="$PKGLIBS -lssl" lp_cv_has_lib_ssl=yes ) fi if test "x$lp_cv_need_lib_crypto" != "xyes"; then AC_CACHE_CHECK(if -lcrypto is needed for SSL, lp_cv_need_lib_crypto, AC_TRY_RUN([ #include void t (void) { DH *dhe1024 = NULL; DH_free(dhe1024); } int main(void) { return 0; } ], lp_cv_need_lib_crypto=no, lp_cv_need_lib_crypto=yes )) if test "$lp_cv_need_lib_crypto" = "yes"; then AC_CHECK_LIB(crypto,main, PKGLIBS="$PKGLIBS -lcrypto") fi fi fi else has_tls=no fi fi # Check for GnuTLS unless not desired if test "$tls_package" = "any" -o "$tls_package" = "gnu"; then AC_CACHE_CHECK(for GnuTLS support,lp_cv_has_gnutls, AC_TRY_COMPILE([ #include void foo(void) { int i = GNUTLS_CIPHER_RIJNDAEL_256_CBC; } ],,lp_cv_has_gnutls=yes, lp_cv_has_gnutls=no )) if test $lp_cv_has_gnutls = yes; then has_tls=yes tls_package=gnu AC_DEFINE(HAS_GNUTLS, 1, [Does the machine offer GnuTLS?]) if test "$enable_use_tls" = "yes"; then AC_CACHE_CHECK(if -lgnutls or similar is needed, lp_cv_need_lib_gnutls, AC_TRY_RUN([ #include void t (void) { gnutls_global_init(); gnutls_global_deinit(); } int main(void) { return 0; } ], lp_cv_need_lib_gnutls=no, lp_cv_need_lib_gnutls=yes )) if test "$lp_cv_need_lib_gnutls" = "yes"; then lp_cv_has_lib_gnutls=no AC_CHECK_LIB(gnutls,gnutls_global_init, PKGLIBS="$PKGLIBS -lgnutls" lp_cv_has_lib_gnutls=yes ) fi AC_CACHE_CHECK(gnutls version, lp_cv_has_gnutls_version, savelibs="$LIBS" LIBS="$PKGLIBS" AC_TRY_RUN([ #include void t (void) { gnutls_dh_params dh_params; gnutls_dh_params_generate2( dh_params, 1024); } int main(void) { return 0; } ], lp_cv_has_gnutls_version=8, lp_cv_has_gnutls_version=7 )) LIBS="$savelibs" AC_DEFINE_UNQUOTED(HAS_GNUTLS_VERSION, $lp_cv_has_gnutls_version, [version of GNUTLS library]) fi else has_tls=no fi fi # Evaluate the results of the checks if test "$has_tls" = no; then if test $enable_use_tls = yes; then echo "TLS not supported - disabling TLS support." AC_NOT_AVAILABLE(use-tls) fi cdef_use_tls="#undef" enable_use_tls=no EXTRA_CFLAGS="$saveeflags" PKGLIBS="$savepkglibs" fi CFLAGS="$saveflags" LIBS="$savelibs" # --- PThreads --- AC_CACHE_CHECK(for pthreads support,lp_cv_has_pthreads, saveflags="$CFLAGS" savelibs="$LIBS" CFLAGS="$CFLAGS" AC_TRY_COMPILE([ #include void foo(void) { int i = PTHREAD_CREATE_JOINABLE; } ],,lp_cv_has_pthreads=yes, lp_cv_has_pthreads=no CFLAGS="$saveflags" )) if test $lp_cv_has_pthreads = yes; then saveflags="$CFLAGS" savelibs="$LIBS" AC_DEFINE(HAS_PTHREADS, 1, [Does the machine offer pthreads?]) AC_CACHE_CHECK(if -lpthread or similar is needed, lp_cv_need_lib_pthread, AC_TRY_RUN([ #include void t (void) { pthread_t pid; pthread_cancel(pid); } int main(void) { return 0; } ], lp_cv_need_lib_pthread=no, lp_cv_need_lib_pthread=yes )) if test "$lp_cv_need_lib_pthread" = "yes"; then lp_cv_has_lib_pthread=no AC_CHECK_LIB(pthread,main, LIBS="$savelibs -lpthread" lp_cv_has_lib_pthread=yes ) if test "$lp_cv_has_lib_pthread" = "no"; then AC_CHECK_LIB(c_r,main, LIBS="$savelibs -lc_r" lp_cv_has_lib_pthread=yes ) fi fi AC_CACHE_CHECK(for pthread_atfork(),lp_cv_has_pthread_atfork, AC_TRY_RUN([ #include void t (void) { pthread_atfork(0, 0, 0); } int main (void) { return 0; } ],lp_cv_has_pthread_atfork=yes, lp_cv_has_pthread_atfork=no ) ) if test $lp_cv_has_pthread_atfork = yes; then AC_DEFINE(HAS_PTHREAD_ATFORK, 1, [Does the machine offer pthread_atfork()?]) fi CFLAGS="$saveflags" if test $enable_use_pthreads = no; then LIBS="$savelibs" fi else if test $enable_use_pthreads = yes; then echo "pthreads not supported - disabling pthreads support." AC_NOT_AVAILABLE(use-pthreads) fi cdef_use_pthreads="#undef" enable_use_pthreads=no fi # --- GNUnet --- echo "--- GNUnet" lp_cv_has_gnunet_lib="no" AC_CHECK_LIB(gnunetcadet,main, lp_cv_has_gnunet_lib="yes") if test $lp_cv_has_gnunet_lib = yes; then LIBS="-lgnunetutil -lgnunetcadet" AC_CACHE_CHECK(for GNUnet crypto,lp_cv_has_gnunet, AC_TRY_RUN([ #include #include #include #include #include int main(void) { const struct GNUNET_HashCode *hash = GC_u2h (4404); const char* expect = "VFQCGVPZJJ6PHN5DQ6NWH1BJY3Q3SNF0BVCT2B1S4Q915SMYHDRW1X2BFTEEWXG9ZC23PVH3Y1W6D4DRKRTHV2CFGHAW66W52QGM0B8"; printf( "u2h(4404) = %s ... ", GNUNET_h2s( hash ) ); if (strcmp(expect, GNUNET_h2s_full( hash ))) return -1; return 0; } ], lp_cv_has_gnunet=yes, lp_cv_has_gnunet=no )) CFLAGS="$saveflags" if test $lp_cv_has_gnunet = yes; then AC_DEFINE(HAS_GNUNET, 1, [Does the machine offer GNUnet?]) PKGLIBS="$PKGLIBS $LIBS" echo " >>> Congrats! GNUnet CADET is available." else echo "GNUnet CADET not available on this system yet." fi fi # --- libpsyc --- echo "--- libpsyc" lp_cv_has_psyc_lib="no" AC_CHECK_LIB(psyc,main, lp_cv_has_psyc_lib="yes") if test $lp_cv_has_psyc_lib = yes; then LIBS="-lpsyc" AC_CACHE_CHECK(for libpsyc functionality,lp_cv_has_psyc, AC_TRY_RUN([ #include #include int main(void) { size_t tlen = 0; const char *t = psyc_template(PSYC_MC_REQUEST_CONTEXT_ENTER, &tlen); printf("%s ... ", t); return PSYC_VERSION ? 0 : -1; } ], lp_cv_has_psyc=yes, lp_cv_has_psyc=no )) CFLAGS="$saveflags" if test $lp_cv_has_psyc = yes; then AC_DEFINE(HAS_PSYC, 1, [Does the machine offer libpsyc?]) PKGLIBS="$PKGLIBS $LIBS" echo " >>> Congrats! libpsyc is available on this system." else echo "libpsyc not available on this system yet." fi fi # --- PCRE --- lp_cv_has_pcre_lib="no" AC_CHECK_LIB(pcre,main, lp_cv_has_pcre_lib="yes") if test $lp_cv_has_pcre_lib = yes; then # saveflags="$CFLAGS" # CFLAGS="$CFLAGS -lpcre" LIBS="-lpcre" AC_CACHE_CHECK(for PCRE functionality,lp_cv_has_pcre, AC_TRY_RUN([ #include pcre_extra foo(void) { pcre_version(); } int main(void) { return 0; } ], lp_cv_has_pcre=yes, lp_cv_has_pcre=no )) CFLAGS="$saveflags" if test $lp_cv_has_pcre = yes; then AC_DEFINE(HAS_PCRE, 1, [Does the machine offer PCRE?]) PKGLIBS="$PKGLIBS -lpcre" else echo "PCRE not available in the system." fi fi # --- iconv --- echo "--- libiconv" # iconv in glibc 2.2.5 is broken - but not every system even # uses glibc. changequote(,)dnl echo "$as_me:$LINENO: checking for broken iconv in glibc 2.0-2.2" >&5 echo $ECHO_N "checking for broken iconv in glibc 2.0-2.2... $ECHO_C" >&6 if test -f /usr/sbin/iconvconfig; then # omg, this was matching 2.10 and higher! # we could probably remove this whole check by now # thanks to spigot for figuring this one out! if /usr/sbin/iconvconfig -V | egrep ' 2\.[0-2]\.' >/dev/null 2>&1; then lp_cv_has_broken_iconv="yes" lp_cv_has_iconv="no" else lp_cv_has_broken_iconv="no" fi else if test -f /usr/local/bin/iconv; then lp_cv_has_broken_iconv="no" lp_cv_has_iconv="yes" else lp_cv_has_broken_iconv="no" lp_cv_has_iconv="no" fi fi echo "$as_me:$LINENO: result: $lp_cv_has_broken_iconv" >&5 echo "${ECHO_T}$lp_cv_has_broken_iconv" >&6 changequote([,])dnl AC_CACHE_CHECK(for iconv,lp_cv_has_iconv, for TESTPATH in "" "/usr/local/include"; do saveflags="$CFLAGS" if test "x$TESTPATH" != "x"; then CFLAGS="-I$TESTPATH $saveflags" fi AC_TRY_COMPILE([ #if defined(__linux__) #include #else #include #endif iconv_t * foo(void) { return 0; } ],, lp_cv_has_iconv=yes if test "x$TESTPATH" != "x"; then EXTRA_CFLAGS="-I$TESTPATH $EXTRA_CFLAGS" fi break; , lp_cv_has_iconv=no CFLAGS="$saveflags" ) done ) # The system has the include files - now perform further checks if test "x$lp_cv_has_iconv" = "xyes"; then saveflags="$CFLAGS" # Some systems define iconv() to take a non-const 'char**' as first arg. AC_MSG_CHECKING(if iconv takes a non-const char**) CFLAGS="$CFLAGS $EXTRA_CFLAGS" tcomp2='${CC-cc} ${CFLAGS} -o conftest.o -c conftest.c 2>&1' cat > conftest.c < #if defined(__linux__) #include #else #include #endif int foo(void) { const char * in; return iconv(NULL, &in, NULL, NULL, NULL); } EOF changequote(,)dnl if echo `eval $tcomp2` | egrep '[a-z]' >/dev/null; then # Success means 'we got output' here :-( lp_cv_has_iconv_nonconst_in=yes else lp_cv_has_iconv_nonconst_in=no fi CFLAGS="$saveflags" changequote([,])dnl AC_MSG_RESULT($lp_cv_has_iconv_nonconst_in) # Does the system need to link in libiconv? AC_CACHE_CHECK(if -liconv is needed, lp_cv_need_lib_iconv, AC_TRY_RUN([ #include #if defined(__linux__) #include #else #include #endif int t (void) { return iconv(NULL, NULL, NULL, NULL, NULL); } int main(void) { return 0; } ], lp_cv_need_lib_iconv=no, lp_cv_need_lib_iconv=yes )) if test "$lp_cv_need_lib_iconv" = "yes"; then # Search the libraries tmp="" AC_CHECK_LIB(iconv,libiconv_close, tmp="-liconv") if test "x$tmp" = "x"; then CFLAGS="$saveflags -L/usr/local/lib" AC_CHECK_LIB(iconv,libiconv_close, tmp="-L/usr/local/lib -liconv") fi if test "x$tmp" = "x"; then echo "iconv library not found." lp_cv_has_iconv="no" else PKGLIBS="$PKGLIBS $tmp" fi fi CFLAGS="$saveflags" fi if test "x$lp_cv_has_iconv" = "xyes"; then AC_DEFINE(HAS_ICONV, 1, [Does the machine offer iconv?]) fi if test "x$lp_cv_has_iconv_nonconst_in" = "xyes"; then AC_DEFINE(HAS_ICONV_NONCONST_IN, 1, [Does the machine's iconv take a non-const 'char**' as first arg?]) fi # --- libidn --- echo "--- libidn" AC_CHECK_HEADER(idna.h, lp_cv_has_idn=yes,lp_cv_has_idn=no) AC_CHECK_HEADER(stringprep.h, lp_cv_has_idn=yes,lp_cv_has_idn=no) # used to check for stringprep_check_version() but we require newer calls # on BSD it also needs -lintl AC_CHECK_LIB(idn, idna_strerror, [lp_cv_has_idn=yes LIBS="${LIBS} -lidn -lintl"],lp_cv_has_idn=no) if test "x$lp_cv_has_idn" = "xyes"; then AC_DEFINE(HAS_IDN, 1, [Does the machine offer IDNA?]) fi # --- mySQL --- # Note: Some compilers don't have /usr/local/include in their standard # searchpath. # Note: Some systems require zlib together with mysqlclient, but don't # like it if -lz precedes the -lmysqlclient in the link command. AC_CACHE_CHECK(for mySQL,lp_cv_has_mysql, for TESTPATH in "" "${mysql_path}/include/mysql" "${mysql_path}/include" "${mysql_path}" "/usr/local/mysql/include/mysql" "/usr/local/mysql/include" "/usr/local/include/mysql" "/usr/local/include" "/usr/lib/mysql/include" "/usr/lib/mysql/mysql" "/usr/lib/mysql" "/usr/include/mysql"; do saveflags="$CFLAGS" if test "x$TESTPATH" != "x"; then CFLAGS="-I$TESTPATH $saveflags" fi AC_TRY_COMPILE([ #include #include #include struct MYSQL * foo(void) { static MYSQL var; return &var; } ],, lp_cv_has_mysql=yes if test "x$TESTPATH" != "x"; then EXTRA_CFLAGS="-I$TESTPATH $EXTRA_CFLAGS" fi break; , lp_cv_has_mysql=no CFLAGS="$saveflags" ) done ) # The system has the include files - now search for the libraries. if test $lp_cv_has_mysql = yes; then saveflags="$CFLAGS" AC_DEFINE(HAS_MYSQL, 1, [Does the machine offer mySQL?]) if test $enable_use_mysql = yes; then tmp="" if test "x$mysql_path" = "x"; then AC_CHECK_LIB(mysqlclient,main, tmp="$PKGLIBS -lmysqlclient") if test "x$tmp" = "x"; then if test -d "/usr/local/mysql/lib/mysql"; then unset ac_cv_lib_mysqlclient_main CFLAGS="$saveflags -L/usr/local/mysql/lib/mysql" AC_CHECK_LIB(mysqlclient,main, tmp="$PKGLIBS -L/usr/local/mysql/lib/mysql -lmysqlclient") elif test -d "/usr/local/mysql/lib"; then unset ac_cv_lib_mysqlclient_main CFLAGS="$saveflags -L/usr/local/mysql/lib" AC_CHECK_LIB(mysqlclient,main, tmp="$PKGLIBS -L/usr/local/mysql/lib -lmysqlclient") elif test -d "/usr/local/lib"; then unset ac_cv_lib_mysqlclient_main CFLAGS="$saveflags -L/usr/local/lib" AC_CHECK_LIB(mysqlclient,main, tmp="$PKGLIBS -L/usr/local/lib -lmysqlclient") elif test -d "/usr/lib/mysql/lib"; then unset ac_cv_lib_mysqlclient_main CFLAGS="$saveflags -L/usr/lib/mysql/lib" AC_CHECK_LIB(mysqlclient,main, tmp="$PKGLIBS -L/usr/lib/mysql/lib -lmysqlclient") fi fi else if test -d "${mysql_path}/lib/mysql"; then CFLAGS="$saveflags -L${mysql_path}/lib/mysql" AC_CHECK_LIB(mysqlclient,main, tmp="$PKGLIBS -L${mysql_path}/lib/mysql -lmysqlclient") elif test -d "${mysql_path}/lib"; then CFLAGS="$saveflags -L${mysql_path}/lib" AC_CHECK_LIB(mysqlclient,main, tmp="$PKGLIBS -L${mysql_path}/lib -lmysqlclient") else CFLAGS="$saveflags -L$mysql_path" AC_CHECK_LIB(mysqlclient,main, tmp="$PKGLIBS -L$mysql_path -lmysqlclient") fi fi if test "x$tmp" = "x"; then echo "mysqlclient library not found - disabling mySQL support" AC_NOT_AVAILABLE(use-mysql) cdef_use_mysql="#undef" enable_use_mysql="no" mysql_path= lp_cv_has_mysql="no" else PKGLIBS="$tmp" fi fi if test $enable_use_mysql = yes; then # Some systems need additional libraries savelibs="$LIBS" LIBS="$LIBS $PKGLIBS" AC_CACHE_CHECK(if -lz is needed, lp_cv_need_lib_z, AC_TRY_RUN([ #include void t (void) { MYSQL *dat; mysql_real_connect(dat, "localhost", "user", "pwd", "db", 0, 0, 0); } int main(void) { return 0; } ], lp_cv_need_lib_z=no, lp_cv_need_lib_z=yes )) if test "$lp_cv_need_lib_z" = "yes"; then AC_CHECK_LIB(z,main, PKGLIBS="$PKGLIBS -lz") fi AC_CACHE_CHECK(if -lnsl is needed, lp_cv_need_lib_nsl, AC_TRY_RUN([ #include void t (void) { MYSQL *dat; mysql_real_connect(dat, "localhost", "user", "pwd", "db", 0, 0, 0); } int main(void) { return 0; } ], lp_cv_need_lib_nsl=no, lp_cv_need_lib_nsl=yes )) if test "$lp_cv_need_lib_nsl" = "yes"; then AC_CHECK_LIB(nsl,main, PKGLIBS="$PKGLIBS -lnsl") fi LIBS="$savelibs" fi CFLAGS="$saveflags" else if test $enable_use_mysql = yes; then AC_NOT_AVAILABLE(use-mysql) cdef_use_mysql="#undef" enable_use_mysql=no fi fi # --- # --- PostgreSQL --- # Note: Some compilers don't have /usr/local/include in their standard # searchpath. AC_CACHE_CHECK(for PostgresSQL,lp_cv_has_pgsql, for TESTPATH in "" "$pgsql_path" "$pgsql_path/include" "/usr/local/pgsql/include" "/usr/local/include/pgsql" "/usr/include/pgsql" "/usr/lib/pgsql" "/usr/local/include"; do saveflags="$CFLAGS" if test "x$TESTPATH" != "x"; then CFLAGS="$saveflags -I$TESTPATH" fi AC_TRY_COMPILE([ #include PGconn * foo(void) { static PGconn * var; return var; } ],, lp_cv_has_pgsql=yes if test "x$TESTPATH" != "x"; then EXTRA_CFLAGS="-I$TESTPATH $EXTRA_CFLAGS" fi break; , lp_cv_has_pgsql=no CFLAGS="$saveflags" ) done ) # The system has the include files - now search for the libraries. if test $lp_cv_has_pgsql = yes; then saveflags="$CFLAGS" AC_DEFINE(HAS_PGSQL, 1, [Does the machine offer PostgreSQL?]) if test $enable_use_pgsql = yes; then tmp="" AC_CHECK_LIB(pq,main, tmp="$PKGLIBS -lpq") if test "x$pgsql_path" == "x"; then unset ac_cv_lib_pq_main if test -d "${pgsql_path}/lib/pgsql"; then CFLAGS="$saveflags -L${pgsql_path}/lib/pgsql" AC_CHECK_LIB(pq,main, tmp="$PKGLIBS -L${pgsql_path}/lib/pgsql -lpq") elif test -d "${pgsql_path}/lib"; then CFLAGS="$saveflags -L${pgsql_path}/lib" AC_CHECK_LIB(pq,main, tmp="$PKGLIBS -L${pgsql_path}/lib -lpq") elif test -d "${pgsql_patch}"; then CFLAGS="$saveflags -L$pgsql_path" AC_CHECK_LIB(pq,main, tmp="$PKGLIBS -L$pgsql_path -lpq") fi fi if test "x$tmp" == "x"; then unset ac_cv_lib_pq_main if test -d "/usr/local/pgsql/lib"; then CFLAGS="$saveflags -L/usr/local/pgsql/lib" AC_CHECK_LIB(pq,main, tmp="$PKGLIBS -L/usr/local/pgsql/lib -lpq") fi fi if test "x$tmp" == "x"; then echo "libpq library not found - disabling PostgreSQL support" AC_NOT_AVAILABLE(use-pgsql) cdef_use_pgsql="#undef" enable_use_pgsql="no" pgsql_path= lp_cv_has_pgsql="no" else PKGLIBS="$tmp" fi fi if test "x$enable_use_pgsql" = "xyes"; then # Some systems need additional libraries savelibs="$LIBS" LIBS="$LIBS $PKGLIBS" AC_CACHE_CHECK(if -lssl is needed, lp_cv_need_lib_ssl, AC_TRY_RUN([ #include void t (void) { PQconnectStart(""); } int main(void) { return 0; } ], lp_cv_need_lib_ssl=no, lp_cv_need_lib_ssl=yes )) if test "$lp_cv_need_lib_ssl" = "yes"; then AC_CHECK_LIB(ssl,main, PKGLIBS="$PKGLIBS -lssl") fi if test "x$lp_cv_need_lib_crypto" != "xyes"; then AC_CACHE_CHECK(if -lcrypto is needed, lp_cv_need_lib_crypto, AC_TRY_RUN([ #include void t (void) { PQconnectStart(""); } int main(void) { return 0; } ], lp_cv_need_lib_crypto=no, lp_cv_need_lib_crypto=yes )) if test "$lp_cv_need_lib_crypto" = "yes"; then AC_CHECK_LIB(crypto,main, PKGLIBS="$PKGLIBS -lcrypto") fi fi LIBS="$savelibs" fi CFLAGS="$saveflags" else if test $enable_use_pgsql = yes; then AC_NOT_AVAILABLE(use-pgsql) cdef_use_pgsql="#undef" enable_use_pgsql=no fi fi # --- SQLite3 --- # Note: Some compilers don't have /usr/local/include in their standard # searchpath. AC_CACHE_CHECK(for SQLite3,lp_cv_has_sqlite3, for TESTPATH in "" "$sqlite_path" "$sqlite_path/include" "/usr/local/include" ; do saveflags="$CFLAGS" if test "x$TESTPATH" != "x"; then CFLAGS="$saveflags -I$TESTPATH" fi AC_TRY_COMPILE([ #include sqlite3 * foo(void) { return (sqlite3*)0; } ],, lp_cv_has_sqlite3=yes if test "x$TESTPATH" != "x"; then EXTRA_CFLAGS="-I$TESTPATH $EXTRA_CFLAGS" fi break; , lp_cv_has_sqlite3=no CFLAGS="$saveflags" ) done ) # The system has the include files - now search for the libraries. if test $lp_cv_has_sqlite3 = yes; then saveflags="$CFLAGS" AC_DEFINE(HAS_SQLITE3, 1, [Does the machine offer SQLite3?]) if test $enable_use_sqlite = yes; then tmp="" AC_CHECK_LIB(sqlite3,main, tmp="$PKGLIBS -lsqlite3") if test "x$sqlite_path" == "x"; then unset ac_cv_lib_sqlite3_main if test -d "${sqlite_path}/lib/sqlite"; then CFLAGS="$saveflags -L${sqlite_path}/lib/sqlite" AC_CHECK_LIB(sqlite3,main, tmp="$PKGLIBS -L${sqlite_path}/lib/sqlite -lsqlite3") elif test -d "${sqlite_path}/lib"; then CFLAGS="$saveflags -L${sqlite_path}/lib" AC_CHECK_LIB(sqlite3,main, tmp="$PKGLIBS -L${sqlite_path}/lib -lsqlite3") elif test -d "${sqlite_patch}"; then CFLAGS="$saveflags -L$sqlite_path" AC_CHECK_LIB(sqlite3,main, tmp="$PKGLIBS -L$sqlite_path -lsqlite3") fi fi if test "x$tmp" == "x"; then unset ac_cv_lib_sqlite3_main if test -d "/usr/local/lib"; then CFLAGS="$saveflags -L/usr/local/pgsql/lib" AC_CHECK_LIB(sqlite3,main, tmp="$PKGLIBS -L/usr/local/lib -lsqlite3") fi fi if test "x$tmp" == "x"; then echo "libsqlite3 library not found - disabling SQLite support" AC_NOT_AVAILABLE(use-sqlite) cdef_use_sqlite="#undef" enable_use_sqlite="no" sqlite= lp_cv_has_sqlite="no" else PKGLIBS="$tmp" fi fi if test "x$enable_use_sqlite" = "xyes"; then savelibs="$LIBS" LIBS="$LIBS $PKGLIBS" # Check if it uses pthreads AC_CHECK_LIB(sqlite3, pthread_create, lp_cv_sqlite3_uses_pthreads=yes, lp_cv_sqlite3_uses_pthreads=no ) if test $lp_cv_sqlite3_uses_pthreads = yes ; then AC_DEFINE(SQLITE3_USES_PTHREADS, 1, [Does SQLite3 use pthreads?]) fi LIBS="$savelibs" fi CFLAGS="$saveflags" else if test $enable_use_sqlite = yes; then AC_NOT_AVAILABLE(use-sqlite) cdef_use_sqlite="#undef" enable_use_sqlite=no fi fi # --- Iksemel --- AC_CACHE_CHECK(for Iksemel,lp_cv_has_iksemel, for TESTPATH in "" "$iksemel_path" "$iksemel_path/include" "/usr/local/include" ; do saveflags="$CFLAGS" if test "x$TESTPATH" != "x"; then CFLAGS="$saveflags -I$TESTPATH" fi AC_TRY_COMPILE([ #include iks * foo(void) { return (iks*)0; } ],, lp_cv_has_iksemel=yes if test "x$TESTPATH" != "x"; then EXTRA_CFLAGS="-I$TESTPATH $EXTRA_CFLAGS" fi break; , lp_cv_has_iksemel=no CFLAGS="$saveflags" ) done ) # The system has the include files - now search for the libraries. if test $lp_cv_has_iksemel = yes; then saveflags="$CFLAGS" AC_DEFINE(HAS_IKSEMEL, 1, [Does the machine offer iksemel?]) if test $enable_use_iksemel = yes; then tmp="" AC_CHECK_LIB(iksemel,main, tmp="$PKGLIBS -liksemel") if test "x$iksemel_path" == "x"; then unset ac_cv_lib_iksemel_main if test -d "${iksemel_path}/lib/iksemel"; then CFLAGS="$saveflags -L${iksemel_path}/lib/iksemel" AC_CHECK_LIB(iksemel,main, tmp="$PKGLIBS -L${iksemel_path}/lib/iksemel -liksemel") elif test -d "${iksemel_path}/lib"; then CFLAGS="$saveflags -L${iksemel_path}/lib" AC_CHECK_LIB(iksemel,main, tmp="$PKGLIBS -L${iksemel_path}/lib -liksemel") elif test -d "${iksemel_patch}"; then CFLAGS="$saveflags -L$iksemel_path" AC_CHECK_LIB(iksemel,main, tmp="$PKGLIBS -L$iksemel_path -liksemel") fi fi if test "x$tmp" == "x"; then unset ac_cv_lib_iksemel_main if test -d "/usr/local/lib"; then CFLAGS="$saveflags -L/usr/local/lib" AC_CHECK_LIB(iksemel,main, tmp="$PKGLIBS -L/usr/local/lib -liksemel") fi fi if test "x$tmp" == "x"; then echo "libiksemel library not found - disabling Iksemel support" AC_NOT_AVAILABLE(use-iksemel) cdef_use_iksemel="#undef" enable_use_iksemel="no" iksemel= lp_cv_has_iksemel="no" else PKGLIBS="$tmp" fi fi CFLAGS="$saveflags" else if test $enable_use_iksemel = yes; then AC_NOT_AVAILABLE(use-iksemel) cdef_use_iksemel="#undef" enable_use_iksemel=no fi fi # --- JSON --- cdef_enable_use_json="#undef" AC_CHECK_HEADER(json/json.h,,[ enable_use_json=no lp_cv_has_json=no ]) # The system has the json include files - now search for the libraries. if test "x$enable_use_json" = "x" || test "x$enable_use_json" = "xyes"; then AC_CHECK_LIB(json, main, [ AC_DEFINE(HAS_JSON, 1, [Does the machine offer json-c support?]) PKGLIBS="$PKGLIBS -ljson" lp_cv_has_json=yes cdef_use_json="#define" ]) fi # --- expat --- cdef_enable_use_expat="#undef" AC_CHECK_HEADER(expat.h,,[ enable_use_expat=no lp_cv_has_expat=no ]) # search for the libraries if test "x$enable_use_expat" = "x" || test "x$enable_use_expat" = "xyes"; then AC_CHECK_LIB(expat, XML_ParserCreate, [ AC_DEFINE(HAS_EXPAT, 1, [Does the machine offer expat?]) PKGLIBS="$PKGLIBS -lexpat" lp_cv_has_expat=yes cdef_use_expat="#define" ]) fi # --- Check if we need zlib libraries for mccp --- if test "x$enable_use_mccp" = "x" || test "x$enable_use_mccp" = "xyes"; then if test "$lp_cv_need_lib_z" != "yes"; then AC_CHECK_LIB(z,main, PKGLIBS="$PKGLIBS -lz" lp_cv_need_lib_z="yes" ) fi if test "$lp_cv_need_lib_z" != "yes"; then echo "libz library not found - disabling MCCP support" AC_NOT_AVAILABLE(use-mccp) cdef_use_mccp="#undef" enable_use_mccp="no" fi fi # --- AC_CACHE_CHECK(if rename handles directories, lp_cv_sys_rename_handles_directories, AC_TRY_RUN([ main() { mkdir("conftestdirfrom", 0770); exit(rename("conftestdirfrom", "conftestdirto")); } ], lp_cv_sys_rename_handles_directories=yes, lp_cv_sys_rename_handles_directories=no)) if test $lp_cv_sys_rename_handles_directories = yes; then AC_DEFINE(RENAME_HANDLES_DIRECTORIES, 1, [Can rename handle directories?]) fi rmdir conftestdirfrom conftestdirto 2> /dev/null if test $ac_cv_func_getrusage = "yes" ; then AC_CACHE_CHECK(full availability of struct rusage members, lp_cv_struct_rusage_full, AC_TRY_COMPILE([ #include /* BSDI 2.0.1 / 2.1 needs this for resource.h */ #include #ifdef HAVE_SYS_RUSAGE_H #include #endif #include #ifndef RUSAGE_SELF #define RUSAGE_SELF 0 #endif ],[ struct rusage rus; long *v = (long *)main; getrusage(RUSAGE_SELF, &rus); *v++ = rus.ru_maxrss; *v++ = rus.ru_ixrss; *v++ = rus.ru_idrss; *v++ = rus.ru_isrss; *v++ = rus.ru_minflt; *v++ = rus.ru_majflt; *v++ = rus.ru_nswap; *v++ = rus.ru_inblock; *v++ = rus.ru_oublock; *v++ = rus.ru_msgsnd; *v++ = rus.ru_msgrcv; *v++ = rus.ru_nsignals; *v++ = rus.ru_nvcsw; *v++ = rus.ru_nivcsw; ],lp_cv_struct_rusage_full=yes,lp_cv_struct_rusage_full=no)) if test $lp_cv_struct_rusage_full = no; then AC_DEFINE(GETRUSAGE_RESTRICTED, 1, [If so, is it restricted to user and system time?]) fi AC_CACHE_CHECK(struct rusage timeval members with tv_usec, lp_cv_struct_rusage_usec, AC_TRY_COMPILE([ #include /* BSDI 2.0.1 / 2.1 needs this for resource.h */ #include #ifdef HAVE_SYS_RUSAGE_H #include #endif #include #ifndef RUSAGE_SELF #define RUSAGE_SELF 0 #endif ],[ struct rusage rus; long *v = (long *)main; getrusage(RUSAGE_SELF, &rus); *v++ = rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000; *v++ = rus.ru_stime.tv_sec * 1000 + rus.ru_stime.tv_usec / 1000; ], lp_cv_struct_rusage_usec=yes, lp_cv_struct_rusage_usec=no)) if test $lp_cv_struct_rusage_usec = yes; then AC_DEFINE(RUSAGE_USEC, 1, [Can ru_utime / ru_stime be accessed as a timeval with tv_sec and tv_usec?]) fi else AC_CACHE_CHECK(for getrusage() via syscall(), lp_cv_func_getrusage_via_syscall, AC_TRY_COMPILE([ #include /* BSDI 2.0.1 / 2.1 needs this for resource.h */ #include #include #ifndef RUSAGE_SELF #define RUSAGE_SELF 0 #endif ],[ struct rusage rus; syscall(SYS_GETRUSAGE, RUSAGE_SELF, rus); ], lp_cv_func_getrusage_via_syscall=yes, lp_cv_func_getrusage_via_syscall=no)) if test $lp_cv_func_getrusage_via_syscall=yes; then AC_DEFINE(HAVE_GETRUSAGE, 1, [Does the system have a getrusage call?]) AC_DEFINE(GETRUSAGE_VIA_SYSCALL, 1, [Is it available as a subfunction of syscall()?]) fi fi dnl I have seen malloc() being declared in on some machines. AC_CACHE_CHECK(if return type of free is void, lp_cv_prop_free_returns_void, AC_TRY_COMPILE([ #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H) #include #endif void free(); ],, lp_cv_prop_free_returns_void=yes, lp_cv_prop_free_returns_void=no)) if test $lp_cv_prop_free_returns_void = yes; then AC_DEFINE(FREE_RETURNS_VOID, 1, [does free() have void as its returntype?]) fi AC_CACHE_CHECK(if void* or char* from malloc, lp_cv_prop_malloc_return_type, AC_TRY_COMPILE([ #include #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H) #include #endif #ifdef __STDC__ #define PROT(x) x #else #define PROT(x) () #endif #define POINTER void * POINTER malloc(size_t); #ifdef FREE_RETURNS_VOID void free PROT((POINTER)); #else int free PROT((POINTER)); #endif ],,lp_cv_prop_malloc_return_type="void *", lp_cv_prop_malloc_return_type="char *")) AC_DEFINE_UNQUOTED(POINTER,$lp_cv_prop_malloc_return_type,[what kind of pointer is used by malloc() et al]) AC_CACHE_CHECK(if CHAR_BIT == 8 or undef, lp_cv_prop_charbits_eq_8, AC_TRY_COMPILE([ #include #include #include #include #ifdef HAVE_VALUES_H #include #endif int i=[1/(CHAR_BIT-8)]; ],,lp_cv_prop_charbits_eq_8=no, lp_cv_prop_charbits_eq_8=yes)) if test $lp_cv_prop_charbits_eq_8 = yes; then AC_DEFINE(CHARBIT_MASK, 0xff, [A mask that allows to extract an unsigned char from a signed]) else dnl TODO: this is something I don't really understand... am I too stupid? dnl TODO:: bitmask set to number of bits ?????? *shudder* [Mubo] AC_DEFINE(CHARBIT_MASK, CHAR_BIT) fi AC_CACHE_CHECK(if strtol broken, lp_cv_prop_strtol_broken, dnl the quoting hell wants two start quotes here, but only one end quote... dnl M4 can be wonderful... :-( [Mubo] AC_TRY_RUN([[ #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_UNISTD_H #include #endif int main() { if (strtol("1]", (char **)0, 10) != 1) exit(1); exit(0); } ], lp_cv_prop_strtol_broken=no, lp_cv_prop_strtol_broken=yes)) if test $lp_cv_prop_strtol_broken = yes; then AC_DEFINE(STRTOL_BROKEN, 1, [the atari strtol() used to consider characters '9' < c < 'A' to be numeric]) fi dnl the following three tests would better be nested, but it seems to overflow dnl internal buffers of m4 AC_CACHE_CHECK(nonblocking using ioctl with FIONBIO, lp_cv_prop_use_ioctl_fionbio, AC_TRY_RUN([ #include /* needed for netinet/in.h */ #include #include #include #include #include #include #include main() { int port, tmp, s; struct sockaddr_in my_sin; struct hostent *hp; char *host_name; host_name = malloc(100); if (gethostname(host_name, 100) == -1) exit(1); hp = gethostbyname(host_name); if (hp == 0) exit(1); memset((char *)&my_sin, '\0', sizeof my_sin); memcpy((char *)&my_sin.sin_addr, hp->h_addr, hp->h_length); my_sin.sin_family = hp->h_addrtype; my_sin.sin_addr.s_addr = INADDR_ANY; alarm(10); for (port = 2000; port < 10000; port++) { my_sin.sin_port = htons((u_short)port); s = socket(hp->h_addrtype, SOCK_STREAM, 0); if (s == -1) exit(1); tmp = 1; if (setsockopt (s, SOL_SOCKET, SO_REUSEADDR, (char *) &tmp, sizeof (tmp)) < 0) exit (1); if (bind(s, (struct sockaddr *)&my_sin, sizeof my_sin) == -1) { if (errno == EADDRINUSE) { close(s); continue; } exit(1); } if (listen(s, 5) == -1) exit(1); tmp = 1; if (ioctl(s, FIONBIO, &tmp) == -1) exit(1); tmp = sizeof my_sin; s = accept(s, (struct sockaddr *)&my_sin, &tmp); if (s == -1) { if (errno == EWOULDBLOCK || errno == EAGAIN) { /* hpux has special problems with sockets from pipe() */ int sockets[[2]]; FILE *fp_read; if(pipe(sockets) < 0) exit(1); fp_read = fdopen(sockets[[0]], "r"); if (fp_read == NULL) exit(1); if (ioctl(fileno(fp_read) , FIONBIO, &tmp) == -1) exit(1); exit(0); } if (errno == EINTR) { close(s); continue; } } break; } exit(1); } ], lp_cv_prop_use_ioctl_fionbio=yes, lp_cv_prop_use_ioctl_fionbio=no, lp_cv_prop_use_ioctl_fionbio=unknown AC_MSG_WARN(You have to supply the correct way to set sockets non-blocking by hand.) )) if test $lp_cv_prop_use_ioctl_fionbio = yes; then AC_DEFINE(USE_IOCTL_FIONBIO, 1, [How to set a socket non-blocking]) fi AC_CACHE_CHECK(nonblocking using fcntl with O_NDELAY, lp_cv_prop_use_fnctl_o_ndelay, AC_TRY_RUN([ #include /* needed for netinet/in.h */ #include #include #include #include #include #include main() { int port, tmp, s; struct sockaddr_in my_sin; struct hostent *hp; char *host_name; host_name = malloc(100); if (gethostname(host_name, 100) == -1) exit(1); hp = gethostbyname(host_name); if (hp == 0) exit(1); memset((char *)&my_sin, '\0', sizeof my_sin); memcpy((char *)&my_sin.sin_addr, hp->h_addr, hp->h_length); my_sin.sin_family = hp->h_addrtype; my_sin.sin_addr.s_addr = INADDR_ANY; alarm(10); for (port = 2000; port < 10000; port++) { my_sin.sin_port = htons((u_short)port); s = socket(hp->h_addrtype, SOCK_STREAM, 0); if (s == -1) exit(1); tmp = 1; if (setsockopt (s, SOL_SOCKET, SO_REUSEADDR, (char *) &tmp, sizeof (tmp)) < 0) exit (1); if (bind(s, (struct sockaddr *)&my_sin, sizeof my_sin) == -1) { if (errno == EADDRINUSE) { close(s); continue; } exit(1); } if (listen(s, 5) == -1) exit(1); if (fcntl(s, F_SETFL, O_NDELAY) == -1) exit(1); tmp = sizeof my_sin; s = accept(s, (struct sockaddr *)&my_sin, &tmp); if (s == -1) { if (errno == EWOULDBLOCK) exit(0); if (errno == EAGAIN) exit(0); if (errno == EINTR) { close(s); continue; } } break; } exit(1); } ], lp_cv_prop_use_fnctl_o_ndelay=yes, lp_cv_prop_use_fnctl_o_ndelay=no, lp_cv_prop_use_fnctl_o_ndelay=unknown)) if test $lp_cv_prop_use_fnctl_o_ndelay = yes; then AC_DEFINE(USE_FCNTL_O_NDELAY, 1, [nonblocking using fcntl with O_NDELAY]) fi AC_CACHE_CHECK(nonblocking using fcntl with FNDELAY, lp_cv_prop_use_fcntl_fndelay, AC_TRY_RUN([ #include /* needed for netinet/in.h */ #include #include #include #include #include #include main() { int port, tmp, s; struct sockaddr_in my_sin; struct hostent *hp; char *host_name; host_name = malloc(100); if (gethostname(host_name, 100) == -1) exit(1); hp = gethostbyname(host_name); if (hp == 0) exit(1); memset((char *)&my_sin, '\0', sizeof my_sin); memcpy((char *)&my_sin.sin_addr, hp->h_addr, hp->h_length); my_sin.sin_family = hp->h_addrtype; my_sin.sin_addr.s_addr = INADDR_ANY; alarm(10); for (port = 2000; port < 10000; port++) { my_sin.sin_port = htons((u_short)port); s = socket(hp->h_addrtype, SOCK_STREAM, 0); if (s == -1) exit(1); tmp = 1; if (setsockopt (s, SOL_SOCKET, SO_REUSEADDR, (char *) &tmp, sizeof (tmp)) < 0) exit (1); if (bind(s, (struct sockaddr *)&my_sin, sizeof my_sin) == -1) { if (errno == EADDRINUSE) { close(s); continue; } exit(1); } if (listen(s, 5) == -1) exit(1); if (fcntl(s, F_SETFL, FNDELAY) == -1) exit(1); tmp = sizeof my_sin; s = accept(s, (struct sockaddr *)&my_sin, &tmp); if (s == -1) { if (errno == EWOULDBLOCK) exit(0); if (errno == EAGAIN) exit(0); if (errno == EINTR) { close(s); continue; } } break; } exit(1); } ],lp_cv_prop_use_fcntl_fndelay=yes, lp_cv_prop_use_fcntl_fndelay=no, lp_cv_prop_use_fcntl_fndelay=unknown)) if test $lp_cv_prop_use_fcntl_fndelay = yes; then AC_DEFINE(USE_FCNTL_FNDELAY, 1, [nonblocking using fcntl with FNDELAY]) fi AC_CACHE_CHECK(if fcntl with SETOWN works, lp_cv_prop_use_fcntl_setown, AC_TRY_RUN([ #include /* needed for netinet/in.h */ #include #include #include #include #include #include main() { int port, tmp, s; struct sockaddr_in my_sin; struct hostent *hp; char *host_name; host_name = malloc(100); if (gethostname(host_name, 100) == -1) exit(1); hp = gethostbyname(host_name); if (hp == 0) exit(1); memset((char *)&my_sin, '\0', sizeof my_sin); memcpy((char *)&my_sin.sin_addr, hp->h_addr, hp->h_length); my_sin.sin_family = hp->h_addrtype; my_sin.sin_addr.s_addr = INADDR_ANY; alarm(10); for (port = 2000; port < 10000; port++) { my_sin.sin_port = htons((u_short)port); s = socket(hp->h_addrtype, SOCK_STREAM, 0); if (s == -1) exit(1); tmp = 1; if (setsockopt (s, SOL_SOCKET, SO_REUSEADDR, (char *) &tmp, sizeof (tmp)) < 0) exit (1); if (bind(s, (struct sockaddr *)&my_sin, sizeof my_sin) == -1) { if (errno == EADDRINUSE) { close(s); continue; } exit(1); } if (listen(s, 5) == -1) exit(1); #ifndef F_SETOWN exit(1); #else if (fcntl(s, F_SETOWN, getpid()) == -1) exit(1); exit(0); #endif } exit(1); } ],lp_cv_prop_use_fcntl_setown=yes, lp_cv_prop_use_fcntl_setown=no, lp_cv_prop_use_fcntl_setown=unknown)) if test $lp_cv_prop_use_fcntl_setown = yes; then AC_DEFINE(USE_FCNTL_SETOWN, 1, [Can F_SETOWN be used on a socket?]) fi AC_CACHE_CHECK(if OOBINLINE works, lp_cv_prop_use_oobinline, AC_TRY_RUN([ #include /* needed for netinet/in.h */ #include #include #include #include #include #include main() { int port, tmp, s; struct sockaddr_in my_sin; struct hostent *hp; char *host_name; host_name = malloc(100); if (gethostname(host_name, 100) == -1) exit(1); hp = gethostbyname(host_name); if (hp == 0) exit(1); memset((char *)&my_sin, '\0', sizeof my_sin); memcpy((char *)&my_sin.sin_addr, hp->h_addr, hp->h_length); my_sin.sin_family = hp->h_addrtype; my_sin.sin_addr.s_addr = INADDR_ANY; alarm(10); for (port = 2000; port < 10000; port++) { int on; my_sin.sin_port = htons((u_short)port); s = socket(hp->h_addrtype, SOCK_STREAM, 0); if (s == -1) exit(1); tmp = 1; if (setsockopt (s, SOL_SOCKET, SO_REUSEADDR, (char *) &tmp, sizeof (tmp)) < 0) exit (1); if (bind(s, (struct sockaddr *)&my_sin, sizeof my_sin) == -1) { if (errno == EADDRINUSE) { close(s); continue; } exit(1); } if (listen(s, 5) == -1) exit(1); #ifndef SO_OOBINLINE exit(1); #else on = 1; if (setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (char *)&on, sizeof on) == -1) exit(1); exit(0); #endif } exit(1); } ],lp_cv_prop_use_oobinline=yes, lp_cv_prop_use_oobinline=no, lp_cv_prop_use_oobinline=unknown)) if test $lp_cv_prop_use_oobinline = yes; then AC_DEFINE(USE_OOBINLINE, 1, [Can SO_OOBINLINE be used on a socket?]) fi AC_CACHE_CHECK(for overlapping bcopy, lp_cv_prop_overlapping_bcopy, AC_TRY_RUN([ main(){ char str[[99]] = "hello world"; bcopy(str, str+2, 12); if(strcmp("hehello world", str)) exit(1); bcopy(str+2, str, 11); if(strcmp("hello worldld", str)) exit(1); exit(0); } ], lp_cv_prop_overlapping_bcopy=yes, lp_cv_prop_overlapping_bcopy=no, lp_cv_prop_overlapping_bcopy=yes)) if test $lp_cv_prop_overlapping_bcopy = yes; then AC_DEFINE(OVERLAPPING_BCOPY, 1, [Define if you have bcopy, and it handles overlapping ranges correctly.]) fi AC_CACHE_CHECK(if strtol needs const char*, lp_cv_prop_strtol_const_charp, AC_TRY_COMPILE([#ifdef HAVE_STDLIB_H #include #endif long strtol(str, ptr, base) char *str; char **ptr; int base; { return 0; } ],,lp_cv_prop_strtol_const_charp=no, lp_cv_prop_strtol_const_charp=yes)) if test $lp_cv_prop_strtol_const_charp = yes; then AC_DEFINE(STRTOL_CONST_CHARP, 1, [needs the first argument of strtol be declared as const?]) fi # --- Check for compiler options --- tcomp='${CC-cc} ${CFLAGS} ${TESTFLAG} -o conftest conftest.c >/dev/null 2>&1' tcomp2='${CC-cc} ${CFLAGS} ${TESTFLAG} -o conftest conftest.c 2>&1' tcomp3='${CC-cc} ${CFLAGS} ${TESTFLAG} -c conftest.c >/dev/null 2>&1' cat > conftest.c < #include double d = 4.5; int main(void) { printf("hello world\n"); return 0; } EOF AC_MSG_CHECKING(warning CFLAGS) changequote(,)dnl CFLAGS= # according to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509 # excess complaints by -Wwarn_unused_result are considered a feature, # not a bug. i think, casting to (void) must not be ignored. so we # are forced to turn off that gcc warning. --lynX 2016 # for TESTFLAG in -Wall -Wno-unused-result -Wparentheses -Wshadow; do if eval $tcomp; then # The option is recognized, but if it generates warnings on the # above correct program, we still can't use it. So check for that. if echo `eval $tcomp2` | egrep '[a-z]' >/dev/null; then : # Success means 'we got output' here :-( else CFLAGS="$CFLAGS $TESTFLAG" fi fi done changequote([,])dnl WCFLAGS=$CFLAGS AC_MSG_RESULT($WCFLAGS) AC_MSG_CHECKING(low optimization CFLAGS) changequote(,)dnl for TESTFLAG in -O; do if eval $tcomp; then if echo `eval $tcomp2` | egrep '[uU]n(recognized|known) [oO]ption' >/dev/null; then : #the [e]grep option -v will not give a failure exit status on the atari else if eval $tcomp; then CFLAGS=$TESTFLAG break fi fi fi done changequote([,])dnl for TESTFLAG in -g; do if eval $tcomp; then CFLAGS="$CFLAGS $TESTFLAG" fi done LCFLAGS=$CFLAGS AC_MSG_RESULT($LCFLAGS) AC_MSG_CHECKING(medium optimization CFLAGS) changequote(,)dnl for TESTFLAG in -O2 -O; do if eval $tcomp; then if echo `eval $tcomp2` | egrep '[uU]n(recognized|known) [oO]ption' >/dev/null; then : #the [e]grep option -v will not give a failure exit status on the atari else if eval $tcomp; then CFLAGS=$TESTFLAG break fi fi fi done for TESTFLAG in -g; do if eval $tcomp; then OPTFLAGS="$OPTFLAGS $TESTFLAG" CFLAGS="$CFLAGS $TESTFLAG" fi done changequote([,])dnl MCFLAGS=$CFLAGS AC_MSG_RESULT($MCFLAGS) AC_MSG_CHECKING(highest optimization CFLAGS) changequote(,)dnl for TESTFLAG in -O4 -O3 -O2 -O; do if eval $tcomp; then if echo `eval $tcomp2` | egrep '[uU]n(recognized|known) [oO]ption' >/dev/null; then : #the [e]grep option -v will not give a failure exit status on the atari else if eval $tcomp; then CFLAGS=$TESTFLAG break fi fi fi done if test "$ac_cv_c_compiler_gnu" = "no"; then for TESTFLAG in -qstrict -qipa -ipo; do if eval $tcomp; then if echo `eval $tcomp2` | egrep '[uU]n(recognized|known) [oO]ption' >/dev/null; then : #the [e]grep option -v will not give a failure exit status on the atari else if eval $tcomp; then CFLAGS="$CFLAGS $TESTFLAG" break fi fi fi done fi changequote([,])dnl # -funroll-all-loops causes some versions of gcc to produce buggy code for TESTFLAG in -fomit-frame-pointer; do if eval $tcomp; then CFLAGS="$CFLAGS $TESTFLAG" fi done OCFLAGS="$CFLAGS $OPTFLAGS" AC_MSG_RESULT($OCFLAGS) if ${CC-cc} -g -c conftest.c ; then DCFLAGS='-g' else DCFLAGS='' fi OPTIMIZE_LINKING='' if ${CC-cc} $OFLAGS -o conftest conftest.c ; then OPTIMIZE_LINKING='$(OPTIMIZE)' fi rm -f conftest.c if test $ac_cv_lib_socket_main = "yes"; then AC_EGREP_CPP(yes,[ #if defined(sun) yes #endif ], [ EXTRA_CFLAGS="${EXTRA_CFLAGS} -Dsolaris" ]) fi AC_ARG_WITH(target,[ --with-target ??], EXTRA_CFLAGS="${EXTRA_CFLAGS} -D${withval}") # Some Unixes require the -n parameter for tail to work properly AC_MSG_CHECKING(if tail accepts the -n parameter) TAIL_N="" if tail -n +2 confdefs.h > /dev/null 2>&1; then AC_MSG_RESULT(yes) TAIL_N="-n" else AC_MSG_RESULT(no) fi AC_MSG_CHECKING(if ${YACC} includes bogus malloc prototypes) cat > conftest.y < #endif #if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H) #include #endif #ifdef HAVE_STDLIB_H #include #endif %} %% all: 'a'; %% int main(){ return 0; } int yyerror(){} int yylex(){ return 0; } EOF rm -f y.tab.c y_tab.c ${YACC} conftest.y if mv y.tab.c conftest.c > /dev/null 2>&1; then YACCTAB=y.tab. else mv y_tab.c conftest.c YACCTAB=y_tab. fi if eval $ac_compile 2>&5; then MOVE_YACC_TAB='$(MV) $(YACCTAB)c' CLEAN_YACC_TAB='' AC_MSG_RESULT(no) else MOVE_YACC_TAB='tail $TAIL_N +2 $(YACCTAB)c >' CLEAN_YACC_TAB='$(RM) $(YACCTAB)c' AC_MSG_RESULT(yes) fi rm -f conftest* AC_MSG_CHECKING(for ${YACC} / / -DSGI_SOURCE / afree name clash) cat > conftest.y < /dev/null 2>&1; then YACCTAB=y.tab. else mv y_tab.c conftest.c YACCTAB=y_tab. fi if eval $ac_compile 2>&5 ; then AC_MSG_RESULT(no) else EXTRA_CFLAGS="${EXTRA_CFLAGS} -U_SGI_SOURCE" AC_MSG_RESULT(yes) fi rm -f conftest* SAVE_LIBS="${LIBS}" SAVE_CFLAGS="${CFLAGS}" CFLAGS='' for TESTFLAG in '' -static -Bstatic -n; do AC_MSG_CHECKING(malloc redefinition with linking flag ${TESTFLAG}) LIBS="${SAVE_LIBS} ${TESTFLAG}" cat > conftest.data < #include #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_STRING_H #include #else #include #endif #if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H) #include #endif #undef malloc #undef calloc int my_malloc_used; int main() { int i, j; FILE *f; alarm(10); /* a crash can be an infinite loop... */ for (i = 0; i < 100; i++) { my_malloc_used = 0; /* strdup seems to be partially unavailable */ f = fopen("conftest.data", "r"); fscanf(f, "%d", &j); fclose(f); if (!my_malloc_used || j != 6*7) exit(1); } /* linking in printf called with variable format makes shared libs * worthwhile. Moreover, calling it is a good test */ printf(f?"%f%% successful\n":(char*)f, 100.); exit(0); } POINTER malloc(size) size_t size; { size_t size2; static char *current_break = 0; char *q; my_malloc_used = 1; if (!current_break) current_break = sbrk(0); size2 = sizeof size + size+7 & ~7; q = current_break; if (brk(current_break+=size2)) exit(1); *(size_t *)q = size; return q + sizeof size; } POINTER calloc(size, num) size_t size, num; { char *q; q = malloc(size*num); memset(q, 0, size); } POINTER realloc(p, size) POINTER p; size_t size; { char *q; if (*(size_t *)p >= size) return p; q = malloc(size); #ifdef HAVE_MEMCPY memcpy(q, p, size); #else bcopy(p, q, size); #endif *(size_t *)q = size; return q + sizeof size; } #ifdef FREE_RETURNS_VOID void free(p) POINTER p; {} #else int free(p) POINTER p; { return 1; } #endif ],SBRK_OK=1) if test -n "${SBRK_OK}"; then if test -z "${TESTFLAG}"; then AC_DEFINE(SBRK_OK, 1, [can we define our own malloc() safely?]) else LDFLAGS="${LDFLAGS} ${TESTFLAG}" EXTRA_CFLAGS="${EXTRA_CFLAGS} -DSBRK_OK" fi break AC_MSG_RESULT(ok) else AC_MSG_RESULT(failed) fi done LIBS="${SAVE_LIBS}" CFLAGS="${SAVE_CFLAGS}" case "$EXTRA_CFLAGS" in *-Dsolaris*) if test $ac_cv_lib_ucb_main = "yes"; then LIBS="${LDFLAGS} -lm -lgcc -lc -lnsl -lgcc -lc -ldl_stubs\ -lnswnis -lnswnisplus -lnswfiles -lnswcompat -lstraddr -lswitch\ -ltcpip -lsocket -lnsl -lgcc -lc /usr/ucblib/libucb.a" LDFLAGS= "-u dgettext -lintl" fi ;; *-DOS2*) LDFLAGS= "$LDFLAGS -Zbsd-signals -Zexe" ;; *-MSWIN*) LDFLAGS= "$LDFLAGS -luser32 -lwinmm -lkernel32 -lwsock32" ;; esac AC_CACHE_CHECK(malloc overhead,lp_cv_sys_malloc_overhead, cat > conftest.c <