From c14cf3e3804b9102fe90f2250e24576552136e85 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 22 Jun 2018 01:02:38 +0100 Subject: [PATCH 1/2] build: Check for ObjC compiler availability Use the same type of check as the one we use for a C++ compiler, as AC_PROG_OBJC cannot be called unconditionally without breaking autoconf, and we don't want a hard dependency on an Objective C compiler outside of the macOS builds. --- configure.ac | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/configure.ac b/configure.ac index 06fac48af3..2aabbbbbe5 100644 --- a/configure.ac +++ b/configure.ac @@ -198,6 +198,22 @@ AC_TRY_CPP([ AC_MSG_RESULT([$glib_have_cocoa]) +dnl Check for a working ObjC compiler, but do not bail out, if none is found. +AC_CHECK_TOOLS(OBJC, [$OBJC gcc clang CC], [gcc]) +AC_LANG_SAVE +AC_LANG_OBJC +AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([#include ], [ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSLog (@"Hello, World!"); + [pool drain]; + ])], + [AC_MSG_RESULT([ok])], + [OBJC=""] +) +AM_CONDITIONAL(HAVE_OBJC, [test "$OBJC" != ""]) +AC_LANG_RESTORE + AM_CONDITIONAL(OS_WIN32, [test "$glib_native_win32" = "yes"]) AM_CONDITIONAL(OS_WIN32_X64, [test "$LIB_EXE_MACHINE_FLAG" = "X64"]) AM_CONDITIONAL(OS_UNIX, [test "$glib_native_win32" != "yes"]) -- GitLab From 59c12bc8aad67d80129e21e3829cb7f7bb91be53 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 22 Jun 2018 01:04:08 +0100 Subject: [PATCH 2/2] build: Use .m files directly If we're on macOS we can count on an Objective C compiler to exist. --- gio/Makefile.am | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/gio/Makefile.am b/gio/Makefile.am index 9dccb68298..91826f91c5 100644 --- a/gio/Makefile.am +++ b/gio/Makefile.am @@ -601,39 +601,17 @@ libgio_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ -export-dynamic $(no_undefined) -# We cannot build .m files because it would require adding AC_PROG_OBJC in -# configure.ac, and it cannot be added conditionally. That means we would always -# depend on an objective-c compiler even when not needed. To work around that -# limitation we rename .m files to .c and compile them separately with -# -xobjective-c into an intermediary library. Note that we cannot rename those -# files to .c directly in the source tree because Meson needs the .m extension. -# This must be done outside of "if OS_COCOA" block otherwise distcheck fails. -# See https://bugzilla.gnome.org/show_bug.cgi?id=672777. -OBJC_FILES = \ - gnextstepsettingsbackend.m \ - gosxcontenttype.m \ - gosxappinfo.m \ - gcocoanotificationbackend.m \ - $(NULL) -OBJC_C_FILES = $(OBJC_FILES:.m=.c) -BUILT_SOURCES += $(OBJC_C_FILES) -CLEANFILES += $(OBJC_C_FILES) -EXTRA_DIST += $(OBJC_FILES) -$(OBJC_C_FILES): %.c: %.m Makefile - cp $< $@ - if OS_COCOA -libgio_objc_2_0_la_CFLAGS = $(libgio_2_0_la_CFLAGS) -xobjective-c +libgio_objc_2_0_la_OBJCFLAGS = $(AM_OBJCFLAGS) $(libgio_2_0_la_CFLAGS) libgio_objc_2_0_la_CPPFLAGS = $(libgio_2_0_la_CPPFLAGS) libgio_objc_2_0_la_LDFLAGS = $(libgio_2_0_la_LDFLAGS) -Wl,-framework,Foundation -Wl,-framework,AppKit libgio_objc_2_0_la_SOURCES = \ - gnextstepsettingsbackend.c \ - gosxcontenttype.c \ - gosxappinfo.c \ - gosxappinfo.h + gnextstepsettingsbackend.m \ + gosxcontenttype.m \ + gosxappinfo.m if MAC_OS_X_9 libgio_objc_2_0_la_SOURCES += \ - gcocoanotificationbackend.c + gcocoanotificationbackend.m endif noinst_LTLIBRARIES += libgio-objc-2.0.la -- GitLab