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 -q $1 || return 1
31 # setting options to "yes" or "no" will make that choice default,
32 # "" means "autodetect".
34 platform_list="generic pandora maemo caanoo libretro"
36 builtin_gpu_list="peops unai neon"
38 sound_driver_list="oss alsa pulseaudio sdl libretro"
40 plugins="plugins/spunull/spunull.so \
41 plugins/dfxvideo/gpu_peops.so plugins/gpu_unai/gpu_unai.so"
58 # these are for known platforms
59 optimize_cortexa8="no"
60 optimize_arm926ej="no"
63 CC="${CC-${CROSS_COMPILE}gcc}"
64 CXX="${CXX-${CROSS_COMPILE}g++}"
65 AS="${AS-${CROSS_COMPILE}as}"
66 AR="${AS-${CROSS_COMPILE}ar}"
67 MAIN_LDLIBS="$LDLIBS -ldl -lm -lpthread"
68 config_mak="config.mak"
76 # call during arg parsing, so that cmd line can override platform defaults
84 sound_drivers="oss alsa"
87 optimize_cortexa8="yes"
94 optimize_cortexa8="yes"
101 optimize_arm926ej="yes"
105 sound_drivers="libretro"
109 fail "unsupported platform: $platform"
115 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'` || true
117 --help|-h) show_help="yes"
119 --platform=*) set_platform "$optarg"
121 --gpu=*) builtin_gpu="$optarg"
123 --sound-drivers=*) sound_drivers="$optarg"
125 --enable-neon) have_arm_neon="yes"
127 --disable-neon) have_arm_neon="no"
129 --disable-dynarec) enable_dynarec="no"
131 *) echo "ERROR: unknown option $opt"; show_help="yes"
136 if [ "$show_help" = "yes" ]; then
138 echo " --help print this message"
139 echo " --platform=NAME target platform [$platform]"
140 echo " available: $platform_list"
141 echo " --gpu=NAME builtin gpu plugin [guessed]"
142 echo " available: $builtin_gpu_list"
143 echo " --sound-drivers=LIST sound output drivers [guessed]"
144 echo " available: $sound_driver_list"
145 echo " --enable-neon"
146 echo " --disable-neon enable/disable ARM NEON optimizations [guessed]"
147 echo " --disable-dynarec disable dynamic recompiler"
148 echo " (dynarec is only available and enabled on ARM)"
149 echo "influential environment variables:"
150 echo " CROSS_COMPILE CC CXX AS AR CFLAGS ASFLAGS LDFLAGS LDLIBS"
154 # validate selections
155 if [ "x$builtin_gpu" != "x" ]; then
156 if ! echo $builtin_gpu_list | grep -q "\<$builtin_gpu\>"; then
157 fail "unsupported builtin gpu plugin: $builtin_gpu"
161 if [ "x$sound_drivers" != "x" ]; then
162 for d in $sound_drivers; do
163 if ! echo $sound_driver_list | grep -q "\<$d\>"; then
164 fail "unsupported sound driver: $sound_driver"
169 if [ "$need_libpicofe" = "yes" ]; then
170 if ! test -f "frontend/libpicofe/README"; then
171 fail "libpicofe is missing, please run 'git submodule init && git submodule update'"
175 if [ "$need_warm" = "yes" ]; then
176 if ! test -f "frontend/warm/README"; then
177 fail "wARM is missing, please run 'git submodule init && git submodule update'"
181 # basic compiler test
184 int main(void) { return 0; }
186 if ! compile_binary; then
187 fail "compiler test failed, please check config.log"
190 if [ -z "$ARCH" ]; then
191 ARCH=`$CC -dumpmachine | awk -F '-' '{print $1}'`
199 if [ "$optimize_cortexa8" = "yes" ]; then
200 CFLAGS="$CFLAGS -mcpu=cortex-a8 -mtune=cortex-a8"
201 ASFLAGS="$ASFLAGS -mcpu=cortex-a8"
203 if [ "$optimize_arm926ej" = "yes" ]; then
204 CFLAGS="$CFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s"
205 ASFLAGS="$ASFLAGS -mcpu=arm926ej-s -mfloat-abi=softfp"
208 if [ "x$have_arm_neon" = "x" ]; then
209 # detect NEON from user-supplied cflags to enable asm code
210 have_arm_neon=`check_define __ARM_NEON__ && echo yes` || true
212 if [ "x$have_armv7" = "x" ]; then
213 if check_define HAVE_ARMV7; then
219 if [ "x$have_armv6" = "x" ]; then
220 if check_define HAVE_ARMV6; then
225 if [ "x$have_armv5" = "x" ]; then
226 have_armv5=`check_define HAVE_ARMV5 && echo yes` || true
229 if [ "x$builtin_gpu" = "x" ]; then
230 if [ "$have_arm_neon" = "yes" ]; then
232 elif [ "$have_armv7" != "yes" ]; then
233 # pre-ARMv7 hardware is usually not fast enough for peops
240 # automatically set mfpu and mfloat-abi if they are not set
241 if [ "$have_arm_neon" = "yes" ]; then
243 elif [ "$have_armv6" = "yes" ]; then
246 if [ "x$fpu" != "x" ]; then
247 echo "$CFLAGS" | grep -q -- '-mfpu=' || CFLAGS="$CFLAGS -mfpu=$fpu"
248 echo "$ASFLAGS" | grep -q -- '-mfpu=' || ASFLAGS="$ASFLAGS -mfpu=$fpu"
249 floatabi_set_by_gcc=`$CC -v 2>&1 | grep -q -- --with-float= && echo yes` || true
250 if [ "$floatabi_set_by_gcc" != "yes" ]; then
251 echo "$CFLAGS" | grep -q -- '-mfloat-abi=' || CFLAGS="$CFLAGS -mfloat-abi=softfp"
252 echo "$ASFLAGS" | grep -q -- '-mfloat-abi=' || ASFLAGS="$ASFLAGS -mfloat-abi=softfp"
256 # must disable thumb as recompiler can't handle it
257 if check_define __thumb__; then
258 CFLAGS="$CFLAGS -marm"
261 # warn about common mistakes
262 if [ "$have_armv5" != "yes" ]; then
263 if ! echo "$CFLAGS" | grep -q -- '-mcpu=\|-march='; then
264 echo "Warning: compiling for ARMv4, is that really what you want?"
265 echo "You probably should specify -mcpu= or -march= like this:"
266 echo " CFLAGS=-march=armv6 ./configure ..."
269 if [ "$have_arm_neon" = "yes" -a "$have_armv7" != "yes" ]; then
270 echo "Warning: compiling for NEON, but not ARMv7?"
271 echo "You probably want to specify -mcpu= or -march= like this:"
272 echo " CFLAGS=-march=armv7-a ./configure ..."
276 # dynarec only available on ARM
281 if [ "x$builtin_gpu" = "x" ]; then
285 # supposedly we can avoid -fPIC on armv5 for slightly better performace?
286 if [ "$ARCH" != "arm" -o "$have_armv6" = "yes" ]; then
287 PLUGIN_CFLAGS="$PLUGIN_CFLAGS -fPIC"
290 if [ "$ram_fixed" = "yes" ]; then
291 CFLAGS="$CFLAGS -DRAM_FIXED"
299 CFLAGS="$CFLAGS -DMAEMO -DMAEMO_CHANGES"
302 CFLAGS="$CFLAGS -fPIC"
303 MAIN_LDFLAGS="$MAIN_LDFLAGS -shared -Wl,--no-undefined"
307 # header/library presence tests
312 int main(void) { uncompress(0, 0, 0, 0); }
321 void main() { png_init_io(0, 0); }
329 #include <sys/soundcard.h>
330 #include <sys/ioctl.h>
331 void main() { int a=0; ioctl(0, SNDCTL_DSP_SETFMT, &a); }
339 #include <alsa/asoundlib.h>
340 void main() { snd_pcm_open(0, 0, 0, 0); }
348 #include <pulse/pulseaudio.h>
349 void main() { pa_threaded_mainloop_new(); }
358 void main() { SDL_OpenAudio(0, 0); }
366 #include <X11/Xlib.h>
367 void *f() { return XOpenDisplay(0); }
372 # see if we have c64_tools for TI C64x DSP
376 #include <inc_libc64_mini.h>
377 int f() { return dsp_open(); }
382 MAIN_LDLIBS="$MAIN_LDLIBS -lz"
383 check_zlib || fail "please install zlib (libz-dev)"
385 MAIN_LDLIBS="-lpng $MAIN_LDLIBS"
386 check_libpng || fail "please install libpng (libpng-dev)"
388 # find what audio support we can compile
389 if [ "x$sound_drivers" = "x" ]; then
390 if check_oss; then sound_drivers="$sound_drivers oss"; fi
391 if check_alsa -lasound; then
392 sound_drivers="$sound_drivers alsa"
393 MAIN_LDLIBS="-lasound $MAIN_LDLIBS"
395 if check_pulseaudio -lpulse; then
396 sound_drivers="$sound_drivers pulseaudio"
397 MAIN_LDLIBS="-lpulse $MAIN_LDLIBS"
399 if [ "$need_sdl" = "yes" ] || check_sdl `sdl-config --cflags --libs`; then
400 sound_drivers="$sound_drivers sdl"
404 if echo $sound_drivers | grep -q "\<oss\>"; then
405 check_oss || fail "oss support is missing"
407 if echo $sound_drivers | grep -q "\<alsa\>"; then
408 MAIN_LDLIBS="-lasound $MAIN_LDLIBS"
409 check_alsa || fail "please install libasound2-dev"
411 if echo $sound_drivers | grep -q "\<pulseaudio\>"; then
412 MAIN_LDLIBS="-lpulse $MAIN_LDLIBS"
413 check_pulseaudio || fail "pulseaudio support is missing"
417 if [ "$need_sdl" = "yes" ]; then
418 which sdl-config > /dev/null || \
419 fail "sdl-config is missing; please install libsdl (libsdl1.2-dev)"
420 CFLAGS="$CFLAGS `sdl-config --cflags`"
421 MAIN_LDLIBS="`sdl-config --libs` $MAIN_LDLIBS"
422 check_sdl || fail "please install libsdl (libsdl1.2-dev)"
425 # check for tslib (only headers needed)
426 if [ "x$have_tslib" = "x" ]; then
429 void test(struct ts_sample sample) {}
431 if compile_object; then
438 # check for VideoCore stuff for Raspberry Pi
439 if [ -d /opt/vc/include -a -d /opt/vc/lib ]; then
440 CFLAGS_GLES="$CFLAGS_GLES -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux"
441 LDLIBS_GLES="$LDLIBS_GLES -L/opt/vc/lib"
442 if [ -f /opt/vc/lib/libbcm_host.so ]; then
443 LDLIBS_GLES="$LDLIBS_GLES -lbcm_host"
448 # check for GLES headers
453 return (int)eglGetDisplay( (EGLNativeDisplayType)0 );
456 if compile_binary $CFLAGS_GLES -lEGL -lGLES_CM $LDLIBS_GLES; then
458 LDLIBS_GLES="-lEGL -lGLES_CM $LDLIBS_GLES"
459 elif compile_binary $CFLAGS_GLES -lEGL -lGLESv1_CM $LDLIBS_GLES; then
461 LDLIBS_GLES="-lEGL -lGLESv1_CM $LDLIBS_GLES"
464 if check_c64_tools; then
468 if [ "$have_gles" = "yes" ]; then
469 plugins="$plugins plugins/gpu-gles/gpu_gles.so"
471 if [ "$have_arm_neon" = "yes" -a "$builtin_gpu" != "neon" ]; then
472 plugins="$plugins plugins/gpu_neon/gpu_neon.so"
475 # check for xlib (only headers needed)
476 if [ "x$need_xlib" = "xyes" ]; then
477 check_xlib_headers || fail "please install libx11-dev"
481 void test(void *f, void *d) { fread(d, 1, 1, f); }
483 if compile_object -Wno-unused-result; then
484 CFLAGS="$CFLAGS -Wno-unused-result"
487 # short plugin list for display
488 for p in $plugins; do
490 plugins_short="$p1 $plugins_short"
493 # set things that failed to autodetect to "no"
494 test "x$have_armv6" != "x" || have_armv6="no"
495 test "x$have_armv7" != "x" || have_armv7="no"
496 test "x$have_arm_neon" != "x" || have_arm_neon="no"
497 test "x$have_gles" != "x" || have_gles="no"
498 test "x$have_c64x_dsp" != "x" || have_c64x_dsp="no"
500 echo "architecture $ARCH"
501 echo "platform $platform"
502 echo "built-in GPU $builtin_gpu"
503 echo "sound drivers $sound_drivers"
504 echo "plugins $plugins_short"
505 echo "C compiler $CC"
506 echo "C compiler flags $CFLAGS"
507 echo "libraries $MAIN_LDLIBS"
508 echo "linker flags $LDFLAGS$MAIN_LDFLAGS"
509 echo "enable dynarec $enable_dynarec"
510 if [ "$ARCH" = "arm" ]; then
511 echo "ARMv7 optimizations $have_armv7"
512 echo "enable ARM NEON $have_arm_neon"
513 echo "TI C64x DSP support $have_c64x_dsp"
515 echo "tslib support $have_tslib"
516 if [ "$platform" = "generic" ]; then
517 echo "OpenGL ES output $have_gles"
520 echo "# Automatically generated by configure" > $config_mak
521 printf "# Configured with:" >> $config_mak
522 printf " '%s'" "$0" "$@" >> $config_mak
525 echo "CC = $CC" >> $config_mak
526 echo "CXX = $CXX" >> $config_mak
527 echo "AS = $AS" >> $config_mak
528 echo "CFLAGS += $CFLAGS" >> $config_mak
529 echo "ASFLAGS += $ASFLAGS" >> $config_mak
530 echo "LDFLAGS += $LDFLAGS" >> $config_mak
531 echo "MAIN_LDFLAGS += $MAIN_LDFLAGS" >> $config_mak
532 echo "MAIN_LDLIBS += $MAIN_LDLIBS" >> $config_mak
533 echo "PLUGIN_CFLAGS += $PLUGIN_CFLAGS" >> $config_mak
536 if [ "$platform" = "libretro" ]; then
537 echo "TARGET = libretro.so" >> $config_mak
539 echo "ARCH = $ARCH" >> $config_mak
540 echo "PLATFORM = $platform" >> $config_mak
541 echo "BUILTIN_GPU = $builtin_gpu" >> $config_mak
542 echo "SOUND_DRIVERS = $sound_drivers" >> $config_mak
543 echo "PLUGINS = $plugins" >> $config_mak
544 if [ "$have_arm_neon" = "yes" ]; then
545 echo "HAVE_NEON = 1" >> $config_mak
547 if [ "$have_tslib" = "yes" ]; then
548 echo "HAVE_TSLIB = 1" >> $config_mak
550 if [ "$have_gles" = "yes" ]; then
551 echo "HAVE_GLES = 1" >> $config_mak
552 echo "CFLAGS_GLES = $CFLAGS_GLES" >> $config_mak
553 echo "LDLIBS_GLES = $LDLIBS_GLES" >> $config_mak
555 if [ "$enable_dynarec" = "yes" ]; then
556 echo "USE_DYNAREC = 1" >> $config_mak
558 if [ "$drc_cache_base" = "yes" ]; then
559 echo "DRC_CACHE_BASE = 1" >> $config_mak
561 if [ "$have_c64x_dsp" = "yes" ]; then
562 echo "HAVE_C64_TOOLS = 1" >> $config_mak
565 # use pandora's skin (for now)
566 test -e skin || ln -s frontend/pandora/skin skin
568 # vim:shiftwidth=2:expandtab