From 6deabcdb5d17e5c547a0c993de2a61873aa340ff Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sat, 4 May 2013 16:36:10 +0000 Subject: [PATCH] Makefiles: allow overriding the optimization level with debugging builds. git-svn-id: https://svn.eduke32.com/eduke32@3725 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/Makefile.common | 13 +++++++++---- polymer/eduke32/build/Makefile | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/polymer/eduke32/Makefile.common b/polymer/eduke32/Makefile.common index cc98d5836..3d212f2bc 100644 --- a/polymer/eduke32/Makefile.common +++ b/polymer/eduke32/Makefile.common @@ -163,10 +163,16 @@ DISABLEINLINING?=0 FORCEWARNINGS?=0 EFENCE?=0 DMALLOC?=0 -OPTLEVEL?=2 PROFILER?=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) override STRIP= endif @@ -311,9 +317,10 @@ ifneq ($(RELEASE)$(DEBUGANYWAY),10) endif endif +debug+= -O$(OPTLEVEL) + ifneq (0,$(RELEASE)) # Debugging disabled - debug+= -O$(OPTLEVEL) ifeq (0,$(CLANG)) debug+= -funswitch-loops ifeq (1,$(strip $(shell expr $(GCC_MAJOR) \< 4))) @@ -336,8 +343,6 @@ ifneq (0,$(RELEASE)) endif else # Debugging enabled - debug+= -O0 - ifeq (0,$(DEBUGANYWAY)) debug+= -DDEBUGGINGAIDS else diff --git a/polymer/eduke32/build/Makefile b/polymer/eduke32/build/Makefile index 8e0ae36c6..448dfd35e 100644 --- a/polymer/eduke32/build/Makefile +++ b/polymer/eduke32/build/Makefile @@ -290,7 +290,7 @@ $(OBJ)/%.$o: $(SRC)/%.nasm # Comment out the following rule to debug a-c.o $(OBJ)/a-c.$o: $(SRC)/a-c.c $(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 $(OBJ)/%.$o: $(SRC)/%.c