@@ -37,11 +37,10 @@ enable_shared="no" enable_threads="no" enable_sockets="no" enable_files="no" - ac_cv_snprintf_useful_ret="yes" ;; m68k-*-amigaos*) AS_IF([test x"$OBJCFLAGS" = x""], [ OBJCFLAGS="-O0" ]) @@ -51,11 +50,10 @@ LDFLAGS="$LDFLAGS -noixemul" enable_files="yes" # Required for reading ENV: enable_shared="no" supports_amiga_lib="yes" - ac_cv_snprintf_useful_ret="yes" AS_IF([test x"$enable_amiga_lib" != x"no"], [ AC_SUBST(OBJFWRT_AMIGA_LIB, objfwrt68k.library) AC_SUBST(SFDC_TARGET, m68k-amigaos) AC_SUBST(SFD_FILE, amigaos3.sfd) @@ -422,12 +420,13 @@ #if defined(__GLIBC__) || defined(__MINGW32__) || \ defined(__NEWLIB__) || defined(__MORPHOS__) egrep_cpp_yes #endif ], [ - CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS" AC_MSG_RESULT(yes) + CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS" + gnu_source="yes" ], [ AC_MSG_RESULT(no) ]) case "$host_os" in @@ -817,53 +816,33 @@ AC_MSG_RESULT(no) ]) ;; esac -AC_CHECK_FUNCS(strerror_r) - AC_CHECK_LIB(m, fmod, LIBS="$LIBS -lm") AC_CHECK_LIB(complex, creal, TESTS_LIBS="$TESTS_LIBS -lcomplex") AC_CHECK_FUNC(asprintf, [ case "$host" in - *-psp-*) - dnl asprintf is broken on the PSP, but snprintf works. + *-*-mingw*) + dnl asprintf from MinGW is broken on older Windows + dnl versions have_asprintf="no" - ac_cv_snprintf_useful_ret="yes" + ;; + *-psp-*) + dnl asprintf is broken on the PSP + have_asprintf="no" ;; *) have_asprintf="yes" AC_DEFINE(HAVE_ASPRINTF, 1, [Whether we have asprintf()]) ;; esac ], [ have_asprintf="no" - - AC_MSG_CHECKING(whether snprintf returns something useful) - AC_CACHE_VAL(ac_cv_snprintf_useful_ret, [ - AC_TRY_RUN([ - #include - - int - main() - { - return (snprintf(NULL, 0, "asd") == 3 ? 0 : 1); - } - ], [ - ac_cv_snprintf_useful_ret="yes" - ], [ - ac_cv_snprintf_useful_ret="no" - ], [ - ac_cv_snprintf_useful_ret="no" - ]) - ]) - AC_MSG_RESULT($ac_cv_snprintf_useful_ret) -]) -test x"$have_asprintf" != x"yes" -a x"$ac_cv_snprintf_useful_ret" != x"yes" && \ - AC_MSG_ERROR(No asprintf and no snprintf returning required space!) +]) AC_ARG_ENABLE(unicode-tables, AS_HELP_STRING([--disable-unicode-tables], [Disable Unicode tables])) AS_IF([test x"$enable_unicode_tables" != x"no"], [ AC_DEFINE(OF_HAVE_UNICODE_TABLES, 1, @@ -1228,10 +1207,59 @@ AC_CHECK_HEADERS(fcntl.h dirent.h) AC_CHECK_FUNCS([sysconf gmtime_r localtime_r nanosleep fcntl]) AC_CHECK_HEADERS(xlocale.h) AC_CHECK_FUNCS([strtod_l strtof_l asprintf_l]) +AS_IF([test x"$gnu_source" != x"yes" -a \( \ + x"$ac_cv_func_strtod_l" = x"yes" -o x"$ac_cv_func_strtof_l" = x"yes" -o \ + x"$ac_cv_func_asprintf_l" = x"yes" \)], [ + AC_MSG_CHECKING(whether *_l functions need _GNU_SOURCE) + AC_TRY_COMPILE([ + #include + #include + + #include + #ifdef HAVE_XLOCALE_H + # include + #endif + ], [ + #ifdef HAVE_STRTOD_L + (void)strtod_l; + #endif + #ifdef HAVE_STRTOF_L + (void)strtof_l; + #endif + #ifdef HAVE_ASPRINTF_L + (void)asprintf_l; + #endif + ], [ + AC_MSG_RESULT(no) + ], [ + AC_MSG_RESULT(yes) + CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS" + ]) +]) + +dnl This check needs to happen after the above, as _GNU_SOURCE can change the +dnl return type. +AC_CHECK_FUNCS(strerror_r, [ + AC_MSG_CHECKING(for return type of strerror_r) + AC_TRY_COMPILE([ + #include + #include + ], [ + switch (strerror_r(0, NULL, 0)) { + case 0:; + } + ], [ + AC_MSG_RESULT(int) + ], [ + AC_MSG_RESULT(char *) + AC_DEFINE(STRERROR_R_RETURNS_CHARP, 1, + [Whether strerror_r returns char *]) + ]) +]) AC_CHECK_HEADERS(sys/utsname.h) AC_CHECK_FUNCS(uname) case "$host_os" in @@ -1274,11 +1302,21 @@ ]) AC_CHECK_HEADER(netinet/tcp.h, [ AC_DEFINE(OF_HAVE_NETINET_TCP_H, 1, [Whether we have netinet/tcp.h]) ]) + AC_CHECK_HEADER(netinet/sctp.h, [ + AC_DEFINE(OF_HAVE_SCTP, 1, [Whether we have SCTP]) + AC_DEFINE(OF_HAVE_NETINET_SCTP_H, 1, + [Whether we have netinet/sctp.h]) + AC_SUBST(USE_SRCS_SCTP, '${SRCS_SCTP}') + ]) AC_CHECK_HEADERS([arpa/inet.h netdb.h]) + AC_CHECK_HEADER(netipx/ipx.h, [ + AC_DEFINE(OF_HAVE_NETIPX_IPX_H, 1, + [Whether we have netipx/ipx.h]) + ]) AC_CHECK_MEMBER([struct sockaddr_in6.sin6_addr], [ AC_EGREP_CPP(egrep_cpp_yes, [ #ifdef _WIN32 typedef int BOOL; @@ -1324,65 +1362,138 @@ # endif # include # include #endif ]) + + AC_CHECK_MEMBER(struct sockaddr_ipx.sipx_network, [], [ + AC_CHECK_MEMBER(struct sockaddr_ipx.sa_netnum, [], [], [ + #ifdef _WIN32 + typedef int BOOL; + #endif + + #ifdef OF_HAVE_NETIPX_IPX_H + # include + #endif + + #ifdef _WIN32 + # ifdef __MINGW32__ + # include <_mingw.h> + # ifdef __MINGW64_VERSION_MAJOR + # include + # endif + # endif + # include + # include + #endif + ]) + ], [ + #ifdef _WIN32 + typedef int BOOL; + #endif + + #ifdef OF_HAVE_NETIPX_IPX_H + # include + #endif + + #ifdef _WIN32 + # ifdef __MINGW32__ + # include <_mingw.h> + # ifdef __MINGW64_VERSION_MAJOR + # include + # endif + # endif + # include + # include + #endif + ]) + AS_IF([test x"$ac_cv_member_struct_sockaddr_ipx_sipx_network" = x"yes" \ + -o x"$ac_cv_member_struct_sockaddr_ipx_sa_netnum" = x"yes"], [ + AC_EGREP_CPP(egrep_cpp_yes, [ + #ifdef _WIN32 + typedef int BOOL; + #endif + + #ifdef OF_HAVE_SYS_SOCKET_H + # include + #endif + + #ifdef _WIN32 + # ifdef __MINGW32__ + # include <_mingw.h> + # ifdef __MINGW64_VERSION_MAJOR + # include + # endif + # endif + # include + # include + #endif + + #ifdef AF_IPX + egrep_cpp_yes + #endif + ], [ + AC_DEFINE(OF_HAVE_IPX, 1, [Whether we have IPX/SPX]) + AC_SUBST(USE_SRCS_IPX, '${SRCS_IPX}') + ]) + ]) AC_CHECK_FUNCS(paccept accept4, break) AC_CHECK_FUNCS(kqueue1 kqueue, [ AC_DEFINE(HAVE_KQUEUE, 1, [Whether we have kqueue]) - AC_SUBST(OFKQUEUEKERNELEVENTOBSERVER_M, + AC_SUBST(OF_KQUEUE_KERNEL_EVENT_OBSERVER_M, "OFKqueueKernelEventObserver.m") break ]) AC_CHECK_FUNCS(epoll_create1 epoll_create, [ AC_DEFINE(HAVE_EPOLL, 1, [Whether we have epoll]) - AC_SUBST(OFEPOLLKERNELEVENTOBSERVER_M, + AC_SUBST(OF_EPOLL_KERNEL_EVENT_OBSERVER_M, "OFEpollKernelEventObserver.m") break ]) AS_IF([test x"$with_wii" = x"yes"], [ AC_DEFINE(HAVE_POLL, 1, [Whether we have poll()]) - AC_SUBST(OFPOLLKERNELEVENTOBSERVER_M, + AC_SUBST(OF_POLL_KERNEL_EVENT_OBSERVER_M, "OFPollKernelEventObserver.m") ], [ AC_CHECK_HEADERS(poll.h) AC_CHECK_FUNC(poll, [ AC_DEFINE(HAVE_POLL, 1, [Whether we have poll()]) - AC_SUBST(OFPOLLKERNELEVENTOBSERVER_M, + AC_SUBST(OF_POLL_KERNEL_EVENT_OBSERVER_M, "OFPollKernelEventObserver.m") ]) ]) case "$host_os" in amigaos* | mingw* | morphos*) AC_DEFINE(HAVE_SELECT, 1, [Whether we have select() or similar]) - AC_SUBST(OFSELECTKERNELEVENTOBSERVER_M, + AC_SUBST(OF_SELECT_KERNEL_EVENT_OBSERVER_M, "OFSelectKernelEventObserver.m") ;; *) AC_CHECK_HEADERS(sys/select.h) AC_CHECK_FUNC(select, [ AC_DEFINE(HAVE_SELECT, 1, [Whether we have select() or similar]) - AC_SUBST(OFSELECTKERNELEVENTOBSERVER_M, + AC_SUBST(OF_SELECT_KERNEL_EVENT_OBSERVER_M, "OFSelectKernelEventObserver.m") ]) ;; esac AS_IF([test x"$enable_threads" != x"no"], [ - AC_SUBST(OFHTTPCLIENTTESTS_M, "OFHTTPClientTests.m") + AC_SUBST(OF_HTTP_CLIENT_TESTS_M, "OFHTTPClientTests.m") ]) AC_SUBST(OFDNS, "ofdns") AS_IF([test x"$enable_files" != x"no"], [ AC_SUBST(OFHTTP, "ofhttp") ]) + AC_SUBST(OFSOCK, "ofsock") ]) AC_DEFUN([CHECK_BUILTIN_BSWAP], [ AC_MSG_CHECKING(for __builtin_bswap$1) AC_TRY_LINK([ @@ -1439,15 +1550,16 @@ ]) ]) ;; esac AS_IF([test x"$have_processes" = x"yes"], [ - AC_SUBST(OFPROCESS_M, "OFProcess.m") + AC_SUBST(OF_PROCESS_M, "OFProcess.m") AC_DEFINE(OF_HAVE_PROCESSES, 1, [Whether we have processes]) ]) AC_CHECK_HEADERS_ONCE([complex.h sys/ioctl.h sys/ttycom.h]) +AC_CHECK_FUNCS(isatty) AC_CHECK_FUNC(pledge, [ AC_DEFINE(OF_HAVE_PLEDGE, 1, [Whether we have pledge()]) ]) @@ -1479,11 +1591,11 @@ AC_TRY_COMPILE([], [ int (^foo)(int bar); foo = ^ (int bar) { return 0; } ], [ OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -Xclang -fblocks" - AC_SUBST(OFBLOCKTESTS_M, "OFBlockTests.m") + AC_SUBST(OF_BLOCK_TESTS_M, "OFBlockTests.m") AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) OBJCFLAGS="$old_OBJCFLAGS" ])