]> git.saurik.com Git - apple/libc.git/blame - BSDmakefile
Libc-594.9.5.tar.gz
[apple/libc.git] / BSDmakefile
CommitLineData
34e8f829
A
1.include <CoreOS/Standard/Commands.mk>
2.include <CoreOS/Standard/Variables.mk>
3
b5d655f7 4ALLARCHS = arm i386 ppc ppc64 x86_64 # installsrc doesn't set RC_ARCHS
34e8f829 5TOP != ${PWD}
224c7076
A
6.ifdef DSTROOT
7DESTDIR = $(DSTROOT)
8.else
9.ifdef DESTDIR
10DSTROOT = $(DESTDIR)
11.else
12DSTROOT = /
13DESTDIR = /
14.endif
15.endif
8e029c65 16.ifndef OBJROOT
34e8f829 17OBJROOT = $(TOP)/OBJROOT
224c7076
A
18.endif
19.ifndef SRCROOT
34e8f829 20SRCROOT = $(TOP)
8e029c65
A
21.endif
22.ifndef SYMROOT
34e8f829 23SYMROOT = $(TOP)/SYMROOT
8e029c65 24.endif
34e8f829 25MYARCH != ${ARCH}
8e029c65 26.ifndef RC_ARCHS
34e8f829 27RC_ARCHS = $(MYARCH)
8e029c65
A
28RC_$(RC_ARCHS) = 1
29.endif
34e8f829 30FIRST_ARCH != ${PERL} -e 'print $$ARGV[0]' ${RC_ARCHS}
b5d655f7
A
31.ifndef RC_NONARCH_CFLAGS
32RC_NONARCH_CFLAGS = -pipe
33.endif
8e029c65
A
34.ifdef ALTUSRLOCALLIBSYSTEM
35LIBSYS = $(ALTUSRLOCALLIBSYSTEM)
36.else
b5d655f7 37LIBSYS = $(SDKROOT)/usr/local/lib/system
8e029c65 38.endif
34e8f829
A
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)
224c7076
A
46
47# Set the DONT-BUILD-arch-form variable to non-empty to turn off building
48#DONT-BUILD-x86_64-static = 1
8e029c65 49
224c7076 50# These variables are to guarantee that the left-hand side of an expression is
8e029c65
A
51# always a variable
52dynamic = dynamic
53static = static
54
b5d655f7 55# Map RC_ARCHS to MACHINE_ARCH
34e8f829 56.for A in $(RC_ARCHS) $(MYARCH) # {
b5d655f7
A
57MACHINE_ARCH-$(A) = $(A:C/^armv.*/arm/)
58.endfor # RC_ARCHS }
8e029c65
A
59
60FORMS := dynamic debug profile static
61
b5d655f7
A
62OBJSUFFIX-dynamic = So
63OBJSUFFIX-debug = do
64OBJSUFFIX-profile = po
65OBJSUFFIX-static = o
66
8e029c65
A
67all: build
68
224c7076
A
69ROOTS := DSTROOT OBJROOT SYMROOT
70.for R in $(ROOTS) # {
71roots: $($(R))
72$($(R)):
34e8f829 73 ${MKDIR} '$($(R))'
224c7076
A
74.endfor # ROOTS }
75
8e029c65
A
76# These are the non B&I defaults
77.ifndef RC_ProjectName
224c7076
A
78
79installhdrs: roots installhdrs-real
80build: roots build-static build-profile build-debug build-dynamic
81install: roots installhdrs install-all
8e029c65
A
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:
224c7076
A
89build: roots build-dynamic
90install: roots BI-install-dynamic
8e029c65
A
91.endif
92.if $(RC_ProjectName) == Libc_headers
224c7076 93installhdrs: roots installhdrs-real
8e029c65 94build:
224c7076 95install: roots installhdrs-real
8e029c65
A
96.endif
97.if $(RC_ProjectName) == Libc_man
98installhdrs:
99build:
224c7076 100install: roots install-man
8e029c65
A
101.endif
102.if $(RC_ProjectName) == Libc_static
103installhdrs:
224c7076
A
104build: roots build-static
105install: roots BI-install-static
8e029c65
A
106.endif
107.if $(RC_ProjectName) == Libc_debug
108installhdrs:
224c7076
A
109build: roots build-debug
110install: roots BI-install-debug
8e029c65
A
111.endif
112.if $(RC_ProjectName) == Libc_profile
113installhdrs:
224c7076
A
114build: roots build-profile
115install: roots BI-install-profile
8e029c65
A
116.endif
117.endif # RC_ProjectName
118
224c7076
A
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}
8e029c65 127.else
b5d655f7 128FRAMEWORKPATH = ${SDKROOT}/System/Library/Frameworks
8e029c65 129.endif
224c7076
A
130$(FRAMEWORKS):
131 $(SRCROOT)/patchHeaders $(FRAMEWORKPATH)/$(PRIVATEHEADERPATH) $(FRAMEWORKS)/$(PRIVATEHEADERPATH:H)
34e8f829 132 ${LN} -fs $(VERSIONSB)/PrivateHeaders $(FRAMEWORKS)/$(SYSTEMFRAMEWORK)/PrivateHeaders
224c7076
A
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)
8e029c65 147build-$(A)-$(F):
34e8f829 148 ${MKDIR} $(OBJROOT)/obj.$(A) && \
b5d655f7 149 MAKEOBJDIR="$(OBJROOT)/obj.$(A)" MACHINE_ARCH=$(MACHINE_ARCH-$(A)) CCARCH=$(A) \
224c7076 150 DSTROOT=$(DSTROOT) OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) \
b5d655f7
A
151 RC_NONARCH_CFLAGS="$(RC_NONARCH_CFLAGS)" MAKEFLAGS="" \
152 OBJSUFFIX="$(OBJSUFFIX-$(F))" \
34e8f829 153 $(MYBSDMAKEJ) libc$(SUFFIX-$(F)).a
224c7076
A
154.else # } {
155build-$(A)-$(F):
156 @echo Not building libc$(PSUFFIX-$(F)).a for $(A)
157.endif # }
158.endfor # RC_ARCHS }
159
34e8f829 160NARCHS-$(F) != ${ECHO} $(ARCHS-$(F)) | ${WC} -w
224c7076
A
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 # } {
34e8f829
A
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 # }
224c7076
A
174build-$(F):
175.if $(NARCHS-$(F)) == 1 # {
34e8f829
A
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 # }
224c7076 180.else # } {
34e8f829
A
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 # }
224c7076
A
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):
b5d655f7
A
192.for A in $(ALLARCHS) # {
193 MACHINE_ARCH=$(A) SRCROOT="$(SRCROOT)" \
34e8f829 194 $(MYBSDMAKE) -C "$(SRCROOT)" autopatch
b5d655f7 195.endfor # ALLARCHS # }
224c7076
A
196 touch $(AUTOPATCHED)
197
198copysrc:
34e8f829 199 ${PAX} -rw -p p . "$(SRCROOT)"
224c7076
A
200
201installsrc: copysrc $(AUTOPATCHED)
202
203installhdrs-real:
8e029c65 204 MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" MAKEFLAGS="" \
224c7076 205 DSTROOT=$(DSTROOT) OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) \
34e8f829 206 $(MYBSDMAKEJ) installhdrs
224c7076 207.for A in $(RC_ARCHS) # {
34e8f829 208 ${MKDIR} "$(OBJROOT)/obj.$(A)" && \
b5d655f7 209 MAKEOBJDIR="$(OBJROOT)/obj.$(A)" MACHINE_ARCH=$(MACHINE_ARCH-$(A)) CCARCH=$(A) \
224c7076 210 DSTROOT=$(DSTROOT) OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) \
b5d655f7 211 MAKEFLAGS="" RC_NONARCH_CFLAGS="$(RC_NONARCH_CFLAGS)" \
34e8f829 212 $(MYBSDMAKEJ) installhdrs-md
224c7076 213.endfor # RC_ARCHS # }
8e029c65 214
224c7076 215.for F in $(FORMS) # {
8e029c65 216BI-install-$(F): build-$(F)
34e8f829 217 ${MKDIR} $(DSTROOT)/usr/local/lib/system
224c7076 218 if [ -f "$(SYMROOT)/libc$(PSUFFIX-$(F)).a" ]; then \
34e8f829
A
219 ${ECHO} "Installing libc$(PSUFFIX-$(F)).a" && \
220 ${INSTALL} -m 444 "$(SYMROOT)/libc$(PSUFFIX-$(F)).a" \
8e029c65 221 $(DSTROOT)/usr/local/lib/system && \
34e8f829 222 ${RANLIB} "$(DSTROOT)/usr/local/lib/system/libc$(PSUFFIX-$(F)).a" || exit 1; \
8e029c65 223 fi
224c7076 224.if $(dynamic) == $(F) # {
34e8f829
A
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
224c7076 231.for A in $(RC_ARCHS) # {
b5d655f7 232 MAKEOBJDIR="$(OBJROOT)/obj.$(A)" MACHINE_ARCH=$(MACHINE_ARCH-$(A)) CCARCH=$(A) \
224c7076
A
233 DSTROOT=$(DSTROOT) OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) \
234 DSTROOT=$(DSTROOT) OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) \
b5d655f7 235 MAKEFLAGS="" RC_NONARCH_CFLAGS="$(RC_NONARCH_CFLAGS)" \
34e8f829 236 $(MYBSDMAKE) copyfiles
224c7076
A
237.endfor # RC_ARCHS # }
238.endif # }
239.endfor # FORMS }
8e029c65
A
240
241# Don't use -j here; it may try to make links before the files are copied
34e8f829
A
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
8e029c65 246install-man:
34e8f829
A
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
224c7076
A
252 MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" \
253 DSTROOT='$(DSTROOT)' OBJROOT='$(OBJROOT)' SYMROOT='$(SYMROOT)' \
34e8f829 254 MACHINE_ARCH="$(MACHINE_ARCH-$(FIRST_ARCH))" CCARCH=$(FIRST_ARCH) MAKEFLAGS="" \
b5d655f7 255 RC_NONARCH_CFLAGS="$(RC_NONARCH_CFLAGS)" \
34e8f829 256 $(MYBSDMAKE) all-man maninstall $(MANARGS)
8e029c65
A
257
258install-all: build install-man
224c7076 259.for F in $(FORMS) # {
8e029c65 260install-all: BI-install-$(F)
224c7076 261.endfor # FORMS }
8e029c65
A
262
263clean:
224c7076 264.for F in $(FORMS) # {
34e8f829 265 ${RM} $(SYMROOT)/libc$(PSUFFIX-$(F)).a
224c7076
A
266.endfor # FORMS }
267.for A in $(RC_ARCHS) # {
34e8f829 268 ${RMDIR} $(OBJROOT)/obj.$(A)
224c7076 269.endfor # RC_ARCHS # }