Before, I had it use the MacPorts libs, but this isn't the best way to do it, even with a development build. Ideally, for debugging purposes, we really want to be using the same libraries we'd use for a release build.
This also adds some command-line options to set the type of build: ARCHS: This can be set to something like "-arch i386 -arch ppc" for a 32-bit universal build. SDK_VER: The Mac OS X SDK version (i.e. 10.4, 10.5, etc) GCC_VER: The GCC version to compile with. For 10.4, you must use version 4.0, but for 10.5 and above, you may use 4.2.
Signed-off-by: Steven Noonan <steven@uplinklabs.net>
FHMTFYXFX5OBWFLRH4PU4ZOWP5JGDCH4OBCJSAMPIC5SREHXM5AQC
GYS5IM6FVZKFSFMT7K4SO5GHS4UULDY23JJRH5BQ2YOYDQYXVJAAC
25CH7HH4LKXFIZ75YNMXS3TSXO6O27DYSOPLOD45K4OCNFWLS4LQC
HBXWZNXAJ7LUX7FYUIHQYBTRMWVJC6CAQQL3NNZHK5ETLIFEZJ7QC
GL5T36G3A2LUTTYSL7ZQVUYONUCXL5DK36532FM6XRAQCLYDWW2QC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
MTVWMQ5HV5LGDRU53GJV45GTANABRJLNIECWT7ZH2MCLO53XLFXAC
ifeq ($(shell uname -s),Darwin)
SDL_CFLAGS := -I/Library/Frameworks/SDL.framework/Headers -I/Library/Frameworks/SDL_image.framework/Headers
SDL_LDFLAGS := -framework SDL -framework SDL_image
PNG_CFLAGS := -I/Library/Frameworks/libpng.framework/Headers
PNG_LDFLAGS := -framework libpng
CFLAGS := -F/Library/Frameworks $(SDL_CFLAGS) $(PNG_CFLAGS)
LDFLAGS := -F/Library/Frameworks $(SDL_LDFLAGS) $(PNG_LDFLAGS)
# FIXME: We need 32-bit until SDL 1.2.14 comes out
CXX ?= g++ -m32
else
EXTRA_FLAGS += -DUSE_TILE
INCLUDES += -I$(RLTILES)
ifeq ($(OSNAME),MacOS)
# Compatibility level for Mac OS X
#
SDK_VER=10.4
GCC_VER=4.0
# FIXME: The '-arch i386' is only here until
# SDL 1.2.14 is available
#
ARCHS=-arch i386
# Mac OS X 10.4 adds a 'u' on the end of the SDK name. Everything
# else is much easier to predict the name of.
ifeq ($(SDK_VER),10.4)
SDKROOT=/Developer/SDKs/MacOSX$(SDK_VER)u.sdk
else
SDKROOT=/Developer/SDKs/MacOSX$(SDK_VER).sdk
endif
ifneq ($(GCC_VER),)
GCC = gcc-$(GCC_VER)
GCXX = g++-$(GCC_VER)
else
GCC = gcc
GCXX = g++
endif
CC = $(GCC) $(ARCHS) -isysroot $(SDKROOT) -mmacosx-version-min=$(SDK_VER)
CXX = $(GCXX) $(ARCHS) -isysroot $(SDKROOT) -mmacosx-version-min=$(SDK_VER)
# Handle the tile build dependencies for Mac a bit
# differently than other platforms.
LIB += -framework OpenGL -framework AppKit
# SDL has a goof in the stock SDL_config.h which checks whether
# __MACOSX__ is defined. It's not one of Apple's stock markers,
# so we define it ourselves here.
#
EXTRA_FLAGS += -D__MACOSX__
EXTRA_OBJECTS += SDLMain.o
# If the /Library/Frameworks folder exists, add a -F flag
#
ifneq ($(shell ls -a /Library/Frameworks 2> /dev/null),)
LIB += -F/Library/Frameworks/
endif
# Check if our dependencies exist as frameworks. If so, use their
# headers and link to them.
#
ifneq ($(shell ls /Library/Frameworks/SDL.framework 2> /dev/null),)
INCLUDES += -I/Library/Frameworks/SDL.framework/Headers
LIB += -framework SDL
endif
ifneq ($(shell ls /Library/Frameworks/SDL_image.framework 2> /dev/null),)
INCLUDES += -I/Library/Frameworks/SDL_image.framework/Headers
LIB += -framework SDL_image
endif
ifneq ($(shell ls /Library/Frameworks/Freetype2.framework 2> /dev/null),)
INCLUDES += -I/Library/Frameworks/Freetype2.framework/Headers
LIB += -framework Freetype2
endif
ifneq ($(shell ls /Library/Frameworks/libpng.framework 2> /dev/null),)
INCLUDES += -I/Library/Frameworks/libpng.framework/Headers
LIB += -framework libpng
endif
else # MacOS
# Okay, we have to assume we're on something else that
# uses standard UNIX-like methods for finding libs.
#
# For instance, on Linux and most other UNIX-likes,
# the app pkg-config can provide the appropriate
# CFLAGS and LDFLAGS.
#