4132e8ca |
1 | #!/bin/sh |
2 | # some elements originated from qemu configure |
3 | set -e |
4 | |
5 | TMPC="/tmp/pcsx-conf-${RANDOM}-$$-${RANDOM}.c" |
6 | TMPO="/tmp/pcsx-conf-${RANDOM}-$$-${RANDOM}.o" |
7 | trap "rm -f $TMPC $TMPO" EXIT INT QUIT TERM |
8 | rm -f config.log |
9 | |
10 | compile_object() |
11 | { |
12 | c="$CC $CFLAGS -c $TMPC -o $TMPO $1" |
13 | echo $c >> config.log |
14 | $c >> config.log 2>&1 |
15 | } |
16 | |
17 | check_define() |
18 | { |
19 | echo "" > $TMPC |
20 | $CC -E -dD $CFLAGS $TMPC | grep -q $1 || return 1 |
21 | return 0 |
22 | } |
23 | |
24 | # setting options to "yes" or "no" will make that choice default, |
25 | # "" means "autodetect". |
26 | |
27 | platform_list="generic pandora maemo caanoo" |
28 | platform="generic" |
29 | sound_driver_list="oss alsa none" |
30 | sound_driver="alsa" |
31 | ram_fixed="no" |
32 | drc_cache_base="no" |
33 | have_armv6="" |
34 | have_armv7="" |
35 | have_arm_neon="" |
36 | have_tslib="" |
37 | enable_dynarec="yes" |
38 | # these are for known platforms |
39 | optimize_cortexa8="no" |
40 | optimize_arm926ej="no" |
41 | |
42 | # hardcoded stuff |
43 | CC="${CC-${CROSS_COMPILE}gcc}" |
ac6575cd |
44 | CXX="${CXX-${CROSS_COMPILE}g++}" |
4132e8ca |
45 | AS="${AS-${CROSS_COMPILE}as}" |
46 | AR="${AS-${CROSS_COMPILE}ar}" |
47 | config_mak="config.mak" |
48 | |
49 | # call during arg parsing, so that cmd line can override platform defaults |
50 | set_platform() |
51 | { |
52 | platform=$1 |
53 | case "$platform" in |
54 | generic) |
55 | ;; |
56 | pandora) |
57 | sound_driver="oss" |
58 | ram_fixed="yes" |
59 | drc_cache_base="yes" |
60 | optimize_cortexa8="yes" |
61 | have_arm_neon="yes" |
62 | ;; |
63 | maemo) |
64 | ram_fixed="yes" |
65 | drc_cache_base="yes" |
66 | optimize_cortexa8="yes" |
67 | have_arm_neon="yes" |
68 | ;; |
69 | caanoo) |
70 | sound_driver="oss" |
71 | ram_fixed="yes" |
72 | drc_cache_base="yes" |
73 | optimize_arm926ej="yes" |
74 | ;; |
75 | *) |
76 | echo "unsupported platform: $platform" |
77 | exit 1 |
78 | ;; |
79 | esac |
80 | } |
81 | |
82 | for opt do |
83 | optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'` || true |
84 | case "$opt" in |
85 | --help|-h) show_help="yes" |
86 | ;; |
87 | --platform=*) set_platform "$optarg" |
88 | ;; |
89 | --sound-driver=*) sound_driver="$optarg" |
90 | ;; |
91 | --enable-neon) have_arm_neon="yes" |
92 | ;; |
93 | --disable-neon) have_arm_neon="no" |
94 | ;; |
95 | --disable-dynarec) enable_dynarec="no" |
96 | ;; |
97 | *) echo "ERROR: unknown option $opt"; show_help="yes" |
98 | ;; |
99 | esac |
100 | done |
101 | |
102 | if [ "$show_help" = "yes" ]; then |
103 | echo "options:" |
104 | echo " --help print this message" |
105 | echo " --platform=NAME target platform [$platform]" |
106 | echo " available: $platform_list" |
107 | echo " --sound-driver=NAME sound output driver [$sound_driver]" |
108 | echo " available: $sound_driver_list" |
109 | echo " --enable-neon" |
110 | echo " --disable-neon enable/disable ARM NEON optimizations [guessed]" |
111 | echo " --disable-dynarec disable dynamic recompiler" |
112 | echo " (dynarec is only available and enabled on ARM)" |
113 | echo "influential environment variables:" |
ac6575cd |
114 | echo " CROSS_COMPILE CC CXX AS AR CFLAGS ASFLAGS LDFLAGS LDLIBS" |
4132e8ca |
115 | exit 1 |
116 | fi |
117 | |
118 | case "$sound_driver" in |
119 | oss|alsa|none) |
120 | ;; |
121 | *) |
122 | echo "unsupported sound driver: $sound_driver" |
123 | exit 1 |
124 | ;; |
125 | esac |
126 | |
127 | if [ -z "$ARCH" ]; then |
128 | ARCH=`$CC -v 2>&1 | grep -i 'target:' | awk '{print $2}' \ |
129 | | awk -F '-' '{print $1}'` |
130 | fi |
131 | |
132 | # ARM stuff |
133 | if [ "$ARCH" = "arm" ]; then |
134 | if [ "$optimize_cortexa8" = "yes" ]; then |
135 | # both: -mfpu=neon |
136 | CFLAGS="$CFLAGS -mcpu=cortex-a8 -mtune=cortex-a8" |
137 | ASFLAGS="$ASFLAGS -mcpu=cortex-a8" |
138 | fi |
139 | if [ "$optimize_arm926ej" = "yes" ]; then |
140 | CFLAGS="$CFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s" |
141 | ASFLAGS="$ASFLAGS -mcpu=arm926ej-s -mfloat-abi=softfp" |
142 | fi |
143 | |
144 | if [ "x$have_arm_neon" = "x" ]; then |
145 | # detect NEON from user-supplied cflags to enable asm code |
146 | have_arm_neon=`check_define __ARM_NEON__ && echo yes` || true |
147 | fi |
148 | if [ "x$have_armv6" = "x" ]; then |
149 | have_armv6=`check_define __ARM_ARCH_6 && echo yes` || true |
150 | fi |
151 | if [ "x$have_armv7" = "x" ]; then |
152 | if check_define __ARM_ARCH_7A__; then |
153 | have_armv6="yes" |
154 | have_armv7="yes" |
155 | fi |
156 | fi |
157 | |
158 | # set mfpu and mfloat-abi if they are not set |
159 | if [ "$have_arm_neon" = "yes" ]; then |
160 | echo "$CFLAGS" | grep -q -- '-mfpu=' || CFLAGS="$CFLAGS -mfpu=neon" |
161 | echo "$ASFLAGS" | grep -q -- '-mfpu=' || ASFLAGS="$ASFLAGS -mfpu=neon" |
162 | elif [ "$have_armv6" = "yes" ]; then |
163 | echo "$CFLAGS" | grep -q -- '-mfpu=' || CFLAGS="$CFLAGS -mfpu=vfp" |
164 | echo "$ASFLAGS" | grep -q -- '-mfpu=' || ASFLAGS="$ASFLAGS -mfpu=vfp" |
165 | fi |
166 | if [ "$have_armv6" = "yes" ]; then |
167 | echo "$CFLAGS" | grep -q -- '-mfloat-abi=' || CFLAGS="$CFLAGS -mfloat-abi=softfp" |
168 | echo "$ASFLAGS" | grep -q -- '-mfloat-abi=' || ASFLAGS="$ASFLAGS -mfloat-abi=softfp" |
169 | fi |
170 | |
171 | if [ "$have_armv7" = "yes" ]; then |
172 | ASFLAGS="$ASFLAGS --defsym HAVE_ARMV7=1" |
173 | else |
174 | ASFLAGS="$ASFLAGS --defsym HAVE_ARMV7=0" |
175 | fi |
176 | else |
177 | # dynarec only available on ARM |
178 | enable_dynarec="no" |
179 | fi |
180 | |
181 | if [ "$ARCH" = "x86_64" ]; then |
182 | # currently we are full of 32bit assumptions, |
183 | # at least savestate compatibility will break without these |
184 | CFLAGS="$CFLAGS -m32" |
185 | LDFLAGS="$LDFLAGS -m32" |
186 | fi |
187 | |
188 | # supposedly we can avoid -fPIC on armv5 for slightly better performace? |
189 | if [ "$ARCH" != "arm" -o "$have_armv6" = "yes" ]; then |
190 | PLUGIN_CFLAGS="$PLUGIN_CFLAGS -fPIC" |
191 | fi |
192 | |
193 | if [ "$ram_fixed" = "yes" ]; then |
194 | CFLAGS="$CFLAGS -DRAM_FIXED" |
195 | fi |
196 | |
7badc935 |
197 | if [ "$platform" = "generic" ]; then |
198 | generic_cflags=`sdl-config --cflags` |
199 | generic_ldlibs=`sdl-config --libs` |
200 | CFLAGS="$CFLAGS $generic_cflags" |
201 | LDFLAGS="$LDFLAGS $generic_ldlibs" |
202 | elif [ "$platform" = "maemo" ]; then |
4132e8ca |
203 | maemo_cflags=`pkg-config --cflags hildon-1` |
204 | maemo_ldlibs=`pkg-config --libs hildon-1` |
205 | CFLAGS="$CFLAGS -DMAEMO -DMAEMO_CHANGES $maemo_cflags" |
206 | LDFLAGS="$LDFLAGS $maemo_ldlibs" |
207 | fi |
208 | |
209 | # check for tslib (only headers needed) |
210 | if [ "x$have_tslib" = "x" ]; then |
211 | cat > $TMPC <<EOF |
212 | #include <tslib.h> |
213 | void test(struct ts_sample sample) {} |
214 | EOF |
215 | if compile_object; then |
216 | have_tslib="yes" |
217 | else |
218 | have_tslib="no" |
219 | fi |
220 | fi |
221 | |
222 | # set things that failed to autodetect to "no" |
223 | test "x$have_armv6" != "x" || have_armv6="no" |
224 | test "x$have_armv7" != "x" || have_armv7="no" |
225 | test "x$have_arm_neon" != "x" || have_arm_neon="no" |
226 | |
227 | echo "architecture $ARCH" |
228 | echo "platform $platform" |
229 | echo "sound driver $sound_driver" |
230 | echo "C compiler $CC" |
231 | echo "C compiler flags $CFLAGS" |
7badc935 |
232 | echo "linker flags $LDFLAGS" |
4132e8ca |
233 | echo "enable dynarec $enable_dynarec" |
234 | echo "ARMv7 optimizations $have_armv7" |
235 | echo "enable ARM NEON $have_arm_neon" |
236 | echo "tslib support $have_tslib" |
237 | |
238 | echo "# Automatically generated by configure" > $config_mak |
239 | printf "# Configured with:" >> $config_mak |
240 | printf " '%s'" "$0" "$@" >> $config_mak |
241 | echo >> $config_mak |
242 | |
243 | echo "CC = $CC" >> $config_mak |
ac6575cd |
244 | echo "CXX = $CXX" >> $config_mak |
4132e8ca |
245 | echo "AS = $AS" >> $config_mak |
246 | echo "CFLAGS += $CFLAGS" >> $config_mak |
247 | echo "ASFLAGS += $ASFLAGS" >> $config_mak |
248 | echo "LDFLAGS += $LDFLAGS" >> $config_mak |
249 | echo "LDLIBS += $LDLIBS" >> $config_mak |
250 | echo "PLUGIN_CFLAGS += $PLUGIN_CFLAGS" >> $config_mak |
251 | echo >> $config_mak |
252 | |
253 | echo "ARCH = $ARCH" >> $config_mak |
254 | echo "PLATFORM = $platform" >> $config_mak |
255 | case "$sound_driver" in |
256 | oss) |
257 | echo "USE_OSS = 1" >> $config_mak |
258 | ;; |
259 | alsa) |
260 | echo "USE_ALSA = 1" >> $config_mak |
261 | ;; |
262 | none) |
263 | echo "USE_NO_SOUND = 1" >> $config_mak |
264 | ;; |
265 | esac |
266 | if [ "$have_armv6" = "yes" ]; then |
267 | echo "HAVE_ARMV6 = 1" >> $config_mak |
268 | fi |
269 | if [ "$have_armv7" = "yes" ]; then |
270 | echo "HAVE_ARMV7 = 1" >> $config_mak |
271 | fi |
272 | if [ "$have_arm_neon" = "yes" ]; then |
273 | echo "HAVE_NEON = 1" >> $config_mak |
274 | fi |
275 | if [ "$have_tslib" = "yes" ]; then |
276 | echo "HAVE_TSLIB = 1" >> $config_mak |
277 | fi |
278 | if [ "$enable_dynarec" = "yes" ]; then |
279 | echo "USE_DYNAREC = 1" >> $config_mak |
280 | fi |
281 | if [ "$drc_cache_base" = "yes" ]; then |
282 | echo "DRC_CACHE_BASE = 1" >> $config_mak |
283 | fi |
284 | |
285 | # vim:shiftwidth=2:expandtab |