]>
Commit | Line | Data |
---|---|---|
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 | # temporary disable multi-threaded builds, which are failing; see 3683272 | |
13 | #BSDMAKE = bsdmake -j 2 | |
14 | BSDMAKE = bsdmake | |
15 | ||
16 | # Remove the arch stuff, since we know better here. | |
17 | LOCAL_CFLAGS = $(filter-out -arch ppc -arch ppc64 -arch i386,$(RC_CFLAGS)) | |
18 | ||
19 | all: build | |
20 | ||
21 | # These are the non B&I defaults | |
22 | ifndef RC_ProjectName | |
23 | installhdrs: installhdrs-real | |
24 | build: build-static build-profile build-debug build-dynamic | |
25 | install: installhdrs install-all | |
26 | endif | |
27 | ||
28 | # And these are to deal with B&I building libc differently | |
29 | # based on RC_ProjectName. | |
30 | ifeq ($(RC_ProjectName),Libc) | |
31 | installhdrs: | |
32 | build: build-dynamic | |
33 | install: BI-install-dynamic | |
34 | endif | |
35 | ifeq ($(RC_ProjectName),Libc_headers) | |
36 | installhdrs: installhdrs-real | |
37 | build: | |
38 | install: installhdrs-real | |
39 | endif | |
40 | ifeq ($(RC_ProjectName),Libc_man) | |
41 | installhdrs: | |
42 | build: | |
43 | install: install-man | |
44 | endif | |
45 | ifeq ($(RC_ProjectName),Libc_static) | |
46 | installhdrs: | |
47 | build: build-static | |
48 | install: BI-install-static | |
49 | endif | |
50 | ifeq ($(RC_ProjectName),Libc_debug) | |
51 | installhdrs: | |
52 | build: build-debug | |
53 | install: BI-install-debug | |
54 | endif | |
55 | ifeq ($(RC_ProjectName),Libc_profile) | |
56 | installhdrs: | |
57 | build: build-profile | |
58 | install: BI-install-profile | |
59 | endif | |
60 | ||
61 | build-static: autopatch build-ppc-static build-ppc64-static build-i386-static | |
62 | @echo "Creating final libc_static.a" | |
63 | ifeq ($(words $(RC_ARCHS)),1) | |
64 | cp -p "$(OBJROOT)/obj.$(RC_ARCHS)/libc_static.a" "$(SYMROOT)" | |
65 | else | |
66 | lipo -create \ | |
67 | $(foreach A,$(RC_ARCHS),-arch $(A) "$(OBJROOT)/obj.$(A)/libc_static.a") \ | |
68 | -output $(SYMROOT)/libc_static.a | |
69 | endif | |
70 | build-profile: autopatch build-ppc-profile build-ppc64-profile build-i386-profile | |
71 | @echo "Creating final libc_profile.a" | |
72 | ifeq ($(words $(RC_ARCHS)),1) | |
73 | cp -p "$(OBJROOT)/obj.$(RC_ARCHS)/libc_profile.a" "$(SYMROOT)" | |
74 | else | |
75 | lipo -create \ | |
76 | $(foreach A,$(RC_ARCHS),-arch $(A) "$(OBJROOT)/obj.$(A)/libc_profile.a") \ | |
77 | -output $(SYMROOT)/libc_profile.a | |
78 | endif | |
79 | build-debug: autopatch build-ppc-debug build-ppc64-debug build-i386-debug | |
80 | @echo "Creating final libc_debug.a" | |
81 | ifeq ($(words $(RC_ARCHS)),1) | |
82 | cp -p "$(OBJROOT)/obj.$(RC_ARCHS)/libc_debug.a" "$(SYMROOT)" | |
83 | else | |
84 | lipo -create \ | |
85 | $(foreach A,$(RC_ARCHS),-arch $(A) "$(OBJROOT)/obj.$(A)/libc_debug.a") \ | |
86 | -output $(SYMROOT)/libc_debug.a | |
87 | endif | |
88 | build-dynamic: autopatch build-ppc-dynamic build-ppc64-dynamic build-i386-dynamic | |
89 | @echo "Creating final libc.a" | |
90 | ifeq ($(words $(RC_ARCHS)),1) | |
91 | cp -p "$(OBJROOT)/obj.$(RC_ARCHS)/libc.a" "$(SYMROOT)" | |
92 | else | |
93 | lipo -create \ | |
94 | $(foreach A,$(RC_ARCHS),-arch $(A) "$(OBJROOT)/obj.$(A)/libc.a") \ | |
95 | -output $(SYMROOT)/libc.a | |
96 | endif | |
97 | build-ppc-static: | |
98 | @if [ ! -z "$(RC_ppc)" ]; then \ | |
99 | mkdir -p $(OBJROOT)/obj.ppc ; \ | |
100 | MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \ | |
101 | MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) libc_static.a;\ | |
102 | fi | |
103 | build-ppc64-static: | |
104 | @if [ ! -z "$(RC_ppc64)" ]; then \ | |
105 | mkdir -p $(OBJROOT)/obj.ppc64 ; \ | |
106 | MAKEOBJDIR="$(OBJROOT)/obj.ppc64" MACHINE_ARCH="ppc64" \ | |
107 | MAKEFLAGS="" CFLAGS="-arch ppc64 $(LOCAL_CFLAGS)" $(BSDMAKE) libc_static.a;\ | |
108 | fi | |
109 | build-i386-static: | |
110 | @if [ ! -z "$(RC_i386)" ]; then \ | |
111 | mkdir -p $(OBJROOT)/obj.i386 ; \ | |
112 | MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \ | |
113 | MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) libc_static.a;\ | |
114 | fi | |
115 | build-ppc-profile: | |
116 | @if [ ! -z "$(RC_ppc)" ]; then \ | |
117 | mkdir -p $(OBJROOT)/obj.ppc ; \ | |
118 | MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \ | |
119 | MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) libc_profile.a;\ | |
120 | fi | |
121 | build-ppc64-profile: | |
122 | @if [ ! -z "$(RC_ppc64)" ]; then \ | |
123 | mkdir -p $(OBJROOT)/obj.ppc64 ; \ | |
124 | MAKEOBJDIR="$(OBJROOT)/obj.ppc64" MACHINE_ARCH="ppc64" \ | |
125 | MAKEFLAGS="" CFLAGS="-arch ppc64 $(LOCAL_CFLAGS)" $(BSDMAKE) libc_profile.a;\ | |
126 | fi | |
127 | build-i386-profile: | |
128 | @if [ ! -z "$(RC_i386)" ]; then \ | |
129 | mkdir -p $(OBJROOT)/obj.i386 ; \ | |
130 | MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \ | |
131 | MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) libc_profile.a;\ | |
132 | fi | |
133 | build-ppc-debug: | |
134 | @if [ ! -z "$(RC_ppc)" ]; then \ | |
135 | mkdir -p $(OBJROOT)/obj.ppc ; \ | |
136 | MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \ | |
137 | MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) libc_debug.a;\ | |
138 | fi | |
139 | build-ppc64-debug: | |
140 | @if [ ! -z "$(RC_ppc64)" ]; then \ | |
141 | mkdir -p $(OBJROOT)/obj.ppc64 ; \ | |
142 | MAKEOBJDIR="$(OBJROOT)/obj.ppc64" MACHINE_ARCH="ppc64" \ | |
143 | MAKEFLAGS="" CFLAGS="-arch ppc64 $(LOCAL_CFLAGS)" $(BSDMAKE) libc_debug.a;\ | |
144 | fi | |
145 | build-i386-debug: | |
146 | @if [ ! -z "$(RC_i386)" ]; then \ | |
147 | mkdir -p $(OBJROOT)/obj.i386 ; \ | |
148 | MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \ | |
149 | MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) libc_debug.a;\ | |
150 | fi | |
151 | build-ppc-dynamic: | |
152 | @if [ ! -z "$(RC_ppc)" ]; then \ | |
153 | mkdir -p $(OBJROOT)/obj.ppc ; \ | |
154 | MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \ | |
155 | MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) libc.a;\ | |
156 | fi | |
157 | build-ppc64-dynamic: | |
158 | @if [ ! -z "$(RC_ppc64)" ]; then \ | |
159 | mkdir -p $(OBJROOT)/obj.ppc64 ; \ | |
160 | MAKEOBJDIR="$(OBJROOT)/obj.ppc64" MACHINE_ARCH="ppc64" \ | |
161 | MAKEFLAGS="" CFLAGS="-arch ppc64 $(LOCAL_CFLAGS)" $(BSDMAKE) libc.a;\ | |
162 | fi | |
163 | build-i386-dynamic: | |
164 | @if [ ! -z "$(RC_i386)" ]; then \ | |
165 | mkdir -p $(OBJROOT)/obj.i386 ; \ | |
166 | MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \ | |
167 | MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) libc.a;\ | |
168 | fi | |
169 | ||
170 | build-ppc: | |
171 | @if [ ! -z "$(RC_ppc)" ]; then \ | |
172 | mkdir -p $(OBJROOT)/obj.ppc ; \ | |
173 | MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \ | |
174 | MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) build;\ | |
175 | fi | |
176 | build-ppc64: | |
177 | @if [ ! -z "$(RC_ppc64)" ]; then \ | |
178 | mkdir -p $(OBJROOT)/obj.ppc64 ; \ | |
179 | MAKEOBJDIR="$(OBJROOT)/obj.ppc64" MACHINE_ARCH="ppc64" \ | |
180 | MAKEFLAGS="" CFLAGS="-arch ppc64 $(LOCAL_CFLAGS)" $(BSDMAKE) build;\ | |
181 | fi | |
182 | build-i386: | |
183 | @if [ ! -z "$(RC_i386)" ]; then \ | |
184 | mkdir -p $(OBJROOT)/obj.i386 ; \ | |
185 | MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \ | |
186 | MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) build;\ | |
187 | fi | |
188 | ||
189 | # We have to separately call bsdmake to patch the FreeBSD files, because of | |
190 | # the way its cache works, it would otherwise pick a file in ${SYMROOT}, even | |
191 | # over a .s file. | |
192 | autopatch: | |
193 | @if [ ! -z "$(RC_i386)" ]; then \ | |
194 | MACHINE_ARCH="i386" $(BSDMAKE) autopatch; \ | |
195 | fi | |
196 | @if [ ! -z "$(RC_ppc)" ]; then \ | |
197 | MACHINE_ARCH="ppc" $(BSDMAKE) autopatch; \ | |
198 | fi | |
199 | @if [ ! -z "$(RC_ppc64)" ]; then \ | |
200 | MACHINE_ARCH="ppc64" $(BSDMAKE) autopatch; \ | |
201 | fi | |
202 | ||
203 | installsrc: | |
204 | $(_v) pax -rw . "$(SRCROOT)" | |
205 | ||
206 | installhdrs-real: | |
207 | MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" MAKEFLAGS="" \ | |
208 | $(BSDMAKE) installhdrs | |
209 | @if [ ! -z "$(RC_i386)" ]; then \ | |
210 | mkdir -p "$(OBJROOT)/obj.i386" ; \ | |
211 | MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \ | |
212 | MAKEFLAGS="" $(BSDMAKE) installhdrs-md ; \ | |
213 | fi | |
214 | @if [ ! -z "$(RC_ppc)" ]; then \ | |
215 | mkdir -p "$(OBJROOT)/obj.ppc" ; \ | |
216 | MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \ | |
217 | MAKEFLAGS="" $(BSDMAKE) installhdrs-md ; \ | |
218 | fi | |
219 | @if [ ! -z "$(RC_ppc64)" ]; then \ | |
220 | mkdir -p "$(OBJROOT)/obj.ppc64" ; \ | |
221 | MAKEOBJDIR="$(OBJROOT)/obj.ppc64" MACHINE_ARCH="ppc64" \ | |
222 | MAKEFLAGS="" $(BSDMAKE) installhdrs-md ; \ | |
223 | fi | |
224 | ||
225 | BI-install-static: build-static | |
226 | mkdir -p $(DSTROOT)/usr/local/lib/system | |
227 | if [ -f "$(SYMROOT)/libc_static.a" ]; then \ | |
228 | echo "Installing libc_static.a" ; \ | |
229 | install -c -m 444 "$(SYMROOT)/libc_static.a" \ | |
230 | $(DSTROOT)/usr/local/lib/system; \ | |
231 | ranlib "$(DSTROOT)/usr/local/lib/system/libc_static.a"; \ | |
232 | fi | |
233 | BI-install-profile: build-profile | |
234 | mkdir -p $(DSTROOT)/usr/local/lib/system | |
235 | if [ -f "$(SYMROOT)/libc_profile.a" ]; then \ | |
236 | echo "Installing libc_profile.a" ; \ | |
237 | install -c -m 444 "$(SYMROOT)/libc_profile.a" \ | |
238 | $(DSTROOT)/usr/local/lib/system; \ | |
239 | ranlib "$(DSTROOT)/usr/local/lib/system/libc_profile.a"; \ | |
240 | fi | |
241 | BI-install-debug: build-debug | |
242 | mkdir -p $(DSTROOT)/usr/local/lib/system | |
243 | if [ -f "$(SYMROOT)/libc_debug.a" ]; then \ | |
244 | echo "Installing libc_debug.a" ; \ | |
245 | install -c -m 444 "$(SYMROOT)/libc_debug.a" \ | |
246 | $(DSTROOT)/usr/local/lib/system; \ | |
247 | ranlib "$(DSTROOT)/usr/local/lib/system/libc_debug.a"; \ | |
248 | fi | |
249 | BI-install-dynamic: build-dynamic | |
250 | mkdir -p $(DSTROOT)/usr/local/lib/system | |
251 | if [ -f "$(SYMROOT)/libc.a" ]; then \ | |
252 | echo "Installing libc.a" ; \ | |
253 | install -c -m 444 "$(SYMROOT)/libc.a" \ | |
254 | $(DSTROOT)/usr/local/lib/system; \ | |
255 | ranlib "$(DSTROOT)/usr/local/lib/system/libc.a"; \ | |
256 | fi | |
257 | ||
258 | # Don't use -j here; it may try to make links before the files are copied | |
259 | install-man: | |
260 | mkdir -p $(DSTROOT)/usr/share/man/man2 | |
261 | mkdir -p $(DSTROOT)/usr/share/man/man3 | |
262 | mkdir -p $(DSTROOT)/usr/share/man/man4 | |
263 | mkdir -p $(DSTROOT)/usr/share/man/man5 | |
264 | mkdir -p $(DSTROOT)/usr/share/man/man7 | |
265 | MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" NOMANCOMPRESS=1 \ | |
266 | MACHINE_ARCH="$(shell arch)" MAKEFLAGS="" bsdmake autopatchman maninstall | |
267 | ||
268 | install-all: build install-man BI-install-dynamic BI-install-static BI-install-profile BI-install-debug | |
269 | ||
270 | clean: | |
271 | rm -rf $(OBJROOT)/obj.ppc $(OBJROOT)/obj.i386 $(OBJROOT)/libc.a \ | |
272 | $(OBJROOT)/libc_static.a $(OBJROOT)/libc_debug.a \ | |
273 | $(OBJROOT)/libc_profile.a |