]> git.saurik.com Git - apple/libc.git/blame - GNUmakefile
Libc-320.1.3.tar.gz
[apple/libc.git] / GNUmakefile
CommitLineData
5b2abdfb
A
1ifndef $(OBJROOT)
2OBJROOT = .
3endif
4ifndef $(SYMROOT)
5SYMROOT = .
6endif
7ARCH = $(shell arch)
8ifndef RC_ppc
9ifndef RC_i386
10RC_ppc = 1
11endif
12endif
9385eb3d 13BSDMAKE = bsdmake -j 2
5b2abdfb
A
14
15# Remove the arch stuff, since we know better here.
16LOCAL_CFLAGS = $(filter-out -arch ppc -arch i386,$(RC_CFLAGS))
17
18all: build
19# These are the non B&I defaults
20ifndef RC_ProjectName
21installhdrs: installhdrs-real
22build: build-static build-profile build-debug build-dynamic
23install: installhdrs install-all
24endif
25
26# And these are to deal with B&I building libc differently
27# based on RC_ProjectName.
28ifeq ($(RC_ProjectName),Libc)
29installhdrs: installhdrs-real
30build: build-man build-dynamic
31install: installhdrs-real BI-install-dynamic install-man
32endif
33ifeq ($(RC_ProjectName),Libc_static)
34installhdrs:
35build: build-static
36install: BI-install-static
37endif
38ifeq ($(RC_ProjectName),Libc_debug)
39installhdrs:
40build: build-debug
41install: BI-install-debug
42endif
43ifeq ($(RC_ProjectName),Libc_profile)
44installhdrs:
45build: build-profile
46install: BI-install-profile
47endif
48
49build-man:
50 MAKEOBJDIR="$(OBJROOT)" MACHINE_ARCH="$(shell arch)" \
9385eb3d 51 MAKEFLAGS="" $(BSDMAKE) buildman
5b2abdfb
A
52build-static: build-ppc-static build-i386-static
53 @echo "Checking for libc_static.a"
54 @if [ -f "$(OBJROOT)/obj.ppc/libc_static.a" -a -f "$(OBJROOT)/obj.i386/libc_static.a" ]; then\
55 lipo -create -arch ppc "$(OBJROOT)/obj.ppc/libc_static.a" \
56 -arch i386 "$(OBJROOT)/obj.i386/libc_static.a" \
57 -output $(SYMROOT)/libc_static.a;\
58 elif [ -f "$(OBJROOT)/obj.ppc/libc_static.a" ]; then \
59 cp -p "$(OBJROOT)/obj.ppc/libc_static.a" "$(SYMROOT)"; \
60 elif [ -f "$(OBJROOT)/obj.i386/libc_static.a" ]; then \
61 cp -p "$(OBJROOT)/obj.i386/libc_static.a" "$(SYMROOT)"; \
62 fi
63build-profile: build-ppc-profile build-i386-profile
64 @echo "Checking for libc_profile.a"
65 @if [ -f "$(OBJROOT)/obj.ppc/libc_profile.a" -a -f "$(OBJROOT)/obj.i386/libc_profile.a" ]; then\
66 lipo -create -arch ppc "$(OBJROOT)/obj.ppc/libc_profile.a" \
67 -arch i386 "$(OBJROOT)/obj.i386/libc_profile.a" \
68 -output $(SYMROOT)/libc_profile.a;\
69 elif [ -f "$(OBJROOT)/obj.ppc/libc_profile.a" ]; then \
70 cp -p "$(OBJROOT)/obj.ppc/libc_profile.a" "$(SYMROOT)"; \
71 elif [ -f "$(OBJROOT)/obj.i386/libc_profile.a" ]; then \
72 cp -p "$(OBJROOT)/obj.i386/libc_profile.a" "$(SYMROOT)"; \
73 fi
74build-debug: build-ppc-debug build-i386-debug
75 @echo "Checking for libc_debug.a"
76 @if [ -f "$(OBJROOT)/obj.ppc/libc_debug.a" -a -f "$(OBJROOT)/obj.i386/libc_debug.a" ]; then\
77 lipo -create -arch ppc "$(OBJROOT)/obj.ppc/libc_debug.a" \
78 -arch i386 "$(OBJROOT)/obj.i386/libc_debug.a" \
79 -output $(SYMROOT)/libc_debug.a;\
80 elif [ -f "$(OBJROOT)/obj.ppc/libc_debug.a" ]; then \
81 cp -p "$(OBJROOT)/obj.ppc/libc_debug.a" "$(SYMROOT)"; \
82 elif [ -f "$(OBJROOT)/obj.i386/libc_debug.a" ]; then \
83 cp -p "$(OBJROOT)/obj.i386/libc_debug.a" "$(SYMROOT)"; \
84 fi
85build-dynamic: build-ppc-dynamic build-i386-dynamic
86 @echo "Checking for libc.a"
87 @if [ -f "$(OBJROOT)/obj.ppc/libc.a" -a -f "$(OBJROOT)/obj.i386/libc.a" ]; then\
88 echo "Creating FAT libc.a"; \
89 lipo -create -arch ppc "$(OBJROOT)/obj.ppc/libc.a" -arch i386 \
90 "$(OBJROOT)/obj.i386/libc.a" -output $(SYMROOT)/libc.a;\
91 elif [ -f "$(OBJROOT)/obj.ppc/libc.a" ]; then \
92 echo "Using thin PPC libc.a" ;\
93 cp -p "$(OBJROOT)/obj.ppc/libc.a" "$(SYMROOT)"; \
94 elif [ -f "$(OBJROOT)/obj.i386/libc.a" ]; then \
95 echo "Using thin i386 libc.a" ;\
96 cp -p "$(OBJROOT)/obj.i386/libc.a" "$(SYMROOT)"; \
97 fi
98build-ppc-static:
99 @if [ ! -z "$(RC_ppc)" ]; then \
100 mkdir -p $(OBJROOT)/obj.ppc ; \
101 MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \
9385eb3d 102 MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) libc_static.a;\
5b2abdfb
A
103 fi
104build-i386-static:
105 @if [ ! -z "$(RC_i386)" ]; then \
106 mkdir -p $(OBJROOT)/obj.i386 ; \
107 MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \
9385eb3d 108 MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) libc_static.a;\
5b2abdfb
A
109 fi
110build-ppc-profile:
111 @if [ ! -z "$(RC_ppc)" ]; then \
112 mkdir -p $(OBJROOT)/obj.ppc ; \
113 MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \
9385eb3d 114 MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) libc_profile.a;\
5b2abdfb
A
115 fi
116build-i386-profile:
117 @if [ ! -z "$(RC_i386)" ]; then \
118 mkdir -p $(OBJROOT)/obj.i386 ; \
119 MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \
9385eb3d 120 MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) libc_profile.a;\
5b2abdfb
A
121 fi
122build-ppc-debug:
123 @if [ ! -z "$(RC_ppc)" ]; then \
124 mkdir -p $(OBJROOT)/obj.ppc ; \
125 MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \
9385eb3d 126 MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) libc_debug.a;\
5b2abdfb
A
127 fi
128build-i386-debug:
129 @if [ ! -z "$(RC_i386)" ]; then \
130 mkdir -p $(OBJROOT)/obj.i386 ; \
131 MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \
9385eb3d 132 MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) libc_debug.a;\
5b2abdfb
A
133 fi
134build-ppc-dynamic:
135 @if [ ! -z "$(RC_ppc)" ]; then \
136 mkdir -p $(OBJROOT)/obj.ppc ; \
137 MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \
9385eb3d 138 MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) libc.a;\
5b2abdfb
A
139 fi
140build-i386-dynamic:
141 @if [ ! -z "$(RC_i386)" ]; then \
142 mkdir -p $(OBJROOT)/obj.i386 ; \
143 MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \
9385eb3d 144 MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) libc.a;\
5b2abdfb
A
145 fi
146
147build-ppc:
148 @if [ ! -z "$(RC_ppc)" ]; then \
149 mkdir -p $(OBJROOT)/obj.ppc ; \
150 MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \
9385eb3d 151 MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) build;\
5b2abdfb
A
152 fi
153build-i386:
154 @if [ ! -z "$(RC_i386)" ]; then \
155 mkdir -p $(OBJROOT)/obj.i386 ; \
156 MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \
9385eb3d 157 MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) build;\
5b2abdfb
A
158 fi
159installsrc:
160 $(_v) pax -rw . "$(SRCROOT)"
9385eb3d 161
5b2abdfb 162installhdrs-real:
9385eb3d
A
163 MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" MAKEFLAGS="" \
164 $(BSDMAKE) installhdrs
165 @if [ ! -z "$(RC_i386)" ]; then \
166 mkdir -p "$(OBJROOT)/obj.i386" ; \
167 MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \
168 MAKEFLAGS="" $(BSDMAKE) installhdrs-md ; \
169 fi
170 @if [ ! -z "$(RC_ppc)" ]; then \
171 mkdir -p "$(OBJROOT)/obj.ppc" ; \
172 MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \
173 MAKEFLAGS="" $(BSDMAKE) installhdrs-md ; \
174 fi
5b2abdfb
A
175
176BI-install-static: build-static
177 mkdir -p $(DSTROOT)/usr/local/lib/system
178 if [ -f "$(SYMROOT)/libc_static.a" ]; then \
179 echo "Installing libc_static.a" ; \
180 install -c -m 444 "$(SYMROOT)/libc_static.a" \
181 $(DSTROOT)/usr/local/lib/system; \
182 ranlib "$(DSTROOT)/usr/local/lib/system/libc_static.a"; \
183 fi
184BI-install-profile: build-profile
185 mkdir -p $(DSTROOT)/usr/local/lib/system
186 if [ -f "$(SYMROOT)/libc_profile.a" ]; then \
187 echo "Installing libc_profile.a" ; \
188 install -c -m 444 "$(SYMROOT)/libc_profile.a" \
189 $(DSTROOT)/usr/local/lib/system; \
190 ranlib "$(DSTROOT)/usr/local/lib/system/libc_profile.a"; \
191 fi
192BI-install-debug: build-debug
193 mkdir -p $(DSTROOT)/usr/local/lib/system
194 if [ -f "$(SYMROOT)/libc_debug.a" ]; then \
195 echo "Installing libc_debug.a" ; \
196 install -c -m 444 "$(SYMROOT)/libc_debug.a" \
197 $(DSTROOT)/usr/local/lib/system; \
198 ranlib "$(DSTROOT)/usr/local/lib/system/libc_debug.a"; \
199 fi
200BI-install-dynamic: build-dynamic
201 mkdir -p $(DSTROOT)/usr/local/lib/system
202 if [ -f "$(SYMROOT)/libc.a" ]; then \
203 echo "Installing libc.a" ; \
204 install -c -m 444 "$(SYMROOT)/libc.a" \
205 $(DSTROOT)/usr/local/lib/system; \
206 ranlib "$(DSTROOT)/usr/local/lib/system/libc.a"; \
207 fi
208
9385eb3d 209# Don't use -j here; it may try to make links before the files are copied
5b2abdfb
A
210install-man:
211 mkdir -p $(DSTROOT)/usr/share/man/man2
212 mkdir -p $(DSTROOT)/usr/share/man/man3
213 mkdir -p $(DSTROOT)/usr/share/man/man4
214 mkdir -p $(DSTROOT)/usr/share/man/man5
215 mkdir -p $(DSTROOT)/usr/share/man/man7
216 MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" NOMANCOMPRESS=1 \
9385eb3d 217 MACHINE_ARCH="$(shell arch)" MAKEFLAGS="" bsdmake fbsdman maninstall
5b2abdfb
A
218
219install-all: build install-man BI-install-dynamic BI-install-static BI-install-profile
220
221clean:
222 rm -rf $(OBJROOT)/obj.ppc $(OBJROOT)/obj.i386 $(OBJROOT)/libc.a \
223 $(OBJROOT)/libc_static.a $(OBJROOT)/libc_debug.a \
224 $(OBJROOT)/libc_profile.a