Added some sane defaults for -g and -O if they are missing from CXXFLAGS
parent
6bdcaefccd
commit
427b45b4e7
24
GNUmakefile
24
GNUmakefile
|
|
@ -11,8 +11,6 @@ MKDIR ?= mkdir
|
||||||
EGREP ?= egrep
|
EGREP ?= egrep
|
||||||
UNAME ?= uname
|
UNAME ?= uname
|
||||||
|
|
||||||
# $(error Flags: $(ARFLAGS))
|
|
||||||
|
|
||||||
# Default setting from environment. Disable verbose flag, add create flag
|
# Default setting from environment. Disable verbose flag, add create flag
|
||||||
ifeq ($(findstring rv,$(ARFLAGS)),rv)
|
ifeq ($(findstring rv,$(ARFLAGS)),rv)
|
||||||
ARFLAGS = cr
|
ARFLAGS = cr
|
||||||
|
|
@ -20,15 +18,35 @@ endif
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
# CXXFLAGS
|
# CXXFLAGS
|
||||||
CXXFLAGS ?= -DNDEBUG -g2 -O3
|
|
||||||
# -fPIC is supported, and enabled by default for x86_64.
|
# -fPIC is supported, and enabled by default for x86_64.
|
||||||
|
|
||||||
|
# We can augment CXXFLAGS if the user exports them in the shell, or if the user
|
||||||
|
# omits them. However, if the user `make CXXFLAGS="-g1"`, then that's what
|
||||||
|
# the user gets. Make does not override them, and does not honor our '+='.
|
||||||
|
CXXFLAGS ?= -DNDEBUG -g2 -O3
|
||||||
|
|
||||||
|
# Add -DNDEBUG if nothing specified
|
||||||
|
ifeq ($(filter -DDEBUG -DNDEBUG,$(CXXFLAGS)),)
|
||||||
|
CXXFLAGS += -DNDEBUG
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Add a symolize if nothing specified
|
||||||
|
ifeq ($(filter -g -g1 -g2 -g3 -Oz,$(CXXFLAGS)),)
|
||||||
|
CXXFLAGS += -g2
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Add an optimize if nothing specified
|
||||||
|
ifeq ($(filter -O -O0 -O1 -O2 -O3 -Og -Os -Oz -Ofast,$(CXXFLAGS)),)
|
||||||
|
CXXFLAGS += -O3
|
||||||
|
endif
|
||||||
|
|
||||||
# the following options reduce code size, but breaks link or makes link very slow on some systems
|
# the following options reduce code size, but breaks link or makes link very slow on some systems
|
||||||
# CXXFLAGS += -ffunction-sections -fdata-sections
|
# CXXFLAGS += -ffunction-sections -fdata-sections
|
||||||
# LDFLAGS += -Wl,--gc-sections
|
# LDFLAGS += -Wl,--gc-sections
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
# Compilers
|
# Compilers
|
||||||
|
|
||||||
CLANG_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "clang")
|
CLANG_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "clang")
|
||||||
INTEL_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "\(ICC\)")
|
INTEL_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "\(ICC\)")
|
||||||
SUN_COMPILER = $(shell $(CXX) -V 2>&1 | $(EGREP) -i -c "CC: Sun")
|
SUN_COMPILER = $(shell $(CXX) -V 2>&1 | $(EGREP) -i -c "CC: Sun")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue