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