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