@@ -44,10 +44,11 @@ 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(OBJFW_AMIGA_LIB, 'objfw${OBJFW_LIB_MAJOR}.library') AC_SUBST(OBJFWRT_AMIGA_LIB, @@ -65,10 +66,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"]) @@ -139,10 +141,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} @@ -177,18 +184,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])) @@ -199,20 +231,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])) @@ -224,23 +256,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" @@ -434,11 +491,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" @@ -648,10 +705,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) @@ -837,10 +897,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-*) @@ -1351,10 +1415,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]) ]) @@ -1407,10 +1474,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; @@ -1524,18 +1625,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) @@ -1571,10 +1778,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" ]) ;;