-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathDeviceMIG.sh
90 lines (80 loc) · 2.58 KB
/
DeviceMIG.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Copyright (c) 2006, 2009 Apple Inc. All rights reserved.
#
# @APPLE_LICENSE_HEADER_START@
#
# This file contains Original Code and/or Modifications of Original Code
# as defined in and that are subject to the Apple Public Source License
# Version 2.0 (the 'License'). You may not use this file except in
# compliance with the License. Please obtain a copy of the License at
# http://www.opensource.apple.com/apsl/ and read it before using this
# file.
#
# The Original Code and all software distributed under the License are
# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
# Please see the License for the specific language governing rights and
# limitations under the License.
#
# @APPLE_LICENSE_HEADER_END@
# This script is run from the shell script build phases in the DeviceMIG target
MIGCC=`xcodebuild -sdk "${SDKROOT}" -find cc`
MIG=`xcodebuild -sdk "${SDKROOT}" -find mig`
if [ install == "$1" ]
then
if [ $SCRIPT_INPUT_FILE_0 -nt $SCRIPT_OUTPUT_FILE_0 ]
then
echo Creating 32 bit Mig header for backward compatibility
cat > $SCRIPT_OUTPUT_FILE_0 <<- EOI_iokitmig
#if !defined(__LP64__)
`cat $SCRIPT_INPUT_FILE_0`
#endif /* !__LP64__ */
EOI_iokitmig
fi
exit
fi
# This script generates the device.defs mig interface for the IOKit.framework to the kernel
runMig()
{
local input=$1 head=$2 user=$3; shift 3
migargs=$@
set -- $ARCHS
MIGARCH=$1; shift
cmd="$MIG -cc $MIGCC -arch $MIGARCH ${migargs} -server /dev/null -header $head -user $user $input";
echo $cmd
eval $cmd
}
# which input files is newest.
if [ $SCRIPT_INPUT_FILE_0 -nt $SCRIPT_INPUT_FILE_1 ]
then
testFile=$SCRIPT_INPUT_FILE_0
else
testFile=$SCRIPT_INPUT_FILE_1
fi
ARCHS32=""
ARCHS64=""
for a in $ARCHS; do
case $a in
*64)
ARCHS64="$ARCHS64 $a"
;;
*)
ARCHS32="$ARCHS32 $a"
;;
esac
done
echo "Inferred 32-bit architectures: $ARCHS32"
echo "Inferred 64-bit architectures: $ARCHS64"
if [ $testFile -nt $SCRIPT_OUTPUT_FILE_0 -o $testFile -nt $SCRIPT_OUTPUT_FILE_1 \
-o $testFile -nt $SCRIPT_OUTPUT_FILE_2 -o $testFile -nt $SCRIPT_OUTPUT_FILE_3 ]
then
ARCHS=${ARCHS32}
runMig $SCRIPT_INPUT_FILE_0 $SCRIPT_OUTPUT_FILE_0 $SCRIPT_OUTPUT_FILE_1 $OTHER_CFLAGS
if [ -n "${ARCHS64}" ]
then
ARCHS=${ARCHS64}
OTHER_CFLAGS="$OTHER_CFLAGS -D__LP64__"
runMig $SCRIPT_INPUT_FILE_0 $SCRIPT_OUTPUT_FILE_2 $SCRIPT_OUTPUT_FILE_3 $OTHER_CFLAGS
fi
fi