]> git.saurik.com Git - apple/libc.git/blame - GNUmakefile
Libc-339.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
59e0d9fe
A
12# temporary disable multi-threaded builds, which are failing; see 3683272
13#BSDMAKE = bsdmake -j 2
14BSDMAKE = bsdmake
5b2abdfb
A
15
16# Remove the arch stuff, since we know better here.
59e0d9fe 17LOCAL_CFLAGS = $(filter-out -arch ppc -arch ppc64 -arch i386,$(RC_CFLAGS))
5b2abdfb
A
18
19all: build
59e0d9fe 20
5b2abdfb
A
21# These are the non B&I defaults
22ifndef RC_ProjectName
23installhdrs: installhdrs-real
24build: build-static build-profile build-debug build-dynamic
25install: installhdrs install-all
26endif
27
28# And these are to deal with B&I building libc differently
29# based on RC_ProjectName.
30ifeq ($(RC_ProjectName),Libc)
59e0d9fe
A
31installhdrs:
32build: build-dynamic
33install: BI-install-dynamic
34endif
35ifeq ($(RC_ProjectName),Libc_headers)
5b2abdfb 36installhdrs: installhdrs-real
59e0d9fe
A
37build:
38install: installhdrs-real
39endif
40ifeq ($(RC_ProjectName),Libc_man)
41installhdrs:
42build:
43install: install-man
5b2abdfb
A
44endif
45ifeq ($(RC_ProjectName),Libc_static)
46installhdrs:
47build: build-static
48install: BI-install-static
49endif
50ifeq ($(RC_ProjectName),Libc_debug)
51installhdrs:
52build: build-debug
53install: BI-install-debug
54endif
55ifeq ($(RC_ProjectName),Libc_profile)
56installhdrs:
57build: build-profile
58install: BI-install-profile
59endif
60
59e0d9fe
A
61build-static: autopatch build-ppc-static build-ppc64-static build-i386-static
62 @echo "Creating final libc_static.a"
63ifeq ($(words $(RC_ARCHS)),1)
64 cp -p "$(OBJROOT)/obj.$(RC_ARCHS)/libc_static.a" "$(SYMROOT)"
65else
66 lipo -create \
67 $(foreach A,$(RC_ARCHS),-arch $(A) "$(OBJROOT)/obj.$(A)/libc_static.a") \
68 -output $(SYMROOT)/libc_static.a
69endif
70build-profile: autopatch build-ppc-profile build-ppc64-profile build-i386-profile
71 @echo "Creating final libc_profile.a"
72ifeq ($(words $(RC_ARCHS)),1)
73 cp -p "$(OBJROOT)/obj.$(RC_ARCHS)/libc_profile.a" "$(SYMROOT)"
74else
75 lipo -create \
76 $(foreach A,$(RC_ARCHS),-arch $(A) "$(OBJROOT)/obj.$(A)/libc_profile.a") \
77 -output $(SYMROOT)/libc_profile.a
78endif
79build-debug: autopatch build-ppc-debug build-ppc64-debug build-i386-debug
80 @echo "Creating final libc_debug.a"
81ifeq ($(words $(RC_ARCHS)),1)
82 cp -p "$(OBJROOT)/obj.$(RC_ARCHS)/libc_debug.a" "$(SYMROOT)"
83else
84 lipo -create \
85 $(foreach A,$(RC_ARCHS),-arch $(A) "$(OBJROOT)/obj.$(A)/libc_debug.a") \
86 -output $(SYMROOT)/libc_debug.a
87endif
88build-dynamic: autopatch build-ppc-dynamic build-ppc64-dynamic build-i386-dynamic
89 @echo "Creating final libc.a"
90ifeq ($(words $(RC_ARCHS)),1)
91 cp -p "$(OBJROOT)/obj.$(RC_ARCHS)/libc.a" "$(SYMROOT)"
92else
93 lipo -create \
94 $(foreach A,$(RC_ARCHS),-arch $(A) "$(OBJROOT)/obj.$(A)/libc.a") \
95 -output $(SYMROOT)/libc.a
96endif
5b2abdfb
A
97build-ppc-static:
98 @if [ ! -z "$(RC_ppc)" ]; then \
99 mkdir -p $(OBJROOT)/obj.ppc ; \
100 MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \
9385eb3d 101 MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) libc_static.a;\
5b2abdfb 102 fi
59e0d9fe
A
103build-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
5b2abdfb
A
109build-i386-static:
110 @if [ ! -z "$(RC_i386)" ]; then \
111 mkdir -p $(OBJROOT)/obj.i386 ; \
112 MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \
9385eb3d 113 MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) libc_static.a;\
5b2abdfb
A
114 fi
115build-ppc-profile:
116 @if [ ! -z "$(RC_ppc)" ]; then \
117 mkdir -p $(OBJROOT)/obj.ppc ; \
118 MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \
9385eb3d 119 MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) libc_profile.a;\
5b2abdfb 120 fi
59e0d9fe
A
121build-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
5b2abdfb
A
127build-i386-profile:
128 @if [ ! -z "$(RC_i386)" ]; then \
129 mkdir -p $(OBJROOT)/obj.i386 ; \
130 MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \
9385eb3d 131 MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) libc_profile.a;\
5b2abdfb
A
132 fi
133build-ppc-debug:
134 @if [ ! -z "$(RC_ppc)" ]; then \
135 mkdir -p $(OBJROOT)/obj.ppc ; \
136 MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \
9385eb3d 137 MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) libc_debug.a;\
5b2abdfb 138 fi
59e0d9fe
A
139build-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
5b2abdfb
A
145build-i386-debug:
146 @if [ ! -z "$(RC_i386)" ]; then \
147 mkdir -p $(OBJROOT)/obj.i386 ; \
148 MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \
9385eb3d 149 MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) libc_debug.a;\
5b2abdfb
A
150 fi
151build-ppc-dynamic:
152 @if [ ! -z "$(RC_ppc)" ]; then \
153 mkdir -p $(OBJROOT)/obj.ppc ; \
154 MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \
9385eb3d 155 MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) libc.a;\
5b2abdfb 156 fi
59e0d9fe
A
157build-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
5b2abdfb
A
163build-i386-dynamic:
164 @if [ ! -z "$(RC_i386)" ]; then \
165 mkdir -p $(OBJROOT)/obj.i386 ; \
166 MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \
9385eb3d 167 MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) libc.a;\
5b2abdfb
A
168 fi
169
170build-ppc:
171 @if [ ! -z "$(RC_ppc)" ]; then \
172 mkdir -p $(OBJROOT)/obj.ppc ; \
173 MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \
9385eb3d 174 MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) build;\
5b2abdfb 175 fi
59e0d9fe
A
176build-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
5b2abdfb
A
182build-i386:
183 @if [ ! -z "$(RC_i386)" ]; then \
184 mkdir -p $(OBJROOT)/obj.i386 ; \
185 MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \
9385eb3d 186 MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) build;\
5b2abdfb 187 fi
59e0d9fe
A
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.
192autopatch:
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
5b2abdfb
A
203installsrc:
204 $(_v) pax -rw . "$(SRCROOT)"
9385eb3d 205
5b2abdfb 206installhdrs-real:
9385eb3d
A
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
59e0d9fe
A
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
5b2abdfb
A
224
225BI-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
233BI-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
241BI-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
249BI-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
9385eb3d 258# Don't use -j here; it may try to make links before the files are copied
5b2abdfb
A
259install-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 \
59e0d9fe 266 MACHINE_ARCH="$(shell arch)" MAKEFLAGS="" bsdmake autopatchman maninstall
5b2abdfb 267
59e0d9fe 268install-all: build install-man BI-install-dynamic BI-install-static BI-install-profile BI-install-debug
5b2abdfb
A
269
270clean:
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