]>
Commit | Line | Data |
---|---|---|
5b2abdfb A |
1 | ifndef $(OBJROOT) |
2 | OBJROOT = . | |
3 | endif | |
4 | ifndef $(SYMROOT) | |
5 | SYMROOT = . | |
6 | endif | |
7 | ARCH = $(shell arch) | |
59e0d9fe A |
8 | ifndef RC_ARCHS |
9 | RC_$(ARCH) = 1 | |
10 | RC_ARCHS = $(ARCH) | |
5b2abdfb | 11 | endif |
3d9156a7 A |
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) | |
5b2abdfb A |
19 | |
20 | # Remove the arch stuff, since we know better here. | |
59e0d9fe | 21 | LOCAL_CFLAGS = $(filter-out -arch ppc -arch ppc64 -arch i386,$(RC_CFLAGS)) |
5b2abdfb A |
22 | |
23 | all: build | |
59e0d9fe | 24 | |
5b2abdfb A |
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) | |
59e0d9fe A |
35 | installhdrs: |
36 | build: build-dynamic | |
37 | install: BI-install-dynamic | |
38 | endif | |
39 | ifeq ($(RC_ProjectName),Libc_headers) | |
5b2abdfb | 40 | installhdrs: installhdrs-real |
59e0d9fe A |
41 | build: |
42 | install: installhdrs-real | |
43 | endif | |
44 | ifeq ($(RC_ProjectName),Libc_man) | |
45 | installhdrs: | |
46 | build: | |
47 | install: install-man | |
5b2abdfb A |
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 | ||
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. | |
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 | |
59e0d9fe A |
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 | |
3d9156a7 | 81 | build-profile: autopatch $(CC_PRINT_OPTIONS_FILE) build-ppc-profile build-ppc64-profile build-i386-profile |
59e0d9fe A |
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 | |
3d9156a7 | 90 | build-debug: autopatch $(CC_PRINT_OPTIONS_FILE) build-ppc-debug build-ppc64-debug build-i386-debug |
59e0d9fe A |
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 | |
3d9156a7 | 99 | build-dynamic: autopatch $(CC_PRINT_OPTIONS_FILE) build-ppc-dynamic build-ppc64-dynamic build-i386-dynamic |
59e0d9fe A |
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 | |
5b2abdfb | 108 | build-ppc-static: |
3d9156a7 A |
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 | |
59e0d9fe | 114 | build-ppc64-static: |
3d9156a7 A |
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 | |
5b2abdfb | 120 | build-i386-static: |
3d9156a7 A |
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 | |
5b2abdfb | 126 | build-ppc-profile: |
3d9156a7 A |
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 | |
59e0d9fe | 132 | build-ppc64-profile: |
3d9156a7 A |
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 | |
5b2abdfb | 138 | build-i386-profile: |
3d9156a7 A |
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 | |
5b2abdfb | 144 | build-ppc-debug: |
3d9156a7 A |
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 | |
59e0d9fe | 150 | build-ppc64-debug: |
3d9156a7 A |
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 | |
5b2abdfb | 156 | build-i386-debug: |
3d9156a7 A |
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 | |
5b2abdfb | 162 | build-ppc-dynamic: |
3d9156a7 A |
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 | |
59e0d9fe | 168 | build-ppc64-dynamic: |
3d9156a7 A |
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 | |
5b2abdfb | 174 | build-i386-dynamic: |
3d9156a7 A |
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 | |
5b2abdfb | 180 | build-ppc: |
3d9156a7 A |
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 | |
59e0d9fe | 186 | build-ppc64: |
3d9156a7 A |
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 | |
5b2abdfb | 192 | build-i386: |
3d9156a7 A |
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 | |
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. | |
202 | autopatch: | |
3d9156a7 A |
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 | |
59e0d9fe | 212 | |
5b2abdfb A |
213 | installsrc: |
214 | $(_v) pax -rw . "$(SRCROOT)" | |
9385eb3d | 215 | |
3d9156a7 | 216 | installhdrs-real: $(CC_PRINT_OPTIONS_FILE) |
9385eb3d A |
217 | MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" MAKEFLAGS="" \ |
218 | $(BSDMAKE) installhdrs | |
3d9156a7 A |
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 | |
5b2abdfb A |
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 | |
3d9156a7 A |
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 | |
5b2abdfb A |
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 | |
3d9156a7 A |
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 | |
5b2abdfb A |
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 | |
3d9156a7 A |
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 | |
5b2abdfb | 288 | |
9385eb3d | 289 | # Don't use -j here; it may try to make links before the files are copied |
5b2abdfb A |
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 \ | |
59e0d9fe | 297 | MACHINE_ARCH="$(shell arch)" MAKEFLAGS="" bsdmake autopatchman maninstall |
5b2abdfb | 298 | |
59e0d9fe | 299 | install-all: build install-man BI-install-dynamic BI-install-static BI-install-profile BI-install-debug |
5b2abdfb A |
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 |