@@ -1,6 +1,6 @@ -AC_INIT(ObjFW, 0.4-dev, js@webkeks.org) +AC_INIT(ObjFW, 0.5.4, js@webkeks.org) AC_CONFIG_SRCDIR(src) AS_IF([test x"$host" = x"psp"], [ OBJCFLAGS="-G0 $OBJCFLAGS" LIBS="$LIBS -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc" @@ -27,11 +27,12 @@ AX_CHECK_COMPILER_FLAGS(-fno-common, [OBJCFLAGS="$OBJCFLAGS -fno-common"]) AX_CHECK_COMPILER_FLAGS(-fno-constant-cfstrings, [ NO_CONST_CFSTRINGS="-fno-constant-cfstrings" OBJCFLAGS="$OBJCFLAGS -fno-constant-cfstrings" ]) -AX_CHECK_COMPILER_FLAGS(-Wshorten-64-to-32, [OBJCFLAGS="$OBJCFLAGS -pipe"]) +AX_CHECK_COMPILER_FLAGS(-Wshorten-64-to-32, + [OBJCFLAGS="$OBJCFLAGS -Wshorten-64-to-32"]) AC_SUBST(NO_CONST_CFSTRINGS) AC_MSG_CHECKING(whether Objective C compiler supports fast enumeration) AC_TRY_COMPILE([ @protocol OFFastEnumeration @@ -96,11 +97,11 @@ AC_MSG_CHECKING(whether Objective C compiler supports blocks) old_OBJCFLAGS="$OBJCFLAGS" OBJCFLAGS="$OBJCFLAGS -fblocks" AC_TRY_COMPILE([], [ int (^foo)(int bar); - foo = ^(int bar) { return 0; } + foo = ^ (int bar) { return 0; } ], [ AC_DEFINE(OF_HAVE_BLOCKS, 1, [Compiler support for blocks]) AC_SUBST(BLOCKS_FLAGS, "-fblocks") AC_SUBST(OFBLOCKTESTS_M, "OFBlockTests.m") AC_MSG_RESULT(yes) @@ -111,10 +112,11 @@ AC_CHECK_HEADERS([objfw-rt.h objc/objc.h]) test x"$ac_cv_header_objfw_rt_h" = x"yes" && objc_runtime="ObjFW-RT" +AC_MSG_CHECKING(which Objective C runtime we use) AS_IF([test x"$ac_cv_header_objc_objc_h" = x"yes"], [ AC_EGREP_CPP(yes, [ #import #ifdef __GNU_LIBOBJC__ yes @@ -133,41 +135,60 @@ ], [ objc_runtime="Apple" ]) ]) ]) +AC_MSG_RESULT($objc_runtime) -AC_MSG_CHECKING(which Objective C runtime we use) case $objc_runtime in ObjFW-RT) AC_DEFINE(OF_OBJFW_RUNTIME, 1, [Whether we use the ObjFW runtime]) AC_SUBST(GNU_RUNTIME, "-fgnu-runtime") OBJCFLAGS="$OBJCFLAGS -fgnu-runtime" - LIBS="-lobjfw-rt $LIBS" + + AC_CHECK_LIB(objfw-rt, objc_msg_lookup, [ + LIBS="-lobjfw-rt $LIBS" + ], [ + AC_MSG_ERROR([libobjfw-rt not found!]) + ]) ;; Apple) AC_DEFINE(OF_APPLE_RUNTIME, 1, [Whether we use the Apple ObjC runtime]) - LIBS="-lobjc $LIBS" + + AC_CHECK_LIB(objc, objc_msgSend, [ + LIBS="-lobjc $LIBS" + ], [ + AC_MSG_ERROR([libobjc not found!]) + ]) ;; GNU) AC_DEFINE(OF_GNU_RUNTIME, 1, [Whether we use the GNU ObjC runtime]) - LIBS="-lobjc $LIBS" + + AC_CHECK_LIB(objc, objc_msg_lookup, [ + LIBS="-lobjc $LIBS" + ], [ + AC_MSG_ERROR([libobjc not found!]) + ]) ;; "old GNU") AC_DEFINE(OF_OLD_GNU_RUNTIME, 1, [Whether we use the old GNU ObjC runtime]) - LIBS="-lobjc $LIBS" + + AC_CHECK_LIB(objc, objc_msg_lookup, [ + LIBS="-lobjc $LIBS" + ], [ + AC_MSG_ERROR([libobjc not found!]) + ]) ;; *) AC_MSG_RESULT(none) AC_MSG_ERROR(No ObjC runtime found! Please install ObjFW-RT!) ;; esac -AC_MSG_RESULT($objc_runtime) AC_CHECK_FUNC(objc_getProperty,, [ AC_DEFINE(NEED_OBJC_PROPERTIES_INIT, 1, [Whether objc_properties_init needs to be called]) AC_SUBST(OBJC_PROPERTIES_M, "objc_properties.m") @@ -450,11 +471,20 @@ ;; esac AS_IF([test x"$have_threadsafe_getaddrinfo" = x"unknown"], [ AC_EGREP_CPP(yes, [ - #include + #ifndef _WIN32 + # include + # include + # include + #else + # define _WIN32_WINNT 0x0501 + # include + # include + #endif + #ifdef h_errno yes #end ], [ have_threadsafe_getaddrinfo="yes" @@ -483,12 +513,11 @@ AC_SUBST(FOUNDATION_COMPAT_M, "foundation-compat.m") ]) ]) AS_IF([test x"$GOBJC" = x"yes"], [ - OBJCFLAGS="$OBJCFLAGS -Wwrite-strings -Wcast-align -Wpointer-arith" - OBJCFLAGS="$OBJCFLAGS -Werror" + OBJCFLAGS="$OBJCFLAGS -Wwrite-strings -Wpointer-arith -Werror" AC_MSG_CHECKING(whether gcc has bug objc/27438) AC_TRY_COMPILE([ @interface OFConstantString { @@ -499,11 +528,11 @@ @end void *_OFConstantStringClassReference; ], [ OFConstantString *test = @""; - test++; /* Get rid of unused variable warning */ + (void)test; /* Get rid of unused variable warning */ ], [ AC_MSG_RESULT(no) ], [ AC_MSG_RESULT([yes, adding -Wno-unused-variable]) OBJCFLAGS="$OBJCFLAGS -Wno-unused-variable" @@ -510,28 +539,53 @@ AC_SUBST(NO_WARN_UNUSED, "-Wno-unused-variable") ]) AC_MSG_CHECKING(whether we need -Wno-strict-aliasing due to gcc bugs) AC_TRY_COMPILE([ - @interface OFObject + @interface Foo { - Class isa; + struct objc_class *isa; } @end static struct { struct objc_class *isa; } object; ], [ - OFObject *test = (OFObject*)&object; - test++; /* Get rid of unused variable warning */ + 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" ]) + + old_OBJCFLAGS="$OBJCFLAGS" + OBJCFLAGS="$OBJCFLAGS -Wcast-align" + AC_MSG_CHECKING(whether -Wcast-align is buggy) + AC_TRY_COMPILE([ + @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" + ]) ]) AS_IF([test x"$cross_compiling" = x"yes"], [ AC_SUBST(BIN_PREFIX, "$host-")