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