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