]> git.saurik.com Git - apple/libc.git/blob - xcodescripts/headers.sh
Libc-1244.50.9.tar.gz
[apple/libc.git] / xcodescripts / headers.sh
1 #!/bin/bash
2 set -x
3
4 # Skip installing headers during Xcode build (buildit uses installhdrs+install)
5 if [ "$ACTION" == build ]; then exit 0; fi
6
7 # Installs Libc header files
8
9 MKDIR="mkdir -p"
10 INSTALL=install
11 MV=mv
12 ECHO=echo
13 CHMOD=chmod
14 CP=cp
15 UNIFDEF=unifdef
16 FIND=find
17 RM=rm
18 ED=ed
19 XARGS=xargs
20 GREP=grep
21 FGREP=fgrep
22
23 eval $(${SRCROOT}/xcodescripts/generate_features.pl --bash)
24 UNIFDEFARGS=$(${SRCROOT}/xcodescripts/generate_features.pl --unifdef)
25
26 INCDIR=${DSTROOT}/${PUBLIC_HEADERS_FOLDER_PATH}
27 LOCINCDIR=${DSTROOT}/${PRIVATE_HEADERS_FOLDER_PATH}
28 SYSTEMFRAMEWORK=${DSTROOT}/System/Library/Frameworks/System.framework
29 KERNELFRAMEWORK=${DSTROOT}/System/Library/Frameworks/Kernel.framework
30
31 PRIVHDRS=${SYSTEMFRAMEWORK}/Versions/B/PrivateHeaders
32 PRIVKERNELHDRS=${KERNELFRAMEWORK}/Versions/A/PrivateHeaders
33 INSTALLMODE=$([[ `id -u` -eq 0 ]] && echo 444 || echo 644)
34
35 INSTHDRS=(
36 ${SRCROOT}/gen/get_compat.h
37 ${SRCROOT}/gen/execinfo.h
38 )
39
40 INC_INSTHDRS=(
41 __wctype.h
42 _ctype.h
43 _locale.h
44 _regex.h
45 _stdio.h
46 _types.h
47 _wctype.h
48 _xlocale.h
49 aio.h
50 alloca.h
51 ar.h
52 assert.h
53 asm.h
54 bitstring.h
55 cpio.h
56 crt_externs.h
57 ctype.h
58 db.h
59 dirent.h
60 disktab.h
61 err.h
62 errno.h
63 fcntl.h
64 fmtmsg.h
65 fnmatch.h
66 fsproperties.h
67 fstab.h
68 fts.h
69 ftw.h
70 getopt.h
71 glob.h
72 inttypes.h
73 iso646.h
74 langinfo.h
75 libc.h
76 libgen.h
77 limits.h
78 locale.h
79 memory.h
80 monetary.h
81 monitor.h
82 mpool.h
83 ndbm.h
84 nlist.h
85 paths.h
86 printf.h
87 poll.h
88 ranlib.h
89 readpassphrase.h
90 regex.h
91 runetype.h
92 search.h
93 semaphore.h
94 sgtty.h
95 signal.h
96 stab.h
97 standards.h
98 stddef.h
99 stdio.h
100 stdint.h
101 stdlib.h
102 strhash.h
103 string.h
104 stringlist.h
105 strings.h
106 struct.h
107 sysexits.h
108 syslog.h
109 tar.h
110 termios.h
111 time.h
112 timeconv.h
113 ttyent.h
114 ulimit.h
115 unistd.h
116 util.h
117 utime.h
118 vis.h
119 wchar.h
120 wctype.h
121 wordexp.h
122 xlocale.h
123 )
124 if [ "x${FEATURE_LEGACY_RUNE_APIS}" == "x1" ]; then
125 INC_INSTHDRS=( "${INC_INSTHDRS[@]}" rune.h )
126 fi
127 if [ "x${FEATURE_LEGACY_UTMP_APIS}" == "x1" ]; then
128 INC_INSTHDRS=( "${INC_INSTHDRS[@]}" utmp.h )
129 fi
130
131 INC_INSTHDRS=(
132 "${INC_INSTHDRS[@]/#/${SRCROOT}/include/}"
133 ${SRCROOT}/include/FreeBSD/nl_types.h
134 ${SRCROOT}/include/NetBSD/utmpx.h
135 ${SRCROOT}/stdtime/FreeBSD/tzfile.h
136 )
137 INSTHDRS=( "${INSTHDRS[@]}" "${INC_INSTHDRS[@]}" )
138
139 INC_ARPA_INSTHDRS=( ftp.h inet.h nameser_compat.h telnet.h tftp.h )
140 ARPA_INSTHDRS=( "${INC_ARPA_INSTHDRS[@]/#/${SRCROOT}/include/arpa/}" )
141
142 if [ "x${FEATURE_THERM_NOTIFICATION_APIS}" == "x1" ]; then
143 INC_THERM_INSTHDRS=( OSThermalNotification.h )
144 THERM_INSTHDRS=( "${INC_THERM_INSTHDRS[@]/#/${SRCROOT}/include/libkern/}" )
145 fi
146
147 INC_PROTO_INSTHDRS=( routed.h rwhod.h talkd.h timed.h )
148 PROTO_INSTHDRS=( "${INC_PROTO_INSTHDRS[@]/#/${SRCROOT}/include/protocols/}" )
149
150 INC_SECURE_INSTHDRS=( _common.h _string.h _strings.h _stdio.h )
151 SECURE_INSTHDRS=( "${INC_SECURE_INSTHDRS[@]/#/${SRCROOT}/include/secure/}" )
152
153 SYS_INSTHDRS=( ${SRCROOT}/include/sys/acl.h ${SRCROOT}/include/sys/statvfs.h )
154
155 INC_XLOCALE_INSTHDRS=(
156 __wctype.h
157 _ctype.h
158 _inttypes.h
159 _langinfo.h
160 _monetary.h
161 _regex.h
162 _stdio.h
163 _stdlib.h
164 _string.h
165 _time.h
166 _wchar.h
167 _wctype.h
168 )
169 XLOCALE_INSTHDRS=( "${INC_XLOCALE_INSTHDRS[@]/#/${SRCROOT}/include/xlocale/}" )
170
171 TYPES_INSTHDRS=(
172 ${SRCROOT}/include/_types/_intmax_t.h
173 ${SRCROOT}/include/_types/_nl_item.h
174 ${SRCROOT}/include/_types/_uint16_t.h
175 ${SRCROOT}/include/_types/_uint32_t.h
176 ${SRCROOT}/include/_types/_uint64_t.h
177 ${SRCROOT}/include/_types/_uint8_t.h
178 ${SRCROOT}/include/_types/_uintmax_t.h
179 ${SRCROOT}/include/_types/_wctrans_t.h
180 ${SRCROOT}/include/_types/_wctype_t.h
181 )
182
183 LOCALHDRS=(
184 ${SRCROOT}/darwin/libc_private.h
185 ${SRCROOT}/gen/utmpx_thread.h
186 ${SRCROOT}/nls/FreeBSD/msgcat.h
187 ${SRCROOT}/libdarwin/dirstat.h
188 )
189
190 OS_LOCALHDRS=( ${SRCROOT}/os/assumes.h ${SRCROOT}/os/debug_private.h )
191
192 PRIV_INSTHDRS=(
193 ${SRCROOT}/stdlib/FreeBSD/atexit.h
194 )
195
196 PRIV_BTREEHDRS=(
197 ${SRCROOT}/db/btree/FreeBSD/btree.h
198 ${SRCROOT}/db/btree/FreeBSD/bt_extern.h
199 )
200
201 SYS_INSTHDRS=(
202 ${SRCROOT}/include/sys/acl.h
203 ${SRCROOT}/include/sys/rbtree.h
204 ${SRCROOT}/include/sys/statvfs.h
205 )
206 PRIVUUID_INSTHDRS=( ${SRCROOT}/uuid/namespace.h )
207
208 ${MKDIR} ${INCDIR}/arpa
209 ${MKDIR} ${INCDIR}/libkern
210 ${MKDIR} ${INCDIR}/malloc
211 ${MKDIR} ${INCDIR}/protocols
212 ${MKDIR} ${INCDIR}/secure
213 ${MKDIR} ${INCDIR}/sys
214 ${MKDIR} ${INCDIR}/xlocale
215 ${MKDIR} ${INCDIR}/_types
216 ${INSTALL} -m ${INSTALLMODE} ${INSTHDRS[@]} ${INCDIR}
217 ${INSTALL} -m ${INSTALLMODE} ${ARPA_INSTHDRS[@]} ${INCDIR}/arpa
218 if [ "x${FEATURE_MEM_NOTIFICATION_APIS}" == "x1" ]; then
219 ${INSTALL} -m ${INSTALLMODE} ${MEM_INSTHDRS[@]} ${INCDIR}/libkern
220 fi
221 if [ "x${FEATURE_THERM_NOTIFICATION_APIS}" == "x1" ]; then
222 ${INSTALL} -m ${INSTALLMODE} ${THERM_INSTHDRS[@]} ${INCDIR}/libkern
223 fi
224 ${INSTALL} -m ${INSTALLMODE} ${PROTO_INSTHDRS[@]} ${INCDIR}/protocols
225 ${INSTALL} -m ${INSTALLMODE} ${SECURE_INSTHDRS[@]} ${INCDIR}/secure
226 ${INSTALL} -m ${INSTALLMODE} ${SYS_INSTHDRS[@]} ${INCDIR}/sys
227 ${INSTALL} -m ${INSTALLMODE} ${XLOCALE_INSTHDRS[@]} ${INCDIR}/xlocale
228 ${INSTALL} -m ${INSTALLMODE} ${TYPES_INSTHDRS[@]} ${INCDIR}/_types
229 ${MKDIR} ${LOCINCDIR}
230 ${MKDIR} ${LOCINCDIR}/os
231 ${INSTALL} -m ${INSTALLMODE} ${LOCALHDRS[@]} ${LOCINCDIR}
232 ${INSTALL} -m ${INSTALLMODE} ${OS_LOCALHDRS[@]} ${LOCINCDIR}/os
233 ${MKDIR} ${PRIVHDRS}/btree
234 ${MKDIR} ${PRIVHDRS}/machine
235 ${MKDIR} ${PRIVHDRS}/uuid
236 ${MKDIR} ${PRIVHDRS}/sys
237 ${MKDIR} ${PRIVKERNELHDRS}/uuid
238 ${INSTALL} -m ${INSTALLMODE} ${PRIV_INSTHDRS[@]} ${PRIVHDRS}
239 ${INSTALL} -m ${INSTALLMODE} ${PRIV_BTREEHDRS[@]} ${PRIVHDRS}/btree
240 ${MV} ${INCDIR}/asm.h ${PRIVHDRS}/machine
241 ${INSTALL} -m ${INSTALLMODE} ${SYS_INSTHDRS[@]} ${PRIVHDRS}/sys
242 ${INSTALL} -m ${INSTALLMODE} ${PRIVUUID_INSTHDRS[@]} ${PRIVHDRS}/uuid
243 ${INSTALL} -m ${INSTALLMODE} ${PRIVUUID_INSTHDRS[@]} ${PRIVKERNELHDRS}/uuid
244
245 for i in `${FIND} "${DSTROOT}" -name \*.h -print0 | ${XARGS} -0 ${GREP} -l '^//Begin-Libc'`; do
246 ${CHMOD} u+w $i &&
247 ${ECHO} ${ED} - $i \< ${SRCROOT}/xcodescripts/strip-header.ed &&
248 ${ED} - $i < ${SRCROOT}/xcodescripts/strip-header.ed &&
249 ${CHMOD} u-w $i || exit 1;
250 done
251 for i in `${FIND} "${DSTROOT}" -name \*.h -print0 | ${XARGS} -0 ${FGREP} -l -e UNIFDEF -e OPEN_SOURCE`; do
252 ${CHMOD} u+w $i &&
253 ${CP} $i $i.orig &&
254 ${ECHO} ${UNIFDEF} ${UNIFDEFARGS} $i.orig \> $i &&
255 { ${UNIFDEF} ${UNIFDEFARGS} $i.orig > $i || [ $? -ne 2 ]; } &&
256 ${RM} $i.orig &&
257 ${CHMOD} u-w $i || exit 1;
258 done
259
260 exit 0