]> git.saurik.com Git - apple/libc.git/blob - GNUmakefile
Libc-391.4.1.tar.gz
[apple/libc.git] / GNUmakefile
1 ifndef $(OBJROOT)
2 OBJROOT = .
3 endif
4 ifndef $(SYMROOT)
5 SYMROOT = .
6 endif
7 ARCH = $(shell arch)
8 ifndef RC_ARCHS
9 RC_$(ARCH) = 1
10 RC_ARCHS = $(ARCH)
11 endif
12 ifdef ALTUSRLOCALLIBSYSTEM
13 LIBSYS = $(ALTUSRLOCALLIBSYSTEM)
14 else
15 LIBSYS = $(NEXT_ROOT)/usr/local/lib/system
16 endif
17 NJOBS = $(shell perl -e '$$n = `/usr/sbin/sysctl -n hw.ncpu`; printf "%d\n", $$n < 2 ? 2 : ($$n * 1.5)')
18 BSDMAKE = bsdmake -j $(NJOBS)
19
20 # Remove the arch stuff, since we know better here.
21 LOCAL_CFLAGS = $(filter-out -arch ppc -arch ppc64 -arch i386,$(RC_CFLAGS))
22
23 all: build
24
25 # These are the non B&I defaults
26 ifndef RC_ProjectName
27 installhdrs: installhdrs-real
28 build: build-static build-profile build-debug build-dynamic
29 install: installhdrs install-all
30 endif
31
32 # And these are to deal with B&I building libc differently
33 # based on RC_ProjectName.
34 ifeq ($(RC_ProjectName),Libc)
35 installhdrs:
36 build: build-dynamic
37 install: BI-install-dynamic
38 endif
39 ifeq ($(RC_ProjectName),Libc_headers)
40 installhdrs: installhdrs-real
41 build:
42 install: installhdrs-real
43 endif
44 ifeq ($(RC_ProjectName),Libc_man)
45 installhdrs:
46 build:
47 install: install-man
48 endif
49 ifeq ($(RC_ProjectName),Libc_static)
50 installhdrs:
51 build: build-static
52 install: BI-install-static
53 endif
54 ifeq ($(RC_ProjectName),Libc_debug)
55 installhdrs:
56 build: build-debug
57 install: BI-install-debug
58 endif
59 ifeq ($(RC_ProjectName),Libc_profile)
60 installhdrs:
61 build: build-profile
62 install: BI-install-profile
63 endif
64
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.
67 ifneq ($(CC_PRINT_OPTIONS_FILE),)
68 $(CC_PRINT_OPTIONS_FILE):
69 touch $(CC_PRINT_OPTIONS_FILE)
70 endif
71
72 build-static: autopatch $(CC_PRINT_OPTIONS_FILE) build-ppc-static build-ppc64-static build-i386-static
73 @echo "Creating final libc_static.a"
74 ifeq ($(words $(RC_ARCHS)),1)
75 cp -p "$(OBJROOT)/obj.$(RC_ARCHS)/libc_static.a" "$(SYMROOT)"
76 else
77 lipo -create \
78 $(foreach A,$(RC_ARCHS),-arch $(A) "$(OBJROOT)/obj.$(A)/libc_static.a") \
79 -output $(SYMROOT)/libc_static.a
80 endif
81 build-profile: autopatch $(CC_PRINT_OPTIONS_FILE) build-ppc-profile build-ppc64-profile build-i386-profile
82 @echo "Creating final libc_profile.a"
83 ifeq ($(words $(RC_ARCHS)),1)
84 cp -p "$(OBJROOT)/obj.$(RC_ARCHS)/libc_profile.a" "$(SYMROOT)"
85 else
86 lipo -create \
87 $(foreach A,$(RC_ARCHS),-arch $(A) "$(OBJROOT)/obj.$(A)/libc_profile.a") \
88 -output $(SYMROOT)/libc_profile.a
89 endif
90 build-debug: autopatch $(CC_PRINT_OPTIONS_FILE) build-ppc-debug build-ppc64-debug build-i386-debug
91 @echo "Creating final libc_debug.a"
92 ifeq ($(words $(RC_ARCHS)),1)
93 cp -p "$(OBJROOT)/obj.$(RC_ARCHS)/libc_debug.a" "$(SYMROOT)"
94 else
95 lipo -create \
96 $(foreach A,$(RC_ARCHS),-arch $(A) "$(OBJROOT)/obj.$(A)/libc_debug.a") \
97 -output $(SYMROOT)/libc_debug.a
98 endif
99 build-dynamic: autopatch $(CC_PRINT_OPTIONS_FILE) build-ppc-dynamic build-ppc64-dynamic build-i386-dynamic
100 @echo "Creating final libc.a"
101 ifeq ($(words $(RC_ARCHS)),1)
102 cp -p "$(OBJROOT)/obj.$(RC_ARCHS)/libc.a" "$(SYMROOT)"
103 else
104 lipo -create \
105 $(foreach A,$(RC_ARCHS),-arch $(A) "$(OBJROOT)/obj.$(A)/libc.a") \
106 -output $(SYMROOT)/libc.a
107 endif
108 build-ppc-static:
109 ifneq ($(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
113 endif
114 build-ppc64-static:
115 ifneq ($(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
119 endif
120 build-i386-static:
121 ifneq ($(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
125 endif
126 build-ppc-profile:
127 ifneq ($(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
131 endif
132 build-ppc64-profile:
133 ifneq ($(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
137 endif
138 build-i386-profile:
139 ifneq ($(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
143 endif
144 build-ppc-debug:
145 ifneq ($(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
149 endif
150 build-ppc64-debug:
151 ifneq ($(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
155 endif
156 build-i386-debug:
157 ifneq ($(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
161 endif
162 build-ppc-dynamic:
163 ifneq ($(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
167 endif
168 build-ppc64-dynamic:
169 ifneq ($(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
173 endif
174 build-i386-dynamic:
175 ifneq ($(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
179 endif
180 build-ppc:
181 ifneq ($(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
185 endif
186 build-ppc64:
187 ifneq ($(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
191 endif
192 build-i386:
193 ifneq ($(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
197 endif
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.
202 autopatch:
203 ifneq ($(RC_i386),)
204 MACHINE_ARCH="i386" $(BSDMAKE) autopatch
205 endif
206 ifneq ($(RC_ppc),)
207 MACHINE_ARCH="ppc" $(BSDMAKE) autopatch
208 endif
209 ifneq ($(RC_ppc64),)
210 MACHINE_ARCH="ppc64" $(BSDMAKE) autopatch
211 endif
212
213 installsrc:
214 $(_v) pax -rw . "$(SRCROOT)"
215
216 installhdrs-real: $(CC_PRINT_OPTIONS_FILE)
217 MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" MAKEFLAGS="" \
218 $(BSDMAKE) installhdrs
219 ifneq ($(RC_i386),)
220 mkdir -p "$(OBJROOT)/obj.i386" ; \
221 MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \
222 MAKEFLAGS="" $(BSDMAKE) installhdrs-md
223 endif
224 ifneq ($(RC_ppc),)
225 mkdir -p "$(OBJROOT)/obj.ppc" ; \
226 MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \
227 MAKEFLAGS="" $(BSDMAKE) installhdrs-md
228 endif
229 ifneq ($(RC_ppc64),)
230 mkdir -p "$(OBJROOT)/obj.ppc64" ; \
231 MAKEOBJDIR="$(OBJROOT)/obj.ppc64" MACHINE_ARCH="ppc64" \
232 MAKEFLAGS="" $(BSDMAKE) installhdrs-md
233 endif
234
235 BI-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
243 BI-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
251 ifneq ($(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
257 endif
258 BI-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
266 ifneq ($(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
272 endif
273 BI-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
281 ifneq ($(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
287 endif
288
289 # Don't use -j here; it may try to make links before the files are copied
290 install-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 \
297 MACHINE_ARCH="$(shell arch)" MAKEFLAGS="" bsdmake autopatchman maninstall
298
299 install-all: build install-man BI-install-dynamic BI-install-static BI-install-profile BI-install-debug
300
301 clean:
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