@@ -1,6 +1,6 @@ -AC_INIT(ObjFW, 1.1-dev, js@nil.im) +AC_INIT(ObjFW, 1.1dev, js@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]) @@ -44,14 +44,16 @@ LDFLAGS="$LDFLAGS -noixemul" LIBS="$LIBS -ldebug" enable_files="yes" # Required for reading ENV: enable_shared="no" + with_tls="no" supports_amiga_lib="yes" AS_IF([test x"$enable_amiga_lib" != x"no"], [ - AC_SUBST(OBJFWRT_AMIGA_LIB, objfwrt68k.library) + AC_SUBST(OBJFWRT_AMIGA_LIB, + ['objfwrt${OBJFWRT_LIB_MAJOR}.library']) dnl For 68000, GCC emits calls to helper functions that dnl do not work properly in a library. t="-mcpu=68020 -fbaserel -noixemul -ffreestanding" AC_SUBST(AMIGA_LIB_CFLAGS, $t) t="$t -resident -nostartfiles -nodefaultlibs -ldebug -lc" @@ -63,10 +65,11 @@ powerpc-*-amigaos*) CPPFLAGS="$CPPFLAGS -D__USE_INLINE__" enable_files="yes" # Required for reading ENV: enable_shared="no" + with_tls="no" AC_SUBST(LIBBASES_M, libbases.m) ;; *-morphos*) AS_IF([test x"$OBJCFLAGS" = x""], [OBJCFLAGS="-O2 -g"]) @@ -78,11 +81,12 @@ enable_files="yes" # Required for reading ENV: enable_shared="no" supports_amiga_lib="yes" AS_IF([test x"$enable_amiga_lib" != x"no"], [ - AC_SUBST(OBJFWRT_AMIGA_LIB, objfwrt.library) + AC_SUBST(OBJFWRT_AMIGA_LIB, + ['objfwrt${OBJFW_LIB_MAJOR}ppc.library']) t="-mresident32 -ffreestanding -noixemul" AC_SUBST(AMIGA_LIB_CFLAGS, $t) t="-mresident32 -nostartfiles -nodefaultlibs -noixemul -ldebug" AC_SUBST(AMIGA_LIB_LDFLAGS, "$t -lc") ]) @@ -133,10 +137,15 @@ dnl also used for .S files. OBJCFLAGS="$OBJCFLAGS -include inttypes.h" dnl We need -latomic for GCC's atomics to work. LIBS="$LIBS -latomic" ;; +*-*-mint*) + enable_shared="no" + enable_threads="no" # TODO + with_tls="no" + ;; 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} @@ -171,18 +180,43 @@ flags="-mrvl -mcpu=750 -meabi -mhard-float" OBJCFLAGS="$OBJCFLAGS $flags" OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags" CPPFLAGS="$CPPFLAGS -DGEKKO -I$DEVKITPRO/libogc/include" + OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -DGEKKO -I\$DEVKITPRO/libogc/include" LDFLAGS="$LDFLAGS -mrvl -mcpu=750 -meabi -mhard-float" LIBS="$LIBS -L$DEVKITPRO/libogc/lib/wii -lfat -logc" TESTS_LIBS="$TESTS_LIBS -lwiiuse -lbte" enable_shared="no" enable_threads="no" # TODO + with_tls="no" AC_DEFINE(OF_WII, 1, [Whether we are compiling for Wii]) - OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -DGEKKO -I\$DEVKITPRO/libogc/include" + AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map']) +]) + +AC_ARG_WITH(wii-u, + AS_HELP_STRING([--with-wii-u], [build for Wii U])) +AS_IF([test x"$with_wii_u" = x"yes"], [ + AS_IF([test x"$DEVKITPRO" = x""], [ + AC_MSG_ERROR([DEVKITPRO is not set! Please set DEVKITPRO.]) + ]) + + flags="-mcpu=750 -meabi -mhard-float" + OBJCFLAGS="$OBJCFLAGS $flags" + OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags" + CPPFLAGS="-isystem $DEVKITPRO/wut/include -D__WIIU__ -D__WUT__" + OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -isystem \$DEVKITPRO/wut/include" + OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -D__WIIU__ -D__WUT__" + LDFLAGS="-specs=$DEVKITPRO/wut/share/wut.specs" + LIBS="-L$DEVKITPRO/wut/lib -L$DEVKITPRO/wut/lib/stubs -lwut" + enable_files="no" # TODO + enable_shared="no" # TODO + enable_threads="no" # TODO + enable_sockets="no" # TODO + + AC_DEFINE(OF_WII_U, 1, [Whether we are compiling for Wii U]) AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map']) ]) AC_ARG_WITH(nds, AS_HELP_STRING([--with-nds], [build for Nintendo DS])) @@ -193,20 +227,20 @@ flags="-march=armv5te -mtune=arm946e-s -mthumb -mthumb-interwork" OBJCFLAGS="$OBJCFLAGS $flags" OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags" CPPFLAGS="$CPPFLAGS -DARM9 -I$DEVKITPRO/libnds/include" + OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -DARM9 -I\$DEVKITPRO/libnds/include" ASFLAGS="$ASFLAGS -march=armv5te" LDFLAGS="$LDFLAGS -specs=ds_arm9.specs" LIBS="$LIBS -L$DEVKITPRO/libnds/lib -lfilesystem -lfat -lnds9" enable_shared="no" enable_threads="no" # TODO enable_sockets="no" # TODO check_pedantic="no" AC_DEFINE(OF_NINTENDO_DS, 1, [Whether we are compiling for Nintendo DS]) - OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -DARM9 -I\$DEVKITPRO/libnds/include" AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map']) ]) AC_ARG_WITH(3ds, AS_HELP_STRING([--with-3ds], [build for Nintendo 3DS])) @@ -218,23 +252,48 @@ flags="-march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft" flags="$flags -mword-relocations" OBJCFLAGS="$OBJCFLAGS $flags" OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags" CPPFLAGS="$CPPFLAGS -DARM11 -I$DEVKITPRO/libctru/include" + OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -DARM11 -I\$DEVKITPRO/libctru/include" ASFLAGS="$ASFLAGS -march=armv6k" LDFLAGS="$LDFLAGS -specs=3dsx.specs -march=armv6k -mtune=mpcore" LDFLAGS="$LDFLAGS -mfloat-abi=hard -mtp=soft -mword-relocations" LIBS="$LIBS -L$DEVKITPRO/libctru/lib -lctru" enable_shared="no" enable_threads="no" # TODO + with_tls="no" check_pedantic="no" AC_DEFINE(OF_NINTENDO_3DS, 1, [Whether we are compiling for Nintendo 3DS]) - OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -DARM11 -I\$DEVKITPRO/libctru/include" AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map']) ]) + +AC_ARG_WITH(nintendo-switch, + AS_HELP_STRING([--with-nintendo-switch], [build for Nintendo Switch])) +AS_IF([test x"$with_nintendo_switch" = x"yes"], [ + AS_IF([test x"$DEVKITPRO" = x""], [ + AC_MSG_ERROR([DEVKITPRO is not set! Please set DEVKITPRO.]) + ]) + + flags="-march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE" + OBJCFLAGS="$OBJCFLAGS $flags" + OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags" + CPPFLAGS="$CPPFLAGS -D__SWITCH__ -I$DEVKITPRO/libnx/include" + OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -D__SWITCH__ -I$DEVKITPRO/libnx/include" + ASFLAGS="$ASFLAGS $flags" + LDFLAGS="$LDFLAGS -specs=$DEVKITPRO/libnx/switch.specs $flags" + LIBS="$LIBS -L$DEVKITPRO/libnx/lib -lnx" + enable_shared="no" + enable_threads="yes" + enable_sockets="no" # TODO + check_pedantic="no" + + AC_DEFINE(OF_NINTENDO_SWITCH, 1, + [Whether we are compiling for Nintendo Switch]) +]) CPP="$OBJCPP" CPPFLAGS="$CPPFLAGS $OBJCPPFLAGS -DOF_COMPILING_OBJFW" flags="-fexceptions -fobjc-exceptions -funwind-tables" flags="$flags -fconstant-string-class=OFConstantString" @@ -258,19 +317,10 @@ ;; i?86-*-darwin* | x86_64-*-darwin*) dnl Don't use -no-integrated-as on Darwin. It breaks building dnl for the iOS simulator. ;; - i?86-*-* | x86_64-*-*) - dnl Many older Clang versions don't support jmp short. - ASFLAGS="$ASFLAGS -no-integrated-as" - ;; - *-*-mingw*) - dnl Clang's assembler on Windows is not complete yet and cannot - dnl compile all .S files. - ASFLAGS="$ASFLAGS -no-integrated-as" - ;; sparc64-*-*openbsd*) dnl Clang generates assembly output on SPARC64 that OpenBSD's dnl assembler does not accept. flag="-integrated-as" OBJCFLAGS="$OBJCFLAGS $flag" @@ -425,11 +475,11 @@ AC_MSG_CHECKING(whether we need -D_GNU_SOURCE) AC_EGREP_CPP(egrep_cpp_yes, [ #include #if defined(__GLIBC__) || defined(__MINGW32__) || \ - defined(__NEWLIB__) || defined(__MORPHOS__) + defined(__NEWLIB__) || defined(__MORPHOS__) || defined(__MINT__) egrep_cpp_yes #endif ], [ AC_MSG_RESULT(yes) CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS" @@ -640,10 +690,13 @@ OBJCFLAGS="$old_OBJCFLAGS" ;; esac case "$host_os" in +mint*) + dnl _Unwind_Backtrace crashes on MiNT + ;; hpux*) dnl _Unwind_Backtrace() returns complete garbage on HP-UX. ;; *) AC_CHECK_FUNCS(_Unwind_Backtrace) @@ -829,10 +882,14 @@ AC_CHECK_FUNCS(strtof truncf) AC_CHECK_FUNC(asprintf, [ case "$host" in + *-*-mint*) + dnl asprintf is not in headers + have_asprintf="no" + ;; *-*-mingw*) dnl asprintf from MinGW is broken on older Windows versions have_asprintf="no" ;; *-psp-*) @@ -980,10 +1037,11 @@ ;; esac AC_DEFINE(OF_HAVE_THREADS, 1, [Whether we have threads]) AC_SUBST(USE_SRCS_THREADS, '${SRCS_THREADS}') + AC_SUBST(OBJC_SYNC, objc_sync) AC_ARG_ENABLE(compiler-tls, AS_HELP_STRING([--disable-compiler-tls], [disable compiler thread local storage])) @@ -1336,10 +1394,13 @@ 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]) + AC_CHECK_HEADER(sys/un.h, [ + AC_DEFINE(OF_HAVE_SYS_UN_H, 1, [Whether we have sys/un.h]) + ]) AC_CHECK_HEADER(netipx/ipx.h, [ AC_DEFINE(OF_HAVE_NETIPX_IPX_H, 1, [Whether we have netipx/ipx.h]) ]) @@ -1369,10 +1430,13 @@ #endif ], [ AC_DEFINE(OF_HAVE_IPV6, 1, [Whether we have IPv6]) ]) ], [ + dnl Work around a bug in autoconf 2.61 that creates a broken + dnl configure if this branch is empty. + : ], [ #ifdef _WIN32 typedef int BOOL; #endif @@ -1389,10 +1453,44 @@ # endif # include # include #endif ]) + + AC_CHECK_HEADERS(afunix.h, [ + AC_DEFINE(OF_HAVE_AFUNIX_H, 1, [Whether we have afunix.h]) + ], [], [ + #ifdef _WIN32 + # include + #endif + ]) + 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}') + ], [], [ + #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 __morphos__ + # error MorphOS has the struct but does not support it + #endif + + #ifdef __MINT__ + # error Gives invalid argument at runtime + #endif + ]) AC_CHECK_MEMBER(struct sockaddr_ipx.sipx_network, [], [ AC_CHECK_MEMBER(struct sockaddr_ipx.sa_netnum, [], [], [ #ifdef _WIN32 typedef int BOOL; @@ -1506,18 +1604,124 @@ AC_SUBST(OF_SELECT_KERNEL_EVENT_OBSERVER_M, "OFSelectKernelEventObserver.m") ]) ;; esac + + 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"], [ + 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, + "OFSecureTransportTLSStream.m") + + AC_CHECK_FUNCS(SSLCreateContext) + ], []) + + LIBS="$old_LIBS" + ]) + ]) + + AS_IF([test x"$with_tls" = x"openssl" \ + -o \( x"$with_tls" = x"yes" -a x"$tls_support" = x"no" \)], [ + case "$host_os" in + morphos*) + ssl="ssl_shared" + crypto="crypto_shared" + ;; + *) + ssl="ssl" + crypto="crypto" + ;; + 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") + ]) + ], [], [-l$crypto]) + ]) + + AS_IF([test x"$with_tls" = x"gnutls" \ + -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") + ], [ + dnl Disable default action-if-not-found, which exits + dnl configure with an error. + : + ]) + ]) + + AS_IF([test x"$tls_support" != x"no"], [ + AC_SUBST(TLS, "tls") + AC_SUBST(TLS_CPPFLAGS) + AC_SUBST(TLS_LIBS) + AC_DEFINE(HAVE_TLS_SUPPORT, 1, + [Whether we have an implementation for TLS]) + AC_CONFIG_FILES(src/tls/Info.plist) + + 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}") + ]) + AS_IF([test x"$enable_static" = x"yes" \ + -o x"$enable_shared" = x"no"], [ + AC_SUBST(OBJFWTLS_STATIC_LIB, "libobjfwtls.a") + ]) + AS_IF([test x"$build_framework" = x"yes"], [ + AC_SUBST(OBJFWTLS_FRAMEWORK, "ObjFWTLS.framework") + ]) + ]) + + AS_IF([test x"$with_tls" != x"no" -a x"$tls_support" = x"no"], [ + AC_MSG_ERROR(m4_normalize([ + No TLS implementation was found. Please install OpenSSL, + GnuTLS or use --without-tls. + ])) + ]) AS_IF([test x"$enable_threads" != x"no"], [ 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(OFHTTP_LIBS) ]) ]) AC_DEFUN([CHECK_BUILTIN_BSWAP], [ AC_MSG_CHECKING(for __builtin_bswap$1) @@ -1553,10 +1757,13 @@ 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" ]) ;; @@ -1830,10 +2037,15 @@ __attribute__((__objc_root_class__)) # endif #endif @interface Test @end + + /** + * @struct Foo conftest.m conftest.m + */ + typedef struct {} Foo; ]) ], [ AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) @@ -1913,11 +2125,10 @@ AC_CHECK_PROG(WINE, wine64, wine64) ;; esac AS_IF([test x"$WINE" != x""], [ - AC_SUBST(RUN_TESTS, "run") AC_SUBST(WRAPPER, "$WINE") ]) AS_IF([test x"$with_wii" = x"yes"], [ dnl Keep this lowercase, as WIILOAD is a variable used by @@ -1927,12 +2138,10 @@ AS_IF([test x"$wiiload" != x""], [ AC_SUBST(WRAPPER, "$wiiload") ]) ]) -], [ - AC_SUBST(RUN_TESTS, "run") ]) AC_ARG_WITH(fish_completions, AS_HELP_STRING([--with-fish-completions], [install completions for the fish shell]))