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 [ "${RC_ProjectName%_Sim}" != "${RC_ProjectName}" ] ; 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" 45# from old Libsystem makefiles 46MACHINE_ARCH=`echo $ARCHS | cut -d' ' -f 1` 47SRC="$SRCROOT/mach" 48MIG_INTERNAL_HEADER_DST="$DERIVED_SOURCES_DIR/mach" 49MIG_DEFS_INCFLAGS="-I${SDKROOT}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders" 50#MIG_DEFS_INCFLAGS="-I${SDKROOT}/System/Library/Frameworks/System.framework/PrivateHeaders" 51 52MIG_ONLY_GEN_HEADERS="-user /dev/null -server /dev/null -sheader /dev/null" 53 54MIGS="clock.defs 55 clock_priv.defs 56 clock_reply.defs 57 exc.defs 58 host_priv.defs 59 host_security.defs 60 lock_set.defs 61 mach_host.defs 62 mach_port.defs 63 processor.defs 64 processor_set.defs 65 vm_map.defs" 66 67MIGS_PRIVATE="" 68 69MIGS_DUAL_PUBLIC_PRIVATE="" 70 71if [ "$PLATFORM" = "iPhoneOS" -o "$RC_ProjectName" = "Libsyscall_headers_Sim" ]; then 72 MIGS_PRIVATE="mach_vm.defs" 73else 74 MIGS="${MIGS} mach_vm.defs" 75fi 76 77 78MIGS_ARCH="thread_act.defs 79 task.defs" 80 81MIGS_INTERNAL="mach_port.defs 82 mach_vm.defs 83 vm_map.defs" 84 85SERVER_HDRS="key_defs.h 86 ls_defs.h 87 netname_defs.h 88 nm_defs.h" 89 90# install /usr/include/server headers 91mkdir -p $SERVER_HEADER_DST 92for hdr in $SERVER_HDRS; do 93 install -o 0 -c -m 444 $SRC/servers/$hdr $SERVER_HEADER_DST 94done 95 96# special case because we only have one to do here 97$MIG -arch $MACHINE_ARCH -header "$SERVER_HEADER_DST/netname.h" $MIG_ONLY_GEN_HEADERS $MIG_DEFS_INCFLAGS $SRC/servers/netname.defs 98 99# install /usr/include/mach mig headers 100 101mkdir -p $MIG_HEADER_DST 102 103for mig in $MIGS $MIGS_DUAL_PUBLIC_PRIVATE; do 104 MIG_NAME=`basename $mig .defs` 105 $MIG -arch $MACHINE_ARCH -cc $MIGCC -header "$MIG_HEADER_DST/$MIG_NAME.h" $MIG_ONLY_GEN_HEADERS $MIG_DEFINES $MIG_DEFS_INCFLAGS $SRC/$mig 106done 107 108mkdir -p $MIG_PRIVATE_HEADER_DST 109 110for mig in $MIGS_PRIVATE $MIGS_DUAL_PUBLIC_PRIVATE; do 111 MIG_NAME=`basename $mig .defs` 112 $MIG -arch $MACHINE_ARCH -cc $MIGCC -header "$MIG_PRIVATE_HEADER_DST/$MIG_NAME.h" $MIG_ONLY_GEN_HEADERS $MIG_DEFINES $MIG_DEFS_INCFLAGS $SRC/$mig 113 if [ ! -e "$MIG_HEADER_DST/$MIG_NAME.h" ]; then 114 echo "#error $MIG_NAME.h unsupported." > "$MIG_HEADER_DST/$MIG_NAME.h" 115 fi 116done 117 118 119# special headers used just for building Libsyscall 120# Note: not including -DLIBSYSCALL_INTERFACE to mig so we'll get the proper 121# 'internal' version of the headers being built 122 123mkdir -p $MIG_INTERNAL_HEADER_DST 124 125for mig in $MIGS_INTERNAL; do 126 MIG_NAME=`basename $mig .defs` 127 $MIG -arch $MACHINE_ARCH -cc $MIGCC -header "$MIG_INTERNAL_HEADER_DST/${MIG_NAME}_internal.h" $MIG_ONLY_GEN_HEADERS $MIG_DEFINES $MIG_DEFS_INCFLAGS $SRC/$mig 128done 129 130ARCHS=`echo $ARCHS | sed -e 's/armv./arm/g'` 131for arch in $ARCHS; do 132 MIG_ARCH_DST="$MIG_HEADER_DST/$arch" 133 134 mkdir -p $MIG_ARCH_DST 135 136 for mig in $MIGS_ARCH; do 137 MIG_NAME=`basename $mig .defs` 138 $MIG -arch $MACHINE_ARCH -cc $MIGCC -header "$MIG_ARCH_DST/$MIG_NAME.h" $MIG_ONLY_GEN_HEADERS $MIG_DEFINES $MIG_DEFS_INCFLAGS $MIG_DEFINES $SRC/$mig 139 done 140done 141