2015-03-02 22:04:26 +00:00
|
|
|
# GNU Makefile for compiling Mac OS X version of QuakeSpasm.
|
2011-08-27 07:11:36 +00:00
|
|
|
# Usage: "make -f Makefile.darwin"
|
2015-03-02 22:04:26 +00:00
|
|
|
# To cross-compile on Linux hosts, see the "build_cross_osx*.sh" scripts.
|
2011-08-27 07:11:36 +00:00
|
|
|
# "make DEBUG=1" to build a debug client.
|
2015-03-02 22:04:26 +00:00
|
|
|
# "make SDL_FRAMEWORK_PATH=/path/to/Frameworks" to specify the directory
|
|
|
|
# containing SDL.framework and override the locally included versions.
|
2014-09-10 07:28:28 +00:00
|
|
|
# "make DO_USERDIRS=1" to enable user directories support
|
|
|
|
|
|
|
|
# Enable/Disable user directories support
|
|
|
|
DO_USERDIRS=0
|
2011-04-24 03:01:40 +00:00
|
|
|
|
2014-09-11 18:47:07 +00:00
|
|
|
### Enable/Disable SDL2
|
|
|
|
USE_SDL2=0
|
|
|
|
|
2011-08-27 07:11:36 +00:00
|
|
|
### Enable/Disable codecs for streaming music support
|
2011-04-24 03:01:40 +00:00
|
|
|
USE_CODEC_WAVE=1
|
2013-07-21 14:02:06 +00:00
|
|
|
USE_CODEC_FLAC=1
|
2011-04-24 03:01:40 +00:00
|
|
|
USE_CODEC_MP3=1
|
|
|
|
USE_CODEC_VORBIS=1
|
2013-07-18 07:03:11 +00:00
|
|
|
USE_CODEC_OPUS=1
|
2013-09-25 11:01:12 +00:00
|
|
|
# either mikmod (preferred) or modplug, not both
|
2014-06-21 15:50:09 +00:00
|
|
|
USE_CODEC_MIKMOD=1
|
2013-09-25 11:01:12 +00:00
|
|
|
USE_CODEC_MODPLUG=0
|
2014-06-21 15:50:09 +00:00
|
|
|
USE_CODEC_UMX=1
|
2011-01-12 09:32:22 +00:00
|
|
|
|
2011-08-27 07:11:36 +00:00
|
|
|
# which library to use for mp3 decoding: mad or mpg123
|
2012-08-16 04:51:41 +00:00
|
|
|
MP3LIB=mad
|
2011-08-27 07:11:36 +00:00
|
|
|
# which library to use for ogg decoding: vorbis or tremor
|
|
|
|
VORBISLIB=vorbis
|
2011-01-11 08:19:22 +00:00
|
|
|
|
2012-10-25 11:15:15 +00:00
|
|
|
# ---------------------------
|
2010-04-22 00:30:57 +00:00
|
|
|
# Helper functions
|
2012-10-25 11:15:15 +00:00
|
|
|
# ---------------------------
|
2010-04-22 00:30:57 +00:00
|
|
|
|
2012-10-25 11:15:15 +00:00
|
|
|
check_gcc = $(shell if echo | $(CC) $(1) -Werror -S -o /dev/null -xc - > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi;)
|
2010-04-22 00:30:57 +00:00
|
|
|
|
2012-10-25 11:15:15 +00:00
|
|
|
# ---------------------------
|
2011-01-12 09:32:22 +00:00
|
|
|
|
2012-05-30 09:28:34 +00:00
|
|
|
HOST_OS := $(shell uname|sed -e s/_.*//|tr '[:upper:]' '[:lower:]')
|
2012-08-16 04:51:41 +00:00
|
|
|
MACH_TYPE= $(shell sh detect.sh arch)
|
2010-04-22 00:30:57 +00:00
|
|
|
|
2012-05-30 09:28:34 +00:00
|
|
|
DEBUG ?= 0
|
|
|
|
|
2012-10-25 11:15:15 +00:00
|
|
|
# ---------------------------
|
2012-03-09 10:11:09 +00:00
|
|
|
# build variables
|
2012-10-25 11:15:15 +00:00
|
|
|
# ---------------------------
|
2010-04-22 00:30:57 +00:00
|
|
|
|
|
|
|
CC ?= gcc
|
2012-05-30 09:47:45 +00:00
|
|
|
LINKER = $(CC)
|
2012-09-02 14:00:34 +00:00
|
|
|
LIPO ?= lipo
|
|
|
|
|
|
|
|
STRIP ?= strip
|
2012-05-30 09:47:45 +00:00
|
|
|
|
2012-09-05 09:03:41 +00:00
|
|
|
CPUFLAGS=
|
|
|
|
LDFLAGS =
|
|
|
|
DFLAGS ?=
|
|
|
|
CFLAGS ?= -Wall
|
2014-09-20 08:37:30 +00:00
|
|
|
# @rpath can be used when targeting 10.5+
|
|
|
|
USE_RPATH=0
|
2012-08-16 04:51:41 +00:00
|
|
|
# require 10.5 for 64 bit builds
|
|
|
|
ifeq ($(MACH_TYPE),ppc64)
|
2012-09-05 09:03:41 +00:00
|
|
|
CFLAGS +=-mmacosx-version-min=10.5
|
2012-09-03 21:21:04 +00:00
|
|
|
LDFLAGS +=-mmacosx-version-min=10.5
|
2014-09-20 08:37:30 +00:00
|
|
|
USE_RPATH=1
|
2012-08-16 04:51:41 +00:00
|
|
|
endif
|
2014-09-17 11:00:28 +00:00
|
|
|
ifeq ($(USE_SDL2),1)
|
|
|
|
# sdl2 needs targetting 10.5+
|
2016-10-15 19:28:47 +00:00
|
|
|
# as of v2.0.5, sdl2 targets 10.6+
|
2014-09-17 11:00:28 +00:00
|
|
|
ifeq ($(MACH_TYPE),x86)
|
2016-10-15 19:28:47 +00:00
|
|
|
CFLAGS +=-mmacosx-version-min=10.6
|
2016-10-16 09:32:25 +00:00
|
|
|
LDFLAGS +=-mmacosx-version-min=10.6
|
2014-09-20 08:37:30 +00:00
|
|
|
USE_RPATH=1
|
2014-09-17 11:00:28 +00:00
|
|
|
endif
|
|
|
|
endif
|
2012-09-09 07:41:43 +00:00
|
|
|
ifeq ($(MACH_TYPE),x86_64)
|
|
|
|
# require 10.6 for amd64 builds, not 10.5 (SDL's requirement.)
|
|
|
|
# bundle1.o is needed for dyld_stub_binding_helper
|
|
|
|
CFLAGS +=-mmacosx-version-min=10.6
|
|
|
|
LDFLAGS +=-mmacosx-version-min=10.6 -Wl,-lbundle1.o
|
2014-09-20 08:37:30 +00:00
|
|
|
USE_RPATH=1
|
2012-09-09 07:41:43 +00:00
|
|
|
endif
|
2010-04-22 00:30:57 +00:00
|
|
|
CFLAGS += $(CPUFLAGS)
|
2014-09-20 08:37:30 +00:00
|
|
|
ifeq ($(USE_RPATH),1)
|
|
|
|
LDFLAGS+=-Wl,-rpath,@executable_path/../Frameworks
|
|
|
|
endif
|
2010-04-22 00:30:57 +00:00
|
|
|
|
|
|
|
ifneq ($(DEBUG),0)
|
|
|
|
DFLAGS += -DDEBUG
|
|
|
|
CFLAGS += -g
|
2010-04-24 14:50:18 +00:00
|
|
|
do_strip=
|
2010-04-22 00:30:57 +00:00
|
|
|
else
|
|
|
|
DFLAGS += -DNDEBUG
|
|
|
|
CFLAGS += -O2
|
|
|
|
CFLAGS += $(call check_gcc,-fweb,)
|
|
|
|
CFLAGS += $(call check_gcc,-frename-registers,)
|
2010-04-24 14:50:18 +00:00
|
|
|
cmd_strip=$(STRIP) $(1)
|
|
|
|
define do_strip
|
|
|
|
$(call cmd_strip,$(1));
|
|
|
|
endef
|
2010-04-22 00:30:57 +00:00
|
|
|
endif
|
|
|
|
|
2014-09-10 07:28:28 +00:00
|
|
|
ifeq ($(DO_USERDIRS),1)
|
|
|
|
CFLAGS += -DDO_USERDIRS=1
|
|
|
|
endif
|
|
|
|
|
2014-09-11 18:47:07 +00:00
|
|
|
ifeq ($(USE_SDL2),1)
|
|
|
|
CFLAGS += -DUSE_SDL2
|
|
|
|
endif
|
|
|
|
|
2012-08-16 04:51:41 +00:00
|
|
|
# not relying on sdl-config command and assuming
|
|
|
|
# /Library/Frameworks/SDL.framework is available
|
|
|
|
SDL_CFLAGS =-D_GNU_SOURCE=1 -D_THREAD_SAFE
|
|
|
|
SDL_CFLAGS+=-DSDL_FRAMEWORK -DNO_SDL_CONFIG
|
2014-09-11 18:47:07 +00:00
|
|
|
ifeq ($(USE_SDL2),1)
|
2014-09-20 08:37:30 +00:00
|
|
|
SDL_FRAMEWORK_NAME = SDL2
|
2014-09-11 18:47:07 +00:00
|
|
|
else
|
2014-09-20 08:37:30 +00:00
|
|
|
SDL_FRAMEWORK_NAME = SDL
|
|
|
|
endif
|
2015-03-02 21:43:04 +00:00
|
|
|
# default to our local SDL[2].framework for build
|
|
|
|
SDL_FRAMEWORK_PATH ?=../MacOSX
|
|
|
|
ifneq ($(SDL_FRAMEWORK_PATH),)
|
2015-03-02 22:03:18 +00:00
|
|
|
SDL_LIBS +=-F$(SDL_FRAMEWORK_PATH)
|
2014-09-20 08:37:30 +00:00
|
|
|
SDL_CFLAGS+=-F$(SDL_FRAMEWORK_PATH)
|
2014-09-11 18:47:07 +00:00
|
|
|
endif
|
2014-09-20 08:37:30 +00:00
|
|
|
SDL_LIBS +=-Wl,-framework,$(SDL_FRAMEWORK_NAME) -Wl,-framework,Cocoa
|
2010-04-22 00:30:57 +00:00
|
|
|
|
2010-09-01 06:10:21 +00:00
|
|
|
NET_LIBS :=
|
2010-04-22 00:30:57 +00:00
|
|
|
|
2011-08-27 07:11:36 +00:00
|
|
|
ifneq ($(VORBISLIB),vorbis)
|
|
|
|
ifneq ($(VORBISLIB),tremor)
|
|
|
|
$(error Invalid VORBISLIB setting)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
ifneq ($(MP3LIB),mpg123)
|
|
|
|
ifneq ($(MP3LIB),mad)
|
|
|
|
$(error Invalid MP3LIB setting)
|
|
|
|
endif
|
|
|
|
endif
|
2011-02-14 20:02:52 +00:00
|
|
|
ifeq ($(MP3LIB),mad)
|
|
|
|
mp3_obj=snd_mp3.o
|
2011-08-27 07:11:36 +00:00
|
|
|
lib_mp3dec=-lmad
|
|
|
|
endif
|
2011-02-14 20:02:52 +00:00
|
|
|
ifeq ($(MP3LIB),mpg123)
|
|
|
|
mp3_obj=snd_mpg123.o
|
2011-08-27 07:11:36 +00:00
|
|
|
lib_mp3dec=-lmpg123
|
|
|
|
endif
|
|
|
|
ifeq ($(VORBISLIB),vorbis)
|
|
|
|
cpp_vorbisdec=
|
|
|
|
lib_vorbisdec=-lvorbisfile -lvorbis -logg
|
2011-02-14 20:02:52 +00:00
|
|
|
endif
|
2011-08-27 07:11:36 +00:00
|
|
|
ifeq ($(VORBISLIB),tremor)
|
|
|
|
cpp_vorbisdec=-DVORBIS_USE_TREMOR
|
|
|
|
lib_vorbisdec=-lvorbisidec -logg
|
2011-02-14 20:02:52 +00:00
|
|
|
endif
|
|
|
|
|
2011-01-05 23:05:17 +00:00
|
|
|
CODECLIBS :=
|
2011-01-12 09:32:22 +00:00
|
|
|
ifeq ($(USE_CODEC_WAVE),1)
|
2011-01-05 23:05:17 +00:00
|
|
|
CFLAGS+= -DUSE_CODEC_WAVE
|
|
|
|
endif
|
2013-07-21 14:02:06 +00:00
|
|
|
ifeq ($(USE_CODEC_FLAC),1)
|
|
|
|
CFLAGS+= -DUSE_CODEC_FLAC
|
|
|
|
CODEC_INC = -I../MacOSX/codecs/include
|
|
|
|
CODEC_LINK= -L../MacOSX/codecs/lib
|
|
|
|
CODECLIBS+= -lFLAC
|
|
|
|
endif
|
2013-07-18 07:03:11 +00:00
|
|
|
ifeq ($(USE_CODEC_OPUS),1)
|
|
|
|
CFLAGS+= -DUSE_CODEC_OPUS
|
|
|
|
CODEC_INC = -I../MacOSX/codecs/include
|
|
|
|
CODEC_LINK= -L../MacOSX/codecs/lib
|
|
|
|
CODECLIBS+= -lopusfile -lopus -logg
|
|
|
|
endif
|
2011-01-12 09:32:22 +00:00
|
|
|
ifeq ($(USE_CODEC_VORBIS),1)
|
2011-08-27 07:11:36 +00:00
|
|
|
CFLAGS+= -DUSE_CODEC_VORBIS $(cpp_vorbisdec)
|
2012-08-16 04:51:41 +00:00
|
|
|
CODEC_INC = -I../MacOSX/codecs/include
|
2012-09-04 07:39:43 +00:00
|
|
|
CODEC_LINK= -L../MacOSX/codecs/lib
|
2011-08-27 07:11:36 +00:00
|
|
|
CODECLIBS+= $(lib_vorbisdec)
|
2011-01-05 23:05:17 +00:00
|
|
|
endif
|
2011-01-12 09:32:22 +00:00
|
|
|
ifeq ($(USE_CODEC_MP3),1)
|
2011-01-05 23:05:17 +00:00
|
|
|
CFLAGS+= -DUSE_CODEC_MP3
|
2012-08-16 04:51:41 +00:00
|
|
|
CODEC_INC = -I../MacOSX/codecs/include
|
2012-09-04 07:39:43 +00:00
|
|
|
CODEC_LINK= -L../MacOSX/codecs/lib
|
2011-08-27 07:11:36 +00:00
|
|
|
CODECLIBS+= $(lib_mp3dec)
|
2011-01-05 23:05:17 +00:00
|
|
|
endif
|
2013-09-25 11:01:12 +00:00
|
|
|
ifeq ($(USE_CODEC_MIKMOD),1)
|
|
|
|
CFLAGS+= -DUSE_CODEC_MIKMOD
|
|
|
|
CODEC_INC = -I../MacOSX/codecs/include
|
|
|
|
CODEC_LINK= -L../MacOSX/codecs/lib
|
|
|
|
CODECLIBS+= -lmikmod
|
|
|
|
endif
|
|
|
|
ifeq ($(USE_CODEC_MODPLUG),1)
|
|
|
|
CFLAGS+= -DUSE_CODEC_MODPLUG
|
|
|
|
CODEC_INC = -I../MacOSX/codecs/include
|
|
|
|
CODEC_LINK= -L../MacOSX/codecs/lib
|
|
|
|
CODECLIBS+= -lmodplug
|
|
|
|
endif
|
|
|
|
ifeq ($(USE_CODEC_UMX),1)
|
|
|
|
CFLAGS+= -DUSE_CODEC_UMX
|
|
|
|
endif
|
2012-08-16 04:51:41 +00:00
|
|
|
CFLAGS+= $(CODEC_INC)
|
2011-01-05 23:05:17 +00:00
|
|
|
|
2012-08-16 04:51:41 +00:00
|
|
|
COMMON_LIBS:= -Wl,-framework,IOKit -Wl,-framework,OpenGL
|
2010-04-22 00:30:57 +00:00
|
|
|
|
2012-08-16 04:51:41 +00:00
|
|
|
LIBS := $(COMMON_LIBS) $(NET_LIBS) $(CODEC_LINK) $(CODECLIBS)
|
2010-04-22 00:30:57 +00:00
|
|
|
|
|
|
|
# ---------------------------
|
|
|
|
# targets
|
|
|
|
# ---------------------------
|
|
|
|
|
|
|
|
.PHONY: clean debug release
|
|
|
|
|
|
|
|
DEFAULT_TARGET := quakespasm
|
|
|
|
|
|
|
|
# ---------------------------
|
|
|
|
# rules
|
|
|
|
# ---------------------------
|
|
|
|
|
|
|
|
%.o: %.c
|
2012-08-16 04:51:41 +00:00
|
|
|
$(CC) $(DFLAGS) -c $(CFLAGS) $(SDL_CFLAGS) -o $@ $^
|
2011-04-24 03:01:40 +00:00
|
|
|
%.o: %.m
|
2012-08-16 04:51:41 +00:00
|
|
|
$(CC) $(DFLAGS) -c $(CFLAGS) $(SDL_CFLAGS) -o $@ $^
|
|
|
|
%.o: ../MacOSX/%.m
|
|
|
|
$(CC) $(DFLAGS) -c -I../MacOSX $(CFLAGS) $(SDL_CFLAGS) -o $@ $^
|
2010-04-22 00:30:57 +00:00
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# objects
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
2011-01-05 23:05:17 +00:00
|
|
|
MUSIC_OBJS:= bgmusic.o \
|
|
|
|
snd_codec.o \
|
2013-07-21 14:02:06 +00:00
|
|
|
snd_flac.o \
|
2011-01-05 23:05:17 +00:00
|
|
|
snd_wave.o \
|
|
|
|
snd_vorbis.o \
|
2013-07-18 07:03:11 +00:00
|
|
|
snd_opus.o \
|
2013-09-25 11:01:12 +00:00
|
|
|
$(mp3_obj) \
|
|
|
|
snd_mikmod.o \
|
|
|
|
snd_modplug.o \
|
|
|
|
snd_umx.o
|
2011-01-05 23:05:17 +00:00
|
|
|
COMOBJ_SND := snd_dma.o snd_mix.o snd_mem.o $(MUSIC_OBJS)
|
2010-04-24 15:55:02 +00:00
|
|
|
SYSOBJ_SND := snd_sdl.o
|
|
|
|
SYSOBJ_CDA := cd_sdl.o
|
|
|
|
SYSOBJ_INPUT := in_sdl.o
|
|
|
|
SYSOBJ_GL_VID:= gl_vidsdl.o
|
* Makefile, Makefile.darwin, Makefile.w32, Makefile.w64: Build changes:
The SDL_net driver is now disabled by default and platform-specific network
drivers will be used. To compile for SDL_net, a command like "make SDLNET=1"
must be used, in which case a new preprocessor macro _USE_SDLNET will be
defined in the CFLAGS. For windows targets when not using SDL_net, WINSOCK2
is added as another option: A command line like "make WINSOCK2=1" will enable
WinSock2 api and a new preprocessor macro _USE_WINSOCK2 will be defined in
the CFLAGS. Or, a command line like "make WINSOCK2=0" will disable WinSock2
api and the old WinSock 1.1 api will be used instead. For Win64, WinSock2 is
enabled by default. For Win32, WinSock 1.1 is the default api.
* net_bsd.c, net_dgrm.c, net_loop.c, net_main.c, net_sdl.c, net_sdlnet.c,
net_udp.c, net_win.c, net_wins.c, net_wipx.c: Use the newly added net_sys.h
header. The sys_socket_t type is not in use, yet.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@215 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-06-21 11:10:38 +00:00
|
|
|
SYSOBJ_NET := net_bsd.o net_udp.o
|
2012-08-16 04:51:41 +00:00
|
|
|
SYSOBJ_LAUNCHER := AppController.o QuakeArgument.o QuakeArguments.o ScreenInfo.o SDLApplication.o
|
2010-06-22 11:01:24 +00:00
|
|
|
SYSOBJ_SYS := pl_osx.o sys_sdl_unix.o
|
2012-08-16 04:51:41 +00:00
|
|
|
SYSOBJ_MAIN:= main_sdl.o SDLMain.o
|
2010-04-24 15:55:02 +00:00
|
|
|
|
|
|
|
GLOBJS = \
|
|
|
|
gl_refrag.o \
|
|
|
|
gl_rlight.o \
|
|
|
|
gl_rmain.o \
|
|
|
|
gl_fog.o \
|
|
|
|
gl_rmisc.o \
|
|
|
|
r_part.o \
|
|
|
|
r_world.o \
|
|
|
|
gl_screen.o \
|
|
|
|
gl_sky.o \
|
|
|
|
gl_warp.o \
|
|
|
|
$(SYSOBJ_GL_VID) \
|
|
|
|
gl_draw.o \
|
|
|
|
image.o \
|
|
|
|
gl_texmgr.o \
|
|
|
|
gl_mesh.o \
|
|
|
|
r_sprite.o \
|
|
|
|
r_alias.o \
|
|
|
|
r_brush.o \
|
|
|
|
gl_model.o
|
|
|
|
|
2011-12-27 11:11:24 +00:00
|
|
|
OBJS := strlcat.o \
|
|
|
|
strlcpy.o \
|
2010-04-24 15:55:02 +00:00
|
|
|
$(GLOBJS) \
|
|
|
|
$(SYSOBJ_INPUT) \
|
|
|
|
$(COMOBJ_SND) \
|
|
|
|
$(SYSOBJ_SND) \
|
|
|
|
$(SYSOBJ_CDA) \
|
|
|
|
$(SYSOBJ_NET) \
|
|
|
|
net_dgrm.o \
|
|
|
|
net_loop.o \
|
|
|
|
net_main.o \
|
|
|
|
chase.o \
|
|
|
|
cl_demo.o \
|
|
|
|
cl_input.o \
|
|
|
|
cl_main.o \
|
|
|
|
cl_parse.o \
|
|
|
|
cl_tent.o \
|
|
|
|
console.o \
|
|
|
|
keys.o \
|
|
|
|
menu.o \
|
|
|
|
sbar.o \
|
|
|
|
view.o \
|
|
|
|
wad.o \
|
|
|
|
cmd.o \
|
|
|
|
common.o \
|
|
|
|
crc.o \
|
|
|
|
cvar.o \
|
2011-12-20 09:22:19 +00:00
|
|
|
cfgfile.o \
|
2010-04-24 15:55:02 +00:00
|
|
|
host.o \
|
|
|
|
host_cmd.o \
|
|
|
|
mathlib.o \
|
|
|
|
pr_cmds.o \
|
|
|
|
pr_edict.o \
|
|
|
|
pr_exec.o \
|
|
|
|
sv_main.o \
|
|
|
|
sv_move.o \
|
|
|
|
sv_phys.o \
|
|
|
|
sv_user.o \
|
|
|
|
world.o \
|
|
|
|
zone.o \
|
2012-08-16 04:51:41 +00:00
|
|
|
$(SYSOBJ_SYS) $(SYSOBJ_LAUNCHER) $(SYSOBJ_MAIN)
|
2010-04-22 00:30:57 +00:00
|
|
|
|
|
|
|
# ------------------------
|
2012-03-09 10:11:09 +00:00
|
|
|
# darwin build rules
|
2010-04-22 00:30:57 +00:00
|
|
|
# ------------------------
|
|
|
|
|
|
|
|
quakespasm: $(OBJS)
|
2012-09-05 16:24:57 +00:00
|
|
|
$(LINKER) $(OBJS) $(LDFLAGS) $(LIBS) $(SDL_LIBS) -o $@
|
2010-04-24 14:50:18 +00:00
|
|
|
$(call do_strip,$@)
|
2010-04-22 00:30:57 +00:00
|
|
|
|
|
|
|
release: quakespasm
|
|
|
|
debug:
|
|
|
|
$(error Use "make DEBUG=1")
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f $(shell find . \( -name '*~' -o -name '#*#' -o -name '*.o' -o -name '*.res' -o -name $(DEFAULT_TARGET) \) -print)
|
|
|
|
|