1*94d3b452SApple OSS Distributions#!/bin/sh -xe 2*94d3b452SApple OSS Distributions# 3*94d3b452SApple OSS Distributions# Copyright (c) 2010 Apple Inc. All rights reserved. 4*94d3b452SApple OSS Distributions# 5*94d3b452SApple OSS Distributions# @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 6*94d3b452SApple OSS Distributions# 7*94d3b452SApple OSS Distributions# This file contains Original Code and/or Modifications of Original Code 8*94d3b452SApple OSS Distributions# as defined in and that are subject to the Apple Public Source License 9*94d3b452SApple OSS Distributions# Version 2.0 (the 'License'). You may not use this file except in 10*94d3b452SApple OSS Distributions# compliance with the License. The rights granted to you under the License 11*94d3b452SApple OSS Distributions# may not be used to create, or enable the creation or redistribution of, 12*94d3b452SApple OSS Distributions# unlawful or unlicensed copies of an Apple operating system, or to 13*94d3b452SApple OSS Distributions# circumvent, violate, or enable the circumvention or violation of, any 14*94d3b452SApple OSS Distributions# terms of an Apple operating system software license agreement. 15*94d3b452SApple OSS Distributions# 16*94d3b452SApple OSS Distributions# Please obtain a copy of the License at 17*94d3b452SApple OSS Distributions# http://www.opensource.apple.com/apsl/ and read it before using this file. 18*94d3b452SApple OSS Distributions# 19*94d3b452SApple OSS Distributions# The Original Code and all software distributed under the License are 20*94d3b452SApple OSS Distributions# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 21*94d3b452SApple OSS Distributions# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 22*94d3b452SApple OSS Distributions# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 23*94d3b452SApple OSS Distributions# FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 24*94d3b452SApple OSS Distributions# Please see the License for the specific language governing rights and 25*94d3b452SApple OSS Distributions# limitations under the License. 26*94d3b452SApple OSS Distributions# 27*94d3b452SApple OSS Distributions# @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 28*94d3b452SApple OSS Distributions# 29*94d3b452SApple OSS Distributions 30*94d3b452SApple OSS Distributions# build inside OBJROOT 31*94d3b452SApple OSS Distributionscd $OBJROOT 32*94d3b452SApple OSS Distributions 33*94d3b452SApple OSS DistributionsMIG=`xcrun -sdk "$SDKROOT" -find mig` 34*94d3b452SApple OSS DistributionsMIGCC=`xcrun -sdk "$SDKROOT" -find cc` 35*94d3b452SApple OSS Distributionsexport MIGCC 36*94d3b452SApple OSS Distributions[ -n "$DRIVERKITROOT" ] && MIG_DRIVERKIT_DEFINES="-DDRIVERKIT" 37*94d3b452SApple OSS DistributionsMIG_DEFINES="-DLIBSYSCALL_INTERFACE $MIG_DRIVERKIT_DEFINES" 38*94d3b452SApple OSS DistributionsMIG_PRIVATE_DEFINES="-DPRIVATE" 39*94d3b452SApple OSS DistributionsMIG_HEADER_OBJ="$OBJROOT/mig_hdr/include/mach" 40*94d3b452SApple OSS DistributionsMIG_HEADER_DST="$BUILT_PRODUCTS_DIR/mig_hdr/include/mach" 41*94d3b452SApple OSS DistributionsMIG_PRIVATE_HEADER_DST="$BUILT_PRODUCTS_DIR/mig_hdr/local/include/mach" 42*94d3b452SApple OSS DistributionsSERVER_HEADER_DST="$BUILT_PRODUCTS_DIR/mig_hdr/include/servers" 43*94d3b452SApple OSS DistributionsMACH_HEADER_DST="$BUILT_PRODUCTS_DIR/mig_hdr/include/mach" 44*94d3b452SApple OSS DistributionsMACH_PRIVATE_HEADER_DST="$BUILT_PRODUCTS_DIR/mig_hdr/local/include/mach" 45*94d3b452SApple OSS DistributionsMIG_INTERNAL_HEADER_DST="$BUILT_PRODUCTS_DIR/internal_hdr/include/mach" 46*94d3b452SApple OSS DistributionsMIG_INCFLAGS="-I${SRCROOT}/../osfmk" 47*94d3b452SApple OSS DistributionsSRC="$SRCROOT/mach" 48*94d3b452SApple OSS DistributionsFILTER_MIG="$SRCROOT/xcodescripts/filter_mig.awk" 49*94d3b452SApple OSS Distributions 50*94d3b452SApple OSS Distributions# 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. 51*94d3b452SApple OSS Distributions# thread_state_t *really* needs to pick up arm64 over intel because it has a larger struct type. 52*94d3b452SApple OSS Distributionscase "$ARCHS" in 53*94d3b452SApple OSS Distributions*arm64*) 54*94d3b452SApple OSS Distributions MACHINE_ARCH=armv7 55*94d3b452SApple OSS Distributions ;; 56*94d3b452SApple OSS Distributions*x86_64*) 57*94d3b452SApple OSS Distributions MACHINE_ARCH=i386 58*94d3b452SApple OSS Distributions ;; 59*94d3b452SApple OSS Distributions*) 60*94d3b452SApple OSS Distributions MACHINE_ARCH=`echo $ARCHS | cut -d' ' -f 1` 61*94d3b452SApple OSS Distributions ;; 62*94d3b452SApple OSS Distributionsesac 63*94d3b452SApple OSS Distributions 64*94d3b452SApple OSS DistributionsASROOT="" 65*94d3b452SApple OSS Distributionsif [ `whoami` = "root" ]; then 66*94d3b452SApple OSS Distributions ASROOT="-o 0" 67*94d3b452SApple OSS Distributionsfi 68*94d3b452SApple OSS Distributions 69*94d3b452SApple OSS Distributions# These are covered by ../../osfmk/mach/mach.modulemap. 70*94d3b452SApple OSS DistributionsMIGS="clock.defs 71*94d3b452SApple OSS Distributions clock_priv.defs 72*94d3b452SApple OSS Distributions clock_reply.defs 73*94d3b452SApple OSS Distributions exc.defs 74*94d3b452SApple OSS Distributions host_priv.defs 75*94d3b452SApple OSS Distributions host_security.defs 76*94d3b452SApple OSS Distributions mach_eventlink.defs 77*94d3b452SApple OSS Distributions mach_host.defs 78*94d3b452SApple OSS Distributions mach_port.defs 79*94d3b452SApple OSS Distributions mach_voucher.defs 80*94d3b452SApple OSS Distributions memory_entry.defs 81*94d3b452SApple OSS Distributions processor.defs 82*94d3b452SApple OSS Distributions processor_set.defs 83*94d3b452SApple OSS Distributions task.defs 84*94d3b452SApple OSS Distributions thread_act.defs 85*94d3b452SApple OSS Distributions vm_map.defs" 86*94d3b452SApple OSS Distributions 87*94d3b452SApple OSS Distributions# These are covered by ../../osfmk/mach/mach_private.modulemap. 88*94d3b452SApple OSS DistributionsMIGS_PRIVATE="" 89*94d3b452SApple OSS Distributions 90*94d3b452SApple OSS DistributionsMIGS_DUAL_PUBLIC_PRIVATE="" 91*94d3b452SApple OSS Distributions 92*94d3b452SApple OSS DistributionsMIGS_PRIVATE_PLATFORMS="iphoneos iphonesimulator tvos tvsimulator appletvos appletvsimulator watchos watchsimulator bridgeos bridgesimulator iphoneosnano iphonenanosimulator" 93*94d3b452SApple OSS Distributions 94*94d3b452SApple OSS Distributionsif ( echo $MIGS_PRIVATE_PLATFORMS | grep -wFq "${PLATFORM_NAME}" ) 95*94d3b452SApple OSS Distributionsthen 96*94d3b452SApple OSS Distributions MIGS_PRIVATE="mach_vm.defs" 97*94d3b452SApple OSS Distributionselse 98*94d3b452SApple OSS Distributions MIGS="$MIGS mach_vm.defs" 99*94d3b452SApple OSS Distributionsfi 100*94d3b452SApple OSS Distributions 101*94d3b452SApple OSS DistributionsMIGS_INTERNAL="mach_port.defs 102*94d3b452SApple OSS Distributions mach_vm.defs 103*94d3b452SApple OSS Distributions task.defs 104*94d3b452SApple OSS Distributions thread_act.defs 105*94d3b452SApple OSS Distributions vm_map.defs" 106*94d3b452SApple OSS Distributions 107*94d3b452SApple OSS DistributionsSERVER_HDRS="key_defs.h 108*94d3b452SApple OSS Distributions ls_defs.h 109*94d3b452SApple OSS Distributions netname_defs.h 110*94d3b452SApple OSS Distributions nm_defs.h" 111*94d3b452SApple OSS Distributions 112*94d3b452SApple OSS Distributions# These are covered by ../../osfmk/mach/mach.modulemap. 113*94d3b452SApple OSS DistributionsMACH_HDRS="mach.h 114*94d3b452SApple OSS Distributions mach_error.h 115*94d3b452SApple OSS Distributions mach_init.h 116*94d3b452SApple OSS Distributions mach_interface.h 117*94d3b452SApple OSS Distributions mach_right.h 118*94d3b452SApple OSS Distributions port_obj.h 119*94d3b452SApple OSS Distributions sync.h 120*94d3b452SApple OSS Distributions vm_task.h 121*94d3b452SApple OSS Distributions vm_page_size.h 122*94d3b452SApple OSS Distributions thread_state.h" 123*94d3b452SApple OSS Distributions 124*94d3b452SApple OSS Distributions# These are covered by ../../osfmk/mach/mach_private.modulemap. 125*94d3b452SApple OSS DistributionsMACH_PRIVATE_HDRS="port_descriptions.h 126*94d3b452SApple OSS Distributions mach_right_private.h 127*94d3b452SApple OSS Distributions mach_sync_ipc.h" 128*94d3b452SApple OSS Distributions 129*94d3b452SApple OSS DistributionsMIG_FILTER_TEMPLATE="add_attributes_to_mig.txt" 130*94d3b452SApple OSS Distributions 131*94d3b452SApple OSS Distributions# install /usr/include/server headers 132*94d3b452SApple OSS Distributionsmkdir -p $SERVER_HEADER_DST 133*94d3b452SApple OSS Distributionsfor hdr in $SERVER_HDRS; do 134*94d3b452SApple OSS Distributions install $ASROOT -c -m 444 $SRC/servers/$hdr $SERVER_HEADER_DST 135*94d3b452SApple OSS Distributionsdone 136*94d3b452SApple OSS Distributions 137*94d3b452SApple OSS Distributions# install /usr/include/mach headers 138*94d3b452SApple OSS Distributionsmkdir -p $MACH_HEADER_DST 139*94d3b452SApple OSS Distributionsfor hdr in $MACH_HDRS; do 140*94d3b452SApple OSS Distributions install $ASROOT -c -m 444 $SRC/mach/$hdr $MACH_HEADER_DST 141*94d3b452SApple OSS Distributionsdone 142*94d3b452SApple OSS Distributions 143*94d3b452SApple OSS Distributions# install /usr/local/include/mach headers 144*94d3b452SApple OSS Distributionsmkdir -p $MACH_PRIVATE_HEADER_DST 145*94d3b452SApple OSS Distributionsfor hdr in $MACH_PRIVATE_HDRS; do 146*94d3b452SApple OSS Distributions install $ASROOT -c -m 444 $SRC/mach/$hdr $MACH_PRIVATE_HEADER_DST 147*94d3b452SApple OSS Distributionsdone 148*94d3b452SApple OSS Distributions 149*94d3b452SApple OSS Distributions# special case because we only have one to do here 150*94d3b452SApple OSS Distributions$MIG -novouchers -arch $MACHINE_ARCH -cc $MIGCC -header "$SERVER_HEADER_DST/netname.h" $MIG_INCFLAGS $SRC/servers/netname.defs 151*94d3b452SApple OSS Distributions 152*94d3b452SApple OSS Distributions# install /usr/include/mach mig headers 153*94d3b452SApple OSS Distributions 154*94d3b452SApple OSS Distributionsmkdir -p $MIG_HEADER_DST 155*94d3b452SApple OSS Distributionsmkdir -p $MIG_HEADER_OBJ 156*94d3b452SApple OSS Distributions 157*94d3b452SApple OSS Distributionsfor mig in $MIGS $MIGS_DUAL_PUBLIC_PRIVATE; do 158*94d3b452SApple OSS Distributions MIG_NAME=`basename $mig .defs` 159*94d3b452SApple OSS Distributions $MIG -novouchers -arch $MACHINE_ARCH -cc $MIGCC -header "$MIG_HEADER_OBJ/$MIG_NAME.h" $MIG_DEFINES $MIG_INCFLAGS $SRC/$mig 160*94d3b452SApple OSS Distributions $FILTER_MIG $SRC/$MIG_FILTER_TEMPLATE $MIG_HEADER_OBJ/$MIG_NAME.h > $MIG_HEADER_OBJ/$MIG_NAME.tmp.h 161*94d3b452SApple OSS Distributions mv $MIG_HEADER_OBJ/$MIG_NAME.tmp.h $MIG_HEADER_OBJ/$MIG_NAME.h 162*94d3b452SApple OSS Distributions install $ASROOT -c -m 444 $MIG_HEADER_OBJ/$MIG_NAME.h $MIG_HEADER_DST/$MIG_NAME.h 163*94d3b452SApple OSS Distributionsdone 164*94d3b452SApple OSS Distributions 165*94d3b452SApple OSS Distributionsmkdir -p $MIG_PRIVATE_HEADER_DST 166*94d3b452SApple OSS Distributions 167*94d3b452SApple OSS Distributionsfor mig in $MIGS_PRIVATE $MIGS_DUAL_PUBLIC_PRIVATE; do 168*94d3b452SApple OSS Distributions MIG_NAME=`basename $mig .defs` 169*94d3b452SApple OSS Distributions $MIG -novouchers -arch $MACHINE_ARCH -cc $MIGCC -header "$MIG_PRIVATE_HEADER_DST/$MIG_NAME.h" $MIG_DEFINES $MIG_PRIVATE_DEFINES $MIG_INCFLAGS $SRC/$mig 170*94d3b452SApple OSS Distributions if [ ! -e "$MIG_HEADER_DST/$MIG_NAME.h" ]; then 171*94d3b452SApple OSS Distributions echo "#error $MIG_NAME.h unsupported." > "$MIG_HEADER_DST/$MIG_NAME.h" 172*94d3b452SApple OSS Distributions fi 173*94d3b452SApple OSS Distributionsdone 174*94d3b452SApple OSS Distributions 175*94d3b452SApple OSS Distributions 176*94d3b452SApple OSS Distributions# special headers used just for building Libsyscall 177*94d3b452SApple OSS Distributions# Note: not including -DLIBSYSCALL_INTERFACE to mig so we'll get the proper 178*94d3b452SApple OSS Distributions# 'internal' version of the headers being built 179*94d3b452SApple OSS Distributions 180*94d3b452SApple OSS Distributionsmkdir -p $MIG_INTERNAL_HEADER_DST 181*94d3b452SApple OSS Distributions 182*94d3b452SApple OSS Distributionsfor mig in $MIGS_INTERNAL; do 183*94d3b452SApple OSS Distributions MIG_NAME=`basename $mig .defs` 184*94d3b452SApple OSS Distributions $MIG -novouchers -arch $MACHINE_ARCH -cc $MIGCC -header "$MIG_INTERNAL_HEADER_DST/${MIG_NAME}_internal.h" $MIG_INCFLAGS $SRC/$mig 185*94d3b452SApple OSS Distributionsdone 186*94d3b452SApple OSS Distributions 187