]> git.saurik.com Git - apple/libc.git/blame - xcodescripts/headers.sh
Libc-997.90.3.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=(
ad3c9f2a
A
41 ${SRCROOT}/gen/get_compat.h
42 ${SRCROOT}/gen/execinfo.h
43)
44
45INC_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)
56if [ "x${FEATURE_LEGACY_RUNE_APIS}" == "x1" ]; then
57 INC_INSTHDRS=( "${INC_INSTHDRS[@]}" rune.h )
58fi
59if [ "x${FEATURE_LEGACY_UTMP_APIS}" == "x1" ]; then
60 INC_INSTHDRS=( "${INC_INSTHDRS[@]}" utmp.h )
61fi
62
63INC_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 69INSTHDRS=( "${INSTHDRS[@]}" "${INC_INSTHDRS[@]}" )
ad3c9f2a 70
6465356a 71INC_ARPA_INSTHDRS=( ftp.h inet.h nameser_compat.h telnet.h tftp.h )
ad3c9f2a
A
72ARPA_INSTHDRS=( "${INC_ARPA_INSTHDRS[@]/#/${SRCROOT}/include/arpa/}" )
73
ad3c9f2a 74if [ "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 77fi
ad3c9f2a
A
78
79INC_PROTO_INSTHDRS=(routed.h rwhod.h talkd.h timed.h )
80PROTO_INSTHDRS=( "${INC_PROTO_INSTHDRS[@]/#/${SRCROOT}/include/protocols/}" )
81
82INC_SECURE_INSTHDRS=( _common.h _string.h _stdio.h )
83SECURE_INSTHDRS=( "${INC_SECURE_INSTHDRS[@]/#/${SRCROOT}/include/secure/}" )
84
85SYS_INSTHDRS=( ${SRCROOT}/include/sys/acl.h ${SRCROOT}/include/sys/statvfs.h )
86
87INC_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)
91XLOCALE_INSTHDRS=( "${INC_XLOCALE_INSTHDRS[@]/#/${SRCROOT}/include/xlocale/}" )
92
6465356a
A
93TYPES_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
105LOCALHDRS=(
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
113OS_LOCALHDRS=( ${SRCROOT}/os/assumes.h ${SRCROOT}/os/base.h ${SRCROOT}/os/trace.h )
114
ad3c9f2a 115PRIV_INSTHDRS=(
ad3c9f2a
A
116 ${SRCROOT}/stdlib/FreeBSD/atexit.h
117)
118
119PRIV_BTREEHDRS=(
120 ${SRCROOT}/db/btree/FreeBSD/btree.h
121 ${SRCROOT}/db/btree/FreeBSD/bt_extern.h
122)
123
6465356a 124SYS_INSTHDRS=( ${SRCROOT}/include/sys/acl.h ${SRCROOT}/include/sys/rbtree.h ${SRCROOT}/include/sys/statvfs.h )
ad3c9f2a
A
125PRIVUUID_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 137if [ "x${FEATURE_MEM_THERM_NOTIFICATION_APIS}" == "x1" ]; then
ad3c9f2a 138${INSTALL} -m ${INSTALLMODE} ${LIBKERN_INSTHDRS[@]} ${INCDIR}/libkern
6465356a 139fi
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
161for 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;
166done
6465356a 167for 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;
174done
175
176exit 0