]>
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} | |
28 | SYSTEMFRAMEWORK=${DSTROOT}/System/Library/Frameworks/System.framework | |
29 | KERNELFRAMEWORK=${DSTROOT}/System/Library/Frameworks/Kernel.framework | |
30 | ||
31 | if [ "$PLATFORM_NAME" = iphonesimulator ]; then | |
32 | SYSTEMFRAMEWORK=${DSTROOT}/${SDKROOT}/System/Library/Frameworks/System.framework | |
33 | KERNELFRAMEWORK=${DSTROOT}/${SDKROOT}/System/Library/Frameworks/Kernel.framework | |
34 | fi | |
35 | ||
36 | PRIVHDRS=${SYSTEMFRAMEWORK}/Versions/B/PrivateHeaders | |
37 | PRIVKERNELHDRS=${KERNELFRAMEWORK}/Versions/A/PrivateHeaders | |
38 | INSTALLMODE=$([[ `id -u` -eq 0 ]] && echo 444 || echo 644) | |
39 | ||
40 | INSTHDRS=( | |
ad3c9f2a A |
41 | ${SRCROOT}/gen/get_compat.h |
42 | ${SRCROOT}/gen/execinfo.h | |
43 | ) | |
44 | ||
45 | INC_INSTHDRS=( | |
46 | NSSystemDirectories.h _locale.h _structs.h _types.h _wctype.h _xlocale.h aio.h alloca.h \ | |
6465356a | 47 | ar.h assert.h asm.h bitstring.h cpio.h crt_externs.h ctype.h db.h dirent.h disktab.h err.h \ |
ad3c9f2a A |
48 | errno.h fcntl.h fmtmsg.h fnmatch.h fsproperties.h fstab.h fts.h ftw.h getopt.h glob.h inttypes.h \ |
49 | iso646.h langinfo.h libc.h libgen.h limits.h locale.h memory.h monetary.h monitor.h mpool.h ndbm.h \ | |
6465356a A |
50 | nlist.h paths.h printf.h poll.h ranlib.h readpassphrase.h regex.h runetype.h search.h \ |
51 | semaphore.h sgtty.h signal.h stab.h standards.h stdbool.h stddef.h stdio.h stdint.h \ | |
ad3c9f2a | 52 | stdlib.h strhash.h string.h stringlist.h strings.h struct.h sysexits.h syslog.h tar.h termios.h time.h \ |
6465356a | 53 | timeconv.h ttyent.h ulimit.h unistd.h util.h utime.h vis.h wchar.h wctype.h \ |
ad3c9f2a A |
54 | wordexp.h xlocale.h |
55 | ) | |
56 | if [ "x${FEATURE_LEGACY_RUNE_APIS}" == "x1" ]; then | |
57 | INC_INSTHDRS=( "${INC_INSTHDRS[@]}" rune.h ) | |
58 | fi | |
59 | if [ "x${FEATURE_LEGACY_UTMP_APIS}" == "x1" ]; then | |
60 | INC_INSTHDRS=( "${INC_INSTHDRS[@]}" utmp.h ) | |
61 | fi | |
62 | ||
63 | INC_INSTHDRS=( | |
64 | "${INC_INSTHDRS[@]/#/${SRCROOT}/include/}" | |
65 | ${SRCROOT}/include/FreeBSD/nl_types.h | |
66 | ${SRCROOT}/include/NetBSD/utmpx.h | |
67 | ${SRCROOT}/stdtime/FreeBSD/tzfile.h | |
68 | ) | |
6465356a | 69 | INSTHDRS=( "${INSTHDRS[@]}" "${INC_INSTHDRS[@]}" ) |
ad3c9f2a | 70 | |
6465356a | 71 | INC_ARPA_INSTHDRS=( ftp.h inet.h nameser_compat.h telnet.h tftp.h ) |
ad3c9f2a A |
72 | ARPA_INSTHDRS=( "${INC_ARPA_INSTHDRS[@]/#/${SRCROOT}/include/arpa/}" ) |
73 | ||
ad3c9f2a | 74 | if [ "x${FEATURE_MEM_THERM_NOTIFICATION_APIS}" == "x1" ]; then |
6465356a A |
75 | INC_LIBKERN_INSTHDRS=( OSMemoryNotification.h OSThermalNotification.h ) |
76 | LIBKERN_INSTHDRS=( "${INC_LIBKERN_INSTHDRS[@]/#/${SRCROOT}/include/libkern/}" ) | |
ad3c9f2a | 77 | fi |
ad3c9f2a A |
78 | |
79 | INC_PROTO_INSTHDRS=(routed.h rwhod.h talkd.h timed.h ) | |
80 | PROTO_INSTHDRS=( "${INC_PROTO_INSTHDRS[@]/#/${SRCROOT}/include/protocols/}" ) | |
81 | ||
82 | INC_SECURE_INSTHDRS=( _common.h _string.h _stdio.h ) | |
83 | SECURE_INSTHDRS=( "${INC_SECURE_INSTHDRS[@]/#/${SRCROOT}/include/secure/}" ) | |
84 | ||
85 | SYS_INSTHDRS=( ${SRCROOT}/include/sys/acl.h ${SRCROOT}/include/sys/statvfs.h ) | |
86 | ||
87 | INC_XLOCALE_INSTHDRS=( | |
88 | __wctype.h _ctype.h _inttypes.h _langinfo.h _monetary.h _regex.h | |
89 | _stdio.h _stdlib.h _string.h _time.h _wchar.h _wctype.h | |
90 | ) | |
91 | XLOCALE_INSTHDRS=( "${INC_XLOCALE_INSTHDRS[@]/#/${SRCROOT}/include/xlocale/}" ) | |
92 | ||
6465356a A |
93 | TYPES_INSTHDRS=( |
94 | ${SRCROOT}/include/_types/_intmax_t.h | |
95 | ${SRCROOT}/include/_types/_nl_item.h | |
96 | ${SRCROOT}/include/_types/_uint16_t.h | |
97 | ${SRCROOT}/include/_types/_uint32_t.h | |
98 | ${SRCROOT}/include/_types/_uint64_t.h | |
99 | ${SRCROOT}/include/_types/_uint8_t.h | |
100 | ${SRCROOT}/include/_types/_uintmax_t.h | |
101 | ${SRCROOT}/include/_types/_wctrans_t.h | |
102 | ${SRCROOT}/include/_types/_wctype_t.h | |
103 | ) | |
104 | ||
ad3c9f2a A |
105 | LOCALHDRS=( |
106 | ${SRCROOT}/darwin/dirhelper.defs | |
107 | ${SRCROOT}/darwin/dirhelper_priv.h | |
6465356a | 108 | ${SRCROOT}/gen/assumes.h |
ad3c9f2a | 109 | ${SRCROOT}/gen/utmpx_thread.h |
ad3c9f2a | 110 | ${SRCROOT}/nls/FreeBSD/msgcat.h |
ad3c9f2a A |
111 | ) |
112 | ||
6465356a A |
113 | OS_LOCALHDRS=( ${SRCROOT}/os/assumes.h ${SRCROOT}/os/base.h ${SRCROOT}/os/trace.h ) |
114 | ||
ad3c9f2a | 115 | PRIV_INSTHDRS=( |
ad3c9f2a A |
116 | ${SRCROOT}/stdlib/FreeBSD/atexit.h |
117 | ) | |
118 | ||
119 | PRIV_BTREEHDRS=( | |
120 | ${SRCROOT}/db/btree/FreeBSD/btree.h | |
121 | ${SRCROOT}/db/btree/FreeBSD/bt_extern.h | |
122 | ) | |
123 | ||
6465356a | 124 | SYS_INSTHDRS=( ${SRCROOT}/include/sys/acl.h ${SRCROOT}/include/sys/rbtree.h ${SRCROOT}/include/sys/statvfs.h ) |
ad3c9f2a A |
125 | PRIVUUID_INSTHDRS=( ${SRCROOT}/uuid/namespace.h ) |
126 | ||
127 | ${MKDIR} ${INCDIR}/arpa | |
128 | ${MKDIR} ${INCDIR}/libkern | |
129 | ${MKDIR} ${INCDIR}/malloc | |
130 | ${MKDIR} ${INCDIR}/protocols | |
131 | ${MKDIR} ${INCDIR}/secure | |
132 | ${MKDIR} ${INCDIR}/sys | |
133 | ${MKDIR} ${INCDIR}/xlocale | |
6465356a | 134 | ${MKDIR} ${INCDIR}/_types |
ad3c9f2a A |
135 | ${INSTALL} -m ${INSTALLMODE} ${INSTHDRS[@]} ${INCDIR} |
136 | ${INSTALL} -m ${INSTALLMODE} ${ARPA_INSTHDRS[@]} ${INCDIR}/arpa | |
6465356a | 137 | if [ "x${FEATURE_MEM_THERM_NOTIFICATION_APIS}" == "x1" ]; then |
ad3c9f2a | 138 | ${INSTALL} -m ${INSTALLMODE} ${LIBKERN_INSTHDRS[@]} ${INCDIR}/libkern |
6465356a | 139 | fi |
ad3c9f2a A |
140 | ${INSTALL} -m ${INSTALLMODE} ${PROTO_INSTHDRS[@]} ${INCDIR}/protocols |
141 | ${INSTALL} -m ${INSTALLMODE} ${SECURE_INSTHDRS[@]} ${INCDIR}/secure | |
142 | ${INSTALL} -m ${INSTALLMODE} ${SYS_INSTHDRS[@]} ${INCDIR}/sys | |
143 | ${INSTALL} -m ${INSTALLMODE} ${XLOCALE_INSTHDRS[@]} ${INCDIR}/xlocale | |
6465356a | 144 | ${INSTALL} -m ${INSTALLMODE} ${TYPES_INSTHDRS[@]} ${INCDIR}/_types |
ad3c9f2a | 145 | ${MKDIR} ${LOCINCDIR} |
6465356a | 146 | ${MKDIR} ${LOCINCDIR}/os |
ad3c9f2a | 147 | ${INSTALL} -m ${INSTALLMODE} ${LOCALHDRS[@]} ${LOCINCDIR} |
6465356a | 148 | ${INSTALL} -m ${INSTALLMODE} ${OS_LOCALHDRS[@]} ${LOCINCDIR}/os |
ad3c9f2a A |
149 | ${MKDIR} ${PRIVHDRS}/btree |
150 | ${MKDIR} ${PRIVHDRS}/machine | |
151 | ${MKDIR} ${PRIVHDRS}/uuid | |
152 | ${MKDIR} ${PRIVHDRS}/sys | |
153 | ${MKDIR} ${PRIVKERNELHDRS}/uuid | |
154 | ${INSTALL} -m ${INSTALLMODE} ${PRIV_INSTHDRS[@]} ${PRIVHDRS} | |
155 | ${INSTALL} -m ${INSTALLMODE} ${PRIV_BTREEHDRS[@]} ${PRIVHDRS}/btree | |
156 | ${MV} ${INCDIR}/asm.h ${PRIVHDRS}/machine | |
157 | ${INSTALL} -m ${INSTALLMODE} ${SYS_INSTHDRS[@]} ${PRIVHDRS}/sys | |
158 | ${INSTALL} -m ${INSTALLMODE} ${PRIVUUID_INSTHDRS[@]} ${PRIVHDRS}/uuid | |
159 | ${INSTALL} -m ${INSTALLMODE} ${PRIVUUID_INSTHDRS[@]} ${PRIVKERNELHDRS}/uuid | |
160 | ||
161 | for i in `${FIND} "${DSTROOT}" -name \*.h -print0 | ${XARGS} -0 ${GREP} -l '^//Begin-Libc'`; do | |
162 | ${CHMOD} u+w $i && | |
163 | ${ECHO} ${ED} - $i \< ${SRCROOT}/xcodescripts/strip-header.ed && | |
164 | ${ED} - $i < ${SRCROOT}/xcodescripts/strip-header.ed && | |
165 | ${CHMOD} u-w $i || exit 1; | |
166 | done | |
6465356a | 167 | for i in `${FIND} "${DSTROOT}" -name \*.h -print0 | ${XARGS} -0 ${FGREP} -l -e UNIFDEF -e OPEN_SOURCE`; do |
ad3c9f2a A |
168 | ${CHMOD} u+w $i && |
169 | ${CP} $i $i.orig && | |
170 | ${ECHO} ${UNIFDEF} ${UNIFDEFARGS} $i.orig \> $i && | |
171 | { ${UNIFDEF} ${UNIFDEFARGS} $i.orig > $i || [ $? -ne 2 ]; } && | |
172 | ${RM} $i.orig && | |
173 | ${CHMOD} u-w $i || exit 1; | |
174 | done | |
175 | ||
176 | exit 0 |