]>
Commit | Line | Data |
---|---|---|
3e170ce0 | 1 | #!/bin/sh -xe |
6d2010ae A |
2 | # |
3 | # Copyright (c) 2010 Apple Inc. All rights reserved. | |
4 | # | |
5 | # @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | |
6 | # | |
7 | # This file contains Original Code and/or Modifications of Original Code | |
8 | # as defined in and that are subject to the Apple Public Source License | |
9 | # Version 2.0 (the 'License'). You may not use this file except in | |
10 | # compliance with the License. The rights granted to you under the License | |
11 | # may not be used to create, or enable the creation or redistribution of, | |
12 | # unlawful or unlicensed copies of an Apple operating system, or to | |
13 | # circumvent, violate, or enable the circumvention or violation of, any | |
14 | # terms of an Apple operating system software license agreement. | |
15 | # | |
16 | # Please obtain a copy of the License at | |
17 | # http://www.opensource.apple.com/apsl/ and read it before using this file. | |
18 | # | |
19 | # The Original Code and all software distributed under the License are | |
20 | # distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
21 | # EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
22 | # INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
23 | # FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
24 | # Please see the License for the specific language governing rights and | |
25 | # limitations under the License. | |
26 | # | |
27 | # @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
28 | # | |
29 | ||
30 | # build inside OBJROOT | |
31 | cd $OBJROOT | |
32 | ||
6d2010ae A |
33 | MIG=`xcrun -sdk "$SDKROOT" -find mig` |
34 | MIGCC=`xcrun -sdk "$SDKROOT" -find cc` | |
35 | export MIGCC | |
c3c9b80d A |
36 | [ -n "$DRIVERKITROOT" ] && MIG_DRIVERKIT_DEFINES="-DDRIVERKIT" |
37 | MIG_DEFINES="-DLIBSYSCALL_INTERFACE $MIG_DRIVERKIT_DEFINES" | |
38 | MIG_PRIVATE_DEFINES="-DPRIVATE -D_OPEN_SOURCE_ -D__OPEN_SOURCE__" | |
3e170ce0 | 39 | MIG_HEADER_OBJ="$OBJROOT/mig_hdr/include/mach" |
fe8ab488 A |
40 | MIG_HEADER_DST="$BUILT_PRODUCTS_DIR/mig_hdr/include/mach" |
41 | MIG_PRIVATE_HEADER_DST="$BUILT_PRODUCTS_DIR/mig_hdr/local/include/mach" | |
42 | SERVER_HEADER_DST="$BUILT_PRODUCTS_DIR/mig_hdr/include/servers" | |
43 | MACH_HEADER_DST="$BUILT_PRODUCTS_DIR/mig_hdr/include/mach" | |
d9a64523 | 44 | MACH_PRIVATE_HEADER_DST="$BUILT_PRODUCTS_DIR/mig_hdr/local/include/mach" |
cb323159 | 45 | MIG_INTERNAL_HEADER_DST="$BUILT_PRODUCTS_DIR/internal_hdr/include/mach" |
c3c9b80d | 46 | MIG_INCFLAGS="-I${SRCROOT}/../osfmk" |
cb323159 A |
47 | SRC="$SRCROOT/mach" |
48 | FILTER_MIG="$SRCROOT/xcodescripts/filter_mig.awk" | |
39236c6e | 49 | |
d9a64523 | 50 | # MACHINE_ARCH *really* needs to be a 32-bit arch to generate vm_map_internal.h correctly, even if there are no 32-bit targets. |
f427ee49 A |
51 | # thread_state_t *really* needs to pick up arm64 over intel because it has a larger struct type. |
52 | case "$ARCHS" in | |
53 | *arm64*) | |
54 | MACHINE_ARCH=armv7 | |
55 | ;; | |
56 | *x86_64*) | |
57 | MACHINE_ARCH=i386 | |
58 | ;; | |
59 | *) | |
60 | MACHINE_ARCH=`echo $ARCHS | cut -d' ' -f 1` | |
61 | ;; | |
62 | esac | |
813fb2f6 | 63 | |
39037602 A |
64 | ASROOT="" |
65 | if [ `whoami` = "root" ]; then | |
66 | ASROOT="-o 0" | |
67 | fi | |
68 | ||
6d2010ae A |
69 | MIGS="clock.defs |
70 | clock_priv.defs | |
71 | clock_reply.defs | |
72 | exc.defs | |
73 | host_priv.defs | |
74 | host_security.defs | |
6d2010ae | 75 | lock_set.defs |
f427ee49 | 76 | mach_eventlink.defs |
6d2010ae | 77 | mach_host.defs |
316670eb | 78 | mach_port.defs |
fe8ab488 | 79 | mach_voucher.defs |
cb323159 | 80 | memory_entry.defs |
6d2010ae A |
81 | processor.defs |
82 | processor_set.defs | |
39236c6e A |
83 | task.defs |
84 | thread_act.defs | |
6d2010ae A |
85 | vm_map.defs" |
86 | ||
316670eb A |
87 | MIGS_PRIVATE="" |
88 | ||
89 | MIGS_DUAL_PUBLIC_PRIVATE="" | |
90 | ||
5ba3f43e | 91 | if ( echo {iphone,tv,appletv,watch,bridge}{os,simulator} iphone{osnano,nanosimulator} | grep -wFq "$PLATFORM_NAME" ) |
316670eb A |
92 | then |
93 | MIGS_PRIVATE="mach_vm.defs" | |
94 | else | |
95 | MIGS+=" mach_vm.defs" | |
96 | fi | |
97 | ||
316670eb A |
98 | MIGS_INTERNAL="mach_port.defs |
99 | mach_vm.defs | |
c3c9b80d | 100 | task.defs |
fe8ab488 | 101 | thread_act.defs |
316670eb A |
102 | vm_map.defs" |
103 | ||
6d2010ae A |
104 | SERVER_HDRS="key_defs.h |
105 | ls_defs.h | |
106 | netname_defs.h | |
107 | nm_defs.h" | |
108 | ||
39236c6e A |
109 | MACH_HDRS="mach.h |
110 | mach_error.h | |
111 | mach_init.h | |
112 | mach_interface.h | |
d9a64523 | 113 | mach_right.h |
39236c6e A |
114 | port_obj.h |
115 | sync.h | |
fe8ab488 | 116 | vm_task.h |
4bd07ac2 A |
117 | vm_page_size.h |
118 | thread_state.h" | |
39236c6e | 119 | |
d9a64523 | 120 | MACH_PRIVATE_HDRS="port_descriptions.h |
b226f5e5 | 121 | mach_right_private.h |
d9a64523 A |
122 | mach_sync_ipc.h" |
123 | ||
4bd07ac2 | 124 | MIG_FILTERS="watchos_prohibited_mig.txt tvos_prohibited_mig.txt" |
3e170ce0 | 125 | |
6d2010ae A |
126 | # install /usr/include/server headers |
127 | mkdir -p $SERVER_HEADER_DST | |
128 | for hdr in $SERVER_HDRS; do | |
39037602 | 129 | install $ASROOT -c -m 444 $SRC/servers/$hdr $SERVER_HEADER_DST |
6d2010ae A |
130 | done |
131 | ||
39236c6e A |
132 | # install /usr/include/mach headers |
133 | mkdir -p $MACH_HEADER_DST | |
134 | for hdr in $MACH_HDRS; do | |
39037602 | 135 | install $ASROOT -c -m 444 $SRC/mach/$hdr $MACH_HEADER_DST |
39236c6e A |
136 | done |
137 | ||
d9a64523 A |
138 | # install /usr/local/include/mach headers |
139 | mkdir -p $MACH_PRIVATE_HEADER_DST | |
140 | for hdr in $MACH_PRIVATE_HDRS; do | |
141 | install $ASROOT -c -m 444 $SRC/mach/$hdr $MACH_PRIVATE_HEADER_DST | |
142 | done | |
143 | ||
6d2010ae | 144 | # special case because we only have one to do here |
cb323159 | 145 | $MIG -novouchers -arch $MACHINE_ARCH -cc $MIGCC -header "$SERVER_HEADER_DST/netname.h" $MIG_INCFLAGS $SRC/servers/netname.defs |
6d2010ae A |
146 | |
147 | # install /usr/include/mach mig headers | |
148 | ||
149 | mkdir -p $MIG_HEADER_DST | |
3e170ce0 | 150 | mkdir -p $MIG_HEADER_OBJ |
6d2010ae | 151 | |
316670eb | 152 | for mig in $MIGS $MIGS_DUAL_PUBLIC_PRIVATE; do |
6d2010ae | 153 | MIG_NAME=`basename $mig .defs` |
cb323159 | 154 | $MIG -novouchers -arch $MACHINE_ARCH -cc $MIGCC -header "$MIG_HEADER_OBJ/$MIG_NAME.h" $MIG_DEFINES $MIG_INCFLAGS $SRC/$mig |
3e170ce0 A |
155 | for filter in $MIG_FILTERS; do |
156 | $FILTER_MIG $SRC/$filter $MIG_HEADER_OBJ/$MIG_NAME.h > $MIG_HEADER_OBJ/$MIG_NAME.tmp.h | |
157 | mv $MIG_HEADER_OBJ/$MIG_NAME.tmp.h $MIG_HEADER_OBJ/$MIG_NAME.h | |
158 | done | |
39037602 | 159 | install $ASROOT -c -m 444 $MIG_HEADER_OBJ/$MIG_NAME.h $MIG_HEADER_DST/$MIG_NAME.h |
6d2010ae A |
160 | done |
161 | ||
316670eb A |
162 | mkdir -p $MIG_PRIVATE_HEADER_DST |
163 | ||
164 | for mig in $MIGS_PRIVATE $MIGS_DUAL_PUBLIC_PRIVATE; do | |
165 | MIG_NAME=`basename $mig .defs` | |
c3c9b80d | 166 | $MIG -novouchers -arch $MACHINE_ARCH -cc $MIGCC -header "$MIG_PRIVATE_HEADER_DST/$MIG_NAME.h" $MIG_DEFINES $MIG_PRIVATE_DEFINES $MIG_INCFLAGS $SRC/$mig |
316670eb | 167 | if [ ! -e "$MIG_HEADER_DST/$MIG_NAME.h" ]; then |
d9a64523 | 168 | echo "#error $MIG_NAME.h unsupported." > "$MIG_HEADER_DST/$MIG_NAME.h" |
316670eb A |
169 | fi |
170 | done | |
171 | ||
172 | ||
173 | # special headers used just for building Libsyscall | |
174 | # Note: not including -DLIBSYSCALL_INTERFACE to mig so we'll get the proper | |
175 | # 'internal' version of the headers being built | |
176 | ||
177 | mkdir -p $MIG_INTERNAL_HEADER_DST | |
178 | ||
179 | for mig in $MIGS_INTERNAL; do | |
180 | MIG_NAME=`basename $mig .defs` | |
cb323159 | 181 | $MIG -novouchers -arch $MACHINE_ARCH -cc $MIGCC -header "$MIG_INTERNAL_HEADER_DST/${MIG_NAME}_internal.h" $MIG_INCFLAGS $SRC/$mig |
316670eb | 182 | done |
c3c9b80d | 183 |