2 # some elements originated from qemu configure
5 TMPC="/tmp/pcsx-conf-${RANDOM}-$$-${RANDOM}.c"
6 TMPO="/tmp/pcsx-conf-${RANDOM}-$$-${RANDOM}.o"
7 TMPB="/tmp/pcsx-conf-${RANDOM}-$$-${RANDOM}"
8 trap "rm -f $TMPC $TMPO $TMPB" EXIT INT QUIT TERM
13 c="$CC $CFLAGS -c $TMPC -o $TMPO $@"
20 c="$CC $CFLAGS $TMPC -o $TMPB $LDFLAGS $MAIN_LDLIBS $@"
27 $CC -E -dD $CFLAGS include/arm_features.h | grep -v '#undef' | grep -q "$1" || return 1
33 $CC -E -dD $CFLAGS include/arm_features.h | grep -v '#undef' | grep "$1" | awk '{print $3}'
37 # setting options to "yes" or "no" will make that choice default,
38 # "" means "autodetect".
40 platform_list="generic pandora maemo caanoo miyoo"
42 builtin_gpu_list="neon peops unai"
43 dynarec_list="ari64 lightrec none"
45 sound_driver_list="oss alsa pulseaudio sdl"
70 # these are for known platforms
71 optimize_cortexa8="no"
72 optimize_arm926ej="no"
79 if test -d /opt/local/include; then
81 CFLAGS="$CFLAGS -I/opt/local/include"
82 LDFLAGS="$LDFLAGS -L/opt/local/lib"
84 if test -d /opt/local/include; then
85 CFLAGS="$CFLAGS -I/usr/local/include"
86 LDFLAGS="$LDFLAGS -L/usr/local/lib"
92 CC="${CC-${CROSS_COMPILE}gcc}"
93 CXX="${CXX-${CROSS_COMPILE}g++}"
96 AS="${AS-${CROSS_COMPILE}as}"
97 AR="${AS-${CROSS_COMPILE}ar}"
98 MAIN_LDLIBS="$LDLIBS -ldl -lm -lpthread"
99 config_mak="config.mak"
104 [ "x${SDL_CONFIG}" = "x" ] && SDL_CONFIG="${SYSROOT}/usr/local/bin/sdl-config"
107 SYSROOT="$(${CC} --print-sysroot 2> /dev/null || true)"
108 [ "x${SDL_CONFIG}" = "x" ] && SDL_CONFIG="${SYSROOT}/usr/bin/sdl-config"
115 if test -n "$DUMP_CONFIG_LOG"; then cat config.log; fi
119 # call during arg parsing, so that cmd line can override platform defaults
127 sound_drivers="oss alsa"
129 optimize_cortexa8="yes"
137 optimize_cortexa8="yes"
145 optimize_arm926ej="yes"
151 optimize_arm926ej="yes"
156 fail "unsupported platform: $platform"
162 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'` || true
164 --help|-h) show_help="yes"
166 --platform=*) set_platform "$optarg"
168 --gpu=*) builtin_gpu="$optarg"
170 --sound-drivers=*) sound_drivers="$optarg"
172 --enable-neon) have_arm_neon="yes"
174 --disable-neon) have_arm_neon="no"
176 --enable-threads) multithreading="yes"
178 --disable-threads) multithreading="no"
180 --enable-dynamic) have_dynamic="yes"
182 --disable-dynamic) have_dynamic="no"
184 --dynarec=*) dynarec="$optarg"
186 --disable-dynarec) dynarec="no"
188 *) echo "ERROR: unknown option $opt"; show_help="yes"
193 if [ "$show_help" = "yes" ]; then
195 echo " --help print this message"
196 echo " --platform=NAME target platform [$platform]"
197 echo " available: $platform_list"
198 echo " --gpu=NAME builtin gpu plugin [guessed]"
199 echo " available: $builtin_gpu_list"
200 echo " --sound-drivers=LIST sound output drivers [guessed]"
201 echo " available: $sound_driver_list"
202 echo " --enable-neon"
203 echo " --disable-neon enable/disable ARM NEON optimizations [guessed]"
204 echo " --enable-threads"
205 echo " --disable-threads enable/disable multithreaded features [guessed]"
206 echo " --enable-dynamic"
207 echo " --disable-dynamic enable/disable dynamic loading obj. eg.plugins [guessed]"
208 echo " --dynarec=NAME select dynamic recompiler [guessed]"
209 echo " available: $dynarec_list"
210 echo "influential environment variables:"
211 echo " CROSS_COMPILE CC CXX AS AR CFLAGS ASFLAGS LDFLAGS LDLIBS"
215 # validate selections
216 if [ "x$builtin_gpu" != "x" ]; then
217 if ! echo $builtin_gpu_list | grep -q "\<$builtin_gpu\>"; then
218 fail "unsupported builtin gpu plugin: $builtin_gpu"
222 if [ "x$sound_drivers" != "x" ]; then
223 for d in $sound_drivers; do
224 if ! echo $sound_driver_list | grep -q "\<$d\>"; then
225 fail "unsupported sound driver: $sound_driver"
230 if [ "$need_libpicofe" = "yes" ]; then
231 if ! test -f "frontend/libpicofe/README"; then
232 fail "libpicofe is missing, please run 'git submodule init && git submodule update'"
236 if [ "$need_warm" = "yes" ]; then
237 if ! test -f "frontend/warm/README"; then
238 fail "wARM is missing, please run 'git submodule init && git submodule update'"
242 # basic compiler test
245 int main(void) { return 0; }
247 if ! compile_binary; then
248 fail "compiler test failed, please check config.log"
251 if [ -z "$ARCH" ]; then
252 ARCH=`$CC -dumpmachine | awk -F '-' '{print $1}'`
259 have_arm_neon_asm="no"
260 if [ "x$dynarec" = "x" ]; then
268 if [ "$optimize_cortexa8" = "yes" ]; then
269 CFLAGS="$CFLAGS -mcpu=cortex-a8 -mtune=cortex-a8"
270 ASFLAGS="$ASFLAGS -mcpu=cortex-a8"
272 if [ "$optimize_arm926ej" = "yes" ]; then
273 CFLAGS="$CFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s"
274 ASFLAGS="$ASFLAGS -mcpu=arm926ej-s -mfloat-abi=softfp"
277 if [ "x$have_arm_neon" = "x" ]; then
278 # detect NEON from user-supplied cflags to enable neon code
279 have_arm_neon=`check_define __ARM_NEON__ && echo yes` || true
281 if [ "x$have_armv7" = "x" ]; then
282 if check_define HAVE_ARMV7; then
288 if [ "x$have_armv6" = "x" ]; then
289 if check_define HAVE_ARMV6; then
294 if [ "x$have_armv5" = "x" ]; then
295 have_armv5=`check_define HAVE_ARMV5 && echo yes` || true
298 if [ "x$dynarec" = "x" ]; then
302 if [ "$have_arm_neon" = "yes" ]; then
305 elif [ "$have_armv6" = "yes" ]; then
308 # automatically set mfpu and mfloat-abi if they are not set
309 if [ "x$fpu" != "x" ]; then
310 echo "$CFLAGS" | grep -q -- '-mfpu=' || CFLAGS="$CFLAGS -mfpu=$fpu"
311 echo "$ASFLAGS" | grep -q -- '-mfpu=' || ASFLAGS="$ASFLAGS -mfpu=$fpu"
312 floatabi_set_by_gcc=`$CC -v 2>&1 | grep -q -- --with-float= && echo yes` || true
313 if [ "$floatabi_set_by_gcc" != "yes" ]; then
314 echo "$CFLAGS" | grep -q -- '-mfloat-abi=' || CFLAGS="$CFLAGS -mfloat-abi=softfp"
315 echo "$ASFLAGS" | grep -q -- '-mfloat-abi=' || ASFLAGS="$ASFLAGS -mfloat-abi=softfp"
319 # must disable thumb as recompiler can't handle it
320 if check_define __thumb__; then
321 CFLAGS="$CFLAGS -marm"
324 # warn about common mistakes
325 if [ "$have_armv5" != "yes" ]; then
326 if ! echo "$CFLAGS" | grep -q -- '-mcpu=\|-march='; then
327 echo "Warning: compiling for ARMv4, is that really what you want?"
328 echo "You probably should specify -mcpu= or -march= like this:"
329 echo " CFLAGS=-march=armv6 ./configure ..."
332 if [ "$have_arm_neon" = "yes" -a "$have_armv7" != "yes" ]; then
333 echo "Warning: compiling for NEON, but not ARMv7?"
334 echo "You probably want to specify -mcpu= or -march= like this:"
335 echo " CFLAGS=-march=armv7-a ./configure ..."
337 have_arm_neon_asm=$have_arm_neon
340 if [ "x$dynarec" = "x" ]; then
346 if [ "x$dynarec" = "x" ]; then
352 if [ "x$builtin_gpu" = "x" ]; then
353 if [ "$have_neon_gpu" = "yes" ]; then
355 elif [ "$ARCH" = "arm" -a "$have_armv7" != "yes" ]; then
356 # pre-ARMv7 hardware is usually not fast enough for peops
363 # supposedly we can avoid -fPIC on armv5 for slightly better performace?
364 if [ "$ARCH" != "arm" -o "$have_armv6" = "yes" ]; then
365 PLUGIN_CFLAGS="$PLUGIN_CFLAGS -fPIC"
367 PLUGIN_CFLAGS="$PLUGIN_CFLAGS -fno-PIC"
375 CFLAGS="$CFLAGS -DMAEMO -DMAEMO_CHANGES"
379 CFLAGS="$CFLAGS -DMIYOO"
383 # header/library presence tests
388 int main(void) { uncompress(0, 0, 0, 0); }
397 void main() { png_init_io(0, 0); }
405 #include <sys/soundcard.h>
406 #include <sys/ioctl.h>
407 void main() { int a=0; ioctl(0, SNDCTL_DSP_SETFMT, &a); }
415 #include <alsa/asoundlib.h>
416 void main() { snd_pcm_open(0, 0, 0, 0); }
424 #include <pulse/pulseaudio.h>
425 void main() { pa_threaded_mainloop_new(); }
434 int main(int argc, char *argv[]) { SDL_OpenAudio(0, 0); }
442 #include <X11/Xlib.h>
443 void *f() { return XOpenDisplay(0); }
448 # see if we have c64_tools for TI C64x DSP
452 #include <inc_libc64_mini.h>
453 int f() { return dsp_open(); }
458 MAIN_LDLIBS="$MAIN_LDLIBS -lz"
459 check_zlib || fail "please install zlib (libz-dev)"
461 MAIN_LDLIBS="-lpng $MAIN_LDLIBS"
462 check_libpng || fail "please install libpng (libpng-dev)"
464 # find what audio support we can compile
465 if [ "x$sound_drivers" = "x" ]; then
466 if check_oss; then sound_drivers="$sound_drivers oss"; fi
467 if check_alsa -lasound; then
468 sound_drivers="$sound_drivers alsa"
469 MAIN_LDLIBS="-lasound $MAIN_LDLIBS"
471 if check_pulseaudio -lpulse; then
472 sound_drivers="$sound_drivers pulseaudio"
473 MAIN_LDLIBS="-lpulse $MAIN_LDLIBS"
475 if [ "$need_sdl" = "yes" ] || check_sdl `${SDL_CONFIG} --cflags --libs`; then
476 sound_drivers="$sound_drivers sdl"
480 if echo $sound_drivers | grep -q "\<oss\>"; then
481 check_oss || fail "oss support is missing"
483 if echo $sound_drivers | grep -q "\<alsa\>"; then
484 MAIN_LDLIBS="-lasound $MAIN_LDLIBS"
485 check_alsa || fail "please install libasound2-dev"
487 if echo $sound_drivers | grep -q "\<pulseaudio\>"; then
488 MAIN_LDLIBS="-lpulse $MAIN_LDLIBS"
489 check_pulseaudio || fail "pulseaudio support is missing"
493 if [ "$need_sdl" = "yes" ]; then
494 which ${SDL_CONFIG} > /dev/null || \
495 fail "sdl-config is missing; please install libsdl (libsdl1.2-dev)"
496 CFLAGS="$CFLAGS `${SDL_CONFIG} --cflags`"
497 MAIN_LDLIBS="`${SDL_CONFIG} --libs` $MAIN_LDLIBS"
498 check_sdl || fail "please install libsdl (libsdl1.2-dev)"
501 # check for tslib (only headers needed)
502 if [ "x$have_tslib" = "x" ]; then
505 void test(struct ts_sample sample) {}
507 if compile_object; then
515 if [ "x$have_evdev" = "x" ]; then
517 #include <linux/input.h>
520 if compile_object; then
524 #include <dev/evdev/input.h>
526 if compile_object; then
532 # check for GLES headers
537 return (int)eglGetDisplay( (EGLNativeDisplayType)0 );
540 if compile_binary $CFLAGS_GLES -lEGL -lGLES_CM $LDLIBS_GLES; then
542 LDLIBS_GLES="-lEGL -lGLES_CM $LDLIBS_GLES"
543 elif compile_binary $CFLAGS_GLES -lEGL -lGLESv1_CM $LDLIBS_GLES; then
545 LDLIBS_GLES="-lEGL -lGLESv1_CM $LDLIBS_GLES"
546 elif compile_object $CFLAGS_GLES; then
550 if check_c64_tools; then
554 # declare available dynamic plugins
555 if [ "$have_dynamic" = "yes" ]; then
556 plugins="plugins/spunull/spunull.so"
558 if [ "$builtin_gpu" != "peops" ]; then
559 plugins="$plugins plugins/dfxvideo/gpu_peops.so"
561 if [ "$builtin_gpu" != "unai" ]; then
562 plugins="$plugins plugins/gpu_unai/gpu_unai.so"
564 if [ "$have_gles" = "yes" -a "x$LDLIBS_GLES" != "x" ]; then
565 plugins="$plugins plugins/gpu-gles/gpu_gles.so"
567 if [ "$have_neon_gpu" = "yes" -a "$builtin_gpu" != "neon" ]; then
568 plugins="$plugins plugins/gpu_neon/gpu_neon.so"
572 CFLAGS="$CFLAGS -DNO_DYLIB"
575 # check for xlib (only headers needed)
576 if [ "x$need_xlib" = "xyes" ]; then
577 check_xlib_headers || fail "please install libx11-dev"
580 sizeof_long=`check_define_val __SIZEOF_LONG__`
581 if [ "x$sizeof_long" = "x4" ]; then
582 CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64"
586 void test(void *f, void *d) { fread(d, 1, 1, f); }
588 if compile_object -Wno-unused-result; then
589 CFLAGS="$CFLAGS -Wno-unused-result"
592 # short plugin list for display
593 for p in $plugins; do
595 plugins_short="$p1 $plugins_short"
598 # set things that failed to autodetect to "no"
599 test "x$have_armv6" != "x" || have_armv6="no"
600 test "x$have_armv7" != "x" || have_armv7="no"
601 test "x$have_arm_neon" != "x" || have_arm_neon="no"
602 test "x$have_arm_neon_asm" != "x" || have_arm_neon_asm="no"
603 test "x$have_gles" != "x" || have_gles="no"
604 test "x$have_c64x_dsp" != "x" || have_c64x_dsp="no"
606 echo "architecture $ARCH"
607 echo "platform $platform"
608 echo "built-in GPU $builtin_gpu"
609 echo "sound drivers $sound_drivers"
610 echo "plugins $plugins_short"
611 echo "C compiler $CC"
612 echo "C compiler flags $CFLAGS"
613 echo "libraries $MAIN_LDLIBS"
614 echo "linker flags $LDFLAGS$MAIN_LDFLAGS"
615 echo "dynarec $dynarec"
616 if [ "$ARCH" = "arm" -o "$ARCH" = "aarch64" ]; then
617 echo "enable ARM NEON $have_arm_neon"
619 if [ "$ARCH" = "arm" ]; then
620 echo "ARMv7 optimizations $have_armv7"
621 echo "TI C64x DSP support $have_c64x_dsp"
623 if [ "$have_dynamic" = "yes" ]; then
624 echo "tslib support $have_tslib"
626 echo "tslib does NOT support staticly linked build"
628 if [ "$platform" = "generic" ]; then
629 echo "OpenGL ES output $have_gles"
631 echo "multithreading $multithreading"
633 echo "# Automatically generated by configure" > $config_mak
634 printf "# Configured with:" >> $config_mak
635 printf " '%s'" "$0" "$@" >> $config_mak
638 echo "CC = $CC" >> $config_mak
639 echo "CXX = $CXX" >> $config_mak
640 echo "AS = $AS" >> $config_mak
641 echo "CFLAGS += $CFLAGS" >> $config_mak
642 echo "ASFLAGS += $ASFLAGS" >> $config_mak
643 echo "LDFLAGS += $LDFLAGS" >> $config_mak
644 echo "MAIN_LDFLAGS += $MAIN_LDFLAGS" >> $config_mak
645 echo "MAIN_LDLIBS += $MAIN_LDLIBS" >> $config_mak
646 echo "PLUGIN_CFLAGS += $PLUGIN_CFLAGS" >> $config_mak
649 echo "ARCH = $ARCH" >> $config_mak
650 echo "PLATFORM = $platform" >> $config_mak
651 echo "BUILTIN_GPU = $builtin_gpu" >> $config_mak
652 echo "SOUND_DRIVERS = $sound_drivers" >> $config_mak
653 echo "PLUGINS = $plugins" >> $config_mak
654 if [ "$have_neon_gpu" = "yes" ]; then
655 echo "HAVE_NEON_GPU = 1" >> $config_mak
657 if [ "$have_arm_neon" = "yes" ]; then
658 echo "HAVE_NEON = 1" >> $config_mak
660 if [ "$have_arm_neon_asm" = "yes" ]; then
661 echo "HAVE_NEON_ASM = 1" >> $config_mak
663 if [ "$have_tslib" = "yes" -a "$have_dynamic" = "yes" ]; then
664 echo "HAVE_TSLIB = 1" >> $config_mak
666 if [ "$have_evdev" = "yes" ]; then
667 echo "HAVE_EVDEV = 1" >> $config_mak
669 if [ "$have_gles" = "yes" ]; then
670 echo "HAVE_GLES = 1" >> $config_mak
671 echo "CFLAGS_GLES = $CFLAGS_GLES" >> $config_mak
672 echo "LDLIBS_GLES = $LDLIBS_GLES" >> $config_mak
674 if [ "$have_fsections" = "no" ]; then
675 echo "NO_FSECTIONS = 1" >> $config_mak
677 if [ "$gnu_linker" = "yes" ]; then
678 echo "GNU_LINKER = 1" >> $config_mak
680 echo "DYNAREC = $dynarec" >> $config_mak
681 if [ "$drc_cache_base" = "yes" ]; then
682 echo "BASE_ADDR_DYNAMIC = 1" >> $config_mak
684 if [ "$have_c64x_dsp" = "yes" ]; then
685 echo "HAVE_C64_TOOLS = 1" >> $config_mak
687 if [ "$multithreading" = "yes" ]; then
688 echo "USE_ASYNC_CDROM = 1" >> $config_mak
689 echo "NDRC_THREAD = 1" >> $config_mak
692 # use pandora's skin (for now)
693 test -e skin || ln -s frontend/pandora/skin skin
695 # vim:shiftwidth=2:expandtab