SRB2/src/Makefile.cfg
Alam Ed Arias 9301344003 Merge branch 'macosx-hacking' into 'master'
OS X Makefile build setup

This merge request:

* Cleans up the OS X bundle resource location code and fixes a SIGSEGV and memory leak
* Simplifies and fixes the OS X desktop alert code, closing more leaks
* Adds the MACOSX build flag to the Makefiles, to allow building a binary (but not Mac app yet) of SRB2.

This is intended to make it easier for developers to build on Mac OS X, without having to pull in all of XCode. You can keep using CMake if you prefer.

To test, use `make -C src MACOSX=1 NONX86=1 SDL=1 NOASM=1` for a release build.

Left to do:

* Add a content bundling script to be run after building, and a flag to trigger doing that.
  `MACOSX_BUNDLE` maybe?
* Somehow get access to a Mac running PowerPC and figure out how to build a multi-platform binary.
* Add the proper magic to compile using gcc if requested. (Right now, compilation is done via LLVM/Clang)

See merge request !72
2016-07-21 15:38:46 -04:00

434 lines
5.9 KiB
INI

#
# Makefile.cfg for SRB2
#
#
# GNU compiler & tools' flags
# and other things
#
ifdef GCC53
GCC52=1
endif
ifdef GCC52
GCC51=1
endif
ifdef GCC51
GCC49=1
endif
ifdef GCC49
GCC48=1
endif
ifdef GCC48
GCC47=1
endif
ifdef GCC47
GCC46=1
endif
ifdef GCC46
GCC45=1
endif
ifdef GCC45
GCC44=1
endif
ifdef GCC44
GCC43=1
endif
ifdef GCC43
GCC42=1
endif
ifdef GCC42
GCC41=1
endif
ifdef GCC41
GCC40=1
VCHELP=1
endif
ifdef GCC295
GCC29=1
endif
ifdef DC
NOCASTALIGNWARN=1
endif
OLDWFLAGS:=$(WFLAGS)
# -W -Wno-unused
WFLAGS=-Wall
ifndef GCC295
#WFLAGS+=-Wno-packed
endif
ifdef ERRORMODE
WARNINGMODE=1
endif
ifdef WARNINGMODE
WFLAGS+=-W
#WFLAGS+=-Wno-sign-compare
ifndef GCC295
WFLAGS+=-Wno-div-by-zero
endif
#WFLAGS+=-Wsystem-headers
ifndef ERRORMODE
#WFLAGS+=-Wfloat-equal
endif
#WFLAGS+=-Wtraditional
ifdef VCHELP
WFLAGS+=-Wdeclaration-after-statement
endif
WFLAGS+=-Wundef
ifndef GCC295
WFLAGS+=-Wendif-labels
endif
ifdef GCC41
WFLAGS+=-Wshadow
endif
#WFLAGS+=-Wlarger-than-%len%
WFLAGS+=-Wpointer-arith -Wbad-function-cast
ifdef GCC45
#WFLAGS+=-Wc++-compat
endif
WFLAGS+=-Wcast-qual
ifndef NOCASTALIGNWARN
WFLAGS+=-Wcast-align
endif
WFLAGS+=-Wwrite-strings
ifndef ERRORMODE
#WFLAGS+=-Wconversion
ifdef GCC43
#WFLAGS+=-Wno-sign-conversion
endif
endif
WFLAGS+=-Wsign-compare
ifdef GCC45
WFLAGS+=-Wlogical-op
endif
WFLAGS+=-Waggregate-return
ifdef HAIKU
ifdef GCC41
#WFLAGS+=-Wno-attributes
endif
endif
#WFLAGS+=-Wstrict-prototypes
ifdef GCC40
WFLAGS+=-Wold-style-definition
endif
ifndef XBOX
WFLAGS+=-Wmissing-prototypes -Wmissing-declarations
endif
ifdef GCC40
WFLAGS+=-Wmissing-field-initializers
endif
ifndef XBOX
WFLAGS+=-Wmissing-noreturn
endif
#WFLAGS+=-Wmissing-format-attribute
#WFLAGS+=-Wno-multichar
#WFLAGS+=-Wno-deprecated-declarations
#WFLAGS+=-Wpacked
#WFLAGS+=-Wpadded
#WFLAGS+=-Wredundant-decls
WFLAGS+=-Wnested-externs
#WFLAGS+=-Wunreachable-code
WFLAGS+=-Winline
ifdef GCC43
WFLAGS+=-funit-at-a-time
WFLAGS+=-Wlogical-op
endif
ifndef GCC295
WFLAGS+=-Wdisabled-optimization
endif
endif
WFLAGS+=-Wformat-y2k
WFLAGS+=-Wformat-security
ifndef GCC29
#WFLAGS+=-Winit-self
endif
ifdef GCC46
WFLAGS+=-Wno-suggest-attribute=noreturn
endif
ifndef MINGW
ifdef GCC45
WFLAGS+=-Wunsuffixed-float-constants
endif
endif
ifdef NOLDWARNING
LDFLAGS+=-Wl,--as-needed
endif
ifdef ERRORMODE
WFLAGS+=-Werror
endif
ifdef GCC43
#WFLAGS+=-Wno-error=clobbered
endif
ifdef GCC46
WFLAGS+=-Wno-error=suggest-attribute=noreturn
endif
WFLAGS+=$(OLDWFLAGS)
#indicate platform and what interface use with
ifndef WINCE
ifndef XBOX
ifndef PSP
ifndef DC
ifndef WII
ifndef PS3N
ifndef LINUX
ifndef FREEBSD
ifndef CYGWIN32
ifndef MINGW
ifndef SDL
ifndef NDS
ifndef DUMMY
DJGPPDOS=1
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
#determine the interface directory (where you put all i_*.c)
i_cdmus_o=$(OBJDIR)/i_cdmus.o
i_net_o=$(OBJDIR)/i_net.o
i_system_o=$(OBJDIR)/i_system.o
i_sound_o=$(OBJDIR)/i_sound.o
i_main_o=$(OBJDIR)/i_main.o
#set OBJDIR and BIN's starting place
OBJDIR=../objs
BIN=../bin
#Nasm ASM and rm
ifdef YASM
NASM?=yasm
else
NASM?=nasm
endif
REMOVE?=rm -f
CP?=cp
MKDIR?=mkdir -p
MKISOFS?=mkisofs
DD?=dd
GZIP?=gzip
GZIP_OPTS?=-9 -f -n
GZIP_OPT2=$(GZIP_OPTS) --rsyncable
UPX?=upx
UPX_OPTS?=--best --preserve-build-id
ifndef ECHO
UPX_OPTS+=-q
endif
#Interface Setup
ifdef DJGPPDOS
INTERFACE=djgppdos
NASMFORMAT=coff
OBJDIR:=$(OBJDIR)/djgppdos
ifdef WATTCP
OBJDIR:=$(OBJDIR)/wattcp
endif
WFLAGS+=-Wno-format
BIN:=$(BIN)/Dos
else
ifdef DUMMY
INTERFACE=dummy
OBJDIR:=$(OBJDIR)/dummy
BIN:=$(BIN)/dummy
else
ifdef LINUX
NASMFORMAT=elf -DLINUX
SDL=1
ifndef NOGETTEXT
GETTEXT=1
endif
ifdef LINUX64
OBJDIR:=$(OBJDIR)/Linux64
BIN:=$(BIN)/Linux64
else
OBJDIR:=$(OBJDIR)/Linux
BIN:=$(BIN)/Linux
endif
else
ifdef FREEBSD
INTERFACE=sdl
NASMFORMAT=elf -DLINUX
SDL=1
OBJDIR:=$(OBJDIR)/FreeBSD
BIN:=$(BIN)/FreeBSD
else
ifdef SOLARIS
INTERFACE=sdl
NASMFORMAT=elf -DLINUX
SDL=1
OBJDIR:=$(OBJDIR)/Solaris
BIN:=$(BIN)/Solaris
else
ifdef CYGWIN32
INTERFACE=sdl
NASMFORMAT=win32
SDL=1
OBJDIR:=$(OBJDIR)/cygwin
BIN:=$(BIN)/Cygwin
else
ifdef MINGW64
INTERFACE=win32
#NASMFORMAT=win64
ifndef NOGETTEXT
#GETTEXT=1
endif
OBJDIR:=$(OBJDIR)/Mingw64
BIN:=$(BIN)/Mingw64
else
ifdef WII
INTERFACE=sdl
NONX86=1
STATIC=1
PREFIX?=powerpc-eabi
SDL=1
SDLMAIN=1
OBJDIR:=$(OBJDIR)/Wii
BIN:=$(BIN)/Wii
NOUPX=1
else
ifdef PS3N
INTERFACE=sdl
NONX86=1
STATIC=1
PREFIX?=ppu
SDL=1
# unsure?
#SDLMAIN=1
# can't compile SDL_mixer for ps3...
NOMIXER=1
OBJDIR:=$(OBJDIR)/PS3
BIN:=$(BIN)/PS3
else
ifdef MINGW
INTERFACE=win32
NASMFORMAT=win32
ifndef NOGETTEXT
GETTEXT=1
endif
OBJDIR:=$(OBJDIR)/Mingw
BIN:=$(BIN)/Mingw
else
ifdef XBOX
INTERFACE=sdl
NASMFORMAT=win32
PREFIX?=/usr/local/openxdk/bin/i386-pc-xbox
SDL=1
OBJDIR:=$(OBJDIR)/XBOX
BIN:=$(BIN)/XBOX
else
ifdef PSP
INTERFACE=sdl
NONX86=1
SDL=1
OBJDIR:=$(OBJDIR)/PSP
BIN:=$(BIN)/PSP
NOUPX=1
else
ifdef DC
INTERFACE=sdl
NONX86=1
SDL=1
OBJDIR:=$(OBJDIR)/DC
BIN:=$(BIN)/DC
NOUPX=1
else
ifdef WINCE
INTERFACE=sdl
NONX86=1
PREFIX?=arm-wince-pe
SDL=1
OBJDIR:=$(OBJDIR)/WinCE
BIN:=$(BIN)/WinCE
else
ifdef NDS
INTERFACE=nds
OBJDIR:=$(OBJDIR)/nds
BIN:=$(BIN)/nds
NOUPX=1
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
ifdef ARCHNAME
OBJDIR:=$(OBJDIR)/$(ARCHNAME)
BIN:=$(BIN)/$(ARCHNAME)
endif
# gcc or g++
ifdef PREFIX
CC=$(PREFIX)-gcc
CXX=$(PREFIX)-g++
OBJCOPY=$(PREFIX)-objcopy
OBJDUMP=$(PREFIX)-objdump
STRIP=$(PREFIX)-strip
WINDRES=$(PREFIX)-windres
else
OBJCOPY=objcopy
OBJDUMP=objdump
STRIP=strip
WINDRES=windres
endif
# because Apple screws with us on this
# need to get bintools from homebrew
ifdef MACOSX
CC=clang
CXX=clang
OBJCOPY=gobjcopy
OBJDUMP=gobjdump
endif
OBJDUMP_OPTS?=--wide --source --line-numbers
LD=$(CC)
ifdef SDL
INTERFACE=sdl
OBJDIR:=$(OBJDIR)/SDL
endif
ifndef DUMMY
ifdef DEBUGMODE
OBJDIR:=$(OBJDIR)/Debug
BIN:=$(BIN)/Debug
else
OBJDIR:=$(OBJDIR)/Release
BIN:=$(BIN)/Release
endif
endif