2010-12-19 22:29:01 +00:00
|
|
|
|
|
|
|
## common definitions for Makefile, build/Makefile, source/enet/Makefile and
|
|
|
|
## source/jaudiolib/Makefile
|
|
|
|
|
|
|
|
# Use colored output
|
2011-02-12 13:25:24 +00:00
|
|
|
PRETTY_OUTPUT ?= 1
|
2010-12-19 22:29:01 +00:00
|
|
|
|
2012-10-29 04:26:25 +00:00
|
|
|
# Tools
|
|
|
|
CC=gcc
|
|
|
|
CXX=g++
|
|
|
|
AS=nasm
|
|
|
|
AR=ar
|
|
|
|
RC=windres
|
|
|
|
RANLIB=ranlib
|
|
|
|
STRIP=strip
|
|
|
|
|
|
|
|
CLANG?=0
|
|
|
|
|
|
|
|
ifneq (0,$(CLANG))
|
|
|
|
CC=clang -std=gnu89
|
|
|
|
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
|
|
|
|
|
2012-03-14 06:27:45 +00:00
|
|
|
# Binary suffix override:
|
|
|
|
EXESUFFIX_OVERRIDE ?=
|
|
|
|
|
2010-12-19 22:29:01 +00:00
|
|
|
# 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:=
|
|
|
|
|
2012-03-04 09:31:37 +00:00
|
|
|
# Mac OS X Frameworks location
|
|
|
|
# Like above, use absolute paths.
|
|
|
|
APPLE_FRAMEWORKS ?=/Library/Frameworks
|
2012-03-08 06:07:10 +00:00
|
|
|
# Since the OS X startup window is generating errors, disable it by default.
|
|
|
|
OSX_STARTUPWINDOW ?= 0
|
2012-03-04 09:31:37 +00:00
|
|
|
|
2010-12-19 22:29:01 +00:00
|
|
|
# Engine options
|
2011-03-04 08:50:58 +00:00
|
|
|
# USE_OPENGL - enables basic OpenGL Polymost renderer
|
|
|
|
# POLYMER - enables fancy Polymer renderer
|
2010-12-19 22:29:01 +00:00
|
|
|
# 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
|
2011-06-17 13:11:19 +00:00
|
|
|
BUILD32_ON_64 ?= 0
|
2011-03-19 17:59:09 +00:00
|
|
|
# DO NOT SET THIS TO 1 AND COMMIT IT.
|
2012-07-20 21:57:53 +00:00
|
|
|
USE_LIBPNG ?= 1
|
2011-10-11 16:53:52 +00:00
|
|
|
USE_LIBVPX ?= 1
|
2010-12-19 22:29:01 +00:00
|
|
|
|
2012-10-29 04:26:25 +00:00
|
|
|
|
2010-12-19 22:29:01 +00:00
|
|
|
ifeq (0,$(USE_OPENGL))
|
|
|
|
POLYMER = 0
|
2011-07-18 19:06:29 +00:00
|
|
|
USE_LIBVPX = 0
|
2010-12-19 22:29:01 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
# Debugging/Build options
|
|
|
|
# RELEASE - 1 = no debugging
|
|
|
|
# DEBUGANYWAY - 1 = include debug symbols even when generating release code
|
|
|
|
# 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
|
2011-03-25 11:42:07 +00:00
|
|
|
# LTO - 1 = enable link-time optimization, for GCC 4.5 and up
|
2010-12-19 22:29:01 +00:00
|
|
|
#
|
|
|
|
RELEASE?=1
|
|
|
|
DEBUGANYWAY?=0
|
|
|
|
KRANDDEBUG?=0
|
|
|
|
EFENCE?=0
|
2012-01-12 20:49:34 +00:00
|
|
|
DMALLOC?=0
|
2010-12-19 22:29:01 +00:00
|
|
|
OPTLEVEL?=2
|
|
|
|
PROFILER?=0
|
2011-03-19 17:59:09 +00:00
|
|
|
MUDFLAP?=0
|
2011-03-25 11:42:07 +00:00
|
|
|
LTO?=0
|
2012-10-29 04:26:25 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
# BASECFLAGS += -fno-leading-underscore
|
|
|
|
|
|
|
|
ifeq (1,$(DARWIN9))
|
|
|
|
F_JUMP_TABLES :=
|
|
|
|
W_STRICT_OVERFLOW :=
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq (1,$(BUILD32_ON_64))
|
|
|
|
BASECFLAGS += $(F_NO_STACK_PROTECTOR)
|
|
|
|
else
|
|
|
|
ifeq ($(findstring ppc,$(ARCH)),ppc)
|
|
|
|
BASECFLAGS += $(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
|
2010-12-19 22:29:01 +00:00
|
|
|
|
|
|
|
ifneq (0,$(KRANDDEBUG))
|
|
|
|
RELEASE=0
|
|
|
|
endif
|
|
|
|
ifneq (0,$(PROFILER))
|
|
|
|
DEBUGANYWAY=1
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2012-03-12 04:49:16 +00:00
|
|
|
|
2010-12-19 22:29:01 +00:00
|
|
|
# compiler flags etc.
|
2012-10-29 04:28:10 +00:00
|
|
|
BASECONLYFLAGS=-Wimplicit -Wdeclaration-after-statement
|
2012-03-23 20:22:10 +00:00
|
|
|
BASECXXFLAGS= -fno-exceptions -fno-rtti
|
|
|
|
BASEASFLAGS=-s #-g
|
|
|
|
BASELDFLAGS=
|
|
|
|
|
2012-05-20 07:25:25 +00:00
|
|
|
ifeq ($(PLATFORM),WII)
|
|
|
|
override USE_LIBPNG = 0
|
|
|
|
override USE_LIBVPX = 0
|
|
|
|
endif
|
|
|
|
|
2010-12-19 22:29:01 +00:00
|
|
|
LIBS=-lm
|
2011-07-18 19:06:29 +00:00
|
|
|
ifneq (0,$(USE_LIBVPX))
|
2011-09-21 22:38:37 +00:00
|
|
|
# On Windows, we link statically to libvpx
|
2011-07-18 19:06:29 +00:00
|
|
|
LIBS+= -lvpx
|
|
|
|
endif
|
2011-03-19 18:07:12 +00:00
|
|
|
|
2012-01-28 14:36:52 +00:00
|
|
|
|
|
|
|
ifneq ($(RELEASE)$(DEBUGANYWAY),10)
|
|
|
|
# debug build or DEBUGANYWAY=1 --> -g flag
|
2012-05-18 21:40:38 +00:00
|
|
|
ifneq (0,$(CLANG))
|
2012-01-28 14:36:52 +00:00
|
|
|
debug=-g
|
2012-05-20 07:25:25 +00:00
|
|
|
else ifeq ($(PLATFORM), WII)
|
|
|
|
debug=-g
|
2012-01-28 14:36:52 +00:00
|
|
|
else
|
|
|
|
debug=-ggdb
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2010-12-19 22:29:01 +00:00
|
|
|
ifneq (0,$(RELEASE))
|
|
|
|
# Debugging disabled
|
2012-01-28 14:36:52 +00:00
|
|
|
debug+= -O$(OPTLEVEL)
|
2012-05-18 21:40:38 +00:00
|
|
|
ifeq (0,$(CLANG))
|
2012-01-28 14:36:52 +00:00
|
|
|
debug+= -funswitch-loops
|
2011-12-15 22:43:01 +00:00
|
|
|
endif
|
2011-09-22 16:52:55 +00:00
|
|
|
ifeq (0,$(DEBUGANYWAY))
|
2012-01-07 20:37:48 +00:00
|
|
|
debug+= -fomit-frame-pointer -DNDEBUG
|
2011-09-22 16:52:55 +00:00
|
|
|
endif
|
2011-03-25 11:42:07 +00:00
|
|
|
ifneq (0,$(LTO))
|
2012-03-23 20:22:10 +00:00
|
|
|
BASELDFLAGS+= -flto
|
2011-11-10 21:47:03 +00:00
|
|
|
debug+= -DUSING_LTO -flto
|
2011-03-25 11:42:07 +00:00
|
|
|
endif
|
2010-12-19 22:29:01 +00:00
|
|
|
else
|
|
|
|
# Debugging enabled
|
2012-01-28 14:36:52 +00:00
|
|
|
debug+= -O0
|
|
|
|
|
Inreased debugging level for catching oob accesses to 'main' arrays.
If enabled, this makes the following arrays be allocated statically:
spriteext, spritesmooth, sector, wall, sprite, tsprite, while
necessarily disabling the clipshape feature (because it relies on
setting sector/wall to different malloc'd block temporarily).
To compile, pass DEBUGANYWAY=1 in addition to RELEASE=0 to 'make',
and it's really only useful with CC=clang, of course.
git-svn-id: https://svn.eduke32.com/eduke32@2270 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-19 23:17:34 +00:00
|
|
|
ifeq (0,$(DEBUGANYWAY))
|
|
|
|
debug+= -DDEBUGGINGAIDS
|
|
|
|
else
|
|
|
|
debug+= -DDEBUGGINGAIDS=2
|
|
|
|
endif
|
|
|
|
|
2012-05-18 21:40:38 +00:00
|
|
|
ifneq (0,$(CLANG))
|
2012-01-28 14:36:52 +00:00
|
|
|
# CLANG_MAJOR := $(shell clang -dM -E -x c /dev/null | grep __clang_major__ | awk '{ print $$3 }')
|
2011-12-09 19:09:00 +00:00
|
|
|
debug+= -fcatch-undefined-behavior
|
2012-01-28 14:36:52 +00:00
|
|
|
# ifeq ($(CLANG_MAJOR),3)
|
|
|
|
# debug+= -faddress-sanitizer
|
|
|
|
# endif
|
2011-12-09 19:09:00 +00:00
|
|
|
endif
|
2011-01-16 07:19:29 +00:00
|
|
|
ifeq ($(PLATFORM),LINUX)
|
|
|
|
LIBS+=-rdynamic
|
|
|
|
endif
|
2011-03-19 17:59:09 +00:00
|
|
|
ifneq (0,$(MUDFLAP))
|
|
|
|
LIBS+= -lmudflapth
|
|
|
|
debug+= -fmudflapth
|
|
|
|
endif
|
2010-12-19 22:29:01 +00:00
|
|
|
ifneq (0,$(PROFILER))
|
2011-07-20 23:04:20 +00:00
|
|
|
# might need to be disabled for Darwin:
|
2010-12-19 22:29:01 +00:00
|
|
|
LIBS+= -lprofiler
|
|
|
|
debug+= -pg
|
|
|
|
endif
|
|
|
|
ifneq (0,$(KRANDDEBUG))
|
|
|
|
debug+=-DKRANDDEBUG=1
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2012-05-18 21:40:38 +00:00
|
|
|
ifeq (0,$(CLANG))
|
2012-08-27 03:48:27 +00:00
|
|
|
# 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
|
2011-12-09 19:08:47 +00:00
|
|
|
else
|
|
|
|
W_NO_UNUSED_RESULT :=
|
|
|
|
endif
|
2011-02-12 13:25:24 +00:00
|
|
|
|
2012-10-29 04:28:10 +00:00
|
|
|
CWARNS := -W -Wall -Werror-implicit-function-declaration \
|
2012-07-01 22:11:35 +00:00
|
|
|
-Wpointer-arith \
|
|
|
|
-Wextra \
|
|
|
|
#-Wstrict-prototypes \
|
|
|
|
#-Waggregate-return \
|
|
|
|
#-Wwrite-strings \
|
|
|
|
#-Wcast-qual -Wcast-align \
|
|
|
|
#-Waddress -Wlogical-op
|
|
|
|
|
2012-10-29 04:26:25 +00:00
|
|
|
BASECFLAGS=$(debug) $(OPTOPT) $(CWARNS) \
|
2010-12-19 22:29:01 +00:00
|
|
|
-funsigned-char -fno-strict-aliasing -DNO_GCC_BUILTINS -D_FORTIFY_SOURCE=2 \
|
2012-07-01 22:11:35 +00:00
|
|
|
$(F_JUMP_TABLES) $(W_NO_UNUSED_RESULT) $(ARCH)
|
2012-05-18 21:40:38 +00:00
|
|
|
ifneq (0,$(CLANG))
|
2011-12-09 19:08:47 +00:00
|
|
|
BASECFLAGS+= -Wno-unused-value -Wno-parentheses
|
|
|
|
endif
|
|
|
|
|
2012-10-29 04:26:25 +00:00
|
|
|
BASELDFLAGS+= $(OPTOPT)
|
|
|
|
|
2012-06-01 20:09:27 +00:00
|
|
|
# This should come from the environment:
|
|
|
|
ifdef EDUKE32_MY_DEVELOPER_ID
|
|
|
|
BASECFLAGS+= -DMY_DEVELOPER_ID=$(EDUKE32_MY_DEVELOPER_ID)
|
|
|
|
endif
|
|
|
|
|
2011-03-19 18:07:12 +00:00
|
|
|
ifneq (0,$(USE_LIBPNG))
|
|
|
|
BASECFLAGS+= -DUSE_LIBPNG
|
|
|
|
endif
|
2011-07-18 19:06:29 +00:00
|
|
|
ifneq (0,$(USE_LIBVPX))
|
|
|
|
BASECFLAGS+= -DUSE_LIBVPX
|
|
|
|
endif
|
2012-03-08 06:07:10 +00:00
|
|
|
ifneq (0,$(OSX_STARTUPWINDOW))
|
|
|
|
BASECFLAGS+= -DOSX_STARTUPWINDOW
|
|
|
|
endif
|
2010-12-19 22:29:01 +00:00
|
|
|
|
2011-10-02 07:16:57 +00:00
|
|
|
ifneq (0,$(EFENCE))
|
|
|
|
LIBS+= -lefence
|
|
|
|
BASECFLAGS+= -DEFENCE
|
|
|
|
endif
|
2012-01-12 20:49:34 +00:00
|
|
|
ifneq (0,$(DMALLOC))
|
|
|
|
LIBS+= -ldmalloc
|
|
|
|
BASECFLAGS+= -DDMALLOC
|
|
|
|
endif
|
2011-10-02 07:16:57 +00:00
|
|
|
|
2010-12-19 22:29:01 +00:00
|
|
|
# Misc. stuff that is constant between Makefiles
|
|
|
|
EROOT:=build
|
|
|
|
|
|
|
|
# will be potentially overridden in build/Makefile.shared
|
|
|
|
EXESUFFIX=
|