summaryrefslogtreecommitdiff
path: root/os/macosx/Makefile.setup
blob: 990efb1221aa16d55fb615ce90d67374a293cded (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# $Id: Makefile 3214 2005-11-17 19:43:37Z bjarni $
# This makefile is not a standalone makefile, but is called from the general one
# it contains code specific to MacOS X

ifdef RELEASE
ifndef STATIC
# all OSX releases needs to be static
# end users don't tend to have the dynamic libs installed
$(warning Compiling a dynamic release. It should be static unless you really know what you are doing!!!)
endif
endif

ifdef RELEASE
ifndef UNIVERSAL_BINARY
$(warning Compiling a release build, that is not a universal binary)
endif
endif

ifdef TRIPPLE_BINARY
ifdef DEBUG
$(error no G5 optimisation is made in debug builds, so tripple binaries aren't possible. Use UNIVERSAL_BINARY instead if you really want a universal debug build)
endif
UNIVERSAL_BINARY:=1
endif

ifndef UNIVERSAL_BINARY
ifndef JAGUAR
ifeq ($(shell uname), Darwin)
# it's a hardware mac, not crosscompiling
$(shell $(CC_HOST) os/macosx/G5_detector.c -o os/macosx/G5_detector)
IS_G5:=$(shell os/macosx/G5_detector)
endif
endif
endif

ifdef UNIVERSAL_BINARY
ifndef STATIC
$(warning Compiling a universal binary, that is not static. Adding static flag)
STATIC:=1
endif
endif

ifdef RELEASE
ifdef DEBUG
$(warning Compiling a release build, that is a debug build)
endif
endif

# setup flags if none are defined
ifndef CFLAGS_PPC
	CFLAGS_PPC:= -isysroot /Developer/SDKs/MacOSX10.2.8.sdk
endif
ifndef LDFLAGS_PPC
	LDFLAGS_PPC:= -Wl,-syslibroot,/Developer/SDKs/MacOSX10.2.8.sdk
endif
ifndef PPC_CC
	PPC_CC:=powerpc-apple-darwin8-gcc-4.0.0
endif
ifndef CFLAGS_x86
	CFLAGS_x86:= -isysroot /Developer/SDKs/MacOSX10.4u.sdk
endif
ifndef LDFLAGS_x86
	LDFLAGS_x86:= -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk
endif
ifndef x86_CC
	x86_CC:=i686-apple-darwin8-gcc-4.0.0
endif
ifdef WITH_PNG
	ifndef LIBPNG_PPC_CONFIG
		LIBPNG_PPC_CONFIG:=$(LIBPNG-CONFIG)
	endif
	ifndef LIBPNG_x86_CONFIG
		LIBPNG_x86_CONFIG:=$(LIBPNG-CONFIG)
	endif
endif
ifdef WITH_SDL
	ifndef SDL_PPC_CONFIG
		SDL_PPC_CONFIG:=$(SDL-CONFIG)
	endif
	ifndef SDL_x86_CONFIG
		SDL_x86_CONFIG:=$(SDL-CONFIG)
	endif
	ifndef x86_SDL_LIB
		x86_SDL_LIB:=$(shell echo "`$(SDL_x86_CONFIG) --prefix`/lib/libSDL-1.2.0.dylib")
	endif
endif

ifdef JAGUAR
	LIBPNG-CONFIG:=$(LIBPNG_PPC_CONFIG)
	SDL-CONFIG:=$(SDL_PPC_CONFIG)
	CC_TARGET:=$(PPC_CC)
	CFLAGS:= $(CFLAGS_PPC) -arch ppc
	LDFLAGS:= $(LDFLAGS_PPC)
endif

ifdef UNIVERSAL_BINARY
	# set up config files
	ifndef SKIP_LIB_TEST
		ifdef WITH_PNG
			TEST:=$(shell lipo -info `$(LIBPNG_PPC_CONFIG) --prefix`/lib/libpng.a | xargs -n 1 | grep "ppc"))
			ifndef TEST
$(error no PPC libpng found)
			endif
			TEST:=$(shell lipo -info `$(LIBPNG_x86_CONFIG) --prefix`/lib/libpng.a | xargs -n 1 | grep "i386"))
			ifndef TEST
$(error no x86 libpng found)
			endif
		endif
	endif
	LIBS:=
	OBJS:=
	ifdef UNIVERSAL_PPC_PART
		LIBPNG-CONFIG:=$(LIBPNG_PPC_CONFIG)
		SDL-CONFIG:=$(SDL_PPC_CONFIG)
		CC_TARGET:=$(PPC_CC)
		CFLAGS:= $(CFLAGS_PPC) -arch ppc
		LDFLAGS:= $(LDFLAGS_PPC)
	else
		LIBPNG-CONFIG:=$(LIBPNG_x86_CONFIG)
		SDL-CONFIG:=$(SDL_x86_CONFIG)
		CC_TARGET:=$(x86_CC)
		# clear the cached list of PPC libs
		CFLAGS:= $(CFLAGS_x86) -arch i386
		LDFLAGS:= $(LDFLAGS_x86)
	endif
endif