]> git.saurik.com Git - apple/libc.git/blame - GNUmakefile
Libc-391.4.2.tar.gz
[apple/libc.git] / GNUmakefile
CommitLineData
5b2abdfb
A
1ifndef $(OBJROOT)
2OBJROOT = .
3endif
4ifndef $(SYMROOT)
5SYMROOT = .
6endif
7ARCH = $(shell arch)
59e0d9fe
A
8ifndef RC_ARCHS
9RC_$(ARCH) = 1
10RC_ARCHS = $(ARCH)
5b2abdfb 11endif
3d9156a7
A
12ifdef ALTUSRLOCALLIBSYSTEM
13LIBSYS = $(ALTUSRLOCALLIBSYSTEM)
14else
15LIBSYS = $(NEXT_ROOT)/usr/local/lib/system
16endif
17NJOBS = $(shell perl -e '$$n = `/usr/sbin/sysctl -n hw.ncpu`; printf "%d\n", $$n < 2 ? 2 : ($$n * 1.5)')
18BSDMAKE = bsdmake -j $(NJOBS)
5b2abdfb
A
19
20# Remove the arch stuff, since we know better here.
59e0d9fe 21LOCAL_CFLAGS = $(filter-out -arch ppc -arch ppc64 -arch i386,$(RC_CFLAGS))
5b2abdfb
A
22
23all: build
59e0d9fe 24
5b2abdfb
A
25# These are the non B&I defaults
26ifndef RC_ProjectName
27installhdrs: installhdrs-real
28build: build-static build-profile build-debug build-dynamic
29install: installhdrs install-all
30endif
31
32# And these are to deal with B&I building libc differently
33# based on RC_ProjectName.
34ifeq ($(RC_ProjectName),Libc)
59e0d9fe
A
35installhdrs:
36build: build-dynamic
37install: BI-install-dynamic
38endif
39ifeq ($(RC_ProjectName),Libc_headers)
5b2abdfb 40installhdrs: installhdrs-real
59e0d9fe
A
41build:
42install: installhdrs-real
43endif
44ifeq ($(RC_ProjectName),Libc_man)
45installhdrs:
46build:
47install: install-man
5b2abdfb
A
48endif
49ifeq ($(RC_ProjectName),Libc_static)
50installhdrs:
51build: build-static
52install: BI-install-static
53endif
54ifeq ($(RC_ProjectName),Libc_debug)
55installhdrs:
56build: build-debug
57install: BI-install-debug
58endif
59ifeq ($(RC_ProjectName),Libc_profile)
60installhdrs:
61build: build-profile
62install: BI-install-profile
63endif
64
3d9156a7
A
65# Because of 3780028, there are random failures on HFS because the
66# CC_PRINT_OPTIONS_FILE can't be created. So we touch it first.
67ifneq ($(CC_PRINT_OPTIONS_FILE),)
68$(CC_PRINT_OPTIONS_FILE):
69 touch $(CC_PRINT_OPTIONS_FILE)
70endif
71
72build-static: autopatch $(CC_PRINT_OPTIONS_FILE) build-ppc-static build-ppc64-static build-i386-static
59e0d9fe
A
73 @echo "Creating final libc_static.a"
74ifeq ($(words $(RC_ARCHS)),1)
75 cp -p "$(OBJROOT)/obj.$(RC_ARCHS)/libc_static.a" "$(SYMROOT)"
76else
77 lipo -create \
78 $(foreach A,$(RC_ARCHS),-arch $(A) "$(OBJROOT)/obj.$(A)/libc_static.a") \
79 -output $(SYMROOT)/libc_static.a
80endif
3d9156a7 81build-profile: autopatch $(CC_PRINT_OPTIONS_FILE) build-ppc-profile build-ppc64-profile build-i386-profile
59e0d9fe
A
82 @echo "Creating final libc_profile.a"
83ifeq ($(words $(RC_ARCHS)),1)
84 cp -p "$(OBJROOT)/obj.$(RC_ARCHS)/libc_profile.a" "$(SYMROOT)"
85else
86 lipo -create \
87 $(foreach A,$(RC_ARCHS),-arch $(A) "$(OBJROOT)/obj.$(A)/libc_profile.a") \
88 -output $(SYMROOT)/libc_profile.a
89endif
3d9156a7 90build-debug: autopatch $(CC_PRINT_OPTIONS_FILE) build-ppc-debug build-ppc64-debug build-i386-debug
59e0d9fe
A
91 @echo "Creating final libc_debug.a"
92ifeq ($(words $(RC_ARCHS)),1)
93 cp -p "$(OBJROOT)/obj.$(RC_ARCHS)/libc_debug.a" "$(SYMROOT)"
94else
95 lipo -create \
96 $(foreach A,$(RC_ARCHS),-arch $(A) "$(OBJROOT)/obj.$(A)/libc_debug.a") \
97 -output $(SYMROOT)/libc_debug.a
98endif
3d9156a7 99build-dynamic: autopatch $(CC_PRINT_OPTIONS_FILE) build-ppc-dynamic build-ppc64-dynamic build-i386-dynamic
59e0d9fe
A
100 @echo "Creating final libc.a"
101ifeq ($(words $(RC_ARCHS)),1)
102 cp -p "$(OBJROOT)/obj.$(RC_ARCHS)/libc.a" "$(SYMROOT)"
103else
104 lipo -create \
105 $(foreach A,$(RC_ARCHS),-arch $(A) "$(OBJROOT)/obj.$(A)/libc.a") \
106 -output $(SYMROOT)/libc.a
107endif
5b2abdfb 108build-ppc-static:
3d9156a7
A
109ifneq ($(RC_ppc),)
110 mkdir -p $(OBJROOT)/obj.ppc ; \
111 MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \
112 MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) libc_static.a
113endif
59e0d9fe 114build-ppc64-static:
3d9156a7
A
115ifneq ($(RC_ppc64),)
116 mkdir -p $(OBJROOT)/obj.ppc64 ; \
117 MAKEOBJDIR="$(OBJROOT)/obj.ppc64" MACHINE_ARCH="ppc64" \
118 MAKEFLAGS="" CFLAGS="-arch ppc64 $(LOCAL_CFLAGS)" $(BSDMAKE) libc_static.a
119endif
5b2abdfb 120build-i386-static:
3d9156a7
A
121ifneq ($(RC_i386),)
122 mkdir -p $(OBJROOT)/obj.i386 ; \
123 MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \
124 MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) libc_static.a
125endif
5b2abdfb 126build-ppc-profile:
3d9156a7
A
127ifneq ($(RC_ppc),)
128 mkdir -p $(OBJROOT)/obj.ppc ; \
129 MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \
130 MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) libc_profile.a
131endif
59e0d9fe 132build-ppc64-profile:
3d9156a7
A
133ifneq ($(RC_ppc64),)
134 mkdir -p $(OBJROOT)/obj.ppc64 ; \
135 MAKEOBJDIR="$(OBJROOT)/obj.ppc64" MACHINE_ARCH="ppc64" \
136 MAKEFLAGS="" CFLAGS="-arch ppc64 $(LOCAL_CFLAGS)" $(BSDMAKE) libc_profile.a
137endif
5b2abdfb 138build-i386-profile:
3d9156a7
A
139ifneq ($(RC_i386),)
140 mkdir -p $(OBJROOT)/obj.i386 ; \
141 MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \
142 MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) libc_profile.a
143endif
5b2abdfb 144build-ppc-debug:
3d9156a7
A
145ifneq ($(RC_ppc),)
146 mkdir -p $(OBJROOT)/obj.ppc ; \
147 MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \
148 MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) libc_debug.a
149endif
59e0d9fe 150build-ppc64-debug:
3d9156a7
A
151ifneq ($(RC_ppc64),)
152 mkdir -p $(OBJROOT)/obj.ppc64 ; \
153 MAKEOBJDIR="$(OBJROOT)/obj.ppc64" MACHINE_ARCH="ppc64" \
154 MAKEFLAGS="" CFLAGS="-arch ppc64 $(LOCAL_CFLAGS)" $(BSDMAKE) libc_debug.a
155endif
5b2abdfb 156build-i386-debug:
3d9156a7
A
157ifneq ($(RC_i386),)
158 mkdir -p $(OBJROOT)/obj.i386 ; \
159 MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \
160 MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) libc_debug.a
161endif
5b2abdfb 162build-ppc-dynamic:
3d9156a7
A
163ifneq ($(RC_ppc),)
164 mkdir -p $(OBJROOT)/obj.ppc ; \
165 MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \
166 MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) libc.a
167endif
59e0d9fe 168build-ppc64-dynamic:
3d9156a7
A
169ifneq ($(RC_ppc64),)
170 mkdir -p $(OBJROOT)/obj.ppc64 ; \
171 MAKEOBJDIR="$(OBJROOT)/obj.ppc64" MACHINE_ARCH="ppc64" \
172 MAKEFLAGS="" CFLAGS="-arch ppc64 $(LOCAL_CFLAGS)" $(BSDMAKE) libc.a
173endif
5b2abdfb 174build-i386-dynamic:
3d9156a7
A
175ifneq ($(RC_i386),)
176 mkdir -p $(OBJROOT)/obj.i386 ; \
177 MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \
178 MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) libc.a
179endif
5b2abdfb 180build-ppc:
3d9156a7
A
181ifneq ($(RC_ppc),)
182 mkdir -p $(OBJROOT)/obj.ppc ; \
183 MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \
184 MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) build
185endif
59e0d9fe 186build-ppc64:
3d9156a7
A
187ifneq ($(RC_ppc64),)
188 mkdir -p $(OBJROOT)/obj.ppc64 ; \
189 MAKEOBJDIR="$(OBJROOT)/obj.ppc64" MACHINE_ARCH="ppc64" \
190 MAKEFLAGS="" CFLAGS="-arch ppc64 $(LOCAL_CFLAGS)" $(BSDMAKE) build
191endif
5b2abdfb 192build-i386:
3d9156a7
A
193ifneq ($(RC_i386),)
194 mkdir -p $(OBJROOT)/obj.i386 ; \
195 MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \
196 MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) build
197endif
59e0d9fe
A
198
199# We have to separately call bsdmake to patch the FreeBSD files, because of
200# the way its cache works, it would otherwise pick a file in ${SYMROOT}, even
201# over a .s file.
202autopatch:
3d9156a7
A
203ifneq ($(RC_i386),)
204 MACHINE_ARCH="i386" $(BSDMAKE) autopatch
205endif
206ifneq ($(RC_ppc),)
207 MACHINE_ARCH="ppc" $(BSDMAKE) autopatch
208endif
209ifneq ($(RC_ppc64),)
210 MACHINE_ARCH="ppc64" $(BSDMAKE) autopatch
211endif
59e0d9fe 212
5b2abdfb
A
213installsrc:
214 $(_v) pax -rw . "$(SRCROOT)"
9385eb3d 215
3d9156a7 216installhdrs-real: $(CC_PRINT_OPTIONS_FILE)
9385eb3d
A
217 MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" MAKEFLAGS="" \
218 $(BSDMAKE) installhdrs
3d9156a7
A
219ifneq ($(RC_i386),)
220 mkdir -p "$(OBJROOT)/obj.i386" ; \
221 MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \
222 MAKEFLAGS="" $(BSDMAKE) installhdrs-md
223endif
224ifneq ($(RC_ppc),)
225 mkdir -p "$(OBJROOT)/obj.ppc" ; \
226 MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \
227 MAKEFLAGS="" $(BSDMAKE) installhdrs-md
228endif
229ifneq ($(RC_ppc64),)
230 mkdir -p "$(OBJROOT)/obj.ppc64" ; \
231 MAKEOBJDIR="$(OBJROOT)/obj.ppc64" MACHINE_ARCH="ppc64" \
232 MAKEFLAGS="" $(BSDMAKE) installhdrs-md
233endif
5b2abdfb
A
234
235BI-install-static: build-static
236 mkdir -p $(DSTROOT)/usr/local/lib/system
237 if [ -f "$(SYMROOT)/libc_static.a" ]; then \
238 echo "Installing libc_static.a" ; \
239 install -c -m 444 "$(SYMROOT)/libc_static.a" \
240 $(DSTROOT)/usr/local/lib/system; \
241 ranlib "$(DSTROOT)/usr/local/lib/system/libc_static.a"; \
242 fi
243BI-install-profile: build-profile
244 mkdir -p $(DSTROOT)/usr/local/lib/system
245 if [ -f "$(SYMROOT)/libc_profile.a" ]; then \
246 echo "Installing libc_profile.a" ; \
247 install -c -m 444 "$(SYMROOT)/libc_profile.a" \
248 $(DSTROOT)/usr/local/lib/system; \
249 ranlib "$(DSTROOT)/usr/local/lib/system/libc_profile.a"; \
250 fi
3d9156a7
A
251ifneq ($(RC_ppc),)
252 if [ -f "$(OBJROOT)/obj.ppc/libc-ldbl128_profile.a" ]; then \
253 echo "Installing libldbl128_profile.a" ; \
254 $(SRCROOT)/make_libldbl128 "$(OBJROOT)/obj.ppc/libc-ldbl128_profile.a" \
255 "_profile" "$(DSTROOT)/usr/local/lib/system" $(LIBSYS) ; \
256 fi
257endif
5b2abdfb
A
258BI-install-debug: build-debug
259 mkdir -p $(DSTROOT)/usr/local/lib/system
260 if [ -f "$(SYMROOT)/libc_debug.a" ]; then \
261 echo "Installing libc_debug.a" ; \
262 install -c -m 444 "$(SYMROOT)/libc_debug.a" \
263 $(DSTROOT)/usr/local/lib/system; \
264 ranlib "$(DSTROOT)/usr/local/lib/system/libc_debug.a"; \
265 fi
3d9156a7
A
266ifneq ($(RC_ppc),)
267 if [ -f "$(OBJROOT)/obj.ppc/libc-ldbl128_debug.a" ]; then \
268 echo "Installing libldbl128_debug.a" ; \
269 $(SRCROOT)/make_libldbl128 "$(OBJROOT)/obj.ppc/libc-ldbl128_debug.a" \
270 "_debug" "$(DSTROOT)/usr/local/lib/system" $(LIBSYS) ; \
271 fi
272endif
5b2abdfb
A
273BI-install-dynamic: build-dynamic
274 mkdir -p $(DSTROOT)/usr/local/lib/system
275 if [ -f "$(SYMROOT)/libc.a" ]; then \
276 echo "Installing libc.a" ; \
277 install -c -m 444 "$(SYMROOT)/libc.a" \
278 $(DSTROOT)/usr/local/lib/system; \
279 ranlib "$(DSTROOT)/usr/local/lib/system/libc.a"; \
280 fi
3d9156a7
A
281ifneq ($(RC_ppc),)
282 if [ -f "$(OBJROOT)/obj.ppc/libc-ldbl128.a" ]; then \
283 echo "Installing libldbl128.a" ; \
284 $(SRCROOT)/make_libldbl128 "$(OBJROOT)/obj.ppc/libc-ldbl128.a" \
285 "" "$(DSTROOT)/usr/local/lib/system" $(LIBSYS) ; \
286 fi
287endif
5b2abdfb 288
9385eb3d 289# Don't use -j here; it may try to make links before the files are copied
5b2abdfb
A
290install-man:
291 mkdir -p $(DSTROOT)/usr/share/man/man2
292 mkdir -p $(DSTROOT)/usr/share/man/man3
293 mkdir -p $(DSTROOT)/usr/share/man/man4
294 mkdir -p $(DSTROOT)/usr/share/man/man5
295 mkdir -p $(DSTROOT)/usr/share/man/man7
296 MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" NOMANCOMPRESS=1 \
59e0d9fe 297 MACHINE_ARCH="$(shell arch)" MAKEFLAGS="" bsdmake autopatchman maninstall
5b2abdfb 298
59e0d9fe 299install-all: build install-man BI-install-dynamic BI-install-static BI-install-profile BI-install-debug
5b2abdfb
A
300
301clean:
302 rm -rf $(OBJROOT)/obj.ppc $(OBJROOT)/obj.i386 $(OBJROOT)/libc.a \
303 $(OBJROOT)/libc_static.a $(OBJROOT)/libc_debug.a \
304 $(OBJROOT)/libc_profile.a