@@ -1,6 +1,6 @@ -AC_INIT(ObjFW, 1.1dev, js@nil.im) +AC_INIT(ObjFW, 1.1dev, js@nil.im, objfw, https://objfw.nil.im/) AC_CONFIG_SRCDIR(src) AC_CONFIG_AUX_DIR(build-aux) AC_CONFIG_MACRO_DIR(build-aux/m4) AC_DEFINE(OBJFW_VERSION_MAJOR, 1, [The major version of ObjFW]) @@ -101,11 +101,11 @@ enable_shared="no" enable_threads="no" enable_sockets="no" ;; *-*-mingw*) - LDFLAGS="$LDFLAGS -Wl,--allow-multiple-definition -static-libgcc" + LDFLAGS="$LDFLAGS -Wl,--allow-multiple-definition" LIBS="$LIBS -lversion" AC_SUBST(USE_SRCS_WINDOWS, '${SRCS_WINDOWS}') ;; *-psp-*) @@ -146,10 +146,18 @@ *-*-mint*) enable_shared="no" enable_threads="no" # TODO with_tls="no" ;; +*-apple-macos*) + enable_shared="no" + enable_threads="no" # TODO + enable_sockets="no" # TODO + + AC_DEFINE(OF_CLASSIC_MACOS, 1, + [Whether we are compiling for classic macOS]) + ;; esac AS_IF([test x"$host_os" = x"msdosdjgpp" -a x"$build_os" = x"msdosdjgpp"], [ dnl Hack to make configure find these on DOS. : ${AR:=ar.exe} @@ -169,11 +177,10 @@ ;; esac AC_PROG_OBJC($potential_compilers) AC_PROG_OBJCPP AC_PROG_LN_S -AC_PROG_EGREP BUILDSYS_CHECK_IOS AC_ARG_WITH(wii, AS_HELP_STRING([--with-wii], [build for Wii])) @@ -418,11 +425,13 @@ AC_ARG_ENABLE(shared, AS_HELP_STRING([--disable-shared], [do not build shared library])) AS_IF([test x"$enable_shared" != x"no"], [ BUILDSYS_SHARED_LIB - AC_SUBST(OBJFW_SHARED_LIB, "${LIB_PREFIX}objfw${LIB_SUFFIX}") + BUILDSYS_PLUGIN + + AC_SUBST(OBJFW_SHARED_LIB, '${LIB_PREFIX}objfw${LIB_SUFFIX}') AC_SUBST(EXCEPTIONS_LIB_A, "exceptions.lib.a") AC_SUBST(FORWARDING_LIB_A, "forwarding.lib.a") AC_SUBST(LOOKUP_ASM_LIB_A, "lookup-asm.lib.a") BUILDSYS_FRAMEWORK([ @@ -594,11 +603,11 @@ AC_SUBST(RUNTIME, "runtime") AC_CONFIG_FILES(src/runtime/Info.plist) AS_IF([test x"$enable_shared" != x"no"], [ AC_SUBST(OBJFWRT_SHARED_LIB, - "${LIB_PREFIX}objfwrt${LIB_SUFFIX}") + '${LIB_PREFIX}objfwrt${LIB_SUFFIX}') ]) AS_IF([test x"$enable_static" = x"yes"], [ AC_SUBST(OBJFWRT_STATIC_LIB, "libobjfwrt.a") ]) @@ -1056,11 +1065,29 @@ AC_DEFINE(OF_HAVE_SCHED_YIELD, 1, [Whether we have sched_yield()]) ]) AC_CHECK_FUNCS(pthread_attr_getschedpolicy) - AC_CHECK_FUNCS(pthread_attr_setinheritsched) + + old_OBJCFLAGS="$OBJCFLAGS" + OBJCFLAGS="$OBJCFLAGS -Werror" + AC_MSG_CHECKING(for pthread_attr_setinheritsched) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ + #include + ], [ + pthread_attr_setinheritsched( + (pthread_attr_t *)-1, 0); + ]) + ], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_PTHREAD_ATTR_SETINHERITSCHED, 1, + [Whether we have pthread_attr_setinheritsched]) + ], [ + AC_MSG_RESULT(no) + ]) + OBJCFLAGS="$old_OBJCFLAGS" AC_CHECK_HEADERS(pthread_np.h, [], [], [#include ]) AC_CHECK_FUNCS(pthread_set_name_np pthread_setname_np, break) ;; esac @@ -1332,11 +1359,11 @@ AC_CHECK_FUNCS([fcntl nanosleep]) ;; esac AC_CHECK_HEADERS(xlocale.h) -AC_CHECK_FUNCS([strtod_l strtof_l asprintf_l]) +AC_CHECK_FUNCS([strtod_l strtof_l asprintf_l uselocale]) 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_COMPILE_IFELSE([ @@ -1418,21 +1445,44 @@ AC_CHECK_HEADER(sys/socket.h, [ AC_DEFINE(OF_HAVE_SYS_SOCKET_H, 1, [Whether we have sys/socket.h]) ]) + AC_CHECK_TYPE([struct sockaddr_storage], [ + AC_DEFINE(OF_HAVE_SOCKADDR_STORAGE, 1, + [Whether we have struct sockaddr_storage]) + ], [], [ + #ifdef OF_HAVE_SYS_TYPES_H + # include + #endif + #ifdef OF_HAVE_SYS_SOCKET_H + # include + #endif + #ifdef _WIN32 + # include + #endif + ]) AC_CHECK_HEADER(netinet/in.h, [ AC_DEFINE(OF_HAVE_NETINET_IN_H, 1, [Whether we have netinet/in.h]) ]) AC_CHECK_HEADER(netinet/tcp.h, [ AC_DEFINE(OF_HAVE_NETINET_TCP_H, 1, [Whether we have netinet/tcp.h]) ]) - AC_CHECK_HEADERS([arpa/inet.h netdb.h net/if.h]) + AC_CHECK_HEADERS([arpa/inet.h netdb.h]) + AC_CHECK_HEADERS([net/if.h net/if_arp.h net/if_dl.h net/if_types.h]) AC_CHECK_FUNCS([if_indextoname if_nametoindex]) + AC_CHECK_TYPES([struct sockaddr_dl], [], [], [ + #ifdef HAVAE_SYS_TYPES_H + # include + #endif + #ifdef HAVE_NET_IF_DL_H + # include + #endif + ]) AC_CHECK_HEADER(sys/un.h, [ AC_DEFINE(OF_HAVE_SYS_UN_H, 1, [Whether we have sys/un.h]) ]) AC_CHECK_MEMBER([struct sockaddr_in6.sin6_addr], [ AC_EGREP_CPP(egrep_cpp_yes, [ @@ -1495,10 +1545,25 @@ ]) AC_CHECK_MEMBER(struct sockaddr_un.sun_path, [ AC_DEFINE(OF_HAVE_UNIX_SOCKETS, 1, [Whether we have UNIX sockets]) AC_SUBST(USE_SRCS_UNIX_SOCKETS, '${SRCS_UNIX_SOCKETS}') + + AC_CHECK_MEMBERS(struct sockaddr_un.sun_len, [], [], [ + #ifdef OF_HAVE_SYS_TYPES_H + # include + #endif + #ifdef OF_HAVE_SYS_UN_H + # include + #endif + #ifdef _WIN32 + # include + #endif + #ifdef HAVE_AFUNIX_H + # include + #endif + ]) ], [], [ #ifdef OF_HAVE_SYS_TYPES_H # include #endif #ifdef OF_HAVE_SYS_UN_H @@ -1516,21 +1581,40 @@ #endif #ifdef __MINT__ # error Gives invalid argument at runtime #endif + + #ifdef __gnu_hurd__ + # error Empty sun_path in the source given by recvfrom() + #endif ]) 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_ipx.sipx_network, [], [ - AC_CHECK_MEMBER(struct sockaddr_ipx.sa_netnum, [], [], [ + AC_CHECK_MEMBER(struct sockaddr_ipx.sa_netnum, [], [ + AC_CHECK_MEMBER(struct sockaddr_ipx.sipx_addr.x_port, [ + ], [], [ + #ifdef HAVE_SYS_TYPES_H + # include + #endif + + #ifdef OF_HAVE_NETIPX_IPX_H + # include + #endif + ]) + ], [ #ifdef _WIN32 typedef int BOOL; #endif + + #ifdef HAVE_SYS_TYPES_H + # include + #endif #ifdef OF_HAVE_NETIPX_IPX_H # include #endif @@ -1547,10 +1631,14 @@ ]) ], [ #ifdef _WIN32 typedef int BOOL; #endif + + #ifdef HAVE_SYS_TYPES_H + # include + #endif #ifdef OF_HAVE_NETIPX_IPX_H # include #endif @@ -1564,11 +1652,12 @@ # 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"], [ + -o x"$ac_cv_member_struct_sockaddr_ipx_sa_netnum" = x"yes" -o \ + x"$ac_cv_member_struct_sockaddr_ipx_sipx_addr_x_port" = x"yes"], [ AC_EGREP_CPP(egrep_cpp_yes, [ #ifdef _WIN32 typedef int BOOL; #endif @@ -1730,27 +1819,27 @@ "OFSelectKernelEventObserver.m") ]) ;; esac + AC_CHECK_HEADERS(net/if.h) + AC_CHECK_FUNCS(if_nameindex) + AC_ARG_WITH(tls, AS_HELP_STRING([--with-tls], [ enable TLS support using the specified library (yes, openssl, gnutls, securetransport or no)])) AS_IF([test x"$with_tls" = x""], [with_tls="yes"]) tls_support="no" AS_IF([test x"$with_tls" = x"securetransport" \ - -o x"$with_tls" = x"yes"], [ + -o x"$with_tls" = x"yes"], [ AC_CHECK_HEADERS(Security/SecureTransport.h, [ old_LIBS="$LIBS" LIBS="-framework Security -framework Foundation $LIBS" AC_CHECK_FUNC(SSLHandshake, [ - AC_DEFINE(HAVE_SECURE_TRANSPORT, 1, - [Whether we have Secure Transport]) - tls_support="Secure Transport" TLS_LIBS="-framework Foundation $TLS_LIBS" TLS_LIBS="-framework Security $TLS_LIBS" AC_SUBST(OF_SECURE_TRANSPORT_TLS_STREAM_M, @@ -1762,14 +1851,12 @@ LIBS="$old_LIBS" ]) ]) AS_IF([test x"$with_tls" = x"gnutls" \ - -o \( x"$with_tls" = x"yes" -a x"$tls_support" = x"no" \)], [ + -o \( x"$with_tls" = x"yes" -a x"$tls_support" = x"no" \)], [ PKG_CHECK_MODULES(gnutls, [gnutls >= 3.5.0], [ - AC_DEFINE(HAVE_GNUTLS, 1, [Whether we have GnuTLS]) - tls_support="GnuTLS" TLS_CPPFLAGS="$gnutls_CFLAGS $TLS_CPPFLAGS" TLS_LIBS="$gnutls_LIBS $TLS_LIBS" AC_SUBST(OF_GNUTLS_TLS_STREAM_M, "OFGnuTLSTLSStream.m") @@ -1779,11 +1866,11 @@ : ]) ]) AS_IF([test x"$with_tls" = x"openssl" \ - -o \( x"$with_tls" = x"yes" -a x"$tls_support" = x"no" \)], [ + -o \( x"$with_tls" = x"yes" -a x"$tls_support" = x"no" \)], [ case "$host_os" in morphos*) ssl="ssl_shared" crypto="crypto_shared" ;; @@ -1793,13 +1880,10 @@ ;; esac AC_CHECK_LIB($ssl, SSL_set1_host, [ AC_CHECK_HEADER(openssl/ssl.h, [ - AC_DEFINE(HAVE_OPENSSL, 1, - [Whether we have OpenSSL]) - tls_support="OpenSSL" TLS_LIBS="-l$ssl -l$crypto $TLS_LIBS" AC_SUBST(OF_OPENSSL_TLS_STREAM_M, "OFOpenSSLTLSStream.m") @@ -1817,11 +1901,11 @@ OFHTTP_LIBS="-lobjfwtls $TLS_LIBS $OFHTTP_LIBS" AS_IF([test x"$enable_shared" != x"no"], [ AC_SUBST(OBJFWTLS_SHARED_LIB, - "${LIB_PREFIX}objfwtls${LIB_SUFFIX}") + '${LIB_PREFIX}objfwtls${LIB_SUFFIX}') ]) AS_IF([test x"$enable_static" = x"yes" \ -o x"$enable_shared" = x"no"], [ AC_SUBST(OBJFWTLS_STATIC_LIB, "libobjfwtls.a") ]) @@ -1881,14 +1965,10 @@ (!defined(TARGET_OS_SIMULATOR) || !TARGET_OS_SIMULATOR) egrep_cpp_yes #endif ], [ AC_MSG_RESULT(yes) - have_subprocesses="yes" - - AC_CHECK_FUNCS(posix_spawnp) - AC_CHECK_HEADERS(spawn.h) ], [ AC_MSG_RESULT(no) have_subprocesses="no" ]) ;; @@ -1896,21 +1976,22 @@ have_subprocesses="yes" ;; msdosdjgpp*) have_subprocesses="no" ;; -*) +esac +AS_IF([test x"$have_subprocesses" = x""], [ AC_HEADER_SYS_WAIT AC_CHECK_FUNCS(kill) AC_CHECK_FUNCS(posix_spawnp, [ AS_IF([test x"$ac_cv_func_kill" = x"yes"], [ - have_subprocesses="yes" - - AC_CHECK_HEADERS(spawn.h) + AC_CHECK_HEADERS(spawn.h, [have_subprocesses="yes"]) ]) - ], [ + ]) + + AS_IF([test x"$have_subprocesses" = x""], [ AC_CHECK_FUNCS([vfork dup2 execvp _exit], [ AS_IF([test x"$ac_cv_func_vfork" = x"yes" \ -a x"$ac_cv_func_pipe" = x"yes" \ -a x"$ac_cv_func_dup2" = x"yes" \ -a x"$ac_cv_func_execvp" = x"yes" \ @@ -1920,19 +2001,18 @@ ]) ], [ break ]) ]) - ;; -esac +]) AS_IF([test x"$have_subprocesses" = x"yes"], [ AC_SUBST(OF_SUBPROCESS_M, "OFSubprocess.m") AC_DEFINE(OF_HAVE_SUBPROCESSES, 1, [Whether we have subprocesses]) ]) AC_CHECK_HEADERS_ONCE([complex.h sys/ioctl.h sys/ttycom.h]) -AC_CHECK_FUNCS(isatty) +AC_CHECK_FUNCS(ioctl isatty) AC_CHECK_FUNC(pledge, [ AC_DEFINE(OF_HAVE_PLEDGE, 1, [Whether we have pledge()]) ]) @@ -1941,11 +2021,11 @@ AC_SUBST(BRIDGE, "bridge") AC_CONFIG_FILES(src/bridge/Info.plist) AS_IF([test x"$enable_shared" != x"no"], [ AC_SUBST(OBJFWBRIDGE_SHARED_LIB, - "${LIB_PREFIX}objfwbridge${LIB_SUFFIX}") + '${LIB_PREFIX}objfwbridge${LIB_SUFFIX}') ]) AS_IF([test x"$enable_static" = x"yes" \ -o x"$enable_shared" = x"no"], [ AC_SUBST(OBJFWBRIDGE_STATIC_LIB, "libobjfwbridge.a") ]) @@ -2219,10 +2299,24 @@ ], [ AC_MSG_RESULT(yes) OBJCFLAGS="$old_OBJCFLAGS" ]) ]) + + AC_MSG_CHECKING(whether we need -Wno-strict-prototypes) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ + #include + ], [ + signal(SIGINT, SIG_DFL); + ]) + ], [ + AC_MSG_RESULT(no) + ], [ + AC_MSG_RESULT(yes) + OBJCFLAGS="$OBJCFLAGS -Wno-strict-prototypes" + ]) AS_IF([test x"$ac_cv_header_complex_h" = x"yes"], [ AC_MSG_CHECKING(whether we need -Wno-gnu-imaginary-constant) AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([ @@ -2249,14 +2343,11 @@ ;; x86_64-*-mingw*) AC_CHECK_PROG(WINE, wine64, wine64) ;; esac - - AS_IF([test x"$WINE" != x""], [ - AC_SUBST(WRAPPER, "$WINE") - ]) + AS_IF([test x"$WINE" != x""], [AC_SUBST(WRAPPER, "$WINE")]) AS_IF([test x"$with_wii" = x"yes"], [ dnl Keep this lowercase, as WIILOAD is a variable used by dnl wiiload and thus likely already set by the user to something dnl that is not the path of the wiiload binary. @@ -2266,21 +2357,10 @@ AC_SUBST(WRAPPER, "$wiiload") ]) ]) ]) -AC_ARG_WITH(fish_completions, - AS_HELP_STRING([--with-fish-completions], - [install completions for the fish shell])) -AS_IF([test x"$with_fish_completions" = x""], [ - AC_CHECK_PROG(FISH, fish, fish) - AS_IF([test x"$FISH" != x""], [with_fish_completions="yes"]) -]) -AS_IF([test x"$with_fish_completions" = x"yes"], [ - AC_SUBST(FISH_COMPLETIONS, fish) -]) - dnl We don't call AC_PROG_CPP, but only AC_PROG_OBJCPP and set CPP to OBJCPP dnl and add OBJCPPFLAGS to CPPFLAGS, thus we need to AC_SUBST these ourself. AC_SUBST(CPP) AC_SUBST(CPPFLAGS) dnl We use the ObjC compiler as our assembler