]>
Commit | Line | Data |
---|---|---|
224c7076 A |
1 | PWD != pwd |
2 | .ifdef DSTROOT | |
3 | DESTDIR = $(DSTROOT) | |
4 | .else | |
5 | .ifdef DESTDIR | |
6 | DSTROOT = $(DESTDIR) | |
7 | .else | |
8 | DSTROOT = / | |
9 | DESTDIR = / | |
10 | .endif | |
11 | .endif | |
8e029c65 | 12 | .ifndef OBJROOT |
224c7076 A |
13 | OBJROOT = $(PWD)/OBJROOT |
14 | .endif | |
15 | .ifndef SRCROOT | |
16 | SRCROOT = $(PWD) | |
8e029c65 A |
17 | .endif |
18 | .ifndef SYMROOT | |
224c7076 | 19 | SYMROOT = $(PWD)/SYMROOT |
8e029c65 A |
20 | .endif |
21 | ARCH != arch | |
22 | .ifndef RC_ARCHS | |
23 | RC_ARCHS = $(ARCH) | |
24 | RC_$(RC_ARCHS) = 1 | |
25 | .endif | |
8e029c65 A |
26 | .ifdef ALTUSRLOCALLIBSYSTEM |
27 | LIBSYS = $(ALTUSRLOCALLIBSYSTEM) | |
28 | .else | |
29 | LIBSYS = $(NEXT_ROOT)/usr/local/lib/system | |
30 | .endif | |
31 | NJOBS != perl -e '$$n = `/usr/sbin/sysctl -n hw.ncpu`; printf "%d\n", $$n < 2 ? 2 : ($$n * 1.5)' | |
32 | BSDMAKE = bsdmake -f Makefile | |
224c7076 A |
33 | #BSDMAKEJ = $(BSDMAKE) -j $(NJOBS) -P |
34 | BSDMAKEJ = $(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 |
41 | dynamic = dynamic | |
42 | static = static | |
43 | ||
44 | # Remove the arch stuff, since we know better here. | |
45 | LOCAL_CFLAGS != echo $(RC_CFLAGS) | sed 's/ *-arch [^ ][^ ]*//g' | |
46 | ||
47 | FORMS := dynamic debug profile static | |
48 | ||
49 | all: build | |
50 | ||
224c7076 A |
51 | ROOTS := DSTROOT OBJROOT SYMROOT |
52 | .for R in $(ROOTS) # { | |
53 | roots: $($(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 | |
61 | installhdrs: roots installhdrs-real | |
62 | build: roots build-static build-profile build-debug build-dynamic | |
63 | install: 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 | |
70 | installhdrs: | |
224c7076 A |
71 | build: roots build-dynamic |
72 | install: roots BI-install-dynamic | |
8e029c65 A |
73 | .endif |
74 | .if $(RC_ProjectName) == Libc_headers | |
224c7076 | 75 | installhdrs: roots installhdrs-real |
8e029c65 | 76 | build: |
224c7076 | 77 | install: roots installhdrs-real |
8e029c65 A |
78 | .endif |
79 | .if $(RC_ProjectName) == Libc_man | |
80 | installhdrs: | |
81 | build: | |
224c7076 | 82 | install: roots install-man |
8e029c65 A |
83 | .endif |
84 | .if $(RC_ProjectName) == Libc_static | |
85 | installhdrs: | |
224c7076 A |
86 | build: roots build-static |
87 | install: roots BI-install-static | |
8e029c65 A |
88 | .endif |
89 | .if $(RC_ProjectName) == Libc_debug | |
90 | installhdrs: | |
224c7076 A |
91 | build: roots build-debug |
92 | install: roots BI-install-debug | |
8e029c65 A |
93 | .endif |
94 | .if $(RC_ProjectName) == Libc_profile | |
95 | installhdrs: | |
224c7076 A |
96 | build: roots build-profile |
97 | install: 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 | |
103 | SYSTEMFRAMEWORK = System.framework | |
104 | VERSIONSB = Versions/B | |
105 | PRIVATEHEADERPATH = $(SYSTEMFRAMEWORK)/$(VERSIONSB)/PrivateHeaders | |
106 | FRAMEWORKS = $(OBJROOT)/Frameworks | |
107 | .ifdef ALTFRAMEWORKSPATH | |
108 | FRAMEWORKPATH = ${ALTFRAMEWORKSPATH} | |
8e029c65 | 109 | .else |
224c7076 | 110 | FRAMEWORKPATH = ${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 | ||
116 | AUTOPATCHED = $(SRCROOT)/.autopatched | |
117 | PARTIAL = -partial | |
118 | .for F in $(FORMS) # { | |
119 | .if $(dynamic) == $(F) # { | |
120 | SUFFIX-$(F) = | |
121 | .else # } { | |
122 | SUFFIX-$(F) = _$(F) | |
123 | .endif # } | |
124 | PSUFFIX-$(F) = $(PARTIAL)$(SUFFIX-$(F)) | |
125 | ||
126 | .for A in $(RC_ARCHS) # { | |
127 | .if empty(DONT-BUILD-$(A)-$(F)) # { | |
128 | ARCHS-$(F) += $(A) | |
8e029c65 A |
129 | build-$(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 # } { | |
135 | build-$(A)-$(F): | |
136 | @echo Not building libc$(PSUFFIX-$(F)).a for $(A) | |
137 | .endif # } | |
138 | .endfor # RC_ARCHS } | |
139 | ||
140 | NARCHS-$(F) != echo $(ARCHS-$(F)) | wc -w | |
141 | ||
142 | build-$(F): $(FRAMEWORKS) $(AUTOPATCHED) | |
143 | .for A in $(RC_ARCHS) # { | |
144 | build-$(F): build-$(A)-$(F) | |
145 | .endfor # RC_ARCHS } | |
146 | .if $(NARCHS-$(F)) == 0 # { | |
147 | build-$(F): | |
148 | @echo No libc$(PSUFFIX-$(F)).a built | |
149 | .else # } { | |
150 | LIPOARGS-$(F) != perl -e 'printf "%s\n", join(" ", map(qq(-arch $$_ \"$(OBJROOT)/obj.$$_/libc$(SUFFIX-$(F)).a\"), qw($(ARCHS-$(F)))))' | |
151 | build-$(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 | ||
171 | copysrc: | |
172 | pax -rw -p p . "$(SRCROOT)" | |
173 | ||
174 | installsrc: copysrc $(AUTOPATCHED) | |
175 | ||
176 | installhdrs-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 |
188 | BI-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 | 207 | MANARGS != test `id -u` -eq 0 || echo MINSTALL=/usr/bin/install |
8e029c65 A |
208 | install-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 | |
219 | install-all: build install-man | |
224c7076 | 220 | .for F in $(FORMS) # { |
8e029c65 | 221 | install-all: BI-install-$(F) |
224c7076 | 222 | .endfor # FORMS } |
8e029c65 A |
223 | |
224 | clean: | |
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 # } |