]> git.saurik.com Git - apple/libc.git/blame_incremental - BSDmakefile
Libc-583.tar.gz
[apple/libc.git] / BSDmakefile
... / ...
CommitLineData
1.include <CoreOS/Standard/Commands.mk>
2.include <CoreOS/Standard/Variables.mk>
3
4ALLARCHS = arm i386 ppc ppc64 x86_64 # installsrc doesn't set RC_ARCHS
5TOP != ${PWD}
6.ifdef DSTROOT
7DESTDIR = $(DSTROOT)
8.else
9.ifdef DESTDIR
10DSTROOT = $(DESTDIR)
11.else
12DSTROOT = /
13DESTDIR = /
14.endif
15.endif
16.ifndef OBJROOT
17OBJROOT = $(TOP)/OBJROOT
18.endif
19.ifndef SRCROOT
20SRCROOT = $(TOP)
21.endif
22.ifndef SYMROOT
23SYMROOT = $(TOP)/SYMROOT
24.endif
25MYARCH != ${ARCH}
26.ifndef RC_ARCHS
27RC_ARCHS = $(MYARCH)
28RC_$(RC_ARCHS) = 1
29.endif
30FIRST_ARCH != ${PERL} -e 'print $$ARGV[0]' ${RC_ARCHS}
31.ifndef RC_NONARCH_CFLAGS
32RC_NONARCH_CFLAGS = -pipe
33.endif
34.ifdef ALTUSRLOCALLIBSYSTEM
35LIBSYS = $(ALTUSRLOCALLIBSYSTEM)
36.else
37LIBSYS = $(SDKROOT)/usr/local/lib/system
38.endif
39NJOBS != ${PERL} -e '$$n = `$(SYSCTL) -n hw.ncpu`; printf "%d\n", $$n < 2 ? 2 : ($$n * 1.5)'
40.ifdef DEBUG
41MYBSDMAKE = $(BSDMAKE) -f Makefile -P
42.else
43MYBSDMAKE = $(BSDMAKE) -f Makefile
44.endif
45MYBSDMAKEJ = $(MYBSDMAKE) -j $(NJOBS)
46
47# Set the DONT-BUILD-arch-form variable to non-empty to turn off building
48#DONT-BUILD-x86_64-static = 1
49
50# These variables are to guarantee that the left-hand side of an expression is
51# always a variable
52dynamic = dynamic
53static = static
54
55# Map RC_ARCHS to MACHINE_ARCH
56.for A in $(RC_ARCHS) $(MYARCH) # {
57MACHINE_ARCH-$(A) = $(A:C/^armv.*/arm/)
58.endfor # RC_ARCHS }
59
60FORMS := dynamic debug profile static
61
62OBJSUFFIX-dynamic = So
63OBJSUFFIX-debug = do
64OBJSUFFIX-profile = po
65OBJSUFFIX-static = o
66
67all: build
68
69ROOTS := DSTROOT OBJROOT SYMROOT
70.for R in $(ROOTS) # {
71roots: $($(R))
72$($(R)):
73 ${MKDIR} '$($(R))'
74.endfor # ROOTS }
75
76# These are the non B&I defaults
77.ifndef RC_ProjectName
78
79installhdrs: roots installhdrs-real
80build: roots build-static build-profile build-debug build-dynamic
81install: roots installhdrs install-all
82
83.else # RC_ProjectName
84
85# And these are to deal with B&I building libc differently
86# based on RC_ProjectName.
87.if $(RC_ProjectName) == Libc
88installhdrs:
89build: roots build-dynamic
90install: roots BI-install-dynamic
91.endif
92.if $(RC_ProjectName) == Libc_headers
93installhdrs: roots installhdrs-real
94build:
95install: roots installhdrs-real
96.endif
97.if $(RC_ProjectName) == Libc_man
98installhdrs:
99build:
100install: roots install-man
101.endif
102.if $(RC_ProjectName) == Libc_static
103installhdrs:
104build: roots build-static
105install: roots BI-install-static
106.endif
107.if $(RC_ProjectName) == Libc_debug
108installhdrs:
109build: roots build-debug
110install: roots BI-install-debug
111.endif
112.if $(RC_ProjectName) == Libc_profile
113installhdrs:
114build: roots build-profile
115install: roots BI-install-profile
116.endif
117.endif # RC_ProjectName
118
119# Make a copy of System.framework/Versions/B/PrivateHeaders, with headers
120# patched so that we can build variant symbols independently
121SYSTEMFRAMEWORK = System.framework
122VERSIONSB = Versions/B
123PRIVATEHEADERPATH = $(SYSTEMFRAMEWORK)/$(VERSIONSB)/PrivateHeaders
124FRAMEWORKS = $(OBJROOT)/Frameworks
125.ifdef ALTFRAMEWORKSPATH
126FRAMEWORKPATH = ${ALTFRAMEWORKSPATH}
127.else
128FRAMEWORKPATH = ${SDKROOT}/System/Library/Frameworks
129.endif
130$(FRAMEWORKS):
131 $(SRCROOT)/patchHeaders $(FRAMEWORKPATH)/$(PRIVATEHEADERPATH) $(FRAMEWORKS)/$(PRIVATEHEADERPATH:H)
132 ${LN} -fs $(VERSIONSB)/PrivateHeaders $(FRAMEWORKS)/$(SYSTEMFRAMEWORK)/PrivateHeaders
133
134AUTOPATCHED = $(SRCROOT)/.autopatched
135PARTIAL = -partial
136.for F in $(FORMS) # {
137.if $(dynamic) == $(F) # {
138SUFFIX-$(F) =
139.else # } {
140SUFFIX-$(F) = _$(F)
141.endif # }
142PSUFFIX-$(F) = $(PARTIAL)$(SUFFIX-$(F))
143
144.for A in $(RC_ARCHS) # {
145.if empty(DONT-BUILD-$(A)-$(F)) # {
146ARCHS-$(F) += $(A)
147build-$(A)-$(F):
148 ${MKDIR} $(OBJROOT)/obj.$(A) && \
149 MAKEOBJDIR="$(OBJROOT)/obj.$(A)" MACHINE_ARCH=$(MACHINE_ARCH-$(A)) CCARCH=$(A) \
150 DSTROOT=$(DSTROOT) OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) \
151 RC_NONARCH_CFLAGS="$(RC_NONARCH_CFLAGS)" MAKEFLAGS="" \
152 OBJSUFFIX="$(OBJSUFFIX-$(F))" \
153 $(MYBSDMAKEJ) libc$(SUFFIX-$(F)).a
154.else # } {
155build-$(A)-$(F):
156 @echo Not building libc$(PSUFFIX-$(F)).a for $(A)
157.endif # }
158.endfor # RC_ARCHS }
159
160NARCHS-$(F) != ${ECHO} $(ARCHS-$(F)) | ${WC} -w
161
162build-$(F): $(FRAMEWORKS) $(AUTOPATCHED)
163.for A in $(RC_ARCHS) # {
164build-$(F): build-$(A)-$(F)
165.endfor # RC_ARCHS }
166.if $(NARCHS-$(F)) == 0 # {
167build-$(F):
168 @echo No libc$(PSUFFIX-$(F)).a built
169.else # } {
170LIPOARGS-$(F) != ${PERL} -e 'printf "%s\n", join(" ", map(qq(-arch $$_ \"$(OBJROOT)/obj.$$_/libc$(SUFFIX-$(F)).a\"), qw($(ARCHS-$(F)))))'
171.if $(dynamic) == $(F) # {
172LIPODYLDARGS-$(F) != ${PERL} -e 'printf "%s\n", join(" ", map(qq(-arch $$_ \"$(OBJROOT)/obj.$$_/libc-dyld.a\"), qw($(ARCHS-$(F)))))'
173.endif # }
174build-$(F):
175.if $(NARCHS-$(F)) == 1 # {
176 ${CP} "$(OBJROOT)/obj.$(RC_ARCHS)/libc$(SUFFIX-$(F)).a" "$(SYMROOT)/libc$(PSUFFIX-$(F)).a"
177.if $(dynamic) == $(F) # {
178 ${CP} "$(OBJROOT)/obj.$(RC_ARCHS)/libc-dyld.a" "$(SYMROOT)/libc-dyld.a"
179.endif # }
180.else # } {
181 ${LIPO} -create $(LIPOARGS-$(F)) -output "$(SYMROOT)/libc$(PSUFFIX-$(F)).a"
182.if $(dynamic) == $(F) # {
183 ${LIPO} -create $(LIPODYLDARGS-$(F)) -output "$(SYMROOT)/libc-dyld.a"
184.endif # }
185.endif # }
186.endif # }
187.endfor # FORMS }
188
189# We autopatch the files into the directory containing the Makefile.inc. This
190# will happen at installsrc.
191$(AUTOPATCHED):
192.for A in $(ALLARCHS) # {
193 MACHINE_ARCH=$(A) SRCROOT="$(SRCROOT)" \
194 $(MYBSDMAKE) -C "$(SRCROOT)" autopatch
195.endfor # ALLARCHS # }
196 touch $(AUTOPATCHED)
197
198copysrc:
199 ${PAX} -rw -p p . "$(SRCROOT)"
200
201installsrc: copysrc $(AUTOPATCHED)
202
203installhdrs-real:
204 MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" MAKEFLAGS="" \
205 DSTROOT=$(DSTROOT) OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) \
206 $(MYBSDMAKEJ) installhdrs
207.for A in $(RC_ARCHS) # {
208 ${MKDIR} "$(OBJROOT)/obj.$(A)" && \
209 MAKEOBJDIR="$(OBJROOT)/obj.$(A)" MACHINE_ARCH=$(MACHINE_ARCH-$(A)) CCARCH=$(A) \
210 DSTROOT=$(DSTROOT) OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) \
211 MAKEFLAGS="" RC_NONARCH_CFLAGS="$(RC_NONARCH_CFLAGS)" \
212 $(MYBSDMAKEJ) installhdrs-md
213.endfor # RC_ARCHS # }
214
215.for F in $(FORMS) # {
216BI-install-$(F): build-$(F)
217 ${MKDIR} $(DSTROOT)/usr/local/lib/system
218 if [ -f "$(SYMROOT)/libc$(PSUFFIX-$(F)).a" ]; then \
219 ${ECHO} "Installing libc$(PSUFFIX-$(F)).a" && \
220 ${INSTALL} -m 444 "$(SYMROOT)/libc$(PSUFFIX-$(F)).a" \
221 $(DSTROOT)/usr/local/lib/system && \
222 ${RANLIB} "$(DSTROOT)/usr/local/lib/system/libc$(PSUFFIX-$(F)).a" || exit 1; \
223 fi
224.if $(dynamic) == $(F) # {
225 if [ -f "$(SYMROOT)/libc-dyld.a" ]; then \
226 ${ECHO} "Installing libc-dyld.a" && \
227 ${INSTALL} -m 444 "$(SYMROOT)/libc-dyld.a" \
228 $(DSTROOT)/usr/local/lib/system && \
229 ${RANLIB} "$(DSTROOT)/usr/local/lib/system/libc-dyld.a" || exit 1; \
230 fi
231.for A in $(RC_ARCHS) # {
232 MAKEOBJDIR="$(OBJROOT)/obj.$(A)" MACHINE_ARCH=$(MACHINE_ARCH-$(A)) CCARCH=$(A) \
233 DSTROOT=$(DSTROOT) OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) \
234 DSTROOT=$(DSTROOT) OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) \
235 MAKEFLAGS="" RC_NONARCH_CFLAGS="$(RC_NONARCH_CFLAGS)" \
236 $(MYBSDMAKE) copyfiles
237.endfor # RC_ARCHS # }
238.endif # }
239.endfor # FORMS }
240
241# Don't use -j here; it may try to make links before the files are copied
242MANARGS != ${TEST} `id -u` -eq 0 || ${ECHO} MINSTALL=/usr/bin/install
243# Variables.mk defines MANDIR=${SHAREDIR}/man, but bsd.man.mk expects that
244# MANDIR=${SHAREDIR}/man/man, so we override.
245MANARGS += MANDIR=${SHAREDIR}/man/man
246install-man:
247 ${MKDIR} $(DSTROOT)/usr/share/man/man2
248 ${MKDIR} $(DSTROOT)/usr/share/man/man3
249 ${MKDIR} $(DSTROOT)/usr/share/man/man4
250 ${MKDIR} $(DSTROOT)/usr/share/man/man5
251 ${MKDIR} $(DSTROOT)/usr/share/man/man7
252 MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" \
253 DSTROOT='$(DSTROOT)' OBJROOT='$(OBJROOT)' SYMROOT='$(SYMROOT)' \
254 MACHINE_ARCH="$(MACHINE_ARCH-$(FIRST_ARCH))" CCARCH=$(FIRST_ARCH) MAKEFLAGS="" \
255 RC_NONARCH_CFLAGS="$(RC_NONARCH_CFLAGS)" \
256 $(MYBSDMAKE) all-man maninstall $(MANARGS)
257
258install-all: build install-man
259.for F in $(FORMS) # {
260install-all: BI-install-$(F)
261.endfor # FORMS }
262
263clean:
264.for F in $(FORMS) # {
265 ${RM} $(SYMROOT)/libc$(PSUFFIX-$(F)).a
266.endfor # FORMS }
267.for A in $(RC_ARCHS) # {
268 ${RMDIR} $(OBJROOT)/obj.$(A)
269.endfor # RC_ARCHS # }