]>
Commit | Line | Data |
---|---|---|
34e8f829 A |
1 | .include <CoreOS/Standard/Commands.mk> |
2 | .include <CoreOS/Standard/Variables.mk> | |
3 | ||
b5d655f7 | 4 | ALLARCHS = arm i386 ppc ppc64 x86_64 # installsrc doesn't set RC_ARCHS |
34e8f829 | 5 | TOP != ${PWD} |
224c7076 A |
6 | .ifdef DSTROOT |
7 | DESTDIR = $(DSTROOT) | |
8 | .else | |
9 | .ifdef DESTDIR | |
10 | DSTROOT = $(DESTDIR) | |
11 | .else | |
12 | DSTROOT = / | |
13 | DESTDIR = / | |
14 | .endif | |
15 | .endif | |
8e029c65 | 16 | .ifndef OBJROOT |
34e8f829 | 17 | OBJROOT = $(TOP)/OBJROOT |
224c7076 A |
18 | .endif |
19 | .ifndef SRCROOT | |
34e8f829 | 20 | SRCROOT = $(TOP) |
8e029c65 A |
21 | .endif |
22 | .ifndef SYMROOT | |
34e8f829 | 23 | SYMROOT = $(TOP)/SYMROOT |
8e029c65 | 24 | .endif |
34e8f829 | 25 | MYARCH != ${ARCH} |
8e029c65 | 26 | .ifndef RC_ARCHS |
34e8f829 | 27 | RC_ARCHS = $(MYARCH) |
8e029c65 A |
28 | RC_$(RC_ARCHS) = 1 |
29 | .endif | |
34e8f829 | 30 | FIRST_ARCH != ${PERL} -e 'print $$ARGV[0]' ${RC_ARCHS} |
b5d655f7 A |
31 | .ifndef RC_NONARCH_CFLAGS |
32 | RC_NONARCH_CFLAGS = -pipe | |
33 | .endif | |
8e029c65 A |
34 | .ifdef ALTUSRLOCALLIBSYSTEM |
35 | LIBSYS = $(ALTUSRLOCALLIBSYSTEM) | |
36 | .else | |
b5d655f7 | 37 | LIBSYS = $(SDKROOT)/usr/local/lib/system |
8e029c65 | 38 | .endif |
34e8f829 A |
39 | NJOBS != ${PERL} -e '$$n = `$(SYSCTL) -n hw.ncpu`; printf "%d\n", $$n < 2 ? 2 : ($$n * 1.5)' |
40 | .ifdef DEBUG | |
41 | MYBSDMAKE = $(BSDMAKE) -f Makefile -P | |
42 | .else | |
43 | MYBSDMAKE = $(BSDMAKE) -f Makefile | |
44 | .endif | |
45 | MYBSDMAKEJ = $(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 |
52 | dynamic = dynamic | |
53 | static = static | |
54 | ||
b5d655f7 | 55 | # Map RC_ARCHS to MACHINE_ARCH |
34e8f829 | 56 | .for A in $(RC_ARCHS) $(MYARCH) # { |
b5d655f7 A |
57 | MACHINE_ARCH-$(A) = $(A:C/^armv.*/arm/) |
58 | .endfor # RC_ARCHS } | |
8e029c65 A |
59 | |
60 | FORMS := dynamic debug profile static | |
61 | ||
b5d655f7 A |
62 | OBJSUFFIX-dynamic = So |
63 | OBJSUFFIX-debug = do | |
64 | OBJSUFFIX-profile = po | |
65 | OBJSUFFIX-static = o | |
66 | ||
8e029c65 A |
67 | all: build |
68 | ||
224c7076 A |
69 | ROOTS := DSTROOT OBJROOT SYMROOT |
70 | .for R in $(ROOTS) # { | |
71 | roots: $($(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 | |
79 | installhdrs: roots installhdrs-real | |
80 | build: roots build-static build-profile build-debug build-dynamic | |
81 | install: 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 | |
88 | installhdrs: | |
224c7076 A |
89 | build: roots build-dynamic |
90 | install: roots BI-install-dynamic | |
8e029c65 A |
91 | .endif |
92 | .if $(RC_ProjectName) == Libc_headers | |
224c7076 | 93 | installhdrs: roots installhdrs-real |
8e029c65 | 94 | build: |
224c7076 | 95 | install: roots installhdrs-real |
8e029c65 A |
96 | .endif |
97 | .if $(RC_ProjectName) == Libc_man | |
98 | installhdrs: | |
99 | build: | |
224c7076 | 100 | install: roots install-man |
8e029c65 A |
101 | .endif |
102 | .if $(RC_ProjectName) == Libc_static | |
103 | installhdrs: | |
224c7076 A |
104 | build: roots build-static |
105 | install: roots BI-install-static | |
8e029c65 A |
106 | .endif |
107 | .if $(RC_ProjectName) == Libc_debug | |
108 | installhdrs: | |
224c7076 A |
109 | build: roots build-debug |
110 | install: roots BI-install-debug | |
8e029c65 A |
111 | .endif |
112 | .if $(RC_ProjectName) == Libc_profile | |
113 | installhdrs: | |
224c7076 A |
114 | build: roots build-profile |
115 | install: 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 | |
121 | SYSTEMFRAMEWORK = System.framework | |
122 | VERSIONSB = Versions/B | |
123 | PRIVATEHEADERPATH = $(SYSTEMFRAMEWORK)/$(VERSIONSB)/PrivateHeaders | |
124 | FRAMEWORKS = $(OBJROOT)/Frameworks | |
125 | .ifdef ALTFRAMEWORKSPATH | |
126 | FRAMEWORKPATH = ${ALTFRAMEWORKSPATH} | |
8e029c65 | 127 | .else |
b5d655f7 | 128 | FRAMEWORKPATH = ${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 | |
134 | AUTOPATCHED = $(SRCROOT)/.autopatched | |
135 | PARTIAL = -partial | |
136 | .for F in $(FORMS) # { | |
137 | .if $(dynamic) == $(F) # { | |
138 | SUFFIX-$(F) = | |
139 | .else # } { | |
140 | SUFFIX-$(F) = _$(F) | |
141 | .endif # } | |
142 | PSUFFIX-$(F) = $(PARTIAL)$(SUFFIX-$(F)) | |
143 | ||
144 | .for A in $(RC_ARCHS) # { | |
145 | .if empty(DONT-BUILD-$(A)-$(F)) # { | |
146 | ARCHS-$(F) += $(A) | |
8e029c65 | 147 | build-$(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 # } { |
155 | build-$(A)-$(F): | |
156 | @echo Not building libc$(PSUFFIX-$(F)).a for $(A) | |
157 | .endif # } | |
158 | .endfor # RC_ARCHS } | |
159 | ||
34e8f829 | 160 | NARCHS-$(F) != ${ECHO} $(ARCHS-$(F)) | ${WC} -w |
224c7076 A |
161 | |
162 | build-$(F): $(FRAMEWORKS) $(AUTOPATCHED) | |
163 | .for A in $(RC_ARCHS) # { | |
164 | build-$(F): build-$(A)-$(F) | |
165 | .endfor # RC_ARCHS } | |
166 | .if $(NARCHS-$(F)) == 0 # { | |
167 | build-$(F): | |
168 | @echo No libc$(PSUFFIX-$(F)).a built | |
169 | .else # } { | |
34e8f829 A |
170 | LIPOARGS-$(F) != ${PERL} -e 'printf "%s\n", join(" ", map(qq(-arch $$_ \"$(OBJROOT)/obj.$$_/libc$(SUFFIX-$(F)).a\"), qw($(ARCHS-$(F)))))' |
171 | .if $(dynamic) == $(F) # { | |
172 | LIPODYLDARGS-$(F) != ${PERL} -e 'printf "%s\n", join(" ", map(qq(-arch $$_ \"$(OBJROOT)/obj.$$_/libc-dyld.a\"), qw($(ARCHS-$(F)))))' | |
173 | .endif # } | |
224c7076 A |
174 | build-$(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 | ||
198 | copysrc: | |
34e8f829 | 199 | ${PAX} -rw -p p . "$(SRCROOT)" |
224c7076 A |
200 | |
201 | installsrc: copysrc $(AUTOPATCHED) | |
202 | ||
203 | installhdrs-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 | 216 | BI-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 |
242 | MANARGS != ${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. | |
245 | MANARGS += MANDIR=${SHAREDIR}/man/man | |
8e029c65 | 246 | install-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 | |
258 | install-all: build install-man | |
224c7076 | 259 | .for F in $(FORMS) # { |
8e029c65 | 260 | install-all: BI-install-$(F) |
224c7076 | 261 | .endfor # FORMS } |
8e029c65 A |
262 | |
263 | clean: | |
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 # } |