Makefiles: allow overriding the optimization level with debugging builds.

git-svn-id: https://svn.eduke32.com/eduke32@3725 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-05-04 16:36:10 +00:00
parent d56e5451d9
commit 6deabcdb5d
2 changed files with 10 additions and 5 deletions

View file

@ -163,10 +163,16 @@ DISABLEINLINING?=0
FORCEWARNINGS?=0 FORCEWARNINGS?=0
EFENCE?=0 EFENCE?=0
DMALLOC?=0 DMALLOC?=0
OPTLEVEL?=2
PROFILER?=0 PROFILER?=0
MUDFLAP?=0 MUDFLAP?=0
# Select the default optimization level for release and debug builds.
ifeq ($RELEASE,0)
OPTLEVEL?=0
else
OPTLEVEL?=2
endif
ifeq ($(RELEASE),0) ifeq ($(RELEASE),0)
override STRIP= override STRIP=
endif endif
@ -311,9 +317,10 @@ ifneq ($(RELEASE)$(DEBUGANYWAY),10)
endif endif
endif endif
debug+= -O$(OPTLEVEL)
ifneq (0,$(RELEASE)) ifneq (0,$(RELEASE))
# Debugging disabled # Debugging disabled
debug+= -O$(OPTLEVEL)
ifeq (0,$(CLANG)) ifeq (0,$(CLANG))
debug+= -funswitch-loops debug+= -funswitch-loops
ifeq (1,$(strip $(shell expr $(GCC_MAJOR) \< 4))) ifeq (1,$(strip $(shell expr $(GCC_MAJOR) \< 4)))
@ -336,8 +343,6 @@ ifneq (0,$(RELEASE))
endif endif
else else
# Debugging enabled # Debugging enabled
debug+= -O0
ifeq (0,$(DEBUGANYWAY)) ifeq (0,$(DEBUGANYWAY))
debug+= -DDEBUGGINGAIDS debug+= -DDEBUGGINGAIDS
else else

View file

@ -290,7 +290,7 @@ $(OBJ)/%.$o: $(SRC)/%.nasm
# Comment out the following rule to debug a-c.o # Comment out the following rule to debug a-c.o
$(OBJ)/a-c.$o: $(SRC)/a-c.c $(OBJ)/a-c.$o: $(SRC)/a-c.c
$(COMPILE_STATUS) $(COMPILE_STATUS)
if $(COMPILER) $(subst -O0,-O2,$(subst -fsanitize=address -fsanitize=undefined,,$(OURCFLAGS))) -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi if $(COMPILER) $(subst -O$(OPTLEVEL),-O2,$(subst -fsanitize=address -fsanitize=undefined,,$(OURCFLAGS))) -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
# KEEPINSYNC the Clang -f option(s) with Makefile.common # KEEPINSYNC the Clang -f option(s) with Makefile.common
$(OBJ)/%.$o: $(SRC)/%.c $(OBJ)/%.$o: $(SRC)/%.c