Added makefile support to use the LLVM (clang) compiler on OSX and other platforms where it may be available (Linux, *BSD, etc.)
This commit is contained in:
parent
0f8e6cfe95
commit
d4e1cac0ea
1 changed files with 24 additions and 11 deletions
35
makefile
35
makefile
|
@ -23,6 +23,10 @@
|
||||||
# If debugging is desired, then GNU make can be invoked with
|
# If debugging is desired, then GNU make can be invoked with
|
||||||
# DEBUG=1 on the command line.
|
# DEBUG=1 on the command line.
|
||||||
#
|
#
|
||||||
|
# OSX and other environments may have the LLVM (clang) compiler
|
||||||
|
# installed. If you want to build with the clang compiler, invoke
|
||||||
|
# make with GCC=clang.
|
||||||
|
#
|
||||||
# Internal ROM support can be disabled if GNU make is invoked with
|
# Internal ROM support can be disabled if GNU make is invoked with
|
||||||
# DONT_USE_ROMS=1 on the command line.
|
# DONT_USE_ROMS=1 on the command line.
|
||||||
#
|
#
|
||||||
|
@ -66,8 +70,17 @@ ifeq ($(WIN32),) #*nix Environments (&& cygwin)
|
||||||
OSTYPE = cygwin
|
OSTYPE = cygwin
|
||||||
OSNAME = windows-build
|
OSNAME = windows-build
|
||||||
endif
|
endif
|
||||||
GCC_VERSION = $(shell $(GCC) -v /dev/null 2>&1 | grep 'gcc version' | awk '{ print $$3 }')
|
ifeq (,$(shell $(GCC) -v /dev/null 2>&1 | grep 'clang version'))
|
||||||
COMPILER_NAME = GCC Version: $(GCC_VERSION)
|
GCC_VERSION = $(shell $(GCC) -v /dev/null 2>&1 | grep 'gcc version' | awk '{ print $$3 }')
|
||||||
|
COMPILER_NAME = GCC Version: $(GCC_VERSION)
|
||||||
|
else
|
||||||
|
COMPILER_NAME = $(shell $(GCC) -v /dev/null 2>&1 | grep 'clang version' | awk '{ print $$1 " " $$2 " " $$3 }')
|
||||||
|
CLANG_VERSION = $(word 3,$(COMPILER_NAME))
|
||||||
|
ifeq (,$(findstring .,$(CLANG_VERSION)))
|
||||||
|
COMPILER_NAME = $(shell $(GCC) -v /dev/null 2>&1 | grep 'clang version' | awk '{ print $$1 " " $$2 " " $$3 " " $$4 }')
|
||||||
|
CLANG_VERSION = $(word 4,$(COMPILER_NAME))
|
||||||
|
endif
|
||||||
|
endif
|
||||||
LTO_EXCLUDE_VERSIONS =
|
LTO_EXCLUDE_VERSIONS =
|
||||||
PCAPLIB = pcap
|
PCAPLIB = pcap
|
||||||
ifeq (agcc,$(findstring agcc,$(GCC))) # Android target build?
|
ifeq (agcc,$(findstring agcc,$(GCC))) # Android target build?
|
||||||
|
@ -86,14 +99,10 @@ ifeq ($(WIN32),) #*nix Environments (&& cygwin)
|
||||||
OSNAME = OSX
|
OSNAME = OSX
|
||||||
LIBEXT = dylib
|
LIBEXT = dylib
|
||||||
# OSX's XCode gcc doesn't support LTO, but gcc built to explicitly enable it will work
|
# OSX's XCode gcc doesn't support LTO, but gcc built to explicitly enable it will work
|
||||||
ifeq (,$(shell $(GCC) -v /dev/null 2>&1 | grep '\-\-enable-lto'))
|
ifneq (,$(GCC_VERSION))
|
||||||
LTO_EXCLUDE_VERSIONS += $(GCC_VERSION)
|
ifeq (,$(shell $(GCC) -v /dev/null 2>&1 | grep '\-\-enable-lto'))
|
||||||
endif
|
LTO_EXCLUDE_VERSIONS += $(GCC_VERSION)
|
||||||
# OSX's clang compiler has different means of determining options than gcc
|
endif
|
||||||
# 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
|
endif
|
||||||
else
|
else
|
||||||
ifeq (Linux,$(OSTYPE))
|
ifeq (Linux,$(OSTYPE))
|
||||||
|
@ -314,7 +323,11 @@ else
|
||||||
ifneq (clang,$(findstring clang,$(COMPILER_NAME)))
|
ifneq (clang,$(findstring clang,$(COMPILER_NAME)))
|
||||||
CFLAGS_O = -O2
|
CFLAGS_O = -O2
|
||||||
else
|
else
|
||||||
CFLAGS_O := -O4 $(CFLAGS_O) -fno-strict-overflow -flto -fwhole-program
|
ifeq (Darwin,$(OSTYPE))
|
||||||
|
CFLAGS_O += -O4 -fno-strict-overflow -flto -fwhole-program
|
||||||
|
else
|
||||||
|
CFLAGS_O := -O2 -fno-strict-overflow
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
LDFLAGS_O =
|
LDFLAGS_O =
|
||||||
GCC_MAJOR_VERSION = $(firstword $(subst ., ,$(GCC_VERSION)))
|
GCC_MAJOR_VERSION = $(firstword $(subst ., ,$(GCC_VERSION)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue