Deal with a few common themes in downstream patches applied by OpenBSD, FreeBSD, Gentoo Linux, and possibly others.

-Respect CC and CXX if already set in the environment.
-Respect CFLAGS, CXXFLAGS, and LDFLAGS if set or specified.
-Give packagers the setting "PACKAGE_REPOSITORY=1" to prevent us from adding our own optimization parameters.

git-svn-id: https://svn.eduke32.com/eduke32@4547 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2014-07-22 11:19:25 +00:00
parent a5fb5f6795
commit 68b56adbe2
2 changed files with 66 additions and 41 deletions

View file

@ -420,7 +420,7 @@ makesdlkeytrans$(EXESUFFIX): $(ENGINE_OBJ)/makesdlkeytrans.$o
$(RECIPE_IF) $(LINKER) -o $@ $^ $(COMMONFLAGS) $(LINKERFLAGS) $(LIBDIRS) $(LIBS) $(UTIL_LIBS) $(SDL_INCLUDES) $(RECIPE_RESULT_ONESTEP)
arttool$(EXESUFFIX): $(ENGINE_OBJ)/arttool.$o
$(ONESTEP_STATUS)
$(RECIPE_IF) $(L_CXX) -o $@ $^ $(COMMONFLAGS) $(LINKERFLAGS) $(LIBDIRS) $(LIBS) $(STATICSTDCPP) $(STDCPPLIB) $(UTIL_LIBS) $(RECIPE_RESULT_ONESTEP)
$(RECIPE_IF) $(L_CXX) $(CPPONLYFLAGS) -o $@ $^ $(COMMONFLAGS) $(LINKERFLAGS) $(LIBDIRS) $(LIBS) $(STATICSTDCPP) $(STDCPPLIB) $(UTIL_LIBS) $(RECIPE_RESULT_ONESTEP)
$(DUKE3D_OBJ)/%.$o: $(DUKE3D_SRC)/%.c
$(COMPILE_STATUS)
@ -490,7 +490,7 @@ $(ENGINE_OBJ)/%.$o: $(ENGINE_SRC)/%.m
$(ENGINE_OBJ)/%.$o: $(ENGINE_SRC)/%.cpp
$(COMPILE_STATUS)
$(RECIPE_IF) $(CXX) $(CXXFLAGS) $(COMMONFLAGS) $(COMPILERFLAGS) $(ENGINE_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
$(RECIPE_IF) $(CXX) $(CPPONLYFLAGS) $(COMMONFLAGS) $(COMPILERFLAGS) $(ENGINE_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
$(ENGINE_OBJ)/%.$o: $(ENGINE_SRC)/misc/%.c
$(COMPILE_STATUS)
@ -506,11 +506,11 @@ $(ENGINE_OBJ)/%.$o: $(ENGINE_SRC)/util/%.c
$(ENGINE_OBJ)/%.$o: $(ENGINE_SRC)/util/%.cpp
$(COMPILE_STATUS)
$(RECIPE_IF) $(CXX) $(CXXFLAGS) $(COMMONFLAGS) $(COMPILERFLAGS) $(ENGINE_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
$(RECIPE_IF) $(CXX) $(CPPONLYFLAGS) $(COMMONFLAGS) $(COMPILERFLAGS) $(ENGINE_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
$(ENGINE_OBJ)/%.$o: $(ENGINE_SRC)/util/%.cc
$(COMPILE_STATUS)
$(RECIPE_IF) $(CXX) $(CXXFLAGS) $(COMMONFLAGS) $(COMPILERFLAGS) $(ENGINE_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
$(RECIPE_IF) $(CXX) $(CPPONLYFLAGS) $(COMMONFLAGS) $(COMPILERFLAGS) $(ENGINE_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
$(ENGINE_OBJ)/%.$o: $(DUKE3D_RSRC)/%.c
$(COMPILE_STATUS)
@ -536,7 +536,7 @@ $(DUKE3D_OBJ)/%.$o: $(DUKE3D_SRC)/%.m
$(DUKE3D_OBJ)/%.$o: $(DUKE3D_SRC)/%.cpp
$(COMPILE_STATUS)
$(RECIPE_IF) $(CXX) $(CXXFLAGS) $(COMMONFLAGS) $(COMPILERFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
$(RECIPE_IF) $(CXX) $(CPPONLYFLAGS) $(COMMONFLAGS) $(COMPILERFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
$(DUKE3D_OBJ)/%.$o: $(DUKE3D_SRC)/jmact/%.c
$(COMPILE_STATUS)

View file

@ -1,26 +1,51 @@
# Use colored output
# OS package maintainers: Please try invoking make with PACKAGE_REPOSITORY=1 to see if that meets your needs before patching out our optimizations entirely.
PACKAGE_REPOSITORY ?= 0
# Use colored output. Disable for build system debugging.
PRETTY_OUTPUT ?= 1
# Tools
CROSS=
CC=$(CROSS)gcc
CXX=$(CROSS)g++
AS=nasm
AR=$(CROSS)ar
RC=$(CROSS)windres
RANLIB=$(CROSS)ranlib
STRIP=$(CROSS)strip
ifneq ($(CROSS),)
undefine CC
undefine CXX
undefine AR
undefine RC
undefine RANLIB
undefine STRIP
endif
CC?=$(CROSS)gcc
CXX?=$(CROSS)g++
AR?=$(CROSS)ar
RC?=$(CROSS)windres
RANLIB?=$(CROSS)ranlib
STRIP?=$(CROSS)strip
AS?=nasm
PKG_CONFIG?=pkg-config
# Override defaults that absolutely will not work.
ifeq ($(CC),cc)
override CC=gcc
endif
ifeq ($(AS),as)
override AS=nasm
endif
L_CC=$(CC)
L_CXX=$(CXX)
CLANG?=0
ifeq ($(findstring clang,$(CC)),clang)
override CLANG=1
endif
ifneq (0,$(CLANG))
CC=clang -x c -std=gnu89
CC=clang -x c
CXX=clang -x c++
L_CC=clang -std=gnu89
L_CC=clang
L_CXX=clang
endif
@ -224,32 +249,28 @@ ifndef LTO
endif
endif
COMMONFLAGS=-O$(OPTLEVEL)
COMMONFLAGS=$(ARCH)
COMPILERFLAGS=
ifneq (,$(ARCH))
COMMONFLAGS+= $(ARCH)
ifeq ($(PACKAGE_REPOSITORY),0)
COMMONFLAGS += $(OPTIMIZATIONS)
endif
COMMONFLAGS+= $(OPTOPT)
OPTIMIZATIONS=-O$(OPTLEVEL) $(OPTOPT)
ifneq ($(RELEASE)$(DEBUGANYWAY),10)
# debug build or DEBUGANYWAY=1 --> -g flag
ifneq (0,$(CLANG))
COMMONFLAGS += -g
else
ifeq ($(PLATFORM), WII)
COMMONFLAGS += -g
else
COMMONFLAGS += -ggdb
endif
DEBUGFLAG=-g
ifneq (0,$(CLANG))
ifneq ($(PLATFORM),WII)
DEBUGFLAG=-ggdb
endif
endif
ifneq ($(RELEASE)$(DEBUGANYWAY),10)
# debug build or DEBUGANYWAY=1 --> -g flag
OPTIMIZATIONS += $(DEBUGFLAG)
endif
CONLYFLAGS=-Wimplicit -Wdeclaration-after-statement
CXXFLAGS= -fno-exceptions -fno-rtti -Wno-write-strings
CONLYFLAGS=-std=gnu89 -Wimplicit -Wdeclaration-after-statement
CPPONLYFLAGS= -fno-exceptions -fno-rtti -Wno-write-strings
ASFORMAT=elf$(SYSBITS)
ASFLAGS=-s -f $(ASFORMAT) #-g
LINKERFLAGS=
@ -355,7 +376,7 @@ endif
# XXX: I (Helixhorned) only know that there's no -Wnarrowing on my OS X 10.6 using GCC 4.2.
ifeq (1,$(strip $(shell expr $(GCC_MAJOR) \>= 4)))
ifeq (1,$(strip $(shell expr $(GCC_MINOR) \>= 3)))
CXXFLAGS+= -Wno-narrowing
CPPONLYFLAGS+= -Wno-narrowing
endif
endif
@ -546,8 +567,6 @@ ifneq (0,$(FORCEWARNINGS))
COMPILERFLAGS+= -DFORCE_WARNINGS
endif
LINKERFLAGS+= $(OPTOPT)
# This should come from the environment:
ifdef EDUKE32_MY_DEVELOPER_ID
COMPILERFLAGS+= -DMY_DEVELOPER_ID=$(EDUKE32_MY_DEVELOPER_ID)
@ -839,19 +858,19 @@ ifeq ($(RENDERTYPE),SDL)
ifeq (1,$(WITHOUT_GTK))
HAVE_GTK2=0
else
ifneq (No,$(shell pkg-config --exists gtk+-2.0 || echo No))
ifneq (No,$(shell $(PKG_CONFIG) --exists gtk+-2.0 || echo No))
HAVE_GTK2=1
# On my 64bit Gentoo box I have Cairo enabled which means the libs list includes
# -lpangocairo-1.0 and -lcairo, however the 32bit compatibility libraries don't
# include cairo, so we need to filter out those -l switches in order to link
ifneq ($(LINKED_GTK),0)
ifeq ($(GTKCOMPAT32),1)
LIBS+= $(shell pkg-config --libs gtk+-2.0 | sed 's/\s-l\(pango\)\{0,1\}cairo\S*\s/ /g')
LIBS+= $(shell $(PKG_CONFIG) --libs gtk+-2.0 | sed 's/\s-l\(pango\)\{0,1\}cairo\S*\s/ /g')
else
LIBS+= $(shell pkg-config --libs gtk+-2.0)
LIBS+= $(shell $(PKG_CONFIG) --libs gtk+-2.0)
endif
endif
COMPILERFLAGS += -DHAVE_GTK2 $(shell pkg-config --cflags gtk+-2.0)
COMPILERFLAGS += -DHAVE_GTK2 $(shell $(PKG_CONFIG) --cflags gtk+-2.0)
else
HAVE_GTK2=0
endif
@ -959,7 +978,7 @@ endif
COMPILER=$(CC) $(CONLYFLAGS)
LINKER=$(L_CC)
ifneq ($(CPLUSPLUS),0)
COMPILER=$(CXX) $(CXXFLAGS)
COMPILER=$(CXX) $(CPPONLYFLAGS)
LINKER=$(L_CXX)
endif
@ -969,6 +988,12 @@ endif
ifneq (,$(CFLAGS))
COMMONFLAGS+= $(CFLAGS)
endif
ifneq (,$(CXXFLAGS))
CPPONLYFLAGS+= $(CXXFLAGS)
endif
ifneq (,$(LDFLAGS))
LINKERFLAGS+= $(LDFLAGS)
endif
ifeq ($(PRETTY_OUTPUT),1)
RECIPE_IF = if