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"
56 # these are for known platforms
57 optimize_cortexa8="no"
58 optimize_arm926ej="no"
61 CC="${CC-${CROSS_COMPILE}gcc}"
62 CXX="${CXX-${CROSS_COMPILE}g++}"
63 AS="${AS-${CROSS_COMPILE}as}"
64 AR="${AS-${CROSS_COMPILE}ar}"
65 MAIN_LDLIBS="$LDLIBS -ldl -lm"
66 config_mak="config.mak"
74 # call during arg parsing, so that cmd line can override platform defaults
82 sound_drivers="oss alsa"
85 optimize_cortexa8="yes"
91 optimize_cortexa8="yes"
98 optimize_arm926ej="yes"
102 sound_drivers="libretro"
106 fail "unsupported platform: $platform"
112 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'` || true
114 --help|-h) show_help="yes"
116 --platform=*) set_platform "$optarg"
118 --gpu=*) builtin_gpu="$optarg"
120 --sound-drivers=*) sound_drivers="$optarg"
122 --enable-neon) have_arm_neon="yes"
124 --disable-neon) have_arm_neon="no"
126 --disable-dynarec) enable_dynarec="no"
128 *) echo "ERROR: unknown option $opt"; show_help="yes"
133 if [ "$show_help" = "yes" ]; then
135 echo " --help print this message"
136 echo " --platform=NAME target platform [$platform]"
137 echo " available: $platform_list"
138 echo " --gpu=NAME builtin gpu plugin [guessed]"
139 echo " available: $builtin_gpu_list"
140 echo " --sound-drivers=LIST sound output drivers [guessed]"
141 echo " available: $sound_driver_list"
142 echo " --enable-neon"
143 echo " --disable-neon enable/disable ARM NEON optimizations [guessed]"
144 echo " --disable-dynarec disable dynamic recompiler"
145 echo " (dynarec is only available and enabled on ARM)"
146 echo "influential environment variables:"
147 echo " CROSS_COMPILE CC CXX AS AR CFLAGS ASFLAGS LDFLAGS LDLIBS"
151 # validate selections
152 if [ "x$builtin_gpu" != "x" ]; then
153 if ! echo $builtin_gpu_list | grep -q "\<$builtin_gpu\>"; then
154 fail "unsupported builtin gpu plugin: $builtin_gpu"
158 if [ "x$sound_drivers" != "x" ]; then
159 for d in $sound_drivers; do
160 if ! echo $sound_driver_list | grep -q "\<$d\>"; then
161 fail "unsupported sound driver: $sound_driver"
166 if [ "$need_libpicofe" = "yes" ]; then
167 if ! test -f "frontend/libpicofe/README"; then
168 fail "libpicofe is missing, please run 'git submodule init && git submodule update'"
172 if [ "$need_warm" = "yes" ]; then
173 if ! test -f "frontend/warm/README"; then
174 fail "wARM is missing, please run 'git submodule init && git submodule update'"
178 # basic compiler test
181 int main(void) { return 0; }
183 if ! compile_binary; then
184 fail "compiler test failed, please check config.log"
187 if [ -z "$ARCH" ]; then
188 ARCH=`$CC -dumpmachine | awk -F '-' '{print $1}'`
196 if [ "$optimize_cortexa8" = "yes" ]; then
197 CFLAGS="$CFLAGS -mcpu=cortex-a8 -mtune=cortex-a8"
198 ASFLAGS="$ASFLAGS -mcpu=cortex-a8"
200 if [ "$optimize_arm926ej" = "yes" ]; then
201 CFLAGS="$CFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s"
202 ASFLAGS="$ASFLAGS -mcpu=arm926ej-s -mfloat-abi=softfp"
205 if [ "x$have_arm_neon" = "x" ]; then
206 # detect NEON from user-supplied cflags to enable asm code
207 have_arm_neon=`check_define __ARM_NEON__ && echo yes` || true
209 if [ "x$have_armv7" = "x" ]; then
210 if check_define HAVE_ARMV7; then
216 if [ "x$have_armv6" = "x" ]; then
217 if check_define HAVE_ARMV6; then
222 if [ "x$have_armv5" = "x" ]; then
223 have_armv5=`check_define HAVE_ARMV5 && echo yes` || true
226 if [ "x$builtin_gpu" = "x" ]; then
227 if [ "$have_arm_neon" = "yes" ]; then
229 elif [ "$have_armv7" != "yes" ]; then
230 # pre-ARMv7 hardware is usually not fast enough for peops
237 # automatically set mfpu and mfloat-abi if they are not set
238 if [ "$have_arm_neon" = "yes" ]; then
240 elif [ "$have_armv6" = "yes" ]; then
243 if [ "x$fpu" != "x" ]; then
244 echo "$CFLAGS" | grep -q -- '-mfpu=' || CFLAGS="$CFLAGS -mfpu=$fpu"
245 echo "$ASFLAGS" | grep -q -- '-mfpu=' || ASFLAGS="$ASFLAGS -mfpu=$fpu"
246 floatabi_set_by_gcc=`$CC -v 2>&1 | grep -q -- --with-float= && echo yes` || true
247 if [ "$floatabi_set_by_gcc" != "yes" ]; then
248 echo "$CFLAGS" | grep -q -- '-mfloat-abi=' || CFLAGS="$CFLAGS -mfloat-abi=softfp"
249 echo "$ASFLAGS" | grep -q -- '-mfloat-abi=' || ASFLAGS="$ASFLAGS -mfloat-abi=softfp"
253 # must disable thumb as recompiler can't handle it
254 if check_define __thumb__; then
255 CFLAGS="$CFLAGS -marm"
258 # warn about common mistakes
259 if [ "$have_armv5" != "yes" ]; then
260 if ! echo "$CFLAGS" | grep -q -- '-mcpu=\|-march='; then
261 echo "Warning: compiling for ARMv4, is that really what you want?"
262 echo "You probably should specify -mcpu= or -march= like this:"
263 echo " CFLAGS=-march=armv6 ./configure ..."
266 if [ "$have_arm_neon" = "yes" -a "$have_armv7" != "yes" ]; then
267 echo "Warning: compiling for NEON, but not ARMv7?"
268 echo "You probably want to specify -mcpu= or -march= like this:"
269 echo " CFLAGS=-march=armv7-a ./configure ..."
273 # dynarec only available on ARM
278 if [ "x$builtin_gpu" = "x" ]; then
282 # supposedly we can avoid -fPIC on armv5 for slightly better performace?
283 if [ "$ARCH" != "arm" -o "$have_armv6" = "yes" ]; then
284 PLUGIN_CFLAGS="$PLUGIN_CFLAGS -fPIC"
287 if [ "$ram_fixed" = "yes" ]; then
288 CFLAGS="$CFLAGS -DRAM_FIXED"
296 maemo_cflags=`pkg-config --cflags hildon-1`
297 maemo_ldlibs=`pkg-config --libs hildon-1`
298 CFLAGS="$CFLAGS -DMAEMO -DMAEMO_CHANGES $maemo_cflags"
299 MAIN_LDLIBS="$MAIN_LDLIBS $maemo_ldlibs"
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); }
363 MAIN_LDLIBS="$MAIN_LDLIBS -lz"
364 check_zlib || fail "please install zlib (libz-dev)"
366 MAIN_LDLIBS="-lpng $MAIN_LDLIBS"
367 check_libpng || fail "please install libpng (libpng-dev)"
369 # find what audio support we can compile
370 if [ "x$sound_drivers" = "x" ]; then
371 if check_oss; then sound_drivers="$sound_drivers oss"; fi
372 if check_alsa -lasound; then
373 sound_drivers="$sound_drivers alsa"
374 MAIN_LDLIBS="-lasound $MAIN_LDLIBS"
376 if check_pulseaudio -lpulse; then
377 sound_drivers="$sound_drivers pulseaudio"
378 MAIN_LDLIBS="-lpulse $MAIN_LDLIBS"
380 if [ "$need_sdl" = "yes" ] || check_sdl `sdl-config --cflags --libs`; then
381 sound_drivers="$sound_drivers sdl"
385 if echo $sound_drivers | grep -q "\<oss\>"; then
386 check_oss || fail "oss support is missing"
388 if echo $sound_drivers | grep -q "\<alsa\>"; then
389 MAIN_LDLIBS="-lasound $MAIN_LDLIBS"
390 check_alsa || fail "please install libasound2-dev"
392 if echo $sound_drivers | grep -q "\<pulseaudio\>"; then
393 MAIN_LDLIBS="-lpulse $MAIN_LDLIBS"
394 check_pulseaudio || fail "pulseaudio support is missing"
398 if [ "$need_sdl" = "yes" ]; then
399 which sdl-config > /dev/null || \
400 fail "sdl-config is missing; please install libsdl (libsdl1.2-dev)"
401 CFLAGS="$CFLAGS `sdl-config --cflags`"
402 MAIN_LDLIBS="`sdl-config --libs` $MAIN_LDLIBS"
403 check_sdl || fail "please install libsdl (libsdl1.2-dev)"
406 # check for tslib (only headers needed)
407 if [ "x$have_tslib" = "x" ]; then
410 void test(struct ts_sample sample) {}
412 if compile_object; then
419 # check for VideoCore stuff for Raspberry Pi
420 if [ -d /opt/vc/include -a -d /opt/vc/lib ]; then
421 CFLAGS_GLES="$CFLAGS_GLES -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads"
422 LDLIBS_GLES="$LDLIBS_GLES -L/opt/vc/lib"
425 # check for GLES headers
430 return (int)eglGetDisplay( (EGLNativeDisplayType)0 );
433 if compile_binary $CFLAGS_GLES -lEGL -lGLES_CM $LDLIBS_GLES; then
435 LDLIBS_GLES="-lEGL -lGLES_CM $LDLIBS_GLES"
436 elif compile_binary $CFLAGS_GLES -lEGL -lGLESv1_CM $LDLIBS_GLES; then
438 LDLIBS_GLES="-lEGL -lGLESv1_CM $LDLIBS_GLES"
441 if [ "$have_gles" = "yes" ]; then
442 plugins="$plugins plugins/gpu-gles/gpu_gles.so"
444 if [ "$have_arm_neon" = "yes" -a "$builtin_gpu" != "neon" ]; then
445 plugins="$plugins plugins/gpu_neon/gpu_neon.so"
449 void test(void *f, void *d) { fread(d, 1, 1, f); }
451 if compile_object -Wno-unused-result; then
452 CFLAGS="$CFLAGS -Wno-unused-result"
455 # short plugin list for display
456 for p in $plugins; do
458 plugins_short="$p1 $plugins_short"
461 # set things that failed to autodetect to "no"
462 test "x$have_armv6" != "x" || have_armv6="no"
463 test "x$have_armv7" != "x" || have_armv7="no"
464 test "x$have_arm_neon" != "x" || have_arm_neon="no"
465 test "x$have_gles" != "x" || have_gles="no"
467 echo "architecture $ARCH"
468 echo "platform $platform"
469 echo "built-in GPU $builtin_gpu"
470 echo "sound drivers $sound_drivers"
471 echo "plugins $plugins_short"
472 echo "C compiler $CC"
473 echo "C compiler flags $CFLAGS"
474 echo "libraries $MAIN_LDLIBS"
475 echo "linker flags $LDFLAGS$MAIN_LDFLAGS"
476 echo "enable dynarec $enable_dynarec"
477 echo "ARMv7 optimizations $have_armv7"
478 echo "enable ARM NEON $have_arm_neon"
479 echo "tslib support $have_tslib"
480 if [ "$platform" = "generic" ]; then
481 echo "OpenGL ES output $have_gles"
484 echo "# Automatically generated by configure" > $config_mak
485 printf "# Configured with:" >> $config_mak
486 printf " '%s'" "$0" "$@" >> $config_mak
489 echo "CC = $CC" >> $config_mak
490 echo "CXX = $CXX" >> $config_mak
491 echo "AS = $AS" >> $config_mak
492 echo "CFLAGS += $CFLAGS" >> $config_mak
493 echo "ASFLAGS += $ASFLAGS" >> $config_mak
494 echo "LDFLAGS += $LDFLAGS" >> $config_mak
495 echo "MAIN_LDFLAGS += $MAIN_LDFLAGS" >> $config_mak
496 echo "MAIN_LDLIBS += $MAIN_LDLIBS" >> $config_mak
497 echo "PLUGIN_CFLAGS += $PLUGIN_CFLAGS" >> $config_mak
500 if [ "$platform" = "libretro" ]; then
501 echo "TARGET = libretro.so" >> $config_mak
503 echo "ARCH = $ARCH" >> $config_mak
504 echo "PLATFORM = $platform" >> $config_mak
505 echo "BUILTIN_GPU = $builtin_gpu" >> $config_mak
506 echo "SOUND_DRIVERS = $sound_drivers" >> $config_mak
507 echo "PLUGINS = $plugins" >> $config_mak
508 if [ "$have_arm_neon" = "yes" ]; then
509 echo "HAVE_NEON = 1" >> $config_mak
511 if [ "$have_tslib" = "yes" ]; then
512 echo "HAVE_TSLIB = 1" >> $config_mak
514 if [ "$have_gles" = "yes" ]; then
515 echo "HAVE_GLES = 1" >> $config_mak
516 echo "CFLAGS_GLES = $CFLAGS_GLES" >> $config_mak
517 echo "LDLIBS_GLES = $LDLIBS_GLES" >> $config_mak
519 if [ "$enable_dynarec" = "yes" ]; then
520 echo "USE_DYNAREC = 1" >> $config_mak
522 if [ "$drc_cache_base" = "yes" ]; then
523 echo "DRC_CACHE_BASE = 1" >> $config_mak
526 # use pandora's skin (for now)
527 test -e skin || ln -s frontend/pandora/skin skin
529 # vim:shiftwidth=2:expandtab