build: Make the base CFLAGS overridable

Only the optimization level, warning level and debug stuff may be
overridden. All other options are enforced because they're required.

While here add a new variable to force a debug build: `make DEBUG=1`.

Based on <https://github.com/yquake2/yquake2/commits/cflags>.

Signed-off-by: Simon McVittie <smcv@debian.org>
This commit is contained in:
Simon McVittie 2020-03-11 11:04:01 +00:00
parent e7cb7e1e48
commit 4bb77517bc

View file

@ -47,30 +47,31 @@ endif
# ---------- # ----------
# Base CFLAGS. # Base CFLAGS. These may be overridden by the environment.
# # Highest supported optimizations are -O2, higher levels
# -O2 are enough optimizations. # will likely break things.
# ifdef DEBUG
CFLAGS ?= -O0 -g -Wall -pipe
else
CFLAGS ?= -O2 -Wall -pipe -fomit-frame-pointer
endif
# Always needed are:
# -fno-strict-aliasing since the source doesn't comply # -fno-strict-aliasing since the source doesn't comply
# with strict aliasing rules and it's next to impossible # with strict aliasing rules and it's next to impossible
# to get it there... # to get it there...
# # -fwrapv for defined integer wrapping. MSVC6 did this
# -fomit-frame-pointer since the framepointer is mostly # and the game code requires it.
# useless for debugging Quake II and slows things down. CFLAGS += -fno-strict-aliasing -fwrapv
#
# -g to build allways with debug symbols. Please do not # -MMD to generate header dependencies. Unsupported by
# change this, since it's our only chance to debug this # the Clang shipped with OS X.
# crap when random crashes happen! ifneq ($(OSTYPE), Darwin)
# CFLAGS += -MMD
# -fPIC for position independend code. endif
#
# -MMD to generate header dependencies.
ifeq ($(OSTYPE), Darwin) ifeq ($(OSTYPE), Darwin)
CFLAGS := -O2 -fno-strict-aliasing -fomit-frame-pointer \ CFLAGS += -arch x86_64
-Wall -pipe -g -fwrapv -arch x86_64
else
CFLAGS := -O2 -fno-strict-aliasing -fomit-frame-pointer \
-Wall -pipe -g -MMD -fwrapv
endif endif
# ---------- # ----------