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