]> git.saurik.com Git - apple/libc.git/blame - BSDmakefile
Libc-498.tar.gz
[apple/libc.git] / BSDmakefile
CommitLineData
224c7076
A
1PWD != pwd
2.ifdef DSTROOT
3DESTDIR = $(DSTROOT)
4.else
5.ifdef DESTDIR
6DSTROOT = $(DESTDIR)
7.else
8DSTROOT = /
9DESTDIR = /
10.endif
11.endif
8e029c65 12.ifndef OBJROOT
224c7076
A
13OBJROOT = $(PWD)/OBJROOT
14.endif
15.ifndef SRCROOT
16SRCROOT = $(PWD)
8e029c65
A
17.endif
18.ifndef SYMROOT
224c7076 19SYMROOT = $(PWD)/SYMROOT
8e029c65
A
20.endif
21ARCH != arch
22.ifndef RC_ARCHS
23RC_ARCHS = $(ARCH)
24RC_$(RC_ARCHS) = 1
25.endif
8e029c65
A
26.ifdef ALTUSRLOCALLIBSYSTEM
27LIBSYS = $(ALTUSRLOCALLIBSYSTEM)
28.else
29LIBSYS = $(NEXT_ROOT)/usr/local/lib/system
30.endif
31NJOBS != perl -e '$$n = `/usr/sbin/sysctl -n hw.ncpu`; printf "%d\n", $$n < 2 ? 2 : ($$n * 1.5)'
32BSDMAKE = bsdmake -f Makefile
224c7076
A
33#BSDMAKEJ = $(BSDMAKE) -j $(NJOBS) -P
34BSDMAKEJ = $(BSDMAKE) -j $(NJOBS)
35
36# Set the DONT-BUILD-arch-form variable to non-empty to turn off building
37#DONT-BUILD-x86_64-static = 1
8e029c65 38
224c7076 39# These variables are to guarantee that the left-hand side of an expression is
8e029c65
A
40# always a variable
41dynamic = dynamic
42static = static
43
44# Remove the arch stuff, since we know better here.
45LOCAL_CFLAGS != echo $(RC_CFLAGS) | sed 's/ *-arch [^ ][^ ]*//g'
46
47FORMS := dynamic debug profile static
48
49all: build
50
224c7076
A
51ROOTS := DSTROOT OBJROOT SYMROOT
52.for R in $(ROOTS) # {
53roots: $($(R))
54$($(R)):
55 mkdir -p '$($(R))'
56.endfor # ROOTS }
57
8e029c65
A
58# These are the non B&I defaults
59.ifndef RC_ProjectName
224c7076
A
60
61installhdrs: roots installhdrs-real
62build: roots build-static build-profile build-debug build-dynamic
63install: roots installhdrs install-all
8e029c65
A
64
65.else # RC_ProjectName
66
67# And these are to deal with B&I building libc differently
68# based on RC_ProjectName.
69.if $(RC_ProjectName) == Libc
70installhdrs:
224c7076
A
71build: roots build-dynamic
72install: roots BI-install-dynamic
8e029c65
A
73.endif
74.if $(RC_ProjectName) == Libc_headers
224c7076 75installhdrs: roots installhdrs-real
8e029c65 76build:
224c7076 77install: roots installhdrs-real
8e029c65
A
78.endif
79.if $(RC_ProjectName) == Libc_man
80installhdrs:
81build:
224c7076 82install: roots install-man
8e029c65
A
83.endif
84.if $(RC_ProjectName) == Libc_static
85installhdrs:
224c7076
A
86build: roots build-static
87install: roots BI-install-static
8e029c65
A
88.endif
89.if $(RC_ProjectName) == Libc_debug
90installhdrs:
224c7076
A
91build: roots build-debug
92install: roots BI-install-debug
8e029c65
A
93.endif
94.if $(RC_ProjectName) == Libc_profile
95installhdrs:
224c7076
A
96build: roots build-profile
97install: roots BI-install-profile
8e029c65
A
98.endif
99.endif # RC_ProjectName
100
224c7076
A
101# Make a copy of System.framework/Versions/B/PrivateHeaders, with headers
102# patched so that we can build variant symbols independently
103SYSTEMFRAMEWORK = System.framework
104VERSIONSB = Versions/B
105PRIVATEHEADERPATH = $(SYSTEMFRAMEWORK)/$(VERSIONSB)/PrivateHeaders
106FRAMEWORKS = $(OBJROOT)/Frameworks
107.ifdef ALTFRAMEWORKSPATH
108FRAMEWORKPATH = ${ALTFRAMEWORKSPATH}
8e029c65 109.else
224c7076 110FRAMEWORKPATH = ${NEXT_ROOT}/System/Library/Frameworks
8e029c65 111.endif
224c7076
A
112$(FRAMEWORKS):
113 $(SRCROOT)/patchHeaders $(FRAMEWORKPATH)/$(PRIVATEHEADERPATH) $(FRAMEWORKS)/$(PRIVATEHEADERPATH:H)
114 ln -fs $(VERSIONSB)/PrivateHeaders $(FRAMEWORKS)/$(SYSTEMFRAMEWORK)/PrivateHeaders
115
116AUTOPATCHED = $(SRCROOT)/.autopatched
117PARTIAL = -partial
118.for F in $(FORMS) # {
119.if $(dynamic) == $(F) # {
120SUFFIX-$(F) =
121.else # } {
122SUFFIX-$(F) = _$(F)
123.endif # }
124PSUFFIX-$(F) = $(PARTIAL)$(SUFFIX-$(F))
125
126.for A in $(RC_ARCHS) # {
127.if empty(DONT-BUILD-$(A)-$(F)) # {
128ARCHS-$(F) += $(A)
8e029c65
A
129build-$(A)-$(F):
130 mkdir -p $(OBJROOT)/obj.$(A) && \
131 MAKEOBJDIR="$(OBJROOT)/obj.$(A)" MACHINE_ARCH="$(A)" \
224c7076
A
132 DSTROOT=$(DSTROOT) OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) \
133 MAKEFLAGS="" CFLAGS="-arch $(A) $(LOCAL_CFLAGS)" $(BSDMAKEJ) libc$(SUFFIX-$(F)).a
134.else # } {
135build-$(A)-$(F):
136 @echo Not building libc$(PSUFFIX-$(F)).a for $(A)
137.endif # }
138.endfor # RC_ARCHS }
139
140NARCHS-$(F) != echo $(ARCHS-$(F)) | wc -w
141
142build-$(F): $(FRAMEWORKS) $(AUTOPATCHED)
143.for A in $(RC_ARCHS) # {
144build-$(F): build-$(A)-$(F)
145.endfor # RC_ARCHS }
146.if $(NARCHS-$(F)) == 0 # {
147build-$(F):
148 @echo No libc$(PSUFFIX-$(F)).a built
149.else # } {
150LIPOARGS-$(F) != perl -e 'printf "%s\n", join(" ", map(qq(-arch $$_ \"$(OBJROOT)/obj.$$_/libc$(SUFFIX-$(F)).a\"), qw($(ARCHS-$(F)))))'
151build-$(F):
152.if $(NARCHS-$(F)) == 1 # {
153 cp -p "$(OBJROOT)/obj.$(RC_ARCHS)/libc$(SUFFIX-$(F)).a" "$(SYMROOT)/libc$(PSUFFIX-$(F)).a"
154.else # } {
155 lipo -create $(LIPOARGS-$(F)) -output "$(SYMROOT)/libc$(PSUFFIX-$(F)).a"
156.endif # }
157.endif # }
158.endfor # FORMS }
159
160# We autopatch the files into the directory containing the Makefile.inc. This
161# will happen at installsrc.
162$(AUTOPATCHED):
163 @set -x && \
164 for m in `find $(SRCROOT) -name Makefile.inc`; do \
165 cd `dirname $$m` && \
166 bsdmake -I $(SRCROOT) -f $(SRCROOT)/Makefile.inc -f Makefile.inc -f $(SRCROOT)/Makefile.autopatch autopatch LIB=c SRCROOT=$(SRCROOT) || \
167 exit 1; \
168 done
169 touch $(AUTOPATCHED)
170
171copysrc:
172 pax -rw -p p . "$(SRCROOT)"
173
174installsrc: copysrc $(AUTOPATCHED)
175
176installhdrs-real:
8e029c65 177 MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" MAKEFLAGS="" \
224c7076
A
178 DSTROOT=$(DSTROOT) OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) \
179 $(BSDMAKEJ) installhdrs
180.for A in $(RC_ARCHS) # {
8e029c65
A
181 mkdir -p "$(OBJROOT)/obj.$(A)" && \
182 MAKEOBJDIR="$(OBJROOT)/obj.$(A)" MACHINE_ARCH="$(A)" \
224c7076
A
183 DSTROOT=$(DSTROOT) OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) \
184 MAKEFLAGS="" $(BSDMAKEJ) installhdrs-md
185.endfor # RC_ARCHS # }
8e029c65 186
224c7076 187.for F in $(FORMS) # {
8e029c65
A
188BI-install-$(F): build-$(F)
189 mkdir -p $(DSTROOT)/usr/local/lib/system
224c7076
A
190 if [ -f "$(SYMROOT)/libc$(PSUFFIX-$(F)).a" ]; then \
191 echo "Installing libc$(PSUFFIX-$(F)).a" && \
192 install -c -m 444 "$(SYMROOT)/libc$(PSUFFIX-$(F)).a" \
8e029c65 193 $(DSTROOT)/usr/local/lib/system && \
224c7076 194 ranlib "$(DSTROOT)/usr/local/lib/system/libc$(PSUFFIX-$(F)).a" || exit 1; \
8e029c65 195 fi
224c7076
A
196.if $(dynamic) == $(F) # {
197.for A in $(RC_ARCHS) # {
198 MAKEOBJDIR="$(OBJROOT)/obj.$(A)" MACHINE_ARCH="$(A)" \
199 DSTROOT=$(DSTROOT) OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) \
200 DSTROOT=$(DSTROOT) OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) \
201 MAKEFLAGS="" $(BSDMAKE) copyfiles
202.endfor # RC_ARCHS # }
203.endif # }
204.endfor # FORMS }
8e029c65
A
205
206# Don't use -j here; it may try to make links before the files are copied
224c7076 207MANARGS != test `id -u` -eq 0 || echo MINSTALL=/usr/bin/install
8e029c65
A
208install-man:
209 mkdir -p $(DSTROOT)/usr/share/man/man2
210 mkdir -p $(DSTROOT)/usr/share/man/man3
211 mkdir -p $(DSTROOT)/usr/share/man/man4
212 mkdir -p $(DSTROOT)/usr/share/man/man5
213 mkdir -p $(DSTROOT)/usr/share/man/man7
224c7076
A
214 MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" \
215 DSTROOT='$(DSTROOT)' OBJROOT='$(OBJROOT)' SYMROOT='$(SYMROOT)' \
216 MACHINE_ARCH="$(ARCH)" MAKEFLAGS="" \
217 $(BSDMAKE) autopatchman all-man maninstall $(MANARGS)
8e029c65
A
218
219install-all: build install-man
224c7076 220.for F in $(FORMS) # {
8e029c65 221install-all: BI-install-$(F)
224c7076 222.endfor # FORMS }
8e029c65
A
223
224clean:
224c7076
A
225.for F in $(FORMS) # {
226 rm -f $(SYMROOT)/libc$(PSUFFIX-$(F)).a
227.endfor # FORMS }
228.for A in $(RC_ARCHS) # {
8e029c65 229 rm -rf $(OBJROOT)/obj.$(A)
224c7076 230.endfor # RC_ARCHS # }