~zooko/cryptopp/trunk

« back to all changes in this revision

Viewing changes to GNUmakefile

  • Committer: noloader
  • Date: 2015-07-15 22:55:06 UTC
  • Revision ID: svn-v4:57ff6487-cd31-0410-9ec3-f628ee90f5f0:trunk/c5:588
Folded OPTIMIZE and SYMBOLS back into CXXFLAGS (we can use 'subst' to modify CXXFLAGS). Moved Cygwin work arounds into block guarded by IS_X86 (Cygwin only runs on Windows)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
CXXFLAGS ?= -DNDEBUG
2
 
SYMBOLS ?= -g2
3
 
OPTIMIZE ?= -O3
 
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")
 
18
 
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")
22
22
 
23
23
# Default prefix for make install
24
24
ifeq ($(PREFIX),)
25
25
PREFIX = /usr
26
26
endif
27
27
 
28
 
# Cygwin work arounds
29
 
ifneq ($(IS_CYGWIN),0)
30
 
 
31
 
# For some reason CXX is gcc on Cygwin 1.1.4
32
 
ifeq ($(CXX),gcc)
33
 
CXX = g++
34
 
endif
35
 
 
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)
38
 
OPTIMIZE = -O2
39
 
endif
40
 
 
41
 
endif
42
 
# End Cygwin work arounds
43
 
 
44
 
# Merge symbols and optimizations
45
 
CXXFLAGS += $(SYMBOLS) $(OPTIMIZE)
46
 
 
47
28
ifeq ($(IS_X86),1)
48
29
 
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])")
55
35
 
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
59
 
ifeq ($(IS_CYGWIN),0)
60
38
CXXFLAGS += -fPIC
61
 
endif
62
 
endif
 
39
endif # PIC for x86_64 targets
 
40
 
 
41
# Cygwin work arounds
 
42
ifneq ($(IS_CYGWIN),0)
 
43
 
 
44
# CXX is gcc on Cygwin 1.1.4
 
45
ifeq ($(CXX),gcc)
 
46
CXX = g++
 
47
endif # CXX
 
48
 
 
49
# -fPIC causes spurious output during compile
 
50
ifeq ($(findstring -fPIC,$(CXXFLAGS)),-fPIC)
 
51
CXXFLAGS := $(subst -fPIC,,$(CXXFLAGS))
 
52
endif # --fPIC
 
53
 
 
54
# -O3 fails to link with GCC 4.5.3
 
55
IS_GCC45 = = $(shell $(CXX) -v 2>&1 | $(EGREP) -c "^gcc version 4\.5\.")
 
56
ifneq ($(IS_GCC45),0)
 
57
ifeq ($(findstring -O3,$(CXXFLAGS)),-O3)
 
58
CXXFLAGS := $(subst -O3,-O2,$(CXXFLAGS))
 
59
endif # -O3
 
60
endif # GCC 4.5
 
61
 
 
62
endif # Cygwin work arounds
63
63
 
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
135
135
endif
136
136
 
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)
139
139
LDFLAGS =
140
140
AR = $(CXX)