]>
Commit | Line | Data |
---|---|---|
ad3c9f2a A |
1 | #!/bin/bash |
2 | set -x | |
3 | ||
ad3c9f2a A |
4 | # Installs Libc header files |
5 | ||
507116e3 A |
6 | if [ -n "${DRIVERKIT}" -a -z "${DRIVERKITSDK}" ]; then |
7 | # Run script in the mode that installs public DriverKit SDK headers first: | |
8 | # required to get the correct header unifdef ordering, that mode strips out more | |
9 | # and rewrites all headers under the parent directory (/System/DriverKit) | |
10 | DRIVERKITSDK=1 SDK_INSTALL_HEADERS_ROOT="${SDK_INSTALL_ROOT}" "${BASH}" -e "$0" | |
11 | fi | |
12 | ||
ad3c9f2a A |
13 | MKDIR="mkdir -p" |
14 | INSTALL=install | |
15 | MV=mv | |
16 | ECHO=echo | |
17 | CHMOD=chmod | |
18 | CP=cp | |
19 | UNIFDEF=unifdef | |
20 | FIND=find | |
21 | RM=rm | |
22 | ED=ed | |
23 | XARGS=xargs | |
24 | GREP=grep | |
25 | FGREP=fgrep | |
26 | ||
27 | eval $(${SRCROOT}/xcodescripts/generate_features.pl --bash) | |
28 | UNIFDEFARGS=$(${SRCROOT}/xcodescripts/generate_features.pl --unifdef) | |
29 | ||
70ad1dc8 A |
30 | if [[ "${DEPLOYMENT_LOCATION}" == "NO" ]] ; then |
31 | HDRROOT=${BUILT_PRODUCTS_DIR} | |
32 | else | |
33 | HDRROOT=${DSTROOT} | |
34 | fi | |
35 | ||
507116e3 A |
36 | INCDIR=${HDRROOT}/${SDK_INSTALL_HEADERS_ROOT}/usr/include |
37 | LOCINCDIR=${HDRROOT}/${SDK_INSTALL_HEADERS_ROOT}/usr/local/include | |
38 | SYSTEMFRAMEWORK=${HDRROOT}/${SDK_INSTALL_HEADERS_ROOT}/System/Library/Frameworks/System.framework | |
39 | KERNELFRAMEWORK=${HDRROOT}/${SDK_INSTALL_HEADERS_ROOT}/System/Library/Frameworks/Kernel.framework | |
ad3c9f2a A |
40 | |
41 | PRIVHDRS=${SYSTEMFRAMEWORK}/Versions/B/PrivateHeaders | |
42 | PRIVKERNELHDRS=${KERNELFRAMEWORK}/Versions/A/PrivateHeaders | |
43 | INSTALLMODE=$([[ `id -u` -eq 0 ]] && echo 444 || echo 644) | |
44 | ||
507116e3 A |
45 | if [ -z "${DRIVERKITSDK}" ]; then |
46 | ||
ad3c9f2a | 47 | INSTHDRS=( |
ad3c9f2a A |
48 | ${SRCROOT}/gen/get_compat.h |
49 | ${SRCROOT}/gen/execinfo.h | |
50 | ) | |
51 | ||
52 | INC_INSTHDRS=( | |
e07eda1a A |
53 | __wctype.h |
54 | _ctype.h | |
23e20b00 | 55 | _locale.h |
e07eda1a A |
56 | _regex.h |
57 | _stdio.h | |
23e20b00 A |
58 | _types.h |
59 | _wctype.h | |
60 | _xlocale.h | |
507116e3 | 61 | _ctermid.h |
23e20b00 A |
62 | aio.h |
63 | alloca.h | |
64 | ar.h | |
65 | assert.h | |
66 | asm.h | |
67 | bitstring.h | |
68 | cpio.h | |
69 | crt_externs.h | |
70 | ctype.h | |
71 | db.h | |
72 | dirent.h | |
73 | disktab.h | |
74 | err.h | |
75 | errno.h | |
76 | fcntl.h | |
77 | fmtmsg.h | |
78 | fnmatch.h | |
79 | fsproperties.h | |
80 | fstab.h | |
81 | fts.h | |
82 | ftw.h | |
83 | getopt.h | |
84 | glob.h | |
85 | inttypes.h | |
86 | iso646.h | |
87 | langinfo.h | |
88 | libc.h | |
89 | libgen.h | |
90 | limits.h | |
91 | locale.h | |
92 | memory.h | |
93 | monetary.h | |
94 | monitor.h | |
95 | mpool.h | |
96 | ndbm.h | |
97 | nlist.h | |
98 | paths.h | |
99 | printf.h | |
100 | poll.h | |
101 | ranlib.h | |
102 | readpassphrase.h | |
103 | regex.h | |
104 | runetype.h | |
105 | search.h | |
106 | semaphore.h | |
107 | sgtty.h | |
108 | signal.h | |
109 | stab.h | |
110 | standards.h | |
23e20b00 A |
111 | stddef.h |
112 | stdio.h | |
113 | stdint.h | |
114 | stdlib.h | |
115 | strhash.h | |
116 | string.h | |
117 | stringlist.h | |
118 | strings.h | |
119 | struct.h | |
120 | sysexits.h | |
121 | syslog.h | |
122 | tar.h | |
123 | termios.h | |
124 | time.h | |
125 | timeconv.h | |
126 | ttyent.h | |
127 | ulimit.h | |
128 | unistd.h | |
129 | util.h | |
130 | utime.h | |
131 | vis.h | |
132 | wchar.h | |
133 | wctype.h | |
134 | wordexp.h | |
135 | xlocale.h | |
ad3c9f2a A |
136 | ) |
137 | if [ "x${FEATURE_LEGACY_RUNE_APIS}" == "x1" ]; then | |
138 | INC_INSTHDRS=( "${INC_INSTHDRS[@]}" rune.h ) | |
139 | fi | |
140 | if [ "x${FEATURE_LEGACY_UTMP_APIS}" == "x1" ]; then | |
141 | INC_INSTHDRS=( "${INC_INSTHDRS[@]}" utmp.h ) | |
142 | fi | |
143 | ||
144 | INC_INSTHDRS=( | |
145 | "${INC_INSTHDRS[@]/#/${SRCROOT}/include/}" | |
146 | ${SRCROOT}/include/FreeBSD/nl_types.h | |
147 | ${SRCROOT}/include/NetBSD/utmpx.h | |
148 | ${SRCROOT}/stdtime/FreeBSD/tzfile.h | |
149 | ) | |
6465356a | 150 | INSTHDRS=( "${INSTHDRS[@]}" "${INC_INSTHDRS[@]}" ) |
ad3c9f2a | 151 | |
6465356a | 152 | INC_ARPA_INSTHDRS=( ftp.h inet.h nameser_compat.h telnet.h tftp.h ) |
ad3c9f2a A |
153 | ARPA_INSTHDRS=( "${INC_ARPA_INSTHDRS[@]/#/${SRCROOT}/include/arpa/}" ) |
154 | ||
23e20b00 A |
155 | if [ "x${FEATURE_THERM_NOTIFICATION_APIS}" == "x1" ]; then |
156 | INC_THERM_INSTHDRS=( OSThermalNotification.h ) | |
157 | THERM_INSTHDRS=( "${INC_THERM_INSTHDRS[@]/#/${SRCROOT}/include/libkern/}" ) | |
ad3c9f2a | 158 | fi |
ad3c9f2a | 159 | |
23e20b00 | 160 | INC_PROTO_INSTHDRS=( routed.h rwhod.h talkd.h timed.h ) |
ad3c9f2a A |
161 | PROTO_INSTHDRS=( "${INC_PROTO_INSTHDRS[@]/#/${SRCROOT}/include/protocols/}" ) |
162 | ||
b061a43b | 163 | INC_SECURE_INSTHDRS=( _common.h _string.h _strings.h _stdio.h ) |
ad3c9f2a A |
164 | SECURE_INSTHDRS=( "${INC_SECURE_INSTHDRS[@]/#/${SRCROOT}/include/secure/}" ) |
165 | ||
166 | SYS_INSTHDRS=( ${SRCROOT}/include/sys/acl.h ${SRCROOT}/include/sys/statvfs.h ) | |
167 | ||
168 | INC_XLOCALE_INSTHDRS=( | |
23e20b00 A |
169 | __wctype.h |
170 | _ctype.h | |
171 | _inttypes.h | |
172 | _langinfo.h | |
173 | _monetary.h | |
174 | _regex.h | |
175 | _stdio.h | |
176 | _stdlib.h | |
177 | _string.h | |
178 | _time.h | |
179 | _wchar.h | |
180 | _wctype.h | |
ad3c9f2a A |
181 | ) |
182 | XLOCALE_INSTHDRS=( "${INC_XLOCALE_INSTHDRS[@]/#/${SRCROOT}/include/xlocale/}" ) | |
183 | ||
a9aaacca A |
184 | MODULEMAPS=( |
185 | ${SRCROOT}/include/_types.modulemap | |
186 | ${SRCROOT}/include/stdint.modulemap | |
187 | ) | |
188 | ||
6465356a A |
189 | TYPES_INSTHDRS=( |
190 | ${SRCROOT}/include/_types/_intmax_t.h | |
191 | ${SRCROOT}/include/_types/_nl_item.h | |
192 | ${SRCROOT}/include/_types/_uint16_t.h | |
193 | ${SRCROOT}/include/_types/_uint32_t.h | |
194 | ${SRCROOT}/include/_types/_uint64_t.h | |
195 | ${SRCROOT}/include/_types/_uint8_t.h | |
196 | ${SRCROOT}/include/_types/_uintmax_t.h | |
197 | ${SRCROOT}/include/_types/_wctrans_t.h | |
198 | ${SRCROOT}/include/_types/_wctype_t.h | |
199 | ) | |
200 | ||
ad3c9f2a | 201 | LOCALHDRS=( |
23e20b00 | 202 | ${SRCROOT}/darwin/libc_private.h |
ad3c9f2a | 203 | ${SRCROOT}/gen/utmpx_thread.h |
ad3c9f2a | 204 | ${SRCROOT}/nls/FreeBSD/msgcat.h |
70ad1dc8 A |
205 | ${SRCROOT}/gen/thread_stack_pcs.h |
206 | ${SRCROOT}/libdarwin/h/dirstat.h | |
a9aaacca | 207 | ${SRCROOT}/darwin/subsystem.h |
ad3c9f2a A |
208 | ) |
209 | ||
23e20b00 | 210 | OS_LOCALHDRS=( ${SRCROOT}/os/assumes.h ${SRCROOT}/os/debug_private.h ) |
6465356a | 211 | |
ad3c9f2a | 212 | PRIV_INSTHDRS=( |
ad3c9f2a A |
213 | ${SRCROOT}/stdlib/FreeBSD/atexit.h |
214 | ) | |
215 | ||
216 | PRIV_BTREEHDRS=( | |
217 | ${SRCROOT}/db/btree/FreeBSD/btree.h | |
218 | ${SRCROOT}/db/btree/FreeBSD/bt_extern.h | |
219 | ) | |
220 | ||
23e20b00 A |
221 | SYS_INSTHDRS=( |
222 | ${SRCROOT}/include/sys/acl.h | |
223 | ${SRCROOT}/include/sys/rbtree.h | |
224 | ${SRCROOT}/include/sys/statvfs.h | |
225 | ) | |
a9aaacca | 226 | |
ad3c9f2a A |
227 | PRIVUUID_INSTHDRS=( ${SRCROOT}/uuid/namespace.h ) |
228 | ||
507116e3 A |
229 | else # DRIVERKITSDK |
230 | ||
231 | # Public DriverKit SDK headers | |
232 | ||
233 | UNIFDEFARGS="${UNIFDEFARGS} -U_USE_EXTENDED_LOCALES_" | |
234 | ||
235 | INC_INSTHDRS=( | |
236 | __wctype.h | |
237 | _ctype.h | |
238 | _locale.h | |
239 | _stdio.h | |
240 | _types.h | |
241 | _wctype.h | |
242 | alloca.h | |
243 | assert.h | |
244 | ctype.h | |
245 | inttypes.h | |
246 | limits.h | |
247 | locale.h | |
248 | runetype.h | |
249 | stddef.h | |
250 | stdio.h | |
251 | stdint.h | |
252 | stdlib.h | |
253 | string.h | |
254 | strings.h | |
255 | time.h | |
256 | wchar.h | |
257 | wctype.h | |
258 | ) | |
259 | ||
260 | TYPES_INSTHDRS=( | |
261 | ${SRCROOT}/include/_types/_intmax_t.h | |
262 | ${SRCROOT}/include/_types/_uint16_t.h | |
263 | ${SRCROOT}/include/_types/_uint32_t.h | |
264 | ${SRCROOT}/include/_types/_uint64_t.h | |
265 | ${SRCROOT}/include/_types/_uint8_t.h | |
266 | ${SRCROOT}/include/_types/_uintmax_t.h | |
267 | ${SRCROOT}/include/_types/_wctrans_t.h | |
268 | ${SRCROOT}/include/_types/_wctype_t.h | |
269 | ) | |
270 | ||
271 | INC_INSTHDRS=( | |
272 | "${INC_INSTHDRS[@]/#/${SRCROOT}/include/}" | |
273 | ) | |
274 | INSTHDRS=( "${INSTHDRS[@]}" "${INC_INSTHDRS[@]}" ) | |
275 | ||
276 | INC_SECURE_INSTHDRS=( _common.h _string.h _strings.h _stdio.h ) | |
277 | SECURE_INSTHDRS=( "${INC_SECURE_INSTHDRS[@]/#/${SRCROOT}/include/secure/}" ) | |
278 | ||
279 | fi # DRIVERKITSDK | |
280 | ||
281 | if [ -n "${INSTHDRS}" ]; then | |
282 | ${MKDIR} ${INCDIR} | |
ad3c9f2a | 283 | ${INSTALL} -m ${INSTALLMODE} ${INSTHDRS[@]} ${INCDIR} |
507116e3 A |
284 | fi |
285 | if [ -n "${ARPA_INSTHDRS}" ]; then | |
286 | ${MKDIR} ${INCDIR}/arpa | |
ad3c9f2a | 287 | ${INSTALL} -m ${INSTALLMODE} ${ARPA_INSTHDRS[@]} ${INCDIR}/arpa |
23e20b00 | 288 | fi |
507116e3 A |
289 | if [ -n "${THERM_INSTHDRS}" ]; then |
290 | ${MKDIR} ${INCDIR}/libkern | |
23e20b00 | 291 | ${INSTALL} -m ${INSTALLMODE} ${THERM_INSTHDRS[@]} ${INCDIR}/libkern |
6465356a | 292 | fi |
507116e3 A |
293 | if [ -n "${PROTO_INSTHDRS}" ]; then |
294 | ${MKDIR} ${INCDIR}/protocols | |
ad3c9f2a | 295 | ${INSTALL} -m ${INSTALLMODE} ${PROTO_INSTHDRS[@]} ${INCDIR}/protocols |
507116e3 A |
296 | fi |
297 | if [ -n "${SECURE_INSTHDRS}" ]; then | |
298 | ${MKDIR} ${INCDIR}/secure | |
ad3c9f2a | 299 | ${INSTALL} -m ${INSTALLMODE} ${SECURE_INSTHDRS[@]} ${INCDIR}/secure |
507116e3 A |
300 | fi |
301 | if [ -n "${SYS_INSTHDRS}" ]; then | |
302 | ${MKDIR} ${INCDIR}/sys | |
ad3c9f2a | 303 | ${INSTALL} -m ${INSTALLMODE} ${SYS_INSTHDRS[@]} ${INCDIR}/sys |
507116e3 A |
304 | fi |
305 | if [ -n "${XLOCALE_INSTHDRS}" ]; then | |
306 | ${MKDIR} ${INCDIR}/xlocale | |
ad3c9f2a | 307 | ${INSTALL} -m ${INSTALLMODE} ${XLOCALE_INSTHDRS[@]} ${INCDIR}/xlocale |
507116e3 A |
308 | fi |
309 | if [ -n "${TYPES_INSTHDRS}" ]; then | |
310 | ${MKDIR} ${INCDIR}/_types | |
6465356a | 311 | ${INSTALL} -m ${INSTALLMODE} ${TYPES_INSTHDRS[@]} ${INCDIR}/_types |
507116e3 | 312 | fi |
a9aaacca A |
313 | if [ -n "${MODULEMAPS}" ]; then |
314 | ${MKDIR} ${INCDIR} | |
315 | ${INSTALL} -m ${INSTALLMODE} ${MODULEMAPS[@]} ${INCDIR} | |
316 | fi | |
507116e3 | 317 | if [ -n "${LOCALHDRS}" ]; then |
ad3c9f2a A |
318 | ${MKDIR} ${LOCINCDIR} |
319 | ${INSTALL} -m ${INSTALLMODE} ${LOCALHDRS[@]} ${LOCINCDIR} | |
507116e3 A |
320 | fi |
321 | if [ -n "${OS_LOCALHDRS}" ]; then | |
322 | ${MKDIR} ${LOCINCDIR}/os | |
6465356a | 323 | ${INSTALL} -m ${INSTALLMODE} ${OS_LOCALHDRS[@]} ${LOCINCDIR}/os |
507116e3 A |
324 | fi |
325 | if [ -n "${PRIV_INSTHDRS}" ]; then | |
326 | ${MKDIR} ${PRIVHDRS} | |
ad3c9f2a | 327 | ${INSTALL} -m ${INSTALLMODE} ${PRIV_INSTHDRS[@]} ${PRIVHDRS} |
507116e3 A |
328 | fi |
329 | if [ -n "${PRIV_BTREEHDRS}" ]; then | |
330 | ${MKDIR} ${PRIVHDRS}/btree | |
ad3c9f2a | 331 | ${INSTALL} -m ${INSTALLMODE} ${PRIV_BTREEHDRS[@]} ${PRIVHDRS}/btree |
507116e3 A |
332 | fi |
333 | if [ -n "${SYS_INSTHDRS}" ]; then | |
334 | ${MKDIR} ${PRIVHDRS}/sys | |
ad3c9f2a | 335 | ${INSTALL} -m ${INSTALLMODE} ${SYS_INSTHDRS[@]} ${PRIVHDRS}/sys |
507116e3 A |
336 | fi |
337 | if [ -n "${PRIVUUID_INSTHDRS}" ]; then | |
338 | ${MKDIR} ${PRIVHDRS}/uuid | |
ad3c9f2a | 339 | ${INSTALL} -m ${INSTALLMODE} ${PRIVUUID_INSTHDRS[@]} ${PRIVHDRS}/uuid |
507116e3 | 340 | ${MKDIR} ${PRIVKERNELHDRS}/uuid |
ad3c9f2a | 341 | ${INSTALL} -m ${INSTALLMODE} ${PRIVUUID_INSTHDRS[@]} ${PRIVKERNELHDRS}/uuid |
507116e3 A |
342 | fi |
343 | if [ -f "${INCDIR}/asm.h" ]; then | |
344 | ${MKDIR} ${PRIVHDRS}/machine | |
345 | ${MV} ${INCDIR}/asm.h ${PRIVHDRS}/machine | |
346 | fi | |
ad3c9f2a | 347 | |
507116e3 | 348 | for i in `${FIND} "${HDRROOT}/${SDK_INSTALL_HEADERS_ROOT}" -name \*.h -print0 | ${XARGS} -0 ${GREP} -l '^//Begin-Libc'`; do |
ad3c9f2a A |
349 | ${CHMOD} u+w $i && |
350 | ${ECHO} ${ED} - $i \< ${SRCROOT}/xcodescripts/strip-header.ed && | |
351 | ${ED} - $i < ${SRCROOT}/xcodescripts/strip-header.ed && | |
352 | ${CHMOD} u-w $i || exit 1; | |
353 | done | |
507116e3 | 354 | for i in `${FIND} "${HDRROOT}/${SDK_INSTALL_HEADERS_ROOT}" -name \*.h -print0 | ${XARGS} -0 ${FGREP} -l -e UNIFDEF -e OPEN_SOURCE -e _USE_EXTENDED_LOCALES_`; do |
ad3c9f2a A |
355 | ${CHMOD} u+w $i && |
356 | ${CP} $i $i.orig && | |
357 | ${ECHO} ${UNIFDEF} ${UNIFDEFARGS} $i.orig \> $i && | |
358 | { ${UNIFDEF} ${UNIFDEFARGS} $i.orig > $i || [ $? -ne 2 ]; } && | |
359 | ${RM} $i.orig && | |
360 | ${CHMOD} u-w $i || exit 1; | |
361 | done | |
362 | ||
363 | exit 0 |