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