From c7f778ca79e52fab66e8d882c8594b797b36d770 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Fri, 27 Apr 2012 14:03:28 -0700 Subject: [PATCH] Cleaned up makefile to support OSX builds with the clang compiler --- makefile | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/makefile b/makefile index cd253954..d5164bda 100644 --- a/makefile +++ b/makefile @@ -67,6 +67,7 @@ ifeq ($(WIN32),) #*nix Environments (&& cygwin) OSNAME = windows-build endif GCC_VERSION = $(shell $(GCC) -v /dev/null 2>&1 | grep 'gcc version' | awk '{ print $$3 }') + COMPILER_NAME = GCC Version: $(GCC_VERSION) LTO_EXCLUDE_VERSIONS = PCAPLIB = pcap ifeq (agcc,$(findstring agcc,$(GCC))) # Android target build? @@ -88,6 +89,12 @@ ifeq ($(WIN32),) #*nix Environments (&& cygwin) ifeq (,$(shell $(GCC) -v /dev/null 2>&1 | grep '\-\-enable-lto')) LTO_EXCLUDE_VERSIONS += $(GCC_VERSION) endif + # OSX's clang compiler has different means of determining options than gcc + # gccm so hard set options here + ifneq (,$(shell $(GCC) -v /dev/null 2>&1 | grep 'clang version')) + COMPILER_NAME = Apple clang version $(shell $(GCC) -v /dev/null 2>&1 | grep 'clang version' | awk '{ print $$4 }') + CFLAGS_O = -Wno-comment -Wno-parentheses + endif else ifeq (Linux,$(OSTYPE)) LIBPATH := $(sort $(foreach lib,$(shell /sbin/ldconfig -p | grep ' => /' | sed 's/^.* => //'),$(dir $(lib)))) @@ -304,7 +311,11 @@ ifneq ($(DEBUG),) CFLAGS_O = -O0 BUILD_FEATURES = - debugging support else - CFLAGS_O = -O2 + ifneq (clang,$(findstring clang,$(COMPILER_NAME))) + CFLAGS_O = -O2 + else + CFLAGS_O := -O4 $(CFLAGS_O) -fno-strict-overflow -flto -fwhole-program + endif LDFLAGS_O = GCC_MAJOR_VERSION = $(firstword $(subst ., ,$(GCC_VERSION))) ifneq (3,$(GCC_MAJOR_VERSION)) @@ -351,7 +362,7 @@ ifneq (3,$(GCC_MAJOR_VERSION)) endif endif ifneq (clean,$(MAKECMDGOALS)) - BUILD_FEATURES := $(BUILD_FEATURES). GCC Version: $(GCC_VERSION) + BUILD_FEATURES := $(BUILD_FEATURES). $(COMPILER_NAME) $(info ***) $(info *** $(BUILD_SINGLE)Simulator$(BUILD_MULTIPLE) being built with:) $(info *** $(BUILD_FEATURES).)