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 $@"
28 $CC -E -dD $CFLAGS $TMPC | grep -q $1 || return 1
32 # setting options to "yes" or "no" will make that choice default,
33 # "" means "autodetect".
35 platform_list="generic pandora maemo caanoo libretro"
37 builtin_gpu_list="peops unai neon"
39 sound_driver_list="oss alsa sdl pulseaudio libretro"
41 plugins="plugins/spunull/spunull.so \
42 plugins/dfxvideo/gpu_peops.so plugins/gpu_unai/gpu_unai.so"
53 # these are for known platforms
54 optimize_cortexa8="no"
55 optimize_arm926ej="no"
58 CC="${CC-${CROSS_COMPILE}gcc}"
59 CXX="${CXX-${CROSS_COMPILE}g++}"
60 AS="${AS-${CROSS_COMPILE}as}"
61 AR="${AS-${CROSS_COMPILE}ar}"
62 MAIN_LDLIBS="$LDLIBS -ldl -lm"
63 config_mak="config.mak"
71 # call during arg parsing, so that cmd line can override platform defaults
79 sound_drivers="oss alsa"
82 optimize_cortexa8="yes"
88 optimize_cortexa8="yes"
95 optimize_arm926ej="yes"
99 sound_drivers="libretro"
103 fail "unsupported platform: $platform"
109 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'` || true
111 --help|-h) show_help="yes"
113 --platform=*) set_platform "$optarg"
115 --gpu=*) builtin_gpu="$optarg"
117 --sound-drivers=*) sound_drivers="$optarg"
119 --enable-neon) have_arm_neon="yes"
121 --disable-neon) have_arm_neon="no"
123 --disable-dynarec) enable_dynarec="no"
125 *) echo "ERROR: unknown option $opt"; show_help="yes"
130 if [ "$show_help" = "yes" ]; then
132 echo " --help print this message"
133 echo " --platform=NAME target platform [$platform]"
134 echo " available: $platform_list"
135 echo " --gpu=NAME builtin gpu plugin [guessed]"
136 echo " available: $builtin_gpu_list"
137 echo " --sound-drivers=LIST sound output drivers [guessed]"
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:"
144 echo " CROSS_COMPILE CC CXX AS AR CFLAGS ASFLAGS LDFLAGS LDLIBS"
148 # validate selections
149 if [ "x$builtin_gpu" != "x" ]; then
150 if ! echo $builtin_gpu_list | grep -q "\<$builtin_gpu\>"; then
151 fail "unsupported builtin gpu plugin: $builtin_gpu"
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"
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'"
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'"
175 if [ -z "$ARCH" ]; then
176 ARCH=`$CC -v 2>&1 | grep -i 'target:' | awk '{print $2}' \
177 | awk -F '-' '{print $1}'`
181 if [ "$ARCH" = "arm" ]; then
182 if [ "$optimize_cortexa8" = "yes" ]; then
183 CFLAGS="$CFLAGS -mcpu=cortex-a8 -mtune=cortex-a8"
184 ASFLAGS="$ASFLAGS -mcpu=cortex-a8"
186 if [ "$optimize_arm926ej" = "yes" ]; then
187 CFLAGS="$CFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s"
188 ASFLAGS="$ASFLAGS -mcpu=arm926ej-s -mfloat-abi=softfp"
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
195 if [ "x$have_armv6" = "x" ]; then
196 have_armv6=`check_define __ARM_ARCH_6 && echo yes` || true
198 if [ "x$have_armv7" = "x" ]; then
199 if check_define __ARM_ARCH_7A__; then
205 if [ "x$builtin_gpu" = "x" ]; then
206 if [ "$have_arm_neon" = "yes" ]; then
208 elif [ "$have_armv7" != "yes" ]; then
209 # pre-ARMv7 hardware is usually not fast enough for peops
216 # automatically set mfpu and mfloat-abi if they are not set
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"
224 floatabi_set_by_gcc=`$CC -v 2>&1 | grep -q -- --with-float= && echo yes` || true
225 if [ "$floatabi_set_by_gcc" != "yes" -a "$have_armv6" = "yes" ]; then
226 echo "$CFLAGS" | grep -q -- '-mfloat-abi=' || CFLAGS="$CFLAGS -mfloat-abi=softfp"
227 echo "$ASFLAGS" | grep -q -- '-mfloat-abi=' || ASFLAGS="$ASFLAGS -mfloat-abi=softfp"
230 # must disable thumb as recompiler can't handle it
231 if check_define __thumb__; then
232 CFLAGS="$CFLAGS -marm"
235 if [ "$have_armv7" = "yes" ]; then
236 ASFLAGS="$ASFLAGS --defsym HAVE_ARMV7=1"
238 ASFLAGS="$ASFLAGS --defsym HAVE_ARMV7=0"
241 # dynarec only available on ARM
245 if [ "x$builtin_gpu" = "x" ]; then
249 # supposedly we can avoid -fPIC on armv5 for slightly better performace?
250 if [ "$ARCH" != "arm" -o "$have_armv6" = "yes" ]; then
251 PLUGIN_CFLAGS="$PLUGIN_CFLAGS -fPIC"
254 if [ "$ram_fixed" = "yes" ]; then
255 CFLAGS="$CFLAGS -DRAM_FIXED"
263 maemo_cflags=`pkg-config --cflags hildon-1`
264 maemo_ldlibs=`pkg-config --libs hildon-1`
265 CFLAGS="$CFLAGS -DMAEMO -DMAEMO_CHANGES $maemo_cflags"
266 MAIN_LDLIBS="$MAIN_LDLIBS $maemo_ldlibs"
269 CFLAGS="$CFLAGS -fPIC"
270 MAIN_LDFLAGS="$MAIN_LDFLAGS -shared -Wl,--no-undefined"
274 # header/library presence tests
279 int main(void) { uncompress(0, 0, 0, 0); }
288 void main() { BZ2_bzBuffToBuffDecompress(0, 0, 0, 0, 0, 0); }
297 void main() { png_init_io(0, 0); }
305 #include <sys/soundcard.h>
306 #include <sys/ioctl.h>
307 void main() { int a=0; ioctl(0, SNDCTL_DSP_SETFMT, &a); }
315 #include <alsa/asoundlib.h>
316 void main() { snd_pcm_open(0, 0, 0, 0); }
325 void main() { SDL_OpenAudio(0, 0); }
330 MAIN_LDLIBS="$MAIN_LDLIBS -lz"
331 check_zlib || fail "please install zlib (libz-dev)"
333 check_bzlib || fail "please install bz2lib (libbz2-dev)"
335 MAIN_LDLIBS="-lpng $MAIN_LDLIBS"
336 check_libpng || fail "please install libpng (libpng-dev)"
338 # find what audio support we can compile
339 if [ "x$sound_drivers" = "x" ]; then
340 if check_oss; then sound_drivers="$sound_drivers oss"; fi
341 if check_alsa -lasound; then
342 sound_drivers="$sound_drivers alsa"
343 MAIN_LDLIBS="-lasound $MAIN_LDLIBS"
345 if [ "$need_sdl" = "yes" ] || check_sdl `sdl-config --cflags --libs`; then
346 sound_drivers="$sound_drivers sdl"
350 if echo $sound_drivers | grep -q "\<oss\>"; then
351 check_oss || fail "oss support is missing"
353 if echo $sound_drivers | grep -q "\<alsa\>"; then
354 MAIN_LDLIBS="-lasound $MAIN_LDLIBS"
355 check_alsa || fail "please install libasound2-dev"
359 if [ "$need_sdl" = "yes" ]; then
360 which sdl-config > /dev/null || \
361 fail "sdl-config is missing; please install libsdl (libsdl1.2-dev)"
362 CFLAGS="$CFLAGS `sdl-config --cflags`"
363 MAIN_LDLIBS="`sdl-config --libs` $MAIN_LDLIBS"
364 check_sdl || fail "please install libsdl (libsdl1.2-dev)"
367 # check for tslib (only headers needed)
368 if [ "x$have_tslib" = "x" ]; then
371 void test(struct ts_sample sample) {}
373 if compile_object; then
380 # check for GLES headers
383 #include <GLES/glext.h>
386 return eglGetDisplay( (EGLNativeDisplayType)0 );
389 if compile_object; then
390 plugins="$plugins plugins/gpu-gles/gpu_gles.so"
393 if [ "$have_arm_neon" = "yes" -a "$builtin_gpu" != "neon" ]; then
394 plugins="$plugins plugins/gpu_neon/gpu_neon.so"
398 void test(void *f, void *d) { fread(d, 1, 1, f); }
400 if compile_object -Wno-unused-result; then
401 CFLAGS="$CFLAGS -Wno-unused-result"
404 # short plugin list for display
405 for p in $plugins; do
407 plugins_short="$p1 $plugins_short"
410 # set things that failed to autodetect to "no"
411 test "x$have_armv6" != "x" || have_armv6="no"
412 test "x$have_armv7" != "x" || have_armv7="no"
413 test "x$have_arm_neon" != "x" || have_arm_neon="no"
415 echo "architecture $ARCH"
416 echo "platform $platform"
417 echo "built-in GPU $builtin_gpu"
418 echo "sound drivers $sound_drivers"
419 echo "plugins $plugins_short"
420 echo "C compiler $CC"
421 echo "C compiler flags $CFLAGS"
422 echo "libraries $MAIN_LDLIBS"
423 echo "linker flags $LDFLAGS$MAIN_LDFLAGS"
424 echo "enable dynarec $enable_dynarec"
425 echo "ARMv7 optimizations $have_armv7"
426 echo "enable ARM NEON $have_arm_neon"
427 echo "tslib support $have_tslib"
429 echo "# Automatically generated by configure" > $config_mak
430 printf "# Configured with:" >> $config_mak
431 printf " '%s'" "$0" "$@" >> $config_mak
434 echo "CC = $CC" >> $config_mak
435 echo "CXX = $CXX" >> $config_mak
436 echo "AS = $AS" >> $config_mak
437 echo "CFLAGS += $CFLAGS" >> $config_mak
438 echo "ASFLAGS += $ASFLAGS" >> $config_mak
439 echo "LDFLAGS += $LDFLAGS" >> $config_mak
440 echo "MAIN_LDFLAGS += $MAIN_LDFLAGS" >> $config_mak
441 echo "MAIN_LDLIBS += $MAIN_LDLIBS" >> $config_mak
442 echo "PLUGIN_CFLAGS += $PLUGIN_CFLAGS" >> $config_mak
445 if [ "$platform" = "libretro" ]; then
446 echo "TARGET = libretro.so" >> $config_mak
448 echo "ARCH = $ARCH" >> $config_mak
449 echo "PLATFORM = $platform" >> $config_mak
450 echo "BUILTIN_GPU = $builtin_gpu" >> $config_mak
451 echo "SOUND_DRIVERS = $sound_drivers" >> $config_mak
452 echo "PLUGINS = $plugins" >> $config_mak
453 if [ "$have_armv6" = "yes" ]; then
454 echo "HAVE_ARMV6 = 1" >> $config_mak
456 if [ "$have_armv7" = "yes" ]; then
457 echo "HAVE_ARMV7 = 1" >> $config_mak
459 if [ "$have_arm_neon" = "yes" ]; then
460 echo "HAVE_NEON = 1" >> $config_mak
462 if [ "$have_tslib" = "yes" ]; then
463 echo "HAVE_TSLIB = 1" >> $config_mak
465 if [ "$enable_dynarec" = "yes" ]; then
466 echo "USE_DYNAREC = 1" >> $config_mak
468 if [ "$drc_cache_base" = "yes" ]; then
469 echo "DRC_CACHE_BASE = 1" >> $config_mak
472 # use pandora's skin (for now)
473 test -e skin || ln -s frontend/pandora/skin skin
475 # vim:shiftwidth=2:expandtab