@@ -17,13 +17,10 @@ BUILDSYS_INIT AC_CANONICAL_HOST -AC_ARG_WITH(ixemul, - AS_HELP_STRING([--with-ixemul], [build with ixemul])) - dnl Used to disable checking for -pedantic on some platforms where it's broken check_pedantic="yes" case "$host" in arm-*-riscos*) @@ -77,36 +74,34 @@ enable_shared="no" AC_SUBST(LIBBASES_M, libbases.m) ;; *-morphos*) - AS_IF([test x"$with_ixemul" != x"yes"], [ - AS_IF([test x"$OBJCFLAGS" = x""], [ - OBJCFLAGS="-O2 -g" - ]) - OBJCFLAGS="$OBJCFLAGS -noixemul" - OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -noixemul" - LDFLAGS="$LDFLAGS -noixemul" - enable_files="yes" # Required for reading ENV: - supports_amiga_lib="yes" - check_pedantic="no" # Breaks generated inlines - - AS_IF([test x"$enable_amiga_lib" != x"no"], [ - AC_SUBST(OBJFW_AMIGA_LIB, objfw.library) - AC_SUBST(OBJFWRT_AMIGA_LIB, objfwrt.library) - AC_SUBST(CVINCLUDE_INLINE_H, inline.h) - t="-mresident32 -ffreestanding -noixemul" - AC_SUBST(AMIGA_LIB_CFLAGS, $t) - t="-mresident32 -nostartfiles -nodefaultlibs" - t="$t -noixemul -lc" - AC_SUBST(AMIGA_LIB_LDFLAGS, $t) - ]) - - AC_SUBST(LIBBASES_M, libbases.m) - ]) - + AS_IF([test x"$OBJCFLAGS" = x""], [ + OBJCFLAGS="-O2 -g" + ]) + OBJCFLAGS="$OBJCFLAGS -noixemul" + OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -noixemul" + LDFLAGS="$LDFLAGS -noixemul" + + enable_files="yes" # Required for reading ENV: enable_shared="no" + supports_amiga_lib="yes" + check_pedantic="no" # Breaks generated inlines + + AS_IF([test x"$enable_amiga_lib" != x"no"], [ + AC_SUBST(OBJFW_AMIGA_LIB, objfw.library) + AC_SUBST(OBJFWRT_AMIGA_LIB, objfwrt.library) + AC_SUBST(CVINCLUDE_INLINE_H, inline.h) + t="-mresident32 -ffreestanding -noixemul" + AC_SUBST(AMIGA_LIB_CFLAGS, $t) + t="-mresident32 -nostartfiles -nodefaultlibs" + t="$t -noixemul -lc" + AC_SUBST(AMIGA_LIB_LDFLAGS, $t) + ]) + + AC_SUBST(LIBBASES_M, libbases.m) ;; *-msdosdjgpp*) enable_shared="no" enable_threads="no" enable_sockets="no" @@ -337,27 +332,29 @@ OBJCFLAGS="$OBJCFLAGS -Wno-pointer-sign" ;; esac AC_MSG_CHECKING(whether Objective C compiler supports properties) -AC_TRY_COMPILE([ - #ifdef __has_attribute - # if __has_attribute(objc_root_class) - __attribute__((__objc_root_class__)) - # endif - #endif - @interface Foo - { - id bar; - } - - @property (nonatomic, retain) id bar; - @end -], [ - Foo *foo = (id)0; - [foo setBar: (id)0]; - foo = [foo bar]; +AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ + #ifdef __has_attribute + # if __has_attribute(objc_root_class) + __attribute__((__objc_root_class__)) + # endif + #endif + @interface Foo + { + id bar; + } + + @property (nonatomic, retain) id bar; + @end + ], [[ + Foo *foo = (id)0; + [foo setBar: (id)0]; + foo = [foo bar]; + ]]) ], [ AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) AC_MSG_ERROR(Compiler does not support properties!) @@ -524,38 +521,40 @@ AC_MSG_CHECKING([whether -fobjc-runtime=objfw is supported]) old_OBJCFLAGS="$OBJCFLAGS" OBJCFLAGS="$OBJCFLAGS -Xclang -fobjc-runtime=objfw" - AC_TRY_LINK([ - #ifdef __has_attribute - # if __has_attribute(objc_root_class) - __attribute__((__objc_root_class__)) - # endif - #endif - @interface Test - + (void)test; - @end - - @implementation Test - + (void)test - { - } - @end - - void * - objc_msg_lookup(void *obj, void *sel) - { - return (void *)0; - } - - void - __objc_exec_class(void *module) - { - } - ], [ - [Test test]; + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([ + #ifdef __has_attribute + # if __has_attribute(objc_root_class) + __attribute__((__objc_root_class__)) + # endif + #endif + @interface Test + + (void)test; + @end + + @implementation Test + + (void)test + { + } + @end + + void * + objc_msg_lookup(void *obj, void *sel) + { + return (void *)0; + } + + void + __objc_exec_class(void *module) + { + } + ], [[ + [Test test]; + ]]) ], [ flag="-Xclang -fobjc-runtime=objfw" OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flag" AC_MSG_RESULT(yes) ], [ @@ -603,18 +602,20 @@ AC_DEFINE(OF_SELUID24, 1, [Whether to use 24 bit selector UIDs]) ]) AC_MSG_CHECKING(for exception type) - AC_TRY_COMPILE([ - extern void foo(); - ], [ - @try { - foo(); - } @finally { - foo(); - } + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ + extern void foo(); + ], [ + @try { + foo(); + } @finally { + foo(); + } + ]) ], [ AS_IF([$EGREP __gnu_objc_personality_v0 \ conftest.$ac_objext >/dev/null], [ exception_type="DWARF" ]) @@ -726,33 +727,35 @@ esac AC_MSG_CHECKING(whether Objective C compiler supports ARC) old_OBJCFLAGS="$OBJCFLAGS" OBJCFLAGS="$OBJCFLAGS -fobjc-arc -fobjc-arc-exceptions" -AC_TRY_COMPILE([ - #ifdef __has_attribute - # if __has_attribute(objc_root_class) - __attribute__((__objc_root_class__)) - # endif - #endif - @interface Foo - { - struct objc_class *_isa; - } - - + (id)alloc; - @end - - @implementation Foo - + (id)alloc - { - return (id)0; - } - @end -], [ - __weak id foo = [Foo alloc]; - (void)foo; +AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ + #ifdef __has_attribute + # if __has_attribute(objc_root_class) + __attribute__((__objc_root_class__)) + # endif + #endif + @interface Foo + { + struct objc_class *_isa; + } + + + (id)alloc; + @end + + @implementation Foo + + (id)alloc + { + return (id)0; + } + @end + ], [[ + __weak id foo = [Foo alloc]; + (void)foo; + ]]) ], [ AC_MSG_RESULT(yes) AC_DEFINE(COMPILER_SUPPORTS_ARC, 1, [Whether the compiler supports ARC]) AC_SUBST(RUNTIME_ARC_TESTS_M, RuntimeARCTests.m) ], [ @@ -848,13 +851,14 @@ [Floating point implementation does not conform to IEEE 754!])]) AC_MSG_CHECKING(for floating point endianess) fp_endianess="unknown" AS_IF([test x"$ac_cv_c_bigendian" != x"universal"], [ - AC_TRY_COMPILE([ - double endianess = 2.993700760838795055656993580068609688772747263874402942272934826871811872228512759832626847251963763755836687759498519784550143745834860002945223766052808125982053455555265216112722718870586961456110693379343178124592311441022662940307099598578775368547768968914916965731708568179631324904813506101190853720749196062963892799499230635163056742330563321122389331703618066046034494287335316842529021563862331183541255013987734473643350285400060357711238514186776429325214739886098119655678483017894951556639821088508565036657794343031121375178126860889964700274558728491825977274341798997758923017217660272136611938897932105874133412726223468780517578125e-259; - ], [ + AC_COMPILE_IFELSE([ + AC_LANG_SOURCE([ + double endianess = 2.993700760838795055656993580068609688772747263874402942272934826871811872228512759832626847251963763755836687759498519784550143745834860002945223766052808125982053455555265216112722718870586961456110693379343178124592311441022662940307099598578775368547768968914916965731708568179631324904813506101190853720749196062963892799499230635163056742330563321122389331703618066046034494287335316842529021563862331183541255013987734473643350285400060357711238514186776429325214739886098119655678483017894951556639821088508565036657794343031121375178126860889964700274558728491825977274341798997758923017217660272136611938897932105874133412726223468780517578125e-259; + ]) ], [ AS_IF([$EGREP BigEnd conftest.$ac_objext >/dev/null], [ AC_DEFINE(OF_FLOAT_BIG_ENDIAN, 1, [Whether floats are big endian]) fp_endianess="big endian" @@ -871,25 +875,29 @@ AS_IF([test x"$fp_endianess" = x"unknown"], [ AC_MSG_ERROR( [Floating point implementation does not conform to IEEE 754!])]) AC_MSG_CHECKING(for INFINITY) -AC_TRY_COMPILE([ - #include - #include -], [ - printf("%f", INFINITY); +AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ + #include + #include + ], [ + printf("%f", INFINITY); + ]) ], [ AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) AC_MSG_CHECKING(for __builtin_inf) - AC_TRY_COMPILE([ - #include - ], [ - printf("%f", __builtin_inf()); + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ + #include + ], [ + printf("%f", __builtin_inf()); + ]) ], [ AC_MSG_RESULT(yes) AC_DEFINE(INFINITY, [(__builtin_inf())], [Workaround for missing INFINITY]) ], [ @@ -900,17 +908,20 @@ ]) case "$host_cpu" in arm* | earm*) AC_MSG_CHECKING(for VFP2 or above) - AC_TRY_COMPILE([], [ - #if !defined(__arm64__) && !defined(__aarch64__) && \ - !defined(__ARM64_ARCH_8__) - __asm__ __volatile__ ( - "vstmdb sp!, {d0-d7}" - ); - #endif + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([], [ + #if !defined(__arm64__) && \ + !defined(__aarch64__) && \ + !defined(__ARM64_ARCH_8__) + __asm__ __volatile__ ( + "vstmdb sp!, {d0-d7}" + ); + #endif + ]) ], [ AC_DEFINE(HAVE_VFP2, 1, [Whether we have VFP2 or above]) AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) @@ -954,40 +965,38 @@ AC_DEFUN([ENCODING_FLAG], [ AC_ARG_ENABLE($1, AS_HELP_STRING([--disable-$1], [Disables support for $3])) AS_IF([test x"$enable_$2" != x"no"], [ - AC_DEFINE($4, 1, - [Whether we have support for $3]) - ENCODINGS_SRCS="$ENCODINGS_SRCS $2.m" + AC_DEFINE($4, 1, [Whether we have support for $3]) + ENCODINGS_SRCS="$ENCODINGS_SRCS $1.m" ]) ]) ENCODING_FLAG(codepage-437, codepage_437, [Codepage 437], HAVE_CODEPAGE_437) ENCODING_FLAG(codepage-850, codepage_850, [Codepage 850], HAVE_CODEPAGE_850) ENCODING_FLAG(codepage-858, codepage_858, [Codepage 858], HAVE_CODEPAGE_858) -ENCODING_FLAG(iso-8859-2, iso_8859-2, [ISO 8859-2], HAVE_ISO_8859_2) -ENCODING_FLAG(iso-8859-3, iso_8859-3, [ISO 8859-3], HAVE_ISO_8859_3) -ENCODING_FLAG(iso-8859-15, iso_8859-15, [ISO 8859-15], HAVE_ISO_8859_15) -ENCODING_FLAG(koi8-r, koi8-r, [KOI8-R], HAVE_KOI8_R) -ENCODING_FLAG(koi8-u, koi8-u, [KOI8-U], HAVE_KOI8_U) +ENCODING_FLAG(iso-8859-2, iso_8859_2, [ISO 8859-2], HAVE_ISO_8859_2) +ENCODING_FLAG(iso-8859-3, iso_8859_3, [ISO 8859-3], HAVE_ISO_8859_3) +ENCODING_FLAG(iso-8859-15, iso_8859_15, [ISO 8859-15], HAVE_ISO_8859_15) +ENCODING_FLAG(koi8-r, koi8_r, [KOI8-R], HAVE_KOI8_R) +ENCODING_FLAG(koi8-u, koi8_u, [KOI8-U], HAVE_KOI8_U) ENCODING_FLAG(mac-roman, mac_roman, [Mac Roman encoding], HAVE_MAC_ROMAN) -ENCODING_FLAG(windows-1251, windows-1251, [Windows-1251], HAVE_WINDOWS_1251) -ENCODING_FLAG(windows-1252, windows-1252, [Windows-1252], HAVE_WINDOWS_1252) +ENCODING_FLAG(windows-1251, windows_1251, [Windows-1251], HAVE_WINDOWS_1251) +ENCODING_FLAG(windows-1252, windows_1252, [Windows-1252], HAVE_WINDOWS_1252) +AS_IF([test x"$ENCODINGS_SRCS" = x""], [ + ENCODINGS_SRCS="dummy.m" +]) AC_SUBST(ENCODINGS_SRCS) -AS_IF([test x"$ENCODINGS_SRCS" != x""], [ - AC_SUBST(ENCODINGS, "encodings") - - AS_IF([test x"$enable_shared" != x"no"], [ - AC_SUBST(ENCODINGS_LIB_A, "encodings.lib.a") - ]) - AS_IF([test x"$enable_static" = x"yes"], [ - AC_SUBST(ENCODINGS_A, "encodings.a") - ]) - AS_IF([test x"$enable_amiga_lib" != x"no"], [ - AC_SUBST(ENCODINGS_AMIGALIB_A, "encodings.amigalib.a") - ]) +AS_IF([test x"$enable_shared" != x"no"], [ + AC_SUBST(ENCODINGS_LIB_A, "encodings.lib.a") +]) +AS_IF([test x"$enable_amiga_lib" != x"no"], [ + AC_SUBST(ENCODINGS_AMIGALIB_A, "encodings.amigalib.a") +]) +AS_IF([test x"$enable_static" = x"yes" -o x"$enable_shared" = x"no"], [ + AC_SUBST(ENCODINGS_A, "encodings.a") ]) AC_CHECK_FUNCS(arc4random arc4random_buf getrandom random, break) AS_IF([test x"$host_os" != x"morphos"], [ @@ -1033,26 +1042,30 @@ CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_THREAD_SAFE" ]) AC_CHECK_LIB(pthread, pthread_create, LIBS="$LIBS -lpthread") - AC_TRY_LINK([ - #include - ], [ - pthread_create(NULL, NULL, NULL, NULL); + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([ + #include + ], [ + pthread_create(NULL, NULL, NULL, NULL); + ]) ], [], [ AC_MSG_ERROR(No supported threads found!) ]) AC_DEFINE(OF_HAVE_PTHREADS, 1, [Whether we have pthreads]) - AC_TRY_COMPILE([ - #include - ], [ - pthread_mutexattr_t attr; - pthread_mutexattr_settype(&attr, - PTHREAD_MUTEX_RECURSIVE); + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ + #include + ], [ + pthread_mutexattr_t attr; + pthread_mutexattr_settype(&attr, + PTHREAD_MUTEX_RECURSIVE); + ]) ], [ AC_DEFINE(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES, 1, [If pthread mutexes can be recursive]) ]) @@ -1102,22 +1115,26 @@ AC_DEFINE(OF_HAVE_THREADS_H, 1, [Whether we have threads.h]) ]) AC_MSG_CHECKING(whether _Thread_local works) - AC_TRY_LINK([ - static _Thread_local int x = 0; - ], [ - x++; + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([ + static _Thread_local int x = 0; + ], [ + x++; + ]) ], [ AS_IF([test x"$enable_shared" != x"no"], [ old_OBJCFLAGS="$OBJCFLAGS" OBJCFLAGS="$OBJCFLAGS -fPIC" - AC_TRY_COMPILE([ - static _Thread_local int x = 0; - ], [ - x++; + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ + static _Thread_local int x = 0; + ], [ + x++; + ]) ], [ AC_MSG_RESULT(yes) AC_DEFINE(OF_HAVE__THREAD_LOCAL, 1, [Whether _Thread_local works]) have_thread_local="yes" @@ -1135,27 +1152,33 @@ AC_MSG_RESULT(no) ]) AS_IF([test x"$have_thread_local" != x"yes"], [ AC_MSG_CHECKING(whether __thread works) - AC_TRY_LINK([ - /* It seems __thread is buggy with GCC 4.1 */ - #if __GNUC__ == 4 && __GNUC_MINOR__ < 2 - # error buggy - #endif - - __thread int x = 0; - ], [ - x++; + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([ + /* + * It seems __thread is buggy with + * GCC 4.1 */ + #if __GNUC__ == 4 && __GNUC_MINOR__ < 2 + # error buggy + #endif + + __thread int x = 0; + ], [ + x++; + ]) ], [ AS_IF([test x"$enable_shared" != x"no"], [ old_OBJCFLAGS="$OBJCFLAGS" OBJCFLAGS="$OBJCFLAGS -fPIC" - AC_TRY_COMPILE([ - __thread int x = 0; - ], [ - x++; + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ + __thread int x = 0; + ], [ + x++; + ]) ], [ AC_MSG_RESULT(yes) AC_DEFINE(OF_HAVE___THREAD, 1, [Whether __thread works] ) @@ -1190,20 +1213,22 @@ ], [ AC_MSG_RESULT(no) ]) AC_MSG_CHECKING(whether __atomic_* works) - AC_TRY_LINK([ - #include - #include - ], [ - int32_t i, j; - if (__atomic_add_fetch(&i, 1, __ATOMIC_RELAXED)) - j = __atomic_sub_fetch(&i, 1, __ATOMIC_RELAXED); - while (!__atomic_compare_exchange_n(&i, &j, 1, false, - __ATOMIC_RELAXED, __ATOMIC_RELAXED)); - __atomic_thread_fence(__ATOMIC_SEQ_CST); + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([ + #include + #include + ], [ + int32_t i, j; + if (__atomic_add_fetch(&i, 1, __ATOMIC_RELAXED)) + j = __atomic_sub_fetch(&i, 1, __ATOMIC_RELAXED); + while (!__atomic_compare_exchange_n(&i, &j, 1, false, + __ATOMIC_RELAXED, __ATOMIC_RELAXED)); + __atomic_thread_fence(__ATOMIC_SEQ_CST); + ]) ], [ AC_MSG_RESULT(yes) test x"$atomic_ops" = x"none" && \ atomic_ops="__atomic_* builtins" AC_DEFINE(OF_HAVE_ATOMIC_BUILTINS, 1, @@ -1211,15 +1236,19 @@ ], [ AC_MSG_RESULT(no) ]) AC_MSG_CHECKING(whether __sync_* works) - AC_TRY_LINK([#include ], [ - int32_t i, j; - if (__sync_add_and_fetch(&i, 1)) - j = __sync_sub_and_fetch(&i, 1); - while (!__sync_bool_compare_and_swap(&i, 0, 1)); + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([ + #include + ], [ + int32_t i, j; + if (__sync_add_and_fetch(&i, 1)) + j = __sync_sub_and_fetch(&i, 1); + while (!__sync_bool_compare_and_swap(&i, 0, 1)); + ]) ], [ AC_MSG_RESULT(yes) test x"$atomic_ops" = x"none" && \ atomic_ops="__sync_* builtins" AC_DEFINE(OF_HAVE_SYNC_BUILTINS, 1, @@ -1285,17 +1314,19 @@ ]) old_OBJCFLAGS="$OBJCFLAGS" OBJCFLAGS="$OBJCFLAGS -Werror" AC_MSG_CHECKING(for readdir_r) - AC_TRY_COMPILE([ - #include - ], [ - DIR *dir = 0; - struct dirent entry, *result; + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ + #include + ], [ + DIR *dir = 0; + struct dirent entry, *result; - readdir_r(dir, &entry, &result); + readdir_r(dir, &entry, &result); + ]) ], [ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_READDIR_R, 1, [Whether we have readdir_r()]) ], [ AC_MSG_RESULT(no) @@ -1310,28 +1341,30 @@ 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_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ + #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" @@ -1340,17 +1373,19 @@ 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_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ + #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, @@ -1587,17 +1622,19 @@ AC_SUBST(OFSOCK, "ofsock") ]) AC_DEFUN([CHECK_BUILTIN_BSWAP], [ AC_MSG_CHECKING(for __builtin_bswap$1) - AC_TRY_LINK([ - #include - #include - #include - ], [ - uint$1_t i = errno; - printf("%d", (int)__builtin_bswap$1(i)); + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([ + #include + #include + #include + ], [ + uint$1_t i = errno; + printf("%d", (int)__builtin_bswap$1(i)); + ]) ], [ AC_MSG_RESULT(yes) AC_DEFINE(OF_HAVE_BUILTIN_BSWAP$1, 1, [Whether we have __builtin_bswap$1]) ], [ @@ -1696,13 +1733,15 @@ dnl which in old glibc versions uses __block. This is worked around in the code dnl by providing a wrapper for unistd.h which takes care of this. AC_MSG_CHECKING(whether Objective C compiler supports blocks) old_OBJCFLAGS="$OBJCFLAGS" OBJCFLAGS="$OBJCFLAGS -Xclang -fblocks" -AC_TRY_COMPILE([], [ - int (^foo)(int bar); - foo = ^ (int bar) { return 0; } +AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([], [ + int (^foo)(int bar); + foo = ^ (int bar) { return 0; } + ]) ], [ OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -Xclang -fblocks" AC_SUBST(OF_BLOCK_TESTS_M, "OFBlockTests.m") AC_MSG_RESULT(yes) ], [ @@ -1712,63 +1751,66 @@ AS_IF([test x"$GOBJC" = x"yes"], [ OBJCFLAGS="$OBJCFLAGS -Wwrite-strings -Wpointer-arith -Werror" AC_MSG_CHECKING(whether we need -Wno-strict-aliasing due to GCC bugs) - AC_TRY_COMPILE([ - #ifdef __has_attribute - # if __has_attribute(objc_root_class) - __attribute__((__objc_root_class__)) - # endif - #endif - @interface Foo - { - struct objc_class *_isa; - } - @end - - static struct { - struct objc_class *_isa; - } object; - ], [ - Foo *test = (Foo *)&object; - (void)test; /* Get rid of unused variable warning */ + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ + #ifdef __has_attribute + # if __has_attribute(objc_root_class) + __attribute__((__objc_root_class__)) + # endif + #endif + @interface Foo + { + struct objc_class *_isa; + } + @end + + static struct { + struct objc_class *_isa; + } object; + ], [ + Foo *test = (Foo *)&object; + (void)test; /* Get rid of unused variable warning */ + ]) ], [ AC_MSG_RESULT(no) ], [ AC_MSG_RESULT(yes) OBJCFLAGS="$OBJCFLAGS -Wno-strict-aliasing" ]) AC_MSG_CHECKING( whether we need -Wno-unused-property-ivar due to Clang bugs) - AC_TRY_COMPILE([ - #ifdef __has_attribute - # if __has_attribute(objc_root_class) - __attribute__((__objc_root_class__)) - # endif - #endif - @interface Foo - { - struct objc_class *_isa; - Foo *_foo; - } - - @property (readonly, nonatomic) Foo *foo; - - + (Foo *)foo; - @end - - @implementation Foo - @synthesize foo = _foo; - - + (Foo *)foo - { - return (Foo *)0; - } - @end - ], [ + AC_COMPILE_IFELSE([ + AC_LANG_SOURCE([ + #ifdef __has_attribute + # if __has_attribute(objc_root_class) + __attribute__((__objc_root_class__)) + # endif + #endif + @interface Foo + { + struct objc_class *_isa; + Foo *_foo; + } + + @property (readonly, nonatomic) Foo *foo; + + + (Foo *)foo; + @end + + @implementation Foo + @synthesize foo = _foo; + + + (Foo *)foo + { + return (Foo *)0; + } + @end + ]) ], [ AC_MSG_RESULT(no) ], [ AC_MSG_RESULT(yes) OBJCFLAGS="$OBJCFLAGS -Wno-unused-property-ivar" @@ -1775,30 +1817,31 @@ ]) old_OBJCFLAGS="$OBJCFLAGS" OBJCFLAGS="$OBJCFLAGS -Wcast-align" AC_MSG_CHECKING(whether -Wcast-align is buggy) - AC_TRY_COMPILE([ - #ifdef __has_attribute - # if __has_attribute(objc_root_class) - __attribute__((__objc_root_class__)) - # endif - #endif - @interface Foo - { - struct objc_class *_isa; - } - @end - - @implementation Foo - - (void)foo - { - struct objc_class *c = _isa; - (void)c; - } - @end - ], [ + AC_COMPILE_IFELSE([ + AC_LANG_SOURCE([ + #ifdef __has_attribute + # if __has_attribute(objc_root_class) + __attribute__((__objc_root_class__)) + # endif + #endif + @interface Foo + { + struct objc_class *_isa; + } + @end + + @implementation Foo + - (void)foo + { + struct objc_class *c = _isa; + (void)c; + } + @end + ]) ], [ AC_MSG_RESULT(no) ], [ AC_MSG_RESULT(yes) OBJCFLAGS="$old_OBJCFLAGS" @@ -1805,93 +1848,97 @@ ]) old_OBJCFLAGS="$OBJCFLAGS" OBJCFLAGS="$OBJCFLAGS -Wunreachable-code" AC_MSG_CHECKING(whether -Wunreachable-code can be used) - AC_TRY_COMPILE([ - #include - - typedef void *SEL; - - #ifdef __has_attribute - # if __has_attribute(objc_root_class) - __attribute__((__objc_root_class__)) - # endif - #endif - @interface Object - - (void)doesNotRecognizeSelector: (SEL)selector - #ifdef __clang__ - __attribute__((__noreturn__)) - #endif - ; - - (void)dealloc; - @end - - @interface Foo: Object - @end - - void - test(void) - { - if (sizeof(int) == 4) - __asm__ (""); - else if (sizeof(int) == 8) - __asm__ (""); - else - abort(); - } - - /* - * Unfortunately, this cannot be shorter, as it only works when - * it is used inside a macro. - */ - #ifdef __clang__ - # define OF_DEALLOC_UNSUPPORTED \ - [self doesNotRecognizeSelector: _cmd]; \ - \ - abort(); \ - \ - _Pragma("clang diagnostic push ignore \"-Wunreachable-code\""); \ - [super dealloc]; \ - _Pragma("clang diagnostic pop"); - #else - # define OF_DEALLOC_UNSUPPORTED \ - [self doesNotRecognizeSelector: _cmd]; \ - \ - abort(); \ - \ - [super dealloc]; - #endif - - @implementation Foo - - (void)dealloc - { - OF_DEALLOC_UNSUPPORTED - } - @end - ], [], [ + AC_COMPILE_IFELSE([ + AC_LANG_SOURCE([[ + #include + + typedef void *SEL; + + #ifdef __has_attribute + # if __has_attribute(objc_root_class) + __attribute__((__objc_root_class__)) + # endif + #endif + @interface Object + - (void)doesNotRecognizeSelector: (SEL)selector + #ifdef __clang__ + __attribute__((__noreturn__)) + #endif + ; + - (void)dealloc; + @end + + @interface Foo: Object + @end + + void + test(void) + { + if (sizeof(int) == 4) + __asm__ (""); + else if (sizeof(int) == 8) + __asm__ (""); + else + abort(); + } + + /* + * Unfortunately, this cannot be shorter, as it only + * works when it is used inside a macro. + */ + #ifdef __clang__ + # define OF_DEALLOC_UNSUPPORTED \ + [self doesNotRecognizeSelector: _cmd]; \ + \ + abort(); \ + \ + _Pragma("clang diagnostic push ignore \ + \"-Wunreachable-code\""); \ + [super dealloc]; \ + _Pragma("clang diagnostic pop"); + #else + # define OF_DEALLOC_UNSUPPORTED \ + [self doesNotRecognizeSelector: _cmd]; \ + \ + abort(); \ + \ + [super dealloc]; + #endif + + @implementation Foo + - (void)dealloc + { + OF_DEALLOC_UNSUPPORTED + } + @end + ]]) + ], [ AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) OBJCFLAGS="$old_OBJCFLAGS" ]) old_OBJCFLAGS="$OBJCFLAGS" OBJCFLAGS="$OBJCFLAGS -Wdocumentation" AC_MSG_CHECKING(whether -Wdocumentation works correctly) - AC_TRY_COMPILE([ - /** - * @class Test conftest.m conftest.m - */ - #ifdef __has_attribute - # if __has_attribute(objc_root_class) - __attribute__((__objc_root_class__)) - # endif - #endif - @interface Test - @end - ], [ + AC_COMPILE_IFELSE([ + AC_LANG_SOURCE([ + /** + * @class Test conftest.m conftest.m + */ + #ifdef __has_attribute + # if __has_attribute(objc_root_class) + __attribute__((__objc_root_class__)) + # endif + #endif + @interface Test + @end + ]) ], [ AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) OBJCFLAGS="$old_OBJCFLAGS" @@ -1899,55 +1946,59 @@ AS_IF([test x"$check_pedantic" = x"yes"], [ old_OBJCFLAGS="$OBJCFLAGS" OBJCFLAGS="$OBJCFLAGS -pedantic" AC_MSG_CHECKING(whether -pedantic is buggy) - AC_TRY_COMPILE([ - #include - - #include - - #ifdef __has_attribute - # if __has_attribute(objc_root_class) - __attribute__((__objc_root_class__)) - # endif - #endif - @interface Foo - { - void *foo; - } - @end - - @interface Bar: Foo - - (void)assert; - @end - - @implementation Bar - - (void)assert - { - /* - * Some versions of glibc break with -pedantic - * when using assert. - */ - assert(1); - } - @end - ], [], [ + AC_COMPILE_IFELSE([ + AC_LANG_SOURCE([ + #include + + #include + + #ifdef __has_attribute + # if __has_attribute(objc_root_class) + __attribute__((__objc_root_class__)) + # endif + #endif + @interface Foo + { + void *foo; + } + @end + + @interface Bar: Foo + - (void)assert; + @end + + @implementation Bar + - (void)assert + { + /* + * Some versions of glibc break with + * -pedantic when using assert. + */ + assert(1); + } + @end + ]) + ], [ AC_MSG_RESULT(no) ], [ AC_MSG_RESULT(yes) OBJCFLAGS="$old_OBJCFLAGS" ]) ]) AS_IF([test x"$ac_cv_header_complex_h" = x"yes"], [ AC_MSG_CHECKING(whether we need -Wno-gnu-imaginary-constant) - AC_TRY_COMPILE([ - #include - ], [ - complex float f = 0.5 + 0.5 * I; - (void)f; + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ + #include + ], [ + complex float f = 0.5 + 0.5 * I; + (void)f; + ]) ], [ AC_MSG_RESULT(no) ], [ AC_MSG_RESULT(yes) OBJCFLAGS="$OBJCFLAGS -Wno-gnu-imaginary-constant"