## common definitions for Makefile, build/Makefile, source/enet/Makefile and ## source/jaudiolib/Makefile # Use colored output PRETTY_OUTPUT ?= 1 # Tools CC=gcc CXX=g++ AS=nasm AR=ar RC=windres RANLIB=ranlib STRIP=strip L_CC=$(CC) L_CXX=$(CXX) CLANG?=0 ifneq (0,$(CLANG)) CC=clang -x c -std=gnu89 CXX=clang -x c++ L_CC=clang -std=gnu89 L_CXX=clang # AR=llvm-ar # RANLIB=llvm-ranlib endif # GCC version, for conditional selection of flags. # This is easier than trying to squeeze it out of gcc --version: GCC_MAJOR?=4 # Detect machine architecture SYSARCH?=$(strip $(shell uname -m)) # Detect the platform if it wasn't explicitly given to us from # the outside world. This allows cross-compilation by overriding # CC and giving us PLATFORM specifically. # ifndef PLATFORM uname=$(strip $(shell uname -s)) PLATFORM=UNKNOWN ifeq ($(findstring Linux,$(uname)),Linux) PLATFORM=LINUX endif ifeq ($(findstring BSD,$(uname)),BSD) PLATFORM=BSD endif ifeq ($(findstring MINGW,$(uname)),MINGW) PLATFORM=WINDOWS endif ifeq ($(findstring Darwin,$(uname)),Darwin) PLATFORM=DARWIN endif ifeq ($(findstring BeOS,$(uname)),BeOS) PLATFORM=BEOS endif ifeq ($(findstring skyos,$(uname)),skyos) PLATFORM=SKYOS endif ifeq ($(findstring QNX,$(uname)),QNX) PLATFORM=QNX endif ifeq ($(findstring SunOS,$(uname)),SunOS) PLATFORM=SUNOS endif ifeq ($(findstring syllable,$(uname)),syllable) PLATFORM=SYLLABLE endif endif # Binary suffix override: EXESUFFIX_OVERRIDE ?= # DirectX SDK location - if nonempty, overrides the DXROOTs of the individual # Makefiles. Should be set to an absolute path since this Makefile is included # at different directory levels DXROOT_OVERRIDE:= # Mac OS X Frameworks location # Like above, use absolute paths. APPLE_FRAMEWORKS ?=/Library/Frameworks # Since the OS X startup window is generating errors, disable it by default. OSX_STARTUPWINDOW ?= 0 # Engine options # USE_OPENGL - enables basic OpenGL Polymost renderer # POLYMER - enables fancy Polymer renderer # NOASM - disables the use of inline assembly pragmas # LINKED_GTK - enables compile-time linkage to GTK # POLYMER = 1 USE_OPENGL = 1 NOASM = 0 LINKED_GTK = 0 BUILD32_ON_64 ?= 0 # DO NOT SET THIS TO 1 AND COMMIT IT. USE_LIBPNG ?= 1 USE_LIBVPX ?= 1 ifeq (0,$(USE_OPENGL)) POLYMER = 0 USE_LIBVPX = 0 endif # Debugging/Build options # CPLUSPLUS - 1 = enable C++ building # RELEASE - 1 = no debugging # DEBUGANYWAY - 1 = include debug symbols even when generating release code # DISABLEINLINING - 1 = compile inline functions as extern instead of static inline # KRANDDEBUG - 1 = include logging of krand() calls for debugging the demo system # EFENCE - 1 = compile with Electric Fence for malloc() debugging # OPTLEVEL - 0..3 = GCC optimization strategy # LTO - 1 = enable link-time optimization, for GCC 4.5 and up # CPLUSPLUS?=0 RELEASE?=1 DEBUGANYWAY?=0 KRANDDEBUG?=0 DISABLEINLINING?=0 EFENCE?=0 DMALLOC?=0 OPTLEVEL?=2 PROFILER?=0 MUDFLAP?=0 ifndef LTO LTO=1 ifneq (0,$(CLANG)) ifeq ($(PLATFORM), WINDOWS) LTO=0 endif endif endif ifeq (4,$(GCC_MAJOR)) endif ifeq (4,$(GCC_MAJOR)) F_NO_STACK_PROTECTOR := -fno-stack-protector # there are some link-time issues with stack protectors, so make it possible to override F_STACK_PROTECTOR_ALL ?= -fstack-protector-all ifeq (0,$(CLANG)) F_JUMP_TABLES := -fjump-tables endif M_TUNE_GENERIC := -mtune=generic M_STACKREALIGN := -mstackrealign W_STRICT_OVERFLOW := -Wstrict-overflow=1 endif ifeq ($(PLATFORM),DARWIN) DARWINVERSION?=$(strip $(shell uname -r | cut -d . -f 1)) ifeq (1,$(strip $(shell expr $(DARWINVERSION) \< 10))) DARWIN9 ?= 1 endif # BASECOMMONFLAGS += -fno-leading-underscore ifeq (1,$(DARWIN9)) F_JUMP_TABLES := W_STRICT_OVERFLOW := endif ifeq (1,$(BUILD32_ON_64)) BASECOMMONFLAGS += $(F_NO_STACK_PROTECTOR) else ifeq ($(findstring ppc,$(ARCH)),ppc) BASECOMMONFLAGS += $(F_NO_STACK_PROTECTOR) endif endif endif ifndef OPTOPT ifeq ($(PLATFORM), WII) OPTOPT= else OPTOPTARCH=$(ARCH) ifeq (,$(OPTOPTARCH)) OPTOPTARCH=$(SYSARCH) endif ifeq (i686,$(findstring i686, $(OPTOPTARCH))) OPTOPT=-march=pentium3 $(M_TUNE_GENERIC) -mmmx # -msse2 -mfpmath=sse,387 -malign-double $(M_STACKREALIGN) else OPTOPT= endif endif ifneq (,$(CUSTOMOPT)) OPTOPT+= $(CUSTOMOPT) endif endif ifneq (0,$(KRANDDEBUG)) RELEASE=0 endif ifneq (0,$(PROFILER)) DEBUGANYWAY=1 endif # compiler flags etc. BASECFLAGS= -Wno-attributes BASECONLYFLAGS=-Wimplicit -Wdeclaration-after-statement BASECXXFLAGS= -fno-exceptions -fno-rtti -fpermissive -Wno-write-strings -Wno-narrowing BASEASFLAGS=-s #-g BASELDFLAGS= ifeq ($(PLATFORM),WII) override USE_LIBPNG = 0 override USE_LIBVPX = 0 endif LIBS=-lm ifneq (0,$(USE_LIBVPX)) # On Windows, we link statically to libvpx LIBS+= -lvpx endif ifneq ($(RELEASE)$(DEBUGANYWAY),10) # debug build or DEBUGANYWAY=1 --> -g flag ifneq (0,$(CLANG)) debug=-g else ifeq ($(PLATFORM), WII) debug=-g else debug=-ggdb endif endif ifneq (0,$(RELEASE)) # Debugging disabled debug+= -O$(OPTLEVEL) ifeq (0,$(CLANG)) debug+= -funswitch-loops endif ifeq (0,$(DEBUGANYWAY)) debug+= -fomit-frame-pointer -DNDEBUG else debug+= -DDEBUGGINGAIDS endif ifneq (0,$(LTO)) BASELDFLAGS+= -flto debug+= -DUSING_LTO -flto endif else # Debugging enabled debug+= -O0 ifeq (0,$(DEBUGANYWAY)) debug+= -DDEBUGGINGAIDS else debug+= -DDEBUGGINGAIDS=2 endif ifneq (0,$(CLANG)) # CLANG_MAJOR := $(shell clang -dM -E -x c /dev/null | grep __clang_major__ | awk '{ print $$3 }') BASECFLAGS+= -Xclang -fcatch-undefined-behavior # ifeq ($(CLANG_MAJOR),3) # debug+= -faddress-sanitizer # endif endif ifeq ($(PLATFORM),LINUX) LIBS+=-rdynamic endif ifneq (0,$(MUDFLAP)) LIBS+= -lmudflapth debug+= -fmudflapth endif ifneq (0,$(PROFILER)) # might need to be disabled for Darwin: LIBS+= -lprofiler debug+= -pg endif ifneq (0,$(KRANDDEBUG)) debug+=-DKRANDDEBUG=1 endif endif ifeq (0,$(CLANG)) # W_NO_UNUSED_RESULT := $(shell echo '' | $(CC) -E -Wno-unused-result - 2>/dev/null && echo -Wno-unused-result) # W_NO_UNUSED_RESULT := $(findstring -Wno-unused-result,$(W_NO_UNUSED_RESULT)) W_NO_UNUSED_RESULT := -Wno-unused-result else W_NO_UNUSED_RESULT := endif CWARNS := -W -Wall -Werror-implicit-function-declaration \ -Wpointer-arith \ -Wextra \ #-Wstrict-prototypes \ #-Waggregate-return \ #-Wwrite-strings \ #-Wcast-qual -Wcast-align \ #-Waddress -Wlogical-op BASECOMMONFLAGS=$(debug) $(OPTOPT) $(CWARNS) \ -funsigned-char -fno-strict-aliasing -DNO_GCC_BUILTINS -D_FORTIFY_SOURCE=2 \ $(F_JUMP_TABLES) $(W_NO_UNUSED_RESULT) $(ARCH) ifneq (0,$(CLANG)) BASECOMMONFLAGS+= -Wno-unused-value -Wno-parentheses endif #### Lunatic development, do not touch! LUNATIC=0 LUAJIT=luajit # for LJ headers: LUAJIT_WIN_SRC:= g:/mod/LuaJIT-2.0.0-beta8/src ifneq ($(LUNATIC),0) # FIXME: Lunatic doesn't build with inlining because of wacky include # chains! override DISABLEINLINING=1 ifeq ($(PLATFORM),WINDOWS) BASECOMMONFLAGS+= -I$(LUAJIT_WIN_SRC) else BASECOMMONFLAGS+= -I/usr/local/include/luajit-2.0 endif BASECOMMONFLAGS+= -I$(SRC)/lunatic -DLUNATIC ifeq ($(PLATFORM),WINDOWS) LIBS+= -LWindows/lib -lluajit else LIBS+= -lluajit-5.1 endif endif #### ifneq (0,$(DISABLEINLINING)) BASECOMMONFLAGS+= -DDISABLE_INLINING endif BASELDFLAGS+= $(OPTOPT) # This should come from the environment: ifdef EDUKE32_MY_DEVELOPER_ID BASECOMMONFLAGS+= -DMY_DEVELOPER_ID=$(EDUKE32_MY_DEVELOPER_ID) endif ifneq (0,$(USE_LIBPNG)) BASECOMMONFLAGS+= -DUSE_LIBPNG endif ifneq (0,$(USE_LIBVPX)) BASECOMMONFLAGS+= -DUSE_LIBVPX endif ifneq (0,$(OSX_STARTUPWINDOW)) BASECOMMONFLAGS+= -DOSX_STARTUPWINDOW endif ifneq (0,$(EFENCE)) LIBS+= -lefence BASECOMMONFLAGS+= -DEFENCE endif ifneq (0,$(DMALLOC)) LIBS+= -ldmalloc BASECOMMONFLAGS+= -DDMALLOC endif # Misc. stuff that is constant between Makefiles EROOT:=build # will be potentially overridden in build/Makefile.shared EXESUFFIX=