3 # Copyright (c) 2010 Apple Inc. All rights reserved.
5 # @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
16 # Please obtain a copy of the License at
17 # http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
27 # @APPLE_OSREFERENCE_LICENSE_HEADER_END@
30 # build inside OBJROOT
33 MIG
=`xcrun -sdk "$SDKROOT" -find mig`
34 MIGCC
=`xcrun -sdk "$SDKROOT" -find cc`
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"
47 FILTER_MIG
="$SRCROOT/xcodescripts/filter_mig.awk"
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 ]]
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 ]]
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`
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" ) ]]
66 if [[ ( "$MACHINE_ARCH" =~ ^
"x86_64" ) ]]
72 if [ `whoami` = "root" ]; then
95 MIGS_DUAL_PUBLIC_PRIVATE
=""
97 if ( echo {iphone
,tv
,appletv
,watch
,bridge
}{os
,simulator
} iphone
{osnano
,nanosimulator
} | grep -wFq "$PLATFORM_NAME" )
99 MIGS_PRIVATE
="mach_vm.defs"
101 MIGS
+=" mach_vm.defs"
104 MIGS_INTERNAL
="mach_port.defs
109 SERVER_HDRS
="key_defs.h
125 MACH_PRIVATE_HDRS
="port_descriptions.h
129 MIG_FILTERS
="watchos_prohibited_mig.txt tvos_prohibited_mig.txt"
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
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
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
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
152 # install /usr/include/mach mig headers
154 mkdir -p $MIG_HEADER_DST
155 mkdir -p $MIG_HEADER_OBJ
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
164 install $ASROOT -c -m 444 $MIG_HEADER_OBJ/$MIG_NAME.h
$MIG_HEADER_DST/$MIG_NAME.h
167 mkdir -p $MIG_PRIVATE_HEADER_DST
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"
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
182 mkdir -p $MIG_INTERNAL_HEADER_DST
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