1
CXXFLAGS ?= -DNDEBUG -g2 -O3
4
2
# -fPIC is supported, and enabled by default for x86_64.
5
3
# the following options reduce code size, but breaks link or makes link very slow on some systems
6
4
# CXXFLAGS += -ffunction-sections -fdata-sections
14
12
IS_X86 = $(shell uname -m | $(EGREP) -c "i.86|x86|i86|amd64")
15
13
IS_X86_64 = $(shell uname -m | $(EGREP) -c "_64|d64")
16
14
IS_DARWIN = $(shell uname -s | $(EGREP) -i -c "darwin")
17
IS_SUN_CC = $(shell $(CXX) -V 2>&1 | $(EGREP) -c "CC: Sun")
18
15
IS_LINUX = $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c "linux")
19
16
IS_MINGW = $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c "mingw")
20
17
IS_CYGWIN = $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c "cygwin")
21
19
CLANG_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "clang")
20
INTEL_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "\(ICC\)")
21
SUN_COMPILER = $(shell $(CXX) -V 2>&1 | $(EGREP) -i -c "CC: Sun")
23
23
# Default prefix for make install
29
ifneq ($(IS_CYGWIN),0)
31
# For some reason CXX is gcc on Cygwin 1.1.4
36
# -O3 fails to link with GCC 4.5.3, and causes a core dump with GCC 4.9
37
ifeq ($(findstring -O3,$(OPTIMIZE)),-O3)
42
# End Cygwin work arounds
44
# Merge symbols and optimizations
45
CXXFLAGS += $(SYMBOLS) $(OPTIMIZE)
49
30
GCC42_OR_LATER = $(shell $(CXX) -v 2>&1 | $(EGREP) -c "^gcc version (4.[2-9]|[5-9])")
50
INTEL_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\)")
51
31
ICC111_OR_LATER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\) ([2-9][0-9]|1[2-9]|11\.[1-9])")
52
32
GAS210_OR_LATER = $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(EGREP) -c "GNU assembler version (2\.[1-9][0-9]|[3-9])")
53
33
GAS217_OR_LATER = $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(EGREP) -c "GNU assembler version (2\.1[7-9]|2\.[2-9]|[3-9])")
56
36
# Enable PIC for x86_64 targets
57
37
ifneq ($(IS_X86_64),0)
58
# But don't enable it on Cygwin x86_64
39
endif # PIC for x86_64 targets
42
ifneq ($(IS_CYGWIN),0)
44
# CXX is gcc on Cygwin 1.1.4
49
# -fPIC causes spurious output during compile
50
ifeq ($(findstring -fPIC,$(CXXFLAGS)),-fPIC)
51
CXXFLAGS := $(subst -fPIC,,$(CXXFLAGS))
54
# -O3 fails to link with GCC 4.5.3
55
IS_GCC45 = = $(shell $(CXX) -v 2>&1 | $(EGREP) -c "^gcc version 4\.5\.")
57
ifeq ($(findstring -O3,$(CXXFLAGS)),-O3)
58
CXXFLAGS := $(subst -O3,-O2,$(CXXFLAGS))
62
endif # Cygwin work arounds
64
64
# We can do integer math using the Posix shell in a GNUmakefile
65
65
# Below, we are building a boolean circuit that says "Darwin && (GCC 4.2 || Clang)"
134
134
CXXFLAGS += -Wno-tautological-compare
137
ifneq ($(IS_SUN_CC),0) # override flags for CC Sun C++ compiler
137
ifneq ($(SUN_COMPILER),0) # override flags for CC Sun C++ compiler
138
138
CXXFLAGS = -DNDEBUG -O -g0 -native -template=no%extdef $(M32OR64)