]> git.saurik.com Git - apple/xnu.git/blob - libsyscall/xcodescripts/mach_install_mig.sh
xnu-7195.60.75.tar.gz
[apple/xnu.git] / libsyscall / xcodescripts / mach_install_mig.sh
1 #!/bin/sh -xe
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
33 MIG=`xcrun -sdk "$SDKROOT" -find mig`
34 MIGCC=`xcrun -sdk "$SDKROOT" -find cc`
35 export MIGCC
36 MIG_DEFINES="-DLIBSYSCALL_INTERFACE"
37 MIG_HEADER_OBJ="$OBJROOT/mig_hdr/include/mach"
38 MIG_HEADER_DST="$BUILT_PRODUCTS_DIR/mig_hdr/include/mach"
39 MIG_PRIVATE_HEADER_DST="$BUILT_PRODUCTS_DIR/mig_hdr/local/include/mach"
40 SERVER_HEADER_DST="$BUILT_PRODUCTS_DIR/mig_hdr/include/servers"
41 MACH_HEADER_DST="$BUILT_PRODUCTS_DIR/mig_hdr/include/mach"
42 MACH_PRIVATE_HEADER_DST="$BUILT_PRODUCTS_DIR/mig_hdr/local/include/mach"
43 MIG_INTERNAL_HEADER_DST="$BUILT_PRODUCTS_DIR/internal_hdr/include/mach"
44 MIG_INCFLAGS="-I${SDKROOT}/${SDK_INSTALL_HEADERS_ROOT}/usr/include -I${SDKROOT}/${SDK_INSTALL_HEADERS_ROOT}/usr/local/include"
45 MIG_PRIVATE_DEFS_INCFLAGS="-I${SDKROOT}/${SDK_INSTALL_HEADERS_ROOT}/System/Library/Frameworks/System.framework/PrivateHeaders"
46 SRC="$SRCROOT/mach"
47 FILTER_MIG="$SRCROOT/xcodescripts/filter_mig.awk"
48
49 # 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.
50 # thread_state_t *really* needs to pick up arm64 over intel because it has a larger struct type.
51 case "$ARCHS" in
52 *arm64*)
53 MACHINE_ARCH=armv7
54 ;;
55 *x86_64*)
56 MACHINE_ARCH=i386
57 ;;
58 *)
59 MACHINE_ARCH=`echo $ARCHS | cut -d' ' -f 1`
60 ;;
61 esac
62
63 ASROOT=""
64 if [ `whoami` = "root" ]; then
65 ASROOT="-o 0"
66 fi
67
68 MIGS="clock.defs
69 clock_priv.defs
70 clock_reply.defs
71 exc.defs
72 host_priv.defs
73 host_security.defs
74 lock_set.defs
75 mach_eventlink.defs
76 mach_host.defs
77 mach_port.defs
78 mach_voucher.defs
79 memory_entry.defs
80 processor.defs
81 processor_set.defs
82 task.defs
83 thread_act.defs
84 vm_map.defs"
85
86 MIGS_PRIVATE=""
87
88 MIGS_DUAL_PUBLIC_PRIVATE=""
89
90 if ( echo {iphone,tv,appletv,watch,bridge}{os,simulator} iphone{osnano,nanosimulator} | grep -wFq "$PLATFORM_NAME" )
91 then
92 MIGS_PRIVATE="mach_vm.defs"
93 else
94 MIGS+=" mach_vm.defs"
95 fi
96
97 MIGS_INTERNAL="mach_port.defs
98 mach_vm.defs
99 thread_act.defs
100 vm_map.defs"
101
102 SERVER_HDRS="key_defs.h
103 ls_defs.h
104 netname_defs.h
105 nm_defs.h"
106
107 MACH_HDRS="mach.h
108 mach_error.h
109 mach_init.h
110 mach_interface.h
111 mach_right.h
112 port_obj.h
113 sync.h
114 vm_task.h
115 vm_page_size.h
116 thread_state.h"
117
118 MACH_PRIVATE_HDRS="port_descriptions.h
119 mach_right_private.h
120 mach_sync_ipc.h"
121
122 MIG_FILTERS="watchos_prohibited_mig.txt tvos_prohibited_mig.txt"
123
124 # install /usr/include/server headers
125 mkdir -p $SERVER_HEADER_DST
126 for hdr in $SERVER_HDRS; do
127 install $ASROOT -c -m 444 $SRC/servers/$hdr $SERVER_HEADER_DST
128 done
129
130 # install /usr/include/mach headers
131 mkdir -p $MACH_HEADER_DST
132 for hdr in $MACH_HDRS; do
133 install $ASROOT -c -m 444 $SRC/mach/$hdr $MACH_HEADER_DST
134 done
135
136 # install /usr/local/include/mach headers
137 mkdir -p $MACH_PRIVATE_HEADER_DST
138 for hdr in $MACH_PRIVATE_HDRS; do
139 install $ASROOT -c -m 444 $SRC/mach/$hdr $MACH_PRIVATE_HEADER_DST
140 done
141
142 # special case because we only have one to do here
143 $MIG -novouchers -arch $MACHINE_ARCH -cc $MIGCC -header "$SERVER_HEADER_DST/netname.h" $MIG_INCFLAGS $SRC/servers/netname.defs
144
145 # install /usr/include/mach mig headers
146
147 mkdir -p $MIG_HEADER_DST
148 mkdir -p $MIG_HEADER_OBJ
149
150 for mig in $MIGS $MIGS_DUAL_PUBLIC_PRIVATE; do
151 MIG_NAME=`basename $mig .defs`
152 $MIG -novouchers -arch $MACHINE_ARCH -cc $MIGCC -header "$MIG_HEADER_OBJ/$MIG_NAME.h" $MIG_DEFINES $MIG_INCFLAGS $SRC/$mig
153 for filter in $MIG_FILTERS; do
154 $FILTER_MIG $SRC/$filter $MIG_HEADER_OBJ/$MIG_NAME.h > $MIG_HEADER_OBJ/$MIG_NAME.tmp.h
155 mv $MIG_HEADER_OBJ/$MIG_NAME.tmp.h $MIG_HEADER_OBJ/$MIG_NAME.h
156 done
157 install $ASROOT -c -m 444 $MIG_HEADER_OBJ/$MIG_NAME.h $MIG_HEADER_DST/$MIG_NAME.h
158 done
159
160 mkdir -p $MIG_PRIVATE_HEADER_DST
161
162 for mig in $MIGS_PRIVATE $MIGS_DUAL_PUBLIC_PRIVATE; do
163 MIG_NAME=`basename $mig .defs`
164 $MIG -novouchers -arch $MACHINE_ARCH -cc $MIGCC -header "$MIG_PRIVATE_HEADER_DST/$MIG_NAME.h" $MIG_DEFINES $MIG_INCFLAGS $MIG_PRIVATE_DEFS_INCFLAGS $SRC/$mig
165 if [ ! -e "$MIG_HEADER_DST/$MIG_NAME.h" ]; then
166 echo "#error $MIG_NAME.h unsupported." > "$MIG_HEADER_DST/$MIG_NAME.h"
167 fi
168 done
169
170
171 # special headers used just for building Libsyscall
172 # Note: not including -DLIBSYSCALL_INTERFACE to mig so we'll get the proper
173 # 'internal' version of the headers being built
174
175 mkdir -p $MIG_INTERNAL_HEADER_DST
176
177 for mig in $MIGS_INTERNAL; do
178 MIG_NAME=`basename $mig .defs`
179 $MIG -novouchers -arch $MACHINE_ARCH -cc $MIGCC -header "$MIG_INTERNAL_HEADER_DST/${MIG_NAME}_internal.h" $MIG_INCFLAGS $SRC/$mig
180 done
181