Make the base CFLAGS overridable.

This was requested several times, the last time in pull request #523.
Only the optimization level, warning level and debug stuff may be
overridden. All other options are enforces because they're required.

While here add a new variable to force a debug build: `make DEBUG=1`.
This commit is contained in:
Yamagi 2020-03-09 09:37:29 +01:00
parent 466e689695
commit 09aad64202

View file

@ -111,33 +111,32 @@ 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 this crappy code.
# ifdef DEBUG
# -fno-strict-aliasing since the source doesn't comply CFLAGS ?= -O0 -g -Wall -pipe
# with strict aliasing rules and it's next to impossible
# to get it there...
#
# -fomit-frame-pointer since the framepointer is mostly
# useless for debugging Quake II and slows things down.
#
# -g to build always with debug symbols. Please DO NOT
# CHANGE THIS, since it's our only chance to debug this
# crap when random crashes happen!
#
# -MMD to generate header dependencies. (They cannot be
# generated if building universal binaries on OSX)
#
# -fwrapv for defined integer wrapping. MSVC6 did this
# and the game code requires it.
ifeq ($(YQ2_OSTYPE), Darwin)
CFLAGS := -O2 -fno-strict-aliasing -fomit-frame-pointer \
-Wall -pipe -g -fwrapv
CFLAGS += $(OSX_ARCH)
else else
CFLAGS := -std=gnu99 -O2 -fno-strict-aliasing \ CFLAGS ?= -O2 -Wall -pipe -fomit-frame-pointer
-Wall -pipe -g -ggdb -MMD -fwrapv endif
# Always needed are:
# -fno-strict-aliasing since the source doesn't comply
# with strict aliasing rules and it's next to impossible
# to get it there...
# -fwrapv for defined integer wrapping. MSVC6 did this
# and the game code requires it.
CFLAGS += -std=gnu99 -fno-strict-aliasing -fwrapv
# -MMD to generate header dependencies. Unsupported by
# the Clang shipped with OS X.
ifneq ($(YQ2_OSTYPE), Darwin)
CFLAGS += -MMD
endif
# OS X architecture.
ifeq ($(YQ2_OSTYPE), Darwin)
CFLAGS += $(OSX_ARCH)
endif endif
# ---------- # ----------