Commit | Line | Data |
---|---|---|
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" | |
07c13dfd | 7 | TMPB="/tmp/pcsx-conf-${RANDOM}-$$-${RANDOM}" |
8 | trap "rm -f $TMPC $TMPO $TMPB" EXIT INT QUIT TERM | |
4132e8ca | 9 | rm -f config.log |
10 | ||
11 | compile_object() | |
12 | { | |
07c13dfd | 13 | c="$CC $CFLAGS -c $TMPC -o $TMPO $@" |
14 | echo $c >> config.log | |
15 | $c >> config.log 2>&1 | |
16 | } | |
17 | ||
18 | compile_binary() | |
19 | { | |
20 | c="$CC $CFLAGS $TMPC -o $TMPB $LDFLAGS $MAIN_LDLIBS $@" | |
4132e8ca | 21 | echo $c >> config.log |
22 | $c >> config.log 2>&1 | |
23 | } | |
24 | ||
25 | check_define() | |
26 | { | |
27 | echo "" > $TMPC | |
28 | $CC -E -dD $CFLAGS $TMPC | grep -q $1 || return 1 | |
29 | return 0 | |
30 | } | |
31 | ||
32 | # setting options to "yes" or "no" will make that choice default, | |
33 | # "" means "autodetect". | |
34 | ||
38c2028e | 35 | platform_list="generic pandora maemo caanoo libretro" |
4132e8ca | 36 | platform="generic" |
61bc6d40 | 37 | builtin_gpu_list="peops unai neon" |
38 | builtin_gpu="" | |
07c13dfd | 39 | sound_driver_list="oss alsa sdl pulseaudio libretro" |
40 | sound_drivers="" | |
dd4d5a35 | 41 | plugins="plugins/spunull/spunull.so \ |
42 | plugins/dfxvideo/gpu_peops.so plugins/gpu_unai/gpu_unai.so" | |
4132e8ca | 43 | ram_fixed="no" |
44 | drc_cache_base="no" | |
45 | have_armv6="" | |
46 | have_armv7="" | |
47 | have_arm_neon="" | |
48 | have_tslib="" | |
49 | enable_dynarec="yes" | |
f89fa2d9 | 50 | need_sdl="no" |
cc56203b | 51 | need_libpicofe="yes" |
52 | need_warm="no" | |
4132e8ca | 53 | # these are for known platforms |
54 | optimize_cortexa8="no" | |
55 | optimize_arm926ej="no" | |
56 | ||
57 | # hardcoded stuff | |
58 | CC="${CC-${CROSS_COMPILE}gcc}" | |
ac6575cd | 59 | CXX="${CXX-${CROSS_COMPILE}g++}" |
4132e8ca | 60 | AS="${AS-${CROSS_COMPILE}as}" |
61 | AR="${AS-${CROSS_COMPILE}ar}" | |
f89fa2d9 | 62 | MAIN_LDLIBS="$LDLIBS -ldl -lm" |
4132e8ca | 63 | config_mak="config.mak" |
64 | ||
07c13dfd | 65 | fail() |
66 | { | |
67 | echo "$@" | |
68 | exit 1 | |
69 | } | |
70 | ||
4132e8ca | 71 | # call during arg parsing, so that cmd line can override platform defaults |
72 | set_platform() | |
73 | { | |
74 | platform=$1 | |
75 | case "$platform" in | |
76 | generic) | |
77 | ;; | |
78 | pandora) | |
07c13dfd | 79 | sound_drivers="oss alsa" |
4132e8ca | 80 | ram_fixed="yes" |
81 | drc_cache_base="yes" | |
82 | optimize_cortexa8="yes" | |
83 | have_arm_neon="yes" | |
84 | ;; | |
85 | maemo) | |
86 | ram_fixed="yes" | |
87 | drc_cache_base="yes" | |
88 | optimize_cortexa8="yes" | |
89 | have_arm_neon="yes" | |
90 | ;; | |
91 | caanoo) | |
07c13dfd | 92 | sound_drivers="oss" |
4132e8ca | 93 | ram_fixed="yes" |
94 | drc_cache_base="yes" | |
95 | optimize_arm926ej="yes" | |
cc56203b | 96 | need_warm="yes" |
4132e8ca | 97 | ;; |
38c2028e | 98 | libretro) |
07c13dfd | 99 | sound_drivers="libretro" |
cc56203b | 100 | need_libpicofe="no" |
38c2028e | 101 | ;; |
4132e8ca | 102 | *) |
07c13dfd | 103 | fail "unsupported platform: $platform" |
4132e8ca | 104 | ;; |
105 | esac | |
106 | } | |
107 | ||
108 | for opt do | |
109 | optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'` || true | |
110 | case "$opt" in | |
111 | --help|-h) show_help="yes" | |
112 | ;; | |
113 | --platform=*) set_platform "$optarg" | |
114 | ;; | |
61bc6d40 | 115 | --gpu=*) builtin_gpu="$optarg" |
116 | ;; | |
07c13dfd | 117 | --sound-drivers=*) sound_drivers="$optarg" |
4132e8ca | 118 | ;; |
119 | --enable-neon) have_arm_neon="yes" | |
120 | ;; | |
121 | --disable-neon) have_arm_neon="no" | |
122 | ;; | |
123 | --disable-dynarec) enable_dynarec="no" | |
124 | ;; | |
125 | *) echo "ERROR: unknown option $opt"; show_help="yes" | |
126 | ;; | |
127 | esac | |
128 | done | |
129 | ||
130 | if [ "$show_help" = "yes" ]; then | |
131 | echo "options:" | |
132 | echo " --help print this message" | |
133 | echo " --platform=NAME target platform [$platform]" | |
134 | echo " available: $platform_list" | |
61bc6d40 | 135 | echo " --gpu=NAME builtin gpu plugin [guessed]" |
136 | echo " available: $builtin_gpu_list" | |
07c13dfd | 137 | echo " --sound-drivers=LIST sound output drivers [guessed]" |
4132e8ca | 138 | echo " available: $sound_driver_list" |
139 | echo " --enable-neon" | |
140 | echo " --disable-neon enable/disable ARM NEON optimizations [guessed]" | |
141 | echo " --disable-dynarec disable dynamic recompiler" | |
142 | echo " (dynarec is only available and enabled on ARM)" | |
143 | echo "influential environment variables:" | |
ac6575cd | 144 | echo " CROSS_COMPILE CC CXX AS AR CFLAGS ASFLAGS LDFLAGS LDLIBS" |
4132e8ca | 145 | exit 1 |
146 | fi | |
147 | ||
07c13dfd | 148 | # validate selections |
61bc6d40 | 149 | if [ "x$builtin_gpu" != "x" ]; then |
07c13dfd | 150 | if ! echo $builtin_gpu_list | grep -q "\<$builtin_gpu\>"; then |
151 | fail "unsupported builtin gpu plugin: $builtin_gpu" | |
152 | fi | |
61bc6d40 | 153 | fi |
154 | ||
07c13dfd | 155 | if [ "x$sound_drivers" != "x" ]; then |
156 | for d in $sound_drivers; do | |
157 | if ! echo $sound_driver_list | grep -q "\<$d\>"; then | |
158 | fail "unsupported sound driver: $sound_driver" | |
159 | fi | |
160 | done | |
161 | fi | |
4132e8ca | 162 | |
cc56203b | 163 | if [ "$need_libpicofe" = "yes" ]; then |
164 | if ! test -f "frontend/libpicofe/README"; then | |
165 | fail "libpicofe is missing, please run 'git submodule init && git submodule update'" | |
166 | fi | |
167 | fi | |
168 | ||
169 | if [ "$need_warm" = "yes" ]; then | |
170 | if ! test -f "frontend/warm/README"; then | |
171 | fail "wARM is missing, please run 'git submodule init && git submodule update'" | |
172 | fi | |
173 | fi | |
174 | ||
4132e8ca | 175 | if [ -z "$ARCH" ]; then |
176 | ARCH=`$CC -v 2>&1 | grep -i 'target:' | awk '{print $2}' \ | |
177 | | awk -F '-' '{print $1}'` | |
178 | fi | |
179 | ||
180 | # ARM stuff | |
181 | if [ "$ARCH" = "arm" ]; then | |
182 | if [ "$optimize_cortexa8" = "yes" ]; then | |
4132e8ca | 183 | CFLAGS="$CFLAGS -mcpu=cortex-a8 -mtune=cortex-a8" |
184 | ASFLAGS="$ASFLAGS -mcpu=cortex-a8" | |
185 | fi | |
186 | if [ "$optimize_arm926ej" = "yes" ]; then | |
187 | CFLAGS="$CFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s" | |
188 | ASFLAGS="$ASFLAGS -mcpu=arm926ej-s -mfloat-abi=softfp" | |
189 | fi | |
190 | ||
191 | if [ "x$have_arm_neon" = "x" ]; then | |
192 | # detect NEON from user-supplied cflags to enable asm code | |
193 | have_arm_neon=`check_define __ARM_NEON__ && echo yes` || true | |
194 | fi | |
195 | if [ "x$have_armv6" = "x" ]; then | |
196 | have_armv6=`check_define __ARM_ARCH_6 && echo yes` || true | |
197 | fi | |
198 | if [ "x$have_armv7" = "x" ]; then | |
199 | if check_define __ARM_ARCH_7A__; then | |
200 | have_armv6="yes" | |
201 | have_armv7="yes" | |
202 | fi | |
203 | fi | |
204 | ||
61bc6d40 | 205 | if [ "x$builtin_gpu" = "x" ]; then |
206 | if [ "$have_arm_neon" = "yes" ]; then | |
207 | builtin_gpu="neon" | |
208 | elif [ "$have_armv7" != "yes" ]; then | |
209 | # pre-ARMv7 hardware is usually not fast enough for peops | |
210 | builtin_gpu="unai" | |
211 | else | |
212 | builtin_gpu="peops" | |
213 | fi | |
214 | fi | |
215 | ||
e795af9e | 216 | # automatically set mfpu and mfloat-abi if they are not set |
4132e8ca | 217 | if [ "$have_arm_neon" = "yes" ]; then |
218 | echo "$CFLAGS" | grep -q -- '-mfpu=' || CFLAGS="$CFLAGS -mfpu=neon" | |
219 | echo "$ASFLAGS" | grep -q -- '-mfpu=' || ASFLAGS="$ASFLAGS -mfpu=neon" | |
220 | elif [ "$have_armv6" = "yes" ]; then | |
221 | echo "$CFLAGS" | grep -q -- '-mfpu=' || CFLAGS="$CFLAGS -mfpu=vfp" | |
222 | echo "$ASFLAGS" | grep -q -- '-mfpu=' || ASFLAGS="$ASFLAGS -mfpu=vfp" | |
223 | fi | |
9f704290 | 224 | floatabi_set_by_gcc=`$CC -v 2>&1 | grep -q -- --with-float= && echo yes` || true |
e795af9e | 225 | if [ "$floatabi_set_by_gcc" != "yes" -a "$have_armv6" = "yes" ]; then |
4132e8ca | 226 | echo "$CFLAGS" | grep -q -- '-mfloat-abi=' || CFLAGS="$CFLAGS -mfloat-abi=softfp" |
227 | echo "$ASFLAGS" | grep -q -- '-mfloat-abi=' || ASFLAGS="$ASFLAGS -mfloat-abi=softfp" | |
228 | fi | |
229 | ||
9f704290 | 230 | # must disable thumb as recompiler can't handle it |
96751f36 | 231 | if check_define __thumb__; then |
9f704290 | 232 | CFLAGS="$CFLAGS -marm" |
96751f36 | 233 | fi |
234 | ||
4132e8ca | 235 | if [ "$have_armv7" = "yes" ]; then |
236 | ASFLAGS="$ASFLAGS --defsym HAVE_ARMV7=1" | |
237 | else | |
238 | ASFLAGS="$ASFLAGS --defsym HAVE_ARMV7=0" | |
239 | fi | |
240 | else | |
241 | # dynarec only available on ARM | |
242 | enable_dynarec="no" | |
243 | fi | |
244 | ||
61bc6d40 | 245 | if [ "x$builtin_gpu" = "x" ]; then |
246 | builtin_gpu="peops" | |
247 | fi | |
248 | ||
791f6e3e | 249 | #if [ "$ARCH" = "x86_64" ]; then |
4132e8ca | 250 | # currently we are full of 32bit assumptions, |
251 | # at least savestate compatibility will break without these | |
791f6e3e T |
252 | # CFLAGS="$CFLAGS -m32" |
253 | # LDFLAGS="$LDFLAGS -m32" | |
254 | #fi | |
4132e8ca | 255 | |
256 | # supposedly we can avoid -fPIC on armv5 for slightly better performace? | |
257 | if [ "$ARCH" != "arm" -o "$have_armv6" = "yes" ]; then | |
258 | PLUGIN_CFLAGS="$PLUGIN_CFLAGS -fPIC" | |
259 | fi | |
260 | ||
261 | if [ "$ram_fixed" = "yes" ]; then | |
262 | CFLAGS="$CFLAGS -DRAM_FIXED" | |
263 | fi | |
264 | ||
38c2028e | 265 | case "$platform" in |
266 | generic) | |
f89fa2d9 | 267 | need_sdl="yes" |
38c2028e | 268 | ;; |
269 | maemo) | |
4132e8ca | 270 | maemo_cflags=`pkg-config --cflags hildon-1` |
271 | maemo_ldlibs=`pkg-config --libs hildon-1` | |
272 | CFLAGS="$CFLAGS -DMAEMO -DMAEMO_CHANGES $maemo_cflags" | |
07c13dfd | 273 | MAIN_LDLIBS="$MAIN_LDLIBS $maemo_ldlibs" |
38c2028e | 274 | ;; |
275 | libretro) | |
276 | CFLAGS="$CFLAGS -fPIC" | |
277 | LDFLAGS="$LDFLAGS -shared" | |
278 | ;; | |
279 | esac | |
4132e8ca | 280 | |
07c13dfd | 281 | # header/library presence tests |
282 | check_zlib() | |
283 | { | |
284 | cat > $TMPC <<EOF | |
285 | #include <zlib.h> | |
791f6e3e | 286 | int main(void) { uncompress(0, 0, 0, 0); } |
07c13dfd | 287 | EOF |
288 | compile_binary | |
289 | } | |
290 | ||
291 | check_bzlib() | |
292 | { | |
293 | cat > $TMPC <<EOF | |
294 | #include <bzlib.h> | |
295 | void main() { BZ2_bzBuffToBuffDecompress(0, 0, 0, 0, 0, 0); } | |
296 | EOF | |
297 | compile_object | |
298 | } | |
299 | ||
300 | check_libpng() | |
301 | { | |
302 | cat > $TMPC <<EOF | |
303 | #include <png.h> | |
304 | void main() { png_init_io(0, 0); } | |
305 | EOF | |
306 | compile_binary | |
307 | } | |
308 | ||
309 | check_oss() | |
310 | { | |
311 | cat > $TMPC <<EOF | |
312 | #include <sys/soundcard.h> | |
313 | #include <sys/ioctl.h> | |
314 | void main() { int a=0; ioctl(0, SNDCTL_DSP_SETFMT, &a); } | |
315 | EOF | |
316 | compile_binary | |
317 | } | |
318 | ||
319 | check_alsa() | |
320 | { | |
321 | cat > $TMPC <<EOF | |
322 | #include <alsa/asoundlib.h> | |
323 | void main() { snd_pcm_open(0, 0, 0, 0); } | |
324 | EOF | |
325 | compile_binary "$@" | |
326 | } | |
327 | ||
328 | check_sdl() | |
329 | { | |
330 | cat > $TMPC <<EOF | |
331 | #include <SDL.h> | |
332 | void main() { SDL_OpenAudio(0, 0); } | |
333 | EOF | |
334 | compile_binary "$@" | |
335 | } | |
336 | ||
f89fa2d9 | 337 | MAIN_LDLIBS="$MAIN_LDLIBS -lz" |
9f704290 | 338 | check_zlib || fail "please install zlib (libz-dev)" |
f89fa2d9 | 339 | |
9f704290 | 340 | check_bzlib || fail "please install bz2lib (libbz2-dev)" |
f89fa2d9 | 341 | |
342 | MAIN_LDLIBS="-lpng $MAIN_LDLIBS" | |
9f704290 | 343 | check_libpng || fail "please install libpng (libpng-dev)" |
07c13dfd | 344 | |
345 | # find what audio support we can compile | |
346 | if [ "x$sound_drivers" = "x" ]; then | |
347 | if check_oss; then sound_drivers="$sound_drivers oss"; fi | |
f89fa2d9 | 348 | if check_alsa -lasound; then |
349 | sound_drivers="$sound_drivers alsa" | |
350 | MAIN_LDLIBS="-lasound $MAIN_LDLIBS" | |
351 | fi | |
9f704290 | 352 | if [ "$need_sdl" = "yes" ] || check_sdl `sdl-config --cflags --libs`; then |
f89fa2d9 | 353 | sound_drivers="$sound_drivers sdl" |
354 | need_sdl="yes" | |
355 | fi | |
356 | else | |
357 | if echo $sound_drivers | grep -q "\<oss\>"; then | |
358 | check_oss || fail "oss support is missing" | |
359 | fi | |
360 | if echo $sound_drivers | grep -q "\<alsa\>"; then | |
361 | MAIN_LDLIBS="-lasound $MAIN_LDLIBS" | |
362 | check_alsa || fail "please install libasound2-dev" | |
363 | fi | |
07c13dfd | 364 | fi |
365 | ||
9f704290 | 366 | if [ "$need_sdl" = "yes" ]; then |
367 | which sdl-config > /dev/null || \ | |
368 | fail "sdl-config is missing; please install libsdl (libsdl1.2-dev)" | |
f89fa2d9 | 369 | CFLAGS="$CFLAGS `sdl-config --cflags`" |
370 | MAIN_LDLIBS="`sdl-config --libs` $MAIN_LDLIBS" | |
9f704290 | 371 | check_sdl || fail "please install libsdl (libsdl1.2-dev)" |
07c13dfd | 372 | fi |
373 | ||
4132e8ca | 374 | # check for tslib (only headers needed) |
375 | if [ "x$have_tslib" = "x" ]; then | |
376 | cat > $TMPC <<EOF | |
377 | #include <tslib.h> | |
378 | void test(struct ts_sample sample) {} | |
379 | EOF | |
380 | if compile_object; then | |
381 | have_tslib="yes" | |
382 | else | |
383 | have_tslib="no" | |
384 | fi | |
385 | fi | |
386 | ||
dd4d5a35 | 387 | # check for GLES headers |
388 | cat > $TMPC <<EOF | |
389 | #include <GLES/gl.h> | |
390 | #include <GLES/glext.h> | |
391 | #include <EGL/egl.h> | |
392 | void *test(void) { | |
393 | return eglGetDisplay( (EGLNativeDisplayType)0 ); | |
394 | } | |
395 | EOF | |
396 | if compile_object; then | |
397 | plugins="$plugins plugins/gpu-gles/gpu_gles.so" | |
398 | fi | |
399 | ||
61bc6d40 | 400 | if [ "$have_arm_neon" = "yes" -a "$builtin_gpu" != "neon" ]; then |
401 | plugins="$plugins plugins/gpu_neon/gpu_neon.so" | |
402 | fi | |
403 | ||
9f704290 | 404 | cat > $TMPC <<EOF |
405 | void test(void *f, void *d) { fread(d, 1, 1, f); } | |
406 | EOF | |
407 | if compile_object -Wno-unused-result; then | |
408 | CFLAGS="$CFLAGS -Wno-unused-result" | |
409 | fi | |
410 | ||
dd4d5a35 | 411 | # short plugin list for display |
412 | for p in $plugins; do | |
413 | p1=`basename $p` | |
414 | plugins_short="$p1 $plugins_short" | |
415 | done | |
416 | ||
4132e8ca | 417 | # set things that failed to autodetect to "no" |
418 | test "x$have_armv6" != "x" || have_armv6="no" | |
419 | test "x$have_armv7" != "x" || have_armv7="no" | |
420 | test "x$have_arm_neon" != "x" || have_arm_neon="no" | |
421 | ||
422 | echo "architecture $ARCH" | |
423 | echo "platform $platform" | |
61bc6d40 | 424 | echo "built-in GPU $builtin_gpu" |
07c13dfd | 425 | echo "sound drivers $sound_drivers" |
dd4d5a35 | 426 | echo "plugins $plugins_short" |
4132e8ca | 427 | echo "C compiler $CC" |
428 | echo "C compiler flags $CFLAGS" | |
07c13dfd | 429 | echo "libraries $MAIN_LDLIBS" |
7badc935 | 430 | echo "linker flags $LDFLAGS" |
4132e8ca | 431 | echo "enable dynarec $enable_dynarec" |
432 | echo "ARMv7 optimizations $have_armv7" | |
433 | echo "enable ARM NEON $have_arm_neon" | |
434 | echo "tslib support $have_tslib" | |
435 | ||
436 | echo "# Automatically generated by configure" > $config_mak | |
437 | printf "# Configured with:" >> $config_mak | |
438 | printf " '%s'" "$0" "$@" >> $config_mak | |
439 | echo >> $config_mak | |
440 | ||
441 | echo "CC = $CC" >> $config_mak | |
ac6575cd | 442 | echo "CXX = $CXX" >> $config_mak |
4132e8ca | 443 | echo "AS = $AS" >> $config_mak |
444 | echo "CFLAGS += $CFLAGS" >> $config_mak | |
445 | echo "ASFLAGS += $ASFLAGS" >> $config_mak | |
446 | echo "LDFLAGS += $LDFLAGS" >> $config_mak | |
07c13dfd | 447 | echo "MAIN_LDLIBS += $MAIN_LDLIBS" >> $config_mak |
4132e8ca | 448 | echo "PLUGIN_CFLAGS += $PLUGIN_CFLAGS" >> $config_mak |
449 | echo >> $config_mak | |
450 | ||
38c2028e | 451 | if [ "$platform" = "libretro" ]; then |
452 | echo "TARGET = libretro.so" >> $config_mak | |
453 | fi | |
4132e8ca | 454 | echo "ARCH = $ARCH" >> $config_mak |
455 | echo "PLATFORM = $platform" >> $config_mak | |
61bc6d40 | 456 | echo "BUILTIN_GPU = $builtin_gpu" >> $config_mak |
07c13dfd | 457 | echo "SOUND_DRIVERS = $sound_drivers" >> $config_mak |
dd4d5a35 | 458 | if [ "$ARCH" = "arm" ]; then |
459 | echo "PLUGINS = $plugins" >> $config_mak | |
460 | else | |
461 | echo -n "PLUGINS =" >> $config_mak | |
462 | for p in $plugins; do | |
463 | echo -n " ${p}.${ARCH}" >> $config_mak | |
464 | done | |
465 | echo >> $config_mak | |
466 | fi | |
4132e8ca | 467 | if [ "$have_armv6" = "yes" ]; then |
468 | echo "HAVE_ARMV6 = 1" >> $config_mak | |
469 | fi | |
470 | if [ "$have_armv7" = "yes" ]; then | |
471 | echo "HAVE_ARMV7 = 1" >> $config_mak | |
472 | fi | |
473 | if [ "$have_arm_neon" = "yes" ]; then | |
474 | echo "HAVE_NEON = 1" >> $config_mak | |
475 | fi | |
476 | if [ "$have_tslib" = "yes" ]; then | |
477 | echo "HAVE_TSLIB = 1" >> $config_mak | |
478 | fi | |
479 | if [ "$enable_dynarec" = "yes" ]; then | |
480 | echo "USE_DYNAREC = 1" >> $config_mak | |
481 | fi | |
482 | if [ "$drc_cache_base" = "yes" ]; then | |
483 | echo "DRC_CACHE_BASE = 1" >> $config_mak | |
484 | fi | |
485 | ||
2e6189bc | 486 | # use pandora's skin (for now) |
487 | test -e skin || ln -s frontend/pandora/skin skin | |
488 | ||
4132e8ca | 489 | # vim:shiftwidth=2:expandtab |