forked from darlinghq/darling-cups
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgettargetflags.sh
executable file
·125 lines (114 loc) · 2.89 KB
/
gettargetflags.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/sh
#
# Determine which target options, if any, are needed for the build.
#
# Uses the SDKROOT environment variable to determine the SDK version,
# other RC_* environment variables as needed...
#
# Usage:
#
# ./gettargetflags.sh cflags
# ./gettargetflags.sh cppflags
# ./gettargetflags.sh cxxflags
# ./gettargetflags.sh dsoflags
# ./gettargetflags.sh host
# ./gettargetflags.sh ldflags
# ./gettargetflags.sh tapi
#
target=""
variant=""
host=""
cflags="`echo $RC_CFLAGS | sed -e '1,$s/-pipe//'`"
dsoflags=""
ldflags="$cflags"
cppflags=""
for arch in $RC_ARCHS; do
if test $arch = x86_64 -o $arch = arm64 -o $arch = arm64_32; then
cppflags="-arch $arch"
break
fi
done
sdk="`basename \"$SDKROOT\"`"
case "$sdk" in
# Current OS's...
MacOSX*)
version="`echo $sdk | sed -E -e '1,$s/^[A-Za-z]+10\.([0-9]+).*$/\1/'`"
iosvers="`expr $version - 2`"
ldflags=""
for arch in $RC_ARCHS; do
target="$target -target $arch-apple-macosx10.$version"
if test $arch != i386; then
ldflags="$ldflags -arch $arch"
variant="$variant -target-variant $arch-apple-ios$iosvers-macabi"
fi
done
;;
iPhoneOS*)
version="`echo $sdk | sed -E -e '1,$s/^[A-Za-z]+([0-9]+).*$/\1/'`"
host="--build `${SRCROOT}/cups/config.guess` --host arm-apple-darwin"
for arch in $RC_ARCHS; do
target="$target -target $arch-apple-ios$version"
done
;;
iPhoneSimulator*)
version="`echo $sdk | sed -E -e '1,$s/^[A-Za-z]+([0-9]+).*$/\1/'`"
for arch in $RC_ARCHS; do
target="$target -target $arch-apple-ios$version-simulator"
done
;;
AppleTVOS*)
version="`echo $sdk | sed -E -e '1,$s/^[A-Za-z]+([0-9]+).*$/\1/'`"
host="--build `${SRCROOT}/cups/config.guess` --host arm-apple-darwin"
for arch in $RC_ARCHS; do
target="$target -target $arch-apple-tvos$version"
done
;;
AppleTVSimulator*)
version="`echo $sdk | sed -E -e '1,$s/^[A-Za-z]+([0-9]+).*$/\1/'`"
for arch in $RC_ARCHS; do
target="$target -target $arch-apple-tvos$version-simulator"
done
;;
WatchOS*)
version="`echo $sdk | sed -E -e '1,$s/^[A-Za-z]+([0-9]+).*$/\1/'`"
host="--build `${SRCROOT}/cups/config.guess` --host arm-apple-darwin"
for arch in $RC_ARCHS; do
target="$target -target $arch-apple-watchos$version"
done
;;
WatchSimulator*)
version="`echo $sdk | sed -E -e '1,$s/^[A-Za-z]+([0-9]+).*$/\1/'`"
for arch in $RC_ARCHS; do
target="$target -target $arch-apple-watchos$version-simulator"
done
;;
# Otherwise default to no target options...
*)
;;
esac
case "$1" in
cflags | cxxflags)
output="$target $cflags"
;;
cppflags)
output="$cppflags"
;;
dsoflags)
output="$dsoflags $target $cflags $variant"
;;
host)
output="$host"
;;
ldflags)
output="$target $ldflags"
;;
tapi)
output="$target $variant"
;;
*)
echo "Usage: ./gettargetflags.sh {cflags,cppflags,cxxflags,dsoflags,host,ldflags,tapi}"
exit 1
;;
esac
echo "gettargetflags.sh $1 returning '$output'" 1>&2
echo $output