]> git.saurik.com Git - apple/xnu.git/blob - libsyscall/xcodescripts/mach_install_mig.sh
xnu-6153.81.5.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 # from old Libsystem makefiles
50 MACHINE_ARCH=`echo $ARCHS | cut -d' ' -f 1`
51 if [[ ( "$MACHINE_ARCH" =~ ^"arm64" || "$MACHINE_ARCH" =~ ^"x86_64" ) && `echo $ARCHS | wc -w` -gt 1 ]]
52 then
53 # MACHINE_ARCH needs to be a 32-bit arch to generate vm_map_internal.h correctly.
54 MACHINE_ARCH=`echo $ARCHS | cut -d' ' -f 2`
55 if [[ ( "$MACHINE_ARCH" =~ ^"arm64" || "$MACHINE_ARCH" =~ ^"x86_64" ) && `echo $ARCHS | wc -w` -gt 2 ]]
56 then
57 # MACHINE_ARCH needs to be a 32-bit arch to generate vm_map_internal.h correctly.
58 MACHINE_ARCH=`echo $ARCHS | cut -d' ' -f 3`
59 fi
60 fi
61 # 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.
62 if [[ ( "$MACHINE_ARCH" =~ ^"arm64" ) ]]
63 then
64 MACHINE_ARCH="armv7"
65 fi
66 if [[ ( "$MACHINE_ARCH" =~ ^"x86_64" ) ]]
67 then
68 MACHINE_ARCH="i386"
69 fi
70
71 ASROOT=""
72 if [ `whoami` = "root" ]; then
73 ASROOT="-o 0"
74 fi
75
76 MIGS="clock.defs
77 clock_priv.defs
78 clock_reply.defs
79 exc.defs
80 host_priv.defs
81 host_security.defs
82 lock_set.defs
83 mach_host.defs
84 mach_port.defs
85 mach_voucher.defs
86 memory_entry.defs
87 processor.defs
88 processor_set.defs
89 task.defs
90 thread_act.defs
91 vm_map.defs"
92
93 MIGS_PRIVATE=""
94
95 MIGS_DUAL_PUBLIC_PRIVATE=""
96
97 if ( echo {iphone,tv,appletv,watch,bridge}{os,simulator} iphone{osnano,nanosimulator} | grep -wFq "$PLATFORM_NAME" )
98 then
99 MIGS_PRIVATE="mach_vm.defs"
100 else
101 MIGS+=" mach_vm.defs"
102 fi
103
104 MIGS_INTERNAL="mach_port.defs
105 mach_vm.defs
106 thread_act.defs
107 vm_map.defs"
108
109 SERVER_HDRS="key_defs.h
110 ls_defs.h
111 netname_defs.h
112 nm_defs.h"
113
114 MACH_HDRS="mach.h
115 mach_error.h
116 mach_init.h
117 mach_interface.h
118 mach_right.h
119 port_obj.h
120 sync.h
121 vm_task.h
122 vm_page_size.h
123 thread_state.h"
124
125 MACH_PRIVATE_HDRS="port_descriptions.h
126 mach_right_private.h
127 mach_sync_ipc.h"
128
129 MIG_FILTERS="watchos_prohibited_mig.txt tvos_prohibited_mig.txt"
130
131 # install /usr/include/server headers
132 mkdir -p $SERVER_HEADER_DST
133 for hdr in $SERVER_HDRS; do
134 install $ASROOT -c -m 444 $SRC/servers/$hdr $SERVER_HEADER_DST
135 done
136
137 # install /usr/include/mach headers
138 mkdir -p $MACH_HEADER_DST
139 for hdr in $MACH_HDRS; do
140 install $ASROOT -c -m 444 $SRC/mach/$hdr $MACH_HEADER_DST
141 done
142
143 # install /usr/local/include/mach headers
144 mkdir -p $MACH_PRIVATE_HEADER_DST
145 for hdr in $MACH_PRIVATE_HDRS; do
146 install $ASROOT -c -m 444 $SRC/mach/$hdr $MACH_PRIVATE_HEADER_DST
147 done
148
149 # special case because we only have one to do here
150 $MIG -novouchers -arch $MACHINE_ARCH -cc $MIGCC -header "$SERVER_HEADER_DST/netname.h" $MIG_INCFLAGS $SRC/servers/netname.defs
151
152 # install /usr/include/mach mig headers
153
154 mkdir -p $MIG_HEADER_DST
155 mkdir -p $MIG_HEADER_OBJ
156
157 for mig in $MIGS $MIGS_DUAL_PUBLIC_PRIVATE; do
158 MIG_NAME=`basename $mig .defs`
159 $MIG -novouchers -arch $MACHINE_ARCH -cc $MIGCC -header "$MIG_HEADER_OBJ/$MIG_NAME.h" $MIG_DEFINES $MIG_INCFLAGS $SRC/$mig
160 for filter in $MIG_FILTERS; do
161 $FILTER_MIG $SRC/$filter $MIG_HEADER_OBJ/$MIG_NAME.h > $MIG_HEADER_OBJ/$MIG_NAME.tmp.h
162 mv $MIG_HEADER_OBJ/$MIG_NAME.tmp.h $MIG_HEADER_OBJ/$MIG_NAME.h
163 done
164 install $ASROOT -c -m 444 $MIG_HEADER_OBJ/$MIG_NAME.h $MIG_HEADER_DST/$MIG_NAME.h
165 done
166
167 mkdir -p $MIG_PRIVATE_HEADER_DST
168
169 for mig in $MIGS_PRIVATE $MIGS_DUAL_PUBLIC_PRIVATE; do
170 MIG_NAME=`basename $mig .defs`
171 $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
172 if [ ! -e "$MIG_HEADER_DST/$MIG_NAME.h" ]; then
173 echo "#error $MIG_NAME.h unsupported." > "$MIG_HEADER_DST/$MIG_NAME.h"
174 fi
175 done
176
177
178 # special headers used just for building Libsyscall
179 # Note: not including -DLIBSYSCALL_INTERFACE to mig so we'll get the proper
180 # 'internal' version of the headers being built
181
182 mkdir -p $MIG_INTERNAL_HEADER_DST
183
184 for mig in $MIGS_INTERNAL; do
185 MIG_NAME=`basename $mig .defs`
186 $MIG -novouchers -arch $MACHINE_ARCH -cc $MIGCC -header "$MIG_INTERNAL_HEADER_DST/${MIG_NAME}_internal.h" $MIG_INCFLAGS $SRC/$mig
187 done
188