]> git.saurik.com Git - apple/xnu.git/blame - libsyscall/xcodescripts/mach_install_mig.sh
xnu-3247.10.11.tar.gz
[apple/xnu.git] / libsyscall / xcodescripts / mach_install_mig.sh
CommitLineData
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
31cd $OBJROOT
32
6d2010ae
A
33MIG=`xcrun -sdk "$SDKROOT" -find mig`
34MIGCC=`xcrun -sdk "$SDKROOT" -find cc`
35export MIGCC
36MIG_DEFINES="-DLIBSYSCALL_INTERFACE"
3e170ce0 37MIG_HEADER_OBJ="$OBJROOT/mig_hdr/include/mach"
fe8ab488
A
38MIG_HEADER_DST="$BUILT_PRODUCTS_DIR/mig_hdr/include/mach"
39MIG_PRIVATE_HEADER_DST="$BUILT_PRODUCTS_DIR/mig_hdr/local/include/mach"
40SERVER_HEADER_DST="$BUILT_PRODUCTS_DIR/mig_hdr/include/servers"
41MACH_HEADER_DST="$BUILT_PRODUCTS_DIR/mig_hdr/include/mach"
39236c6e 42
6d2010ae
A
43# from old Libsystem makefiles
44MACHINE_ARCH=`echo $ARCHS | cut -d' ' -f 1`
fe8ab488 45if [[ ( "$MACHINE_ARCH" = "arm64" || "$MACHINE_ARCH" = "x86_64" || "$MACHINE_ARCH" = "x86_64h" ) && `echo $ARCHS | wc -w` -gt 1 ]]
39236c6e
A
46then
47 # MACHINE_ARCH needs to be a 32-bit arch to generate vm_map_internal.h correctly.
48 MACHINE_ARCH=`echo $ARCHS | cut -d' ' -f 2`
fe8ab488
A
49 if [[ ( "$MACHINE_ARCH" = "arm64" || "$MACHINE_ARCH" = "x86_64" || "$MACHINE_ARCH" = "x86_64h" ) && `echo $ARCHS | wc -w` -gt 1 ]]
50 then
51 # MACHINE_ARCH needs to be a 32-bit arch to generate vm_map_internal.h correctly.
52 MACHINE_ARCH=`echo $ARCHS | cut -d' ' -f 3`
53 fi
39236c6e 54fi
6d2010ae 55SRC="$SRCROOT/mach"
fe8ab488 56MIG_INTERNAL_HEADER_DST="$BUILT_PRODUCTS_DIR/internal_hdr/include/mach"
316670eb 57MIG_PRIVATE_DEFS_INCFLAGS="-I${SDKROOT}/System/Library/Frameworks/System.framework/PrivateHeaders"
3e170ce0 58FILTER_MIG="$SRCROOT/xcodescripts/filter_mig.awk"
6d2010ae
A
59
60MIGS="clock.defs
61 clock_priv.defs
62 clock_reply.defs
63 exc.defs
64 host_priv.defs
65 host_security.defs
6d2010ae 66 lock_set.defs
6d2010ae 67 mach_host.defs
316670eb 68 mach_port.defs
fe8ab488 69 mach_voucher.defs
6d2010ae
A
70 processor.defs
71 processor_set.defs
39236c6e
A
72 task.defs
73 thread_act.defs
6d2010ae
A
74 vm_map.defs"
75
316670eb
A
76MIGS_PRIVATE=""
77
78MIGS_DUAL_PUBLIC_PRIVATE=""
79
3e170ce0 80if [[ "$PLATFORM_NAME" = "iphoneos" || "$PLATFORM_NAME" = "iphonesimulator" || "$PLATFORM_NAME" = "iphoneosnano" || "$PLATFORM_NAME" = "iphonenanosimulator" || "$PLATFORM_NAME" = "tvos" || "$PLATFOM_NAME" = "tvsimulator" || "$PLATFOM_NAME" = "appletvos" || "$PLATFOM_NAME" = "appletvsimulator" || "$PLATFOM_NAME" = "watchos" || "$PLATFOM_NAME" = "watchsimulator" ]]
316670eb
A
81then
82 MIGS_PRIVATE="mach_vm.defs"
83else
84 MIGS+=" mach_vm.defs"
85fi
86
316670eb
A
87MIGS_INTERNAL="mach_port.defs
88 mach_vm.defs
fe8ab488 89 thread_act.defs
316670eb
A
90 vm_map.defs"
91
6d2010ae
A
92SERVER_HDRS="key_defs.h
93 ls_defs.h
94 netname_defs.h
95 nm_defs.h"
96
39236c6e
A
97MACH_HDRS="mach.h
98 mach_error.h
99 mach_init.h
100 mach_interface.h
101 port_obj.h
102 sync.h
fe8ab488
A
103 vm_task.h
104 vm_page_size.h"
39236c6e 105
3e170ce0
A
106MIG_FILTERS="watchos_prohibited_mig.txt"
107
6d2010ae
A
108# install /usr/include/server headers
109mkdir -p $SERVER_HEADER_DST
110for hdr in $SERVER_HDRS; do
111 install -o 0 -c -m 444 $SRC/servers/$hdr $SERVER_HEADER_DST
112done
113
39236c6e
A
114# install /usr/include/mach headers
115mkdir -p $MACH_HEADER_DST
116for hdr in $MACH_HDRS; do
117 install -o 0 -c -m 444 $SRC/mach/$hdr $MACH_HEADER_DST
118done
119
6d2010ae 120# special case because we only have one to do here
fe8ab488 121$MIG -novouchers -arch $MACHINE_ARCH -header "$SERVER_HEADER_DST/netname.h" $SRC/servers/netname.defs
6d2010ae
A
122
123# install /usr/include/mach mig headers
124
125mkdir -p $MIG_HEADER_DST
3e170ce0 126mkdir -p $MIG_HEADER_OBJ
6d2010ae 127
316670eb 128for mig in $MIGS $MIGS_DUAL_PUBLIC_PRIVATE; do
6d2010ae 129 MIG_NAME=`basename $mig .defs`
3e170ce0
A
130 $MIG -novouchers -arch $MACHINE_ARCH -cc $MIGCC -header "$MIG_HEADER_OBJ/$MIG_NAME.h" $MIG_DEFINES $SRC/$mig
131 for filter in $MIG_FILTERS; do
132 $FILTER_MIG $SRC/$filter $MIG_HEADER_OBJ/$MIG_NAME.h > $MIG_HEADER_OBJ/$MIG_NAME.tmp.h
133 mv $MIG_HEADER_OBJ/$MIG_NAME.tmp.h $MIG_HEADER_OBJ/$MIG_NAME.h
134 done
135 install -o 0 -c -m 444 $MIG_HEADER_OBJ/$MIG_NAME.h $MIG_HEADER_DST/$MIG_NAME.h
6d2010ae
A
136done
137
316670eb
A
138mkdir -p $MIG_PRIVATE_HEADER_DST
139
140for mig in $MIGS_PRIVATE $MIGS_DUAL_PUBLIC_PRIVATE; do
141 MIG_NAME=`basename $mig .defs`
fe8ab488 142 $MIG -novouchers -arch $MACHINE_ARCH -cc $MIGCC -header "$MIG_PRIVATE_HEADER_DST/$MIG_NAME.h" $MIG_DEFINES $MIG_PRIVATE_DEFS_INCFLAGS $SRC/$mig
316670eb
A
143 if [ ! -e "$MIG_HEADER_DST/$MIG_NAME.h" ]; then
144 echo "#error $MIG_NAME.h unsupported." > "$MIG_HEADER_DST/$MIG_NAME.h"
145 fi
146done
147
148
149# special headers used just for building Libsyscall
150# Note: not including -DLIBSYSCALL_INTERFACE to mig so we'll get the proper
151# 'internal' version of the headers being built
152
153mkdir -p $MIG_INTERNAL_HEADER_DST
154
155for mig in $MIGS_INTERNAL; do
156 MIG_NAME=`basename $mig .defs`
fe8ab488 157 $MIG -novouchers -arch $MACHINE_ARCH -cc $MIGCC -header "$MIG_INTERNAL_HEADER_DST/${MIG_NAME}_internal.h" $SRC/$mig
316670eb
A
158done
159