]> git.saurik.com Git - apple/libc.git/blob - Makefile.xbs
Libc-594.9.5.tar.gz
[apple/libc.git] / Makefile.xbs
1 # This is a replacement for bsd.lib.mk for the libc project to get it
2 # doing the Right Thing in XBS, which is substantially different than
3 # the BSD build system.
4 #
5 # The main problems arise when libc.a isn't meant to be static, but
6 # libc_static.a is. We also build a debug version of the library
7 # in addition to shared, static, and profile. Also, we build all
8 # versions of libc with debugging enabled, unstripped. The BSD style
9 # is to strip every object file after it is built but here, libc.a
10 # will get merged into the larger libSystem.dylib, which will eventually
11 # be stripped. We also don't build a libc.dylib, since it will be
12 # munged into libSystem.dylib.
13 #
14 # And another difference, B&I wishes to build the 4 incarnations of Libc
15 # in parallel on different machines. To do this, we must look at the
16 # RC_ProjectName variable (which B&I sets) to determine which of the 4
17 # versions of Libc we will be building. Remember that the installhdrs
18 # pass should only be invoked on one of the 4 versions, and man pages
19 # should only be installed once as well. Both of these get done when
20 # we're invoked as "Libc".
21
22 MYBSDMAKE = ${BSDMAKE} -f Makefile
23
24 .PATH: .
25 .MAIN: all
26 all: libc.a libc_static.a libc_debug.a libc_profile.a
27 install: ${SYMROOTINC}/${MACHINE_ARCH}/libc-features.h installhdrs install_libc.a \
28 install_libc_profile.a install_libc_debug.a \
29 maninstall
30
31 .SUFFIXES:
32 .SUFFIXES: .o .po .So .do
33 .SUFFIXES: .S .s .c .cc .cpp .cxx .m .C
34 .SUFFIXES: -fbsd.c -nbsd.c -obsd.c -uuid.c
35 .SUFFIXES: .f .y .l .defs .h
36 .SUFFIXES: User.c User.o User.po User.So User.do
37 .SUFFIXES: Server.c Server.o Server.po Server.So Server.do
38 .SUFFIXES: .3-uuid.in .3
39
40 OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
41 DOBJS+= ${OBJS:.o=.do}
42 POBJS+= ${OBJS:.o=.po} ${STATICOBJS:.o=.po}
43 SOBJS+= ${OBJS:.o=.So}
44
45 #### Variant Rules ####################################################
46 # The following magic is used for variants to avoid the exponental explosion
47 # of suffix rules. To add a variant, select a name (typically all-caps).
48 # Add that name to the VARIANTS variable. Create a CFLAGS_XXX variable
49 # (XXX is the variant name) that contains the extra flags to pass to the
50 # compiler (currently, no slashes are permitted in the flags). Then, just
51 # define a XXXSRCS variable with the names of the files to recompile with the
52 # additional flags. For auto-patched files, don't use the auto-patched file
53 # name. Just use the original file name.
54 #
55 # Note that this magic also deals with combinations of variants; e.g.,
56 # for two variants XXX and YYY, there are three variant combinations,
57 # XXX, XXX-YYY and YYY. In this example, you can use XXX-YYYSRCS to
58 # specify sources that will build with both the CFLAGS_XXX and CFLAGS_YYY
59 # flags set. The variants are always in alphabetic order.
60 #
61 # The DYLD variant is special; it builds a separate archive for use by dyld,
62 # and contains customized binaries that are used to override the behavior of
63 # the corresponding binaries in libc.a. The DYLD variant by itself does not
64 # cause BUILDING_VARIANT to be defined, and object files are in DYLDOBJS.
65 #
66 VARIANTS = CANCELABLE DARWINEXTSN DYLD
67
68 .ifndef FEATURE_ONLY_64_BIT_INO_T
69 VARIANTS += INODE32
70 .endif
71 .ifndef FEATURE_ONLY_1050_VARIANTS
72 VARIANTS += PRE1050
73 .endif
74 .ifndef FEATURE_ONLY_UNIX_CONFORMANCE
75 VARIANTS+= LEGACY
76 .endif
77 # Append the 64-bit long double sources (ppc only)
78 .if (${MACHINE_ARCH} == ppc)
79 VARIANTS += LDBL
80 MDSRCS += ldbl64.s
81 .endif
82
83 CFLAGS_CANCELABLE= -DVARIANT_CANCELABLE
84 CFLAGS_DARWINEXTSN= -DVARIANT_DARWINEXTSN
85 CFLAGS_DYLD= -DVARIANT_DYLD
86 CFLAGS_INODE32= -U__DARWIN_64_BIT_INO_T -D__DARWIN_64_BIT_INO_T=0 -DVARIANT_INODE32
87 CFLAGS_LDBL= -mlong-double-64 -DLDBL_COMPAT
88 CFLAGS_LEGACY= -U__DARWIN_UNIX03 -D__DARWIN_UNIX03=0 -U__DARWIN_64_BIT_INO_T -D__DARWIN_64_BIT_INO_T=0 -DVARIANT_LEGACY
89 CFLAGS_PRE1050= -U__DARWIN_VERS_1050 -D__DARWIN_VERS_1050=0 -DVARIANT_PRE1050
90
91 # to insure a variable expansion of the left-hand side of a comparison
92 DYLD = DYLD
93
94 .for _v in ${VARIANTS}
95 COMBOARGS+= ${_v}/${CFLAGS_${_v}}
96 .endfor
97 .ifdef COMBOARGS
98 # makeCombos is a perl script that creates all the variant combinations
99 # and all the combinations of flags
100 VARIANTCOMBOCFLAGS != ${.CURDIR}/makeCombos ${COMBOARGS}
101 .endif
102 # For each of the variant combinations as target (and possibly suffixed with
103 # _D, _P, and _S for the four kinds on compile styles, we create a subdirectory
104 # to do the compiling in, and then call ${MYBSDMAKE} with the new directory, and
105 # setting VARIANTCFLAGS, which are the extra flags to be added to CFLAGS.
106 .for _v in ${VARIANTCOMBOCFLAGS}
107 VARIANTCOMBOS+= ${_v:H:S,/,,}
108 .if ${DYLD} != ${_v:H:S,/,,}
109 ${_v:H:S,/,,}_BUILDING_VARIANT = -DBUILDING_VARIANT
110 .endif
111 ${_v:H:S,/,,}:
112 .ifdef ${_v:H:S,/,,}SRCS
113 ${MKDIR} ${MAKEOBJDIR}/${_v:H:S,/,,}; \
114 MAKEOBJDIR="${MAKEOBJDIR}/${_v:H:S,/,,}" VARIANTCFLAGS="-DBUILDING_VARIANT ${_v:T:S/@/ /g}" ${MYBSDMAKE} -C "${.CURDIR}" build_${_v:H:S,/,,}
115 .endif
116 ${_v:H:S,/,,}_D:
117 .ifdef ${_v:H:S,/,,}SRCS
118 ${MKDIR} ${MAKEOBJDIR}/${_v:H:S,/,,}; \
119 MAKEOBJDIR="${MAKEOBJDIR}/${_v:H:S,/,,}" VARIANTCFLAGS="-DBUILDING_VARIANT ${_v:T:S/@/ /g}" ${MYBSDMAKE} -C "${.CURDIR}" build_${_v:H:S,/,,}_D
120 .endif
121 ${_v:H:S,/,,}_P:
122 .ifdef ${_v:H:S,/,,}SRCS
123 ${MKDIR} ${MAKEOBJDIR}/${_v:H:S,/,,}; \
124 MAKEOBJDIR="${MAKEOBJDIR}/${_v:H:S,/,,}" VARIANTCFLAGS="-DBUILDING_VARIANT ${_v:T:S/@/ /g}" ${MYBSDMAKE} -C "${.CURDIR}" build_${_v:H:S,/,,}_P
125 .endif
126 ${_v:H:S,/,,}_S:
127 .ifdef ${_v:H:S,/,,}SRCS
128 ${MKDIR} ${MAKEOBJDIR}/${_v:H:S,/,,}; \
129 MAKEOBJDIR="${MAKEOBJDIR}/${_v:H:S,/,,}" VARIANTCFLAGS="${${_v:H:S,/,,}_BUILDING_VARIANT} ${_v:T:S/@/ /g}" ${MYBSDMAKE} -C "${.CURDIR}" build_${_v:H:S,/,,}_S
130 .endif
131 .endfor
132
133 # The non-DYLD variants
134 .for _v in ${VARIANTCOMBOS:N*DYLD*}
135 # Variant suffix rules so the filenames are unique and Libsystem won't complain
136 # because of ambiguities with -sectorder
137 .SUFFIXES: -${_v}.o -${_v}.do -${_v}.po -${_v}.So
138 .o-${_v}.o .do-${_v}.do .po-${_v}.po .So-${_v}.So:
139 ${MV} ${.IMPSRC} ${.TARGET}
140
141 # These are the build targets of the above ${MYBSDMAKE} calls, which just builds
142 # using the standard rules, but with the additional flags.
143 VARIANTOBJS+= ${${_v}SRCS:N*.h:R:S/$/-${_v}.o/g:S,^,${_v}/,g}
144 build_${_v}: ${${_v}SRCS:N*.h:R:S/$/-${_v}.o/g}
145 build_${_v}_D: ${${_v}SRCS:N*.h:R:S/$/-${_v}.do/g}
146 build_${_v}_P: ${${_v}SRCS:N*.h:R:S/$/-${_v}.po/g}
147 build_${_v}_S: ${${_v}SRCS:N*.h:R:S/$/-${_v}.So/g}
148 .endfor
149 # These variables, plus VARIANTOBJS above, are the extra binaries that get
150 # added to the .a files. Note that these objects are in subdirectories
151 # of the main build directory.
152 VARIANTDOBJS+= ${VARIANTOBJS:.o=.do}
153 VARIANTPOBJS+= ${VARIANTOBJS:.o=.po}
154 VARIANTSOBJS+= ${VARIANTOBJS:.o=.So}
155
156 # Now for the DYLD variants
157 .for _v in ${VARIANTCOMBOS:M*DYLD*}
158 # Variant suffix rules so the filenames are unique and Libsystem won't complain
159 # because of ambiguities with -sectorder
160 .SUFFIXES: -${_v}.o -${_v}.do -${_v}.po -${_v}.So
161 .o-${_v}.o .do-${_v}.do .po-${_v}.po .So-${_v}.So:
162 ${MV} ${.IMPSRC} ${.TARGET}
163
164 # These are the build targets of the above ${MYBSDMAKE} calls, which just builds
165 # using the standard rules, but with the additional flags.
166 DYLDOBJS+= ${${_v}SRCS:N*.h:R:S/$/-${_v}.So/g:S,^,${_v}/,g}
167 build_${_v}:
168 build_${_v}_D:
169 build_${_v}_P:
170 build_${_v}_S: ${${_v}SRCS:N*.h:R:S/$/-${_v}.So/g}
171 .endfor
172 #### FreeBSD Rules ##################################################
173 PREFBSDFLAGS= -I${.CURDIR}/fbsdcompat
174 FBSDFLAGS= -include _fbsd_compat_.h
175
176 -fbsd.c.o:
177 ${MYCC} -static \
178 ${PREFBSDFLAGS} ${PRECFLAGS} ${PRECFLAGS-${.IMPSRC:T}} \
179 ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
180 ${VARIANTCFLAGS} ${FBSDFLAGS} ${LIBCFLAGS} \
181 -Os ${OPTIMIZE-${.IMPSRC:T}} -c ${.IMPSRC} -o ${.TARGET}
182 -fbsd.c.po:
183 ${MYCC} -pg -DPROFILE \
184 ${PREFBSDFLAGS} ${PRECFLAGS} ${PRECFLAGS-${.IMPSRC:T}} \
185 ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
186 ${VARIANTCFLAGS} ${FBSDFLAGS} ${LIBCFLAGS} \
187 -Os ${OPTIMIZE-${.IMPSRC:T}} -c ${.IMPSRC} -o ${.TARGET}
188 -fbsd.c.So:
189 ${MYCC} \
190 ${PREFBSDFLAGS} ${PRECFLAGS} ${PRECFLAGS-${.IMPSRC:T}} \
191 ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
192 ${VARIANTCFLAGS} ${FBSDFLAGS} ${LIBCFLAGS} \
193 -Os ${OPTIMIZE-${.IMPSRC:T}} -c ${.IMPSRC} -o ${.TARGET}
194 -fbsd.c.do:
195 ${MYCC} -DDEBUG \
196 ${PREFBSDFLAGS} ${PRECFLAGS} ${PRECFLAGS-${.IMPSRC:T}} \
197 ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
198 ${VARIANTCFLAGS} ${FBSDFLAGS} ${LIBCFLAGS} \
199 -c ${.IMPSRC} -o ${.TARGET}
200
201 #### NetBSD Rules ##################################################
202 PRENBSDFLAGS= -I${.CURDIR}/nbsdcompat
203 NBSDFLAGS= -include _nbsd_compat_.h
204
205 -nbsd.c.o:
206 ${MYCC} -static \
207 ${PRENBSDFLAGS} ${PRECFLAGS} ${PRECFLAGS-${.IMPSRC:T}} \
208 ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
209 ${VARIANTCFLAGS} ${NBSDFLAGS} ${LIBCFLAGS} \
210 -Os ${OPTIMIZE-${.IMPSRC:T}} -c ${.IMPSRC} -o ${.TARGET}
211 -nbsd.c.po:
212 ${MYCC} -pg -DPROFILE \
213 ${PRENBSDFLAGS} ${PRECFLAGS} ${PRECFLAGS-${.IMPSRC:T}} \
214 ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
215 ${VARIANTCFLAGS} ${NBSDFLAGS} ${LIBCFLAGS} \
216 -Os ${OPTIMIZE-${.IMPSRC:T}} -c ${.IMPSRC} -o ${.TARGET}
217 -nbsd.c.So:
218 ${MYCC} \
219 ${PRENBSDFLAGS} ${PRECFLAGS} ${PRECFLAGS-${.IMPSRC:T}} \
220 ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
221 ${VARIANTCFLAGS} ${NBSDFLAGS} ${LIBCFLAGS} \
222 -Os ${OPTIMIZE-${.IMPSRC:T}} -c ${.IMPSRC} -o ${.TARGET}
223 -nbsd.c.do:
224 ${MYCC} -DDEBUG \
225 ${PRENBSDFLAGS} ${PRECFLAGS} ${PRECFLAGS-${.IMPSRC:T}} \
226 ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
227 ${VARIANTCFLAGS} ${NBSDFLAGS} ${LIBCFLAGS} \
228 -c ${.IMPSRC} -o ${.TARGET}
229
230 #### OpenBSD Rules ##################################################
231 PREOBSDFLAGS=
232 OBSDFLAGS=
233
234 -obsd.c.o:
235 ${MYCC} -static \
236 ${PREOBSDFLAGS} ${PRECFLAGS} ${PRECFLAGS-${.IMPSRC:T}} \
237 ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
238 ${VARIANTCFLAGS} ${OBSDFLAGS} ${LIBCFLAGS} \
239 -Os ${OPTIMIZE-${.IMPSRC:T}} -c ${.IMPSRC} -o ${.TARGET}
240 -obsd.c.po:
241 ${MYCC} -pg -DPROFILE \
242 ${PREOBSDFLAGS} ${PRECFLAGS} ${PRECFLAGS-${.IMPSRC:T}} \
243 ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
244 ${VARIANTCFLAGS} ${OBSDFLAGS} ${LIBCFLAGS} \
245 -Os ${OPTIMIZE-${.IMPSRC:T}} -c ${.IMPSRC} -o ${.TARGET}
246 -obsd.c.So:
247 ${MYCC} \
248 ${PREOBSDFLAGS} ${PRECFLAGS} ${PRECFLAGS-${.IMPSRC:T}} \
249 ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
250 ${VARIANTCFLAGS} ${OBSDFLAGS} ${LIBCFLAGS} \
251 -Os ${OPTIMIZE-${.IMPSRC:T}} -c ${.IMPSRC} -o ${.TARGET}
252 -obsd.c.do:
253 ${MYCC} -DDEBUG \
254 ${PREOBSDFLAGS} ${PRECFLAGS} ${PRECFLAGS-${.IMPSRC:T}} \
255 ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
256 ${VARIANTCFLAGS} ${OBSDFLAGS} ${LIBCFLAGS} \
257 -c ${.IMPSRC} -o ${.TARGET}
258
259 #### UUID Rules ######################################################
260 PREUUIDFLAGS= -I${.CURDIR}/uuid
261 UUIDFLAGS= -include uuid-config.h
262
263 -uuid.c.o:
264 ${MYCC} -static \
265 ${PREUUIDFLAGS} ${PRECFLAGS} ${PRECFLAGS-${.IMPSRC:T}} \
266 ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
267 ${VARIANTCFLAGS} ${UUIDFLAGS} ${LIBCFLAGS} \
268 -Os ${OPTIMIZE-${.IMPSRC:T}} -c ${.IMPSRC} -o ${.TARGET}
269 -uuid.c.po:
270 ${MYCC} -pg -DPROFILE \
271 ${PREUUIDFLAGS} ${PRECFLAGS} ${PRECFLAGS-${.IMPSRC:T}} \
272 ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
273 ${VARIANTCFLAGS} ${UUIDFLAGS} ${LIBCFLAGS} \
274 -Os ${OPTIMIZE-${.IMPSRC:T}} -c ${.IMPSRC} -o ${.TARGET}
275 -uuid.c.So:
276 ${MYCC} \
277 ${PREUUIDFLAGS} ${PRECFLAGS} ${PRECFLAGS-${.IMPSRC:T}} \
278 ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
279 ${VARIANTCFLAGS} ${UUIDFLAGS} ${LIBCFLAGS} \
280 -Os ${OPTIMIZE-${.IMPSRC:T}} -c ${.IMPSRC} -o ${.TARGET}
281 -uuid.c.do:
282 ${MYCC} -DDEBUG \
283 ${PREUUIDFLAGS} ${PRECFLAGS} ${PRECFLAGS-${.IMPSRC:T}} \
284 ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
285 ${VARIANTCFLAGS} ${UUIDFLAGS} ${LIBCFLAGS} \
286 -c ${.IMPSRC} -o ${.TARGET}
287 .3-uuid.in.3:
288 ${SED} -f ${SRCROOT}/uuid/uuidman.sed ${.IMPSRC} > ${.TARGET}
289
290 #### Standard C Rules #################################################
291 # If you change any of these standard rule, make corresponding changes
292 # to the _STANDARD_* macros in Makefile.inc
293 #######################################################################
294 .c.o User.cUser.o Server.cServer.o:
295 ${MYCC} -static \
296 ${PRECFLAGS} ${PRECFLAGS-${.IMPSRC:T}} \
297 ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
298 ${VARIANTCFLAGS} ${LIBCFLAGS} \
299 -Os ${OPTIMIZE-${.IMPSRC:T}} -c ${.IMPSRC} -o ${.TARGET}
300 .c.po User.cUser.po Server.cServer.po:
301 ${MYCC} -pg -DPROFILE \
302 ${PRECFLAGS} ${PRECFLAGS-${.IMPSRC:T}} \
303 ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
304 ${VARIANTCFLAGS} ${LIBCFLAGS} \
305 -Os ${OPTIMIZE-${.IMPSRC:T}} -c ${.IMPSRC} -o ${.TARGET}
306 .c.So User.cUser.So Server.cServer.So:
307 ${MYCC} \
308 ${PRECFLAGS} ${PRECFLAGS-${.IMPSRC:T}} \
309 ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
310 ${VARIANTCFLAGS} ${LIBCFLAGS} \
311 -Os ${OPTIMIZE-${.IMPSRC:T}} -c ${.IMPSRC} -o ${.TARGET}
312 .c.do User.cUser.do Server.cServer.do:
313 ${MYCC} -DDEBUG \
314 ${PRECFLAGS} ${PRECFLAGS-${.IMPSRC:T}} \
315 ${CFLAGS} ${CFLAGS-${.IMPSRC:T}} \
316 ${VARIANTCFLAGS} ${LIBCFLAGS} \
317 -c ${.IMPSRC} -o ${.TARGET}
318
319 #### Standard Assembler Rules #########################################
320 .s.o .S.o:
321 ${MYCC} -static -x assembler-with-cpp \
322 ${PRECFLAGS:M-[BIDFU]*} ${PRECFLAGS-${.IMPSRC:T}:M-[BIDFU]*} \
323 ${CFLAGS:M-[BIDFU]*} ${CFLAGS-${.IMPSRC:T}:M-[BIDFU]*} ${AINC} \
324 -Os ${OPTIMIZE-${.IMPSRC:T}} -c ${.IMPSRC} -o ${.TARGET}
325 .s.po .S.po:
326 ${MYCC} -pg -x assembler-with-cpp -DPROFILE \
327 ${PRECFLAGS:M-[BIDFU]*} ${PRECFLAGS-${.IMPSRC:T}:M-[BIDFU]*} \
328 ${CFLAGS:M-[BIDFU]*} ${CFLAGS-${.IMPSRC:T}:M-[BIDFU]*} ${AINC} \
329 -Os ${OPTIMIZE-${.IMPSRC:T}} -c ${.IMPSRC} -o ${.TARGET}
330 .s.So .S.So:
331 ${MYCC} -x assembler-with-cpp \
332 ${PRECFLAGS:M-[BIDFU]*} ${PRECFLAGS-${.IMPSRC:T}:M-[BIDFU]*} \
333 ${CFLAGS:M-[BIDFU]*} ${CFLAGS-${.IMPSRC:T}:M-[BIDFU]*} ${AINC} \
334 -Os ${OPTIMIZE-${.IMPSRC:T}} -c ${.IMPSRC} -o ${.TARGET}
335 .s.do .S.do:
336 ${MYCC} -x assembler-with-cpp -DDEBUG \
337 ${PRECFLAGS:M-[BIDFU]*} ${PRECFLAGS-${.IMPSRC:T}:M-[BIDFU]*} \
338 ${CFLAGS:M-[BIDFU]*} ${CFLAGS-${.IMPSRC:T}:M-[BIDFU]*} ${AINC} \
339 -c ${.IMPSRC} -o ${.TARGET}
340
341 #### mig Rules ########################################################
342 .defs.h .defsUser.c .defsServer.c:
343 ${MIG} -arch ${CCARCH} -cc ${MYCC} -user ${.PREFIX}User.c -server ${.PREFIX}Server.c -header ${.PREFIX}.h ${.IMPSRC}
344
345 gen_mig_defs: ${SRVMIGHDRS} ${MIGHDRS}
346 gen_md_mig_defs: ${MD_MIGHDRS}
347
348 #### Library Rules ####################################################
349 ${VARIANTCOMBOS:N*DYLD*} ${OBJS} ${STATICOBJS}: ${SYMROOTINC}/${MACHINE_ARCH}/libc-features.h
350 lib${LIB}_static.a:: ${VARIANTCOMBOS:N*DYLD*} ${OBJS} ${STATICOBJS}
351 @${ECHO} building static ${LIB} library
352 @${RM} lib${LIB}_static.a
353 @${AR} cq lib${LIB}_static.a `${LORDER} ${OBJS} ${STATICOBJS} ${VARIANTOBJS} | ${TSORT} -q`
354 ${RANLIB} lib${LIB}_static.a
355
356 ${VARIANTCOMBOS:N*DYLD*:S/$/_P/g} ${POBJS}: ${SYMROOTINC}/${MACHINE_ARCH}/libc-features.h
357 lib${LIB}_profile.a:: ${VARIANTCOMBOS:N*DYLD*:S/$/_P/g} ${POBJS}
358 @${ECHO} building profiled ${LIB} library
359 @${RM} lib${LIB}_profile.a
360 @${AR} cq lib${LIB}_profile.a `${LORDER} ${POBJS} ${VARIANTPOBJS} | ${TSORT} -q`
361 ${RANLIB} lib${LIB}_profile.a
362
363 ${VARIANTCOMBOS:N*DYLD*:S/$/_D/g} ${DOBJS}: ${SYMROOTINC}/${MACHINE_ARCH}/libc-features.h
364 lib${LIB}_debug.a:: ${VARIANTCOMBOS:N*DYLD*:S/$/_D/g} ${DOBJS}
365 @${ECHO} building debug ${LIB} library
366 @${RM} lib${LIB}_debug.a
367 @${AR} cq lib${LIB}_debug.a `${LORDER} ${DOBJS} ${VARIANTDOBJS} | ${TSORT} -q`
368 ${RANLIB} lib${LIB}_debug.a
369
370 ${VARIANTCOMBOS:S/$/_S/g} ${SOBJS}: ${SYMROOTINC}/${MACHINE_ARCH}/libc-features.h
371 lib${LIB}.a:: ${VARIANTCOMBOS:S/$/_S/g} ${SOBJS}
372 @${ECHO} building standard ${LIB} library
373 @${RM} lib${LIB}.a
374 @${AR} cq lib${LIB}.a `${LORDER} ${SOBJS} ${VARIANTSOBJS} | ${TSORT} -q`
375 ${RANLIB} lib${LIB}.a
376 @${ECHO} building custom ${LIB} library for dyld
377 @${RM} lib${LIB}-dyld.a
378 @${AR} cq lib${LIB}-dyld.a `${LORDER} ${DYLDOBJS} | ${TSORT} -q`
379 ${RANLIB} lib${LIB}-dyld.a
380
381 CLEANFILES += ${DOBJS} libc_static.a libc_profile.a libc_debug.a
382
383 INCDIR = ${DESTDIR}/usr/include
384 LOCINCDIR = ${DESTDIR}/usr/local/include
385 SYSTEMFRAMEWORK = ${DESTDIR}/System/Library/Frameworks/System.framework
386 PRIVHDRS = ${SYSTEMFRAMEWORK}/Versions/B/PrivateHeaders
387 KERNELFRAMEWORK = ${DESTDIR}/System/Library/Frameworks/Kernel.framework
388 PRIVKERNELHDRS = ${KERNELFRAMEWORK}/Versions/A/PrivateHeaders
389 INSTALLMODE != ${TEST} `id -u` -eq 0 && ${ECHO} 444 || ${ECHO} 644
390
391 installhdrs-md: gen_md_mig_defs
392
393 installhdrs: modifyhdrs
394
395 copyhdrs: gen_mig_defs
396 ${MKDIR} ${INCDIR}/arpa
397 ${MKDIR} ${INCDIR}/libkern
398 ${MKDIR} ${INCDIR}/malloc
399 .ifdef OBJC_INSTHDRS
400 ${MKDIR} ${INCDIR}/objc
401 .endif
402 ${MKDIR} ${INCDIR}/protocols
403 ${MKDIR} ${INCDIR}/secure
404 ${MKDIR} ${INCDIR}/sys
405 ${MKDIR} ${INCDIR}/xlocale
406 ${INSTALL} -m ${INSTALLMODE} ${INSTHDRS} ${INCDIR}
407 ${INSTALL} -m ${INSTALLMODE} ${ARPA_INSTHDRS} ${INCDIR}/arpa
408 ${INSTALL} -m ${INSTALLMODE} ${LIBKERN_INSTHDRS} ${INCDIR}/libkern
409 ${INSTALL} -m ${INSTALLMODE} ${MALLOC_INSTHDRS} ${INCDIR}/malloc
410 .ifdef OBJC_INSTHDRS
411 ${INSTALL} -m ${INSTALLMODE} ${OBJC_INSTHDRS} ${INCDIR}/objc
412 .endif
413 ${INSTALL} -m ${INSTALLMODE} ${PROTO_INSTHDRS} ${INCDIR}/protocols
414 ${INSTALL} -m ${INSTALLMODE} ${SECURE_INSTHDRS} ${INCDIR}/secure
415 ${INSTALL} -m ${INSTALLMODE} ${SYS_INSTHDRS} ${INCDIR}/sys
416 ${INSTALL} -m ${INSTALLMODE} ${XLOCALE_INSTHDRS} ${INCDIR}/xlocale
417 ${MKDIR} ${LOCINCDIR}
418 ${INSTALL} -m ${INSTALLMODE} ${LOCALHDRS} ${LOCINCDIR}
419 ${MKDIR} ${PRIVHDRS}/btree
420 ${MKDIR} ${PRIVHDRS}/machine
421 ${MKDIR} ${PRIVHDRS}/objc
422 ${MKDIR} ${PRIVHDRS}/uuid
423 ${MKDIR} ${PRIVHDRS}/sys
424 ${MKDIR} ${PRIVKERNELHDRS}/uuid
425 ${INSTALL} -m ${INSTALLMODE} ${PRIV_INSTHDRS} ${PRIVHDRS}
426 ${INSTALL} -m ${INSTALLMODE} ${INSTBTREEPRIVHDRS_AUTOPATCH} ${PRIVHDRS}/btree
427 ${INSTALL} -m ${INSTALLMODE} ${SRCROOT}/internat/NXCType.h ${PRIVHDRS}/objc
428 ${MV} ${DESTDIR}/usr/include/asm.h ${PRIVHDRS}/machine
429 ${INSTALL} -m ${INSTALLMODE} ${SYS_INSTHDRS} ${PRIVHDRS}/sys
430 ${INSTALL} -m ${INSTALLMODE} ${PRIVUUID_INSTHDRS} ${PRIVHDRS}/uuid
431 ${INSTALL} -m ${INSTALLMODE} ${PRIVUUID_INSTHDRS} ${PRIVKERNELHDRS}/uuid
432
433 modifyhdrs: copyhdrs
434 @for i in `${FIND} '${DESTDIR}' -name \*.h -print0 | ${XARGS} -0 ${GREP} -l '^//Begin-Libc'`; do \
435 ${CHMOD} u+w $$i && \
436 ${ECHO} ${ED} - $$i \< ${.CURDIR}/strip-header.ed && \
437 ${ED} - $$i < ${.CURDIR}/strip-header.ed && \
438 ${CHMOD} u-w $$i || exit 1; \
439 done
440 @for i in `${FIND} '${DESTDIR}' -name \*.h -print0 | ${XARGS} -0 ${FGREP} -l UNIFDEF`; do \
441 ${CHMOD} u+w $$i && \
442 ${CP} $$i $$i.orig && \
443 ${ECHO} ${UNIFDEF} ${UNIFDEFARGS} $$i.orig \> $$i && \
444 { ${UNIFDEF} ${UNIFDEFARGS} $$i.orig > $$i || [ $$? -ne 2 ]; } && \
445 ${RM} $$i.orig && \
446 ${CHMOD} u-w $$i || exit 1; \
447 done
448
449 install_lib${LIB}_static.a:
450 ${INSTALL} -m ${INSTALLMODE} lib${LIB}_static.a ${DESTDIR}/usr/local/lib/system/
451 install_lib${LIB}_profile.a:
452 ${INSTALL} -m ${INSTALLMODE} lib${LIB}_profile.a ${DESTDIR}/usr/local/lib/system
453 install_lib${LIB}_debug.a:
454 ${INSTALL} -m ${INSTALLMODE} lib${LIB}_debug.a ${DESTDIR}/usr/local/lib/system/
455 install_lib${LIB}.a:
456 ${INSTALL} -m ${INSTALLMODE} lib${LIB}.a ${DESTDIR}/usr/local/lib/system/
457
458 autopatch: ${AUTOPATCHHDRS} ${AUTOPATCHSRCS} ${AUTOPATCHMAN}
459
460 copyfiles:
461 .if !empty(COPYFILES)
462 ${INSTALL} -m ${INSTALLMODE} ${COPYFILES} ${DESTDIR}/usr/local/lib/system
463 .endif
464 .if !empty(MDCOPYFILES)
465 ${INSTALL} -m ${INSTALLMODE} ${MDCOPYFILES} ${DESTDIR}/usr/local/lib/system
466 .endif
467
468 clean:
469 ${RM} ${OBJS} ${POBJS} ${DOBJS} ${SOBJS} ${CLEANFILES}
470 ${RM} lib${LIB}.a lib${LIB}_static.a lib${LIB}_profile.a \
471 lib${LIB}_debug.a