]> git.saurik.com Git - apple/libc.git/blame - xcodescripts/headers.sh
Libc-825.25.tar.gz
[apple/libc.git] / xcodescripts / headers.sh
CommitLineData
ad3c9f2a
A
1#!/bin/bash
2set -x
3
4# Skip installing headers during Xcode build (buildit uses installhdrs+install)
5if [ "$ACTION" == build ]; then exit 0; fi
6
7# Installs Libc header files
8
9MKDIR="mkdir -p"
10INSTALL=install
11MV=mv
12ECHO=echo
13CHMOD=chmod
14CP=cp
15UNIFDEF=unifdef
16FIND=find
17RM=rm
18ED=ed
19XARGS=xargs
20GREP=grep
21FGREP=fgrep
22
23eval $(${SRCROOT}/xcodescripts/generate_features.pl --bash)
24UNIFDEFARGS=$(${SRCROOT}/xcodescripts/generate_features.pl --unifdef)
25
26INCDIR=${DSTROOT}/${PUBLIC_HEADERS_FOLDER_PATH}
27LOCINCDIR=${DSTROOT}/${PRIVATE_HEADERS_FOLDER_PATH}
28SYSTEMFRAMEWORK=${DSTROOT}/System/Library/Frameworks/System.framework
29KERNELFRAMEWORK=${DSTROOT}/System/Library/Frameworks/Kernel.framework
30
31if [ "$PLATFORM_NAME" = iphonesimulator ]; then
32 SYSTEMFRAMEWORK=${DSTROOT}/${SDKROOT}/System/Library/Frameworks/System.framework
33 KERNELFRAMEWORK=${DSTROOT}/${SDKROOT}/System/Library/Frameworks/Kernel.framework
34fi
35
36PRIVHDRS=${SYSTEMFRAMEWORK}/Versions/B/PrivateHeaders
37PRIVKERNELHDRS=${KERNELFRAMEWORK}/Versions/A/PrivateHeaders
38INSTALLMODE=$([[ `id -u` -eq 0 ]] && echo 444 || echo 644)
39
40INSTHDRS=(
41 ${SRCROOT}/darwin/libproc.h
42 ${SRCROOT}/gen/get_compat.h
43 ${SRCROOT}/gen/execinfo.h
44)
45
46INC_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)
57if [ "x${FEATURE_LEGACY_RUNE_APIS}" == "x1" ]; then
58 INC_INSTHDRS=( "${INC_INSTHDRS[@]}" rune.h )
59fi
60if [ "x${FEATURE_LEGACY_UTMP_APIS}" == "x1" ]; then
61 INC_INSTHDRS=( "${INC_INSTHDRS[@]}" utmp.h )
62fi
63
64INC_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)
70INC_PTHREADHDRS=(
71 ${SRCROOT}/pthreads/pthread.h
72 ${SRCROOT}/pthreads/pthread_spis.h
73 ${SRCROOT}/pthreads/pthread_impl.h
74 ${SRCROOT}/pthreads/sched.h
75)
76INSTHDRS=( "${INSTHDRS[@]}" "${INC_INSTHDRS[@]}" "${INC_PTHREADHDRS[@]}" )
77
78INC_ARPA_INSTHDRS=( ftp.h nameser_compat.h telnet.h tftp.h )
79ARPA_INSTHDRS=( "${INC_ARPA_INSTHDRS[@]/#/${SRCROOT}/include/arpa/}" )
80
81INC_LIBKERN_INSTHDRS=( OSAtomic.h OSCacheControl.h )
82if [ "x${FEATURE_MEM_THERM_NOTIFICATION_APIS}" == "x1" ]; then
83 INC_LIBKERN_INSTHDRS+=( OSMemoryNotification.h OSThermalNotification.h )
84fi
85LIBKERN_INSTHDRS=( "${INC_LIBKERN_INSTHDRS[@]/#/${SRCROOT}/include/libkern/}" )
86
87MALLOC_INSTHDRS=( ${SRCROOT}/include/malloc/malloc.h )
88
89INC_PROTO_INSTHDRS=(routed.h rwhod.h talkd.h timed.h )
90PROTO_INSTHDRS=( "${INC_PROTO_INSTHDRS[@]/#/${SRCROOT}/include/protocols/}" )
91
92INC_SECURE_INSTHDRS=( _common.h _string.h _stdio.h )
93SECURE_INSTHDRS=( "${INC_SECURE_INSTHDRS[@]/#/${SRCROOT}/include/secure/}" )
94
95SYS_INSTHDRS=( ${SRCROOT}/include/sys/acl.h ${SRCROOT}/include/sys/statvfs.h )
96
97INC_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)
101XLOCALE_INSTHDRS=( "${INC_XLOCALE_INSTHDRS[@]/#/${SRCROOT}/include/xlocale/}" )
102
103LOCALHDRS=(
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
124PRIV_INSTHDRS=(
125 ${SRCROOT}/gen/stack_logging.h
126 ${SRCROOT}/pthreads/pthread_machdep.h
127 ${SRCROOT}/stdlib/FreeBSD/atexit.h
128)
129
130PRIV_BTREEHDRS=(
131 ${SRCROOT}/db/btree/FreeBSD/btree.h
132 ${SRCROOT}/db/btree/FreeBSD/bt_extern.h
133)
134
135SYS_INSTHDRS=( ${SRCROOT}/include/sys/acl.h ${SRCROOT}/include/sys/statvfs.h )
136PRIVUUID_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
167for 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;
172done
173for 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;
180done
181
182exit 0