-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
196 lines (159 loc) · 5.18 KB
/
Makefile
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# Makefile for striptease project
# Copyright (C) 2011,2012 Kyle J. McKay. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the author(s) shall not
# be used in advertising or otherwise to promote the sale, use or other
# dealings in this Software without prior written authorization from the
# author(s).
include version.mak
.PHONY : all clean
ifeq ($(DEBUG),)
DEBUG := 0
endif
export DEBUG
CC = gcc-4.0
CINC = -Iinclude
XSDK := $(shell xcode-select -print-path 2>/dev/null)
ifeq ($(XSDK),)
XSDK := /Developer
endif
ifeq (0,$(shell test -d '$(XSDK)/Platforms/MacOSX.platform/Developer/SDKs'; echo $$?))
XSDK := $(XSDK)/Platforms/MacOSX.platform/Developer/SDKs
else
ifeq (0,$(shell test -d '$(XSDK)/SDKs'; echo $$?))
XSDK := $(XSDK)/SDKs
else
ifeq ($(DEBUG),0)
ifneq ($(MAKECMDGOALS),clean)
$(error Could not find Developer SDKs directory)
endif
endif
endif
endif
OSXNUVER := $(shell uname -r | cut -d. -f1)
OSXNUVERACTUAL := $(shell uname -r | cut -d. -f1)
ifeq (0,$(shell test -d '$(XSDK)/MacOSX10.4u.sdk'; echo $$?))
OSXNUVER := 8
endif
ifeq ($(DEBUG),0)
$(shell mkdir -p build/Release/libstuff)
DD=build/Release/
COPTS=$(ARCH) -Os
LDEXTRA=$(ARCH) -Wl,-S -Wl,-x
else
$(shell mkdir -p build/Debug/libstuff)
DD=build/Debug/
COPTS=-O0 -g
LDEXTRA=-g
endif
# The 10.4u SDK can be used, but do not require it except on 10.4.x
# Always build x86_64 if actually running on 10.5 or later
ifeq ($(OSXNUVER),8)
ifneq ($(OSXNUVERACTUAL),8)
ARCH = -arch x86_64 -arch i386 -arch ppc
ARCH += -Xarch_ppc -mmacosx-version-min=10.4
ARCH += -Xarch_ppc -isysroot$(XSDK)/MacOSX10.4u.sdk
ARCH += -Xarch_i386 -mmacosx-version-min=10.4
ARCH += -Xarch_i386 -isysroot$(XSDK)/MacOSX10.4u.sdk
ARCH += -Xarch_x86_64 -mmacosx-version-min=10.5
ARCH += -Xarch_x86_64 -isysroot$(XSDK)/MacOSX10.5.sdk
else
ARCH = -arch i386 -arch ppc
ARCH += -mmacosx-version-min=10.4 -isysroot$(XSDK)/MacOSX10.4u.sdk
endif
else
ARCH = -arch x86_64 -arch i386 -arch ppc
ARCH += -Xarch_ppc -mmacosx-version-min=10.4
ARCH += -Xarch_i386 -mmacosx-version-min=10.4
ARCH += -Xarch_x86_64 -mmacosx-version-min=10.5
ARCH += -isysroot$(XSDK)/MacOSX10.5.sdk
endif
COPTS += -include preinc.h -DCCTOOLSVER=$(CCTOOLSVER)
LDOPTS = -Wl,-no_uuid -Wl,-dead_strip -Wl,-multiply_defined,suppress
LDOPTS += $(LDEXTRA)
all : $(DD)tease
.PHONY : tools tease strip install_name_tool nm
tools : strip install_name_tool nm tease
tease : $(DD)tease
strip : $(DD)strip
install_name_tool : $(DD)install_name_tool
nm : $(DD)nm
LIBSTUFF_SRC := $(wildcard libstuff/*.c)
TEASE_SRC = \
tease.c \
$(LIBSTUFF_SRC)
STRIP_SRC = \
strip.c \
$(LIBSTUFF_SRC)
INSTALL_NAME_TOOL_SRC = \
install_name_tool.c \
$(LIBSTUFF_SRC)
NM_SRC = \
nm.c \
$(LIBSTUFF_SRC)
TEASE_OBJS = $(addprefix $(DD),$(TEASE_SRC:.c=.o)) $(DD)version_tease.o
STRIP_OBJS = $(addprefix $(DD),$(STRIP_SRC:.c=.o)) $(DD)version_strip.o
INSTALL_NAME_TOOL_OBJS = $(addprefix $(DD),$(INSTALL_NAME_TOOL_SRC:.c=.o)) \
$(DD)version_install_name_tool.o
NM_OBJS = $(addprefix $(DD),$(NM_SRC:.c=.o)) $(DD)nm.o
$(DD)%.o : %.c
$(CC) -Wall -c $(COPTS) $(CINC) -o $@ $<
$(DD)version_tease.o : version.c
$(CC) -Wall -c $(COPTS) $(CINC) -DPROGRAMNAME=tease -o $@ $<
$(DD)version_strip.o : version.c
$(CC) -Wall -c $(COPTS) $(CINC) -DPROGRAMNAME=strip -o $@ $<
$(DD)version_install_name_tool.o : version.c
$(CC) -Wall -c $(COPTS) $(CINC) -DPROGRAMNAME=install_name_tool -o $@ $<
$(DD)version_nm.o : version.c
$(CC) -Wall -c $(COPTS) $(CINC) -DPROGRAMNAME=nm -o $@ $<
$(DD)tease : $(TEASE_OBJS)
$(CC) -o $@ $(LDOPTS) $^
ifneq ($(DEBUG),0)
dsymutil $@
else
strip $@
cd '$(@D)' && zip -X -9 '$(@F)-$(CCTOOLSVER).zip' '$(@F)'
endif
$(DD)strip : $(STRIP_OBJS)
$(CC) -o $@ $(LDOPTS) $^
ifneq ($(DEBUG),0)
dsymutil $@
else
strip $@
cd '$(@D)' && zip -X -9 '$(@F)-$(CCTOOLSVER).zip' '$(@F)'
endif
$(DD)install_name_tool : $(INSTALL_NAME_TOOL_OBJS)
$(CC) -o $@ $(LDOPTS) $^
ifneq ($(DEBUG),0)
dsymutil $@
else
strip $@
cd '$(@D)' && zip -X -9 '$(@F)-$(CCTOOLSVER).zip' '$(@F)'
endif
$(DD)nm : $(NM_OBJS)
$(CC) -o $@ $(LDOPTS) $^
ifneq ($(DEBUG),0)
dsymutil $@
else
strip $@
cd '$(@D)' && zip -X -9 '$(@F)-$(CCTOOLSVER).zip' '$(@F)'
endif
clean :
rm -rf build