Debian Codegraph @

Xpjproject/configure-iphone

raw symbols SCIP
1 #!/bin/bash
2
3 F="configure-iphone"
4
5 if test "$*" = "--help" -o "$*" = "-h"; then
6 echo "$F [OPTIONS]"
7 echo ""
8 echo "where:"
9 echo " OPTIONS Other options that will be passed directly to"
10 echo " ./aconfigure script. Run ./aconfigure --help"
11 echo " for more info."
12 echo ""
13 echo "Environment variables:"
14 echo " IPHONESDK Optionally specify which SDK to use. Value is the full "
15 echo " path of the SDK. By default, the latest SDK installed"
16 echo " will be used."
17 echo " CC Optionally specify the path of the ARM cross compiler"
18 echo " to use. By default, the compiler is deduced from the"
19 echo " SDK."
20 echo " ARCH Optional flags to specify target architecture, e.g."
21 echo " ARCH=\"-arch armv7\". Default is arm64."
22 echo " MIN_IOS Optional flags to specify minimum supported iOS"
23 echo " versions, e.g. MIN_IOS=\"-miphoneos-version-min=11.0\". "
24 echo " Default is 11.0."
25 echo ""
26 exit 0
27 fi
28
29 # Set the main iPhone developer directory, if not set
30 if test "x${DEVPATH}" = "x"; then
31 DEVPATH=/Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
32 if test ! -d $DEVPATH; then
33 DEVPATH=/Developer/Platforms/iPhoneOS.platform/Developer
34 fi
35 echo "$F: DEVPATH is not specified, using ${DEVPATH}"
36 fi
37
38 # Make sure $DEVPATH directory exist
39 if test ! -d $DEVPATH; then
40 echo "$F error: directory $DEVPATH does not exist. Please install iPhone development kit"
41 exit 1
42 fi
43
44 # Choose SDK version to use
45 if test "$IPHONESDK" = ""; then
46 # If IPHONESDK is not set, use the latest one
47 for f in `ls $DEVPATH/SDKs/`; do echo $f | sed 's/\(.sdk\)//'; done | sort | tail -1 > tmpsdkname
48 IPHONESDK=`cat tmpsdkname`.sdk
49 rm -f tmpsdkname
50 SDKPATH=${DEVPATH}/SDKs/${IPHONESDK}
51 echo "$F: IPHONESDK is not specified, choosing ${IPHONESDK}"
52 elif test -d ${IPHONESDK}; then
53 # .. else if IPHONESDK is set and it points to a valid path, just use it
54 SDKPATH=${IPHONESDK}
55 else
56 # .. else assume the SDK name is used.
57 SDKPATH=${DEVPATH}/SDKs/${IPHONESDK}
58 fi
59
60 # Test the SDK directory
61 if test ! -d ${SDKPATH}/usr/include; then
62 echo "$F error: unable to find valid iPhone SDK in ${SDKPATH}"
63 exit 1
64 fi
65
66 # Default CFLAGS if it's not specified
67 if test "$CFLAGS" = ""; then
68 CFLAGS="-O2 -Wno-unused-label"
69 fi
70
71 # Default LDFLAGS if it's not specified
72 if test "$LDFLAGS" = ""; then
73 LDFLAGS="-O2"
74 fi
75
76 # Test the toolchain directory
77 TCPATH="${DEVPATH}/../../../Toolchains/XcodeDefault.xctoolchain"
78 if test ! -d ${TCPATH}/usr/bin; then
79 TCPATH="${DEVPATH}"
80 fi
81
82 # Determine which gcc for this SDK. Binaries should have the
83 # full path as it's not normally in user's PATH
84
85 if test "${CC}" = ""; then
86 # Try to use clang if available
87 ccpath="${TCPATH}/usr/bin/clang"
88 # Next, try to use llvm-gcc
89 gccpath="${DEVPATH}/usr/bin/llvm-gcc"
90 if test -e ${ccpath}; then
91 export CC="${ccpath}"
92 elif test -e ${gccpath}; then
93 export CC="${gccpath}"
94 else
95 for archpath in `ls -d ${SDKPATH}/usr/lib/gcc/arm-apple-darwin*`; do
96 archname=`basename ${archpath}`
97 for gccver in `ls ${archpath}`; do
98 gccpath="${DEVPATH}/usr/bin/${archname}-gcc-${gccver}"
99 if test -e ${gccpath}; then
100 export CC="${gccpath}"
101 fi
102 done
103 done
104 fi
105 if test ! "${CC}" = ""; then
106 echo "$F: CC is not specified, choosing ${CC}"
107 fi
108 fi
109
110 if test "${CC}" = ""; then
111 echo "$F error: unable to find gcc for ${IPHONESDK}. If you think you have the right gcc, set the full path in CC environment variable."
112 exit 1
113 fi
114
115 if test "${ARCH}" = ""; then
116 export ARCH="-arch arm64"
117 echo "$F: ARCH is not specified, choosing ${ARCH}"
118 fi
119 export ARCH_VAL=`echo ${ARCH} | sed 's/\-arch //' | sed -e 's/^[ \t]*//;s/[ \t]*$//' `
120
121 if test "${ARCH_VAL}" = "arm64e"; then
122 export ARCH_VAL="arm64"
123 fi
124
125 if test "${MIN_IOS}" = ""; then
126 MIN_IOS_VER="11.0"
127 echo "$F: MIN_IOS is not specified, choosing ${MIN_IOS_VER}"
128 MIN_IOS="-miphoneos-version-min=${MIN_IOS_VER}"
129 fi
130 CFLAGS="${CFLAGS} ${MIN_IOS}"
131 LDFLAGS="${LDFLAGS} ${MIN_IOS}"
132
133
134 # Set CXX if not set
135 if test "${CXX}" = ""; then
136 export CXX=`echo ${CC} | sed 's/clang/clang++/'`
137 echo "$F: CXX is not specified, using ${CXX}"
138 fi
139
140 # Other settings to feed to configure script.
141 #ARCH="-arch armv6"
142 export CFLAGS="${CFLAGS} -DPJ_SDK_NAME=\"\\\"`basename $SDKPATH`\\\"\" ${ARCH} -isysroot ${SDKPATH}"
143 export LDFLAGS="${LDFLAGS} ${ARCH} -isysroot ${SDKPATH} -framework AudioToolbox -framework Foundation"
144 export AR="${TCPATH}/usr/bin/libtool -static -o"
145 export AR_FLAGS=" "
146 export RANLIB="echo ranlib"
147 # Use gcc -E as preprocessor instead of cpp, since cpp will find the
148 # header files in standard /usr/include instead of in isysroot
149 export CPP="${CC} ${ARCH} -E -isysroot ${SDKPATH}"
150
151 # Print settings
152 if test "1" = "1"; then
153 echo "$F: calling ./aconfigure with env vars:"
154 echo " MIN_IOS = ${MIN_IOS}"
155 echo " CC = ${CC}"
156 echo " CXX = ${CXX}"
157 echo " SDKPATH = ${SDKPATH}"
158 echo " CFLAGS = ${CFLAGS}"
159 echo " LDFLAGS = ${LDFLAGS}"
160 echo " AR = ${AR}"
161 echo " RANLIB = ${RANLIB}"
162 echo " ARCH = ${ARCH_VAL}"
163 fi
164
165 # And finally invoke the configure script itself
166 ./aconfigure --host=${ARCH_VAL}-apple-darwin_ios --disable-sdl $*
167
168 if test "$?" = "0"; then
169 echo "Done configuring for `basename $SDKPATH`"
170 echo ""
171 fi
172