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"
50 # these are for known platforms
51 optimize_cortexa8="no"
52 optimize_arm926ej="no"
55 CC="${CC-${CROSS_COMPILE}gcc}"
56 CXX="${CXX-${CROSS_COMPILE}g++}"
57 AS="${AS-${CROSS_COMPILE}as}"
58 AR="${AS-${CROSS_COMPILE}ar}"
59 MAIN_LDLIBS="$LDLIBS -ldl -lpng -lz"
60 config_mak="config.mak"
68 # call during arg parsing, so that cmd line can override platform defaults
76 sound_drivers="oss alsa"
79 optimize_cortexa8="yes"
85 optimize_cortexa8="yes"
92 optimize_arm926ej="yes"
95 sound_drivers="libretro"
98 fail "unsupported platform: $platform"
104 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'` || true
106 --help|-h) show_help="yes"
108 --platform=*) set_platform "$optarg"
110 --gpu=*) builtin_gpu="$optarg"
112 --sound-drivers=*) sound_drivers="$optarg"
114 --enable-neon) have_arm_neon="yes"
116 --disable-neon) have_arm_neon="no"
118 --disable-dynarec) enable_dynarec="no"
120 *) echo "ERROR: unknown option $opt"; show_help="yes"
125 if [ "$show_help" = "yes" ]; then
127 echo " --help print this message"
128 echo " --platform=NAME target platform [$platform]"
129 echo " available: $platform_list"
130 echo " --gpu=NAME builtin gpu plugin [guessed]"
131 echo " available: $builtin_gpu_list"
132 echo " --sound-drivers=LIST sound output drivers [guessed]"
133 echo " available: $sound_driver_list"
134 echo " --enable-neon"
135 echo " --disable-neon enable/disable ARM NEON optimizations [guessed]"
136 echo " --disable-dynarec disable dynamic recompiler"
137 echo " (dynarec is only available and enabled on ARM)"
138 echo "influential environment variables:"
139 echo " CROSS_COMPILE CC CXX AS AR CFLAGS ASFLAGS LDFLAGS LDLIBS"
143 # validate selections
144 if [ "x$builtin_gpu" != "x" ]; then
145 if ! echo $builtin_gpu_list | grep -q "\<$builtin_gpu\>"; then
146 fail "unsupported builtin gpu plugin: $builtin_gpu"
150 if [ "x$sound_drivers" != "x" ]; then
151 for d in $sound_drivers; do
152 if ! echo $sound_driver_list | grep -q "\<$d\>"; then
153 fail "unsupported sound driver: $sound_driver"
158 if [ -z "$ARCH" ]; then
159 ARCH=`$CC -v 2>&1 | grep -i 'target:' | awk '{print $2}' \
160 | awk -F '-' '{print $1}'`
164 if [ "$ARCH" = "arm" ]; then
165 if [ "$optimize_cortexa8" = "yes" ]; then
167 CFLAGS="$CFLAGS -mcpu=cortex-a8 -mtune=cortex-a8"
168 ASFLAGS="$ASFLAGS -mcpu=cortex-a8"
170 if [ "$optimize_arm926ej" = "yes" ]; then
171 CFLAGS="$CFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s"
172 ASFLAGS="$ASFLAGS -mcpu=arm926ej-s -mfloat-abi=softfp"
175 if [ "x$have_arm_neon" = "x" ]; then
176 # detect NEON from user-supplied cflags to enable asm code
177 have_arm_neon=`check_define __ARM_NEON__ && echo yes` || true
179 if [ "x$have_armv6" = "x" ]; then
180 have_armv6=`check_define __ARM_ARCH_6 && echo yes` || true
182 if [ "x$have_armv7" = "x" ]; then
183 if check_define __ARM_ARCH_7A__; then
189 if [ "x$builtin_gpu" = "x" ]; then
190 if [ "$have_arm_neon" = "yes" ]; then
192 elif [ "$have_armv7" != "yes" ]; then
193 # pre-ARMv7 hardware is usually not fast enough for peops
200 # set mfpu and mfloat-abi if they are not set
201 if [ "$have_arm_neon" = "yes" ]; then
202 echo "$CFLAGS" | grep -q -- '-mfpu=' || CFLAGS="$CFLAGS -mfpu=neon"
203 echo "$ASFLAGS" | grep -q -- '-mfpu=' || ASFLAGS="$ASFLAGS -mfpu=neon"
204 elif [ "$have_armv6" = "yes" ]; then
205 echo "$CFLAGS" | grep -q -- '-mfpu=' || CFLAGS="$CFLAGS -mfpu=vfp"
206 echo "$ASFLAGS" | grep -q -- '-mfpu=' || ASFLAGS="$ASFLAGS -mfpu=vfp"
208 if [ "$have_armv6" = "yes" ]; then
209 echo "$CFLAGS" | grep -q -- '-mfloat-abi=' || CFLAGS="$CFLAGS -mfloat-abi=softfp"
210 echo "$ASFLAGS" | grep -q -- '-mfloat-abi=' || ASFLAGS="$ASFLAGS -mfloat-abi=softfp"
213 # must disable -mthumb as recompiler can't handle it
214 if check_define __thumb__; then
215 CFLAGS="$CFLAGS -mno-thumb"
218 if [ "$have_armv7" = "yes" ]; then
219 ASFLAGS="$ASFLAGS --defsym HAVE_ARMV7=1"
221 ASFLAGS="$ASFLAGS --defsym HAVE_ARMV7=0"
224 # dynarec only available on ARM
228 if [ "x$builtin_gpu" = "x" ]; then
232 if [ "$ARCH" = "x86_64" ]; then
233 # currently we are full of 32bit assumptions,
234 # at least savestate compatibility will break without these
235 CFLAGS="$CFLAGS -m32"
236 LDFLAGS="$LDFLAGS -m32"
239 # supposedly we can avoid -fPIC on armv5 for slightly better performace?
240 if [ "$ARCH" != "arm" -o "$have_armv6" = "yes" ]; then
241 PLUGIN_CFLAGS="$PLUGIN_CFLAGS -fPIC"
244 if [ "$ram_fixed" = "yes" ]; then
245 CFLAGS="$CFLAGS -DRAM_FIXED"
250 generic_cflags=`sdl-config --cflags`
251 generic_ldlibs=`sdl-config --libs`
252 CFLAGS="$CFLAGS $generic_cflags"
253 MAIN_LDLIBS="$MAIN_LDLIBS $generic_ldlibs"
256 maemo_cflags=`pkg-config --cflags hildon-1`
257 maemo_ldlibs=`pkg-config --libs hildon-1`
258 CFLAGS="$CFLAGS -DMAEMO -DMAEMO_CHANGES $maemo_cflags"
259 MAIN_LDLIBS="$MAIN_LDLIBS $maemo_ldlibs"
262 CFLAGS="$CFLAGS -fPIC"
263 LDFLAGS="$LDFLAGS -shared"
267 # header/library presence tests
272 void main() { uncompress(0, 0, 0, 0); }
281 void main() { BZ2_bzBuffToBuffDecompress(0, 0, 0, 0, 0, 0); }
290 void main() { png_init_io(0, 0); }
298 #include <sys/soundcard.h>
299 #include <sys/ioctl.h>
300 void main() { int a=0; ioctl(0, SNDCTL_DSP_SETFMT, &a); }
308 #include <alsa/asoundlib.h>
309 void main() { snd_pcm_open(0, 0, 0, 0); }
318 void main() { SDL_OpenAudio(0, 0); }
323 check_zlib || fail "please install libz-dev"
324 check_bzlib || fail "please install libbz2-dev"
325 check_libpng || fail "please install libpng-dev"
327 # find what audio support we can compile
328 if [ "x$sound_drivers" = "x" ]; then
329 if check_oss; then sound_drivers="$sound_drivers oss"; fi
330 if check_alsa -lasound; then sound_drivers="$sound_drivers alsa"; fi
331 if check_sdl; then sound_drivers="$sound_drivers sdl"; fi
334 if echo $sound_drivers | grep -q "\<oss\>"; then
335 check_oss || fail "oss support missing"
337 if echo $sound_drivers | grep -q "\<alsa\>"; then
338 MAIN_LDLIBS="$MAIN_LDLIBS -lasound"
339 check_alsa || fail "please install libasound2-dev"
341 if echo $sound_drivers | grep -q "\<sdl\>"; then
342 echo $MAIN_LDLIBS | grep -qi SDL || CFLAGS="$CFLAGS `sdl-config --cflags`"
343 echo $MAIN_LDLIBS | grep -qi SDL || MAIN_LDLIBS="$MAIN_LDLIBS `sdl-config --libs`"
344 check_sdl || fail "please install libsdl1.2-dev"
347 # check for tslib (only headers needed)
348 if [ "x$have_tslib" = "x" ]; then
351 void test(struct ts_sample sample) {}
353 if compile_object; then
360 # check for GLES headers
363 #include <GLES/glext.h>
366 return eglGetDisplay( (EGLNativeDisplayType)0 );
369 if compile_object; then
370 plugins="$plugins plugins/gpu-gles/gpu_gles.so"
373 if [ "$have_arm_neon" = "yes" -a "$builtin_gpu" != "neon" ]; then
374 plugins="$plugins plugins/gpu_neon/gpu_neon.so"
377 # short plugin list for display
378 for p in $plugins; do
380 plugins_short="$p1 $plugins_short"
383 # set things that failed to autodetect to "no"
384 test "x$have_armv6" != "x" || have_armv6="no"
385 test "x$have_armv7" != "x" || have_armv7="no"
386 test "x$have_arm_neon" != "x" || have_arm_neon="no"
388 echo "architecture $ARCH"
389 echo "platform $platform"
390 echo "built-in GPU $builtin_gpu"
391 echo "sound drivers $sound_drivers"
392 echo "plugins $plugins_short"
393 echo "C compiler $CC"
394 echo "C compiler flags $CFLAGS"
395 echo "libraries $MAIN_LDLIBS"
396 echo "linker flags $LDFLAGS"
397 echo "enable dynarec $enable_dynarec"
398 echo "ARMv7 optimizations $have_armv7"
399 echo "enable ARM NEON $have_arm_neon"
400 echo "tslib support $have_tslib"
402 echo "# Automatically generated by configure" > $config_mak
403 printf "# Configured with:" >> $config_mak
404 printf " '%s'" "$0" "$@" >> $config_mak
407 echo "CC = $CC" >> $config_mak
408 echo "CXX = $CXX" >> $config_mak
409 echo "AS = $AS" >> $config_mak
410 echo "CFLAGS += $CFLAGS" >> $config_mak
411 echo "ASFLAGS += $ASFLAGS" >> $config_mak
412 echo "LDFLAGS += $LDFLAGS" >> $config_mak
413 echo "MAIN_LDLIBS += $MAIN_LDLIBS" >> $config_mak
414 echo "PLUGIN_CFLAGS += $PLUGIN_CFLAGS" >> $config_mak
417 if [ "$platform" = "libretro" ]; then
418 echo "TARGET = libretro.so" >> $config_mak
420 echo "ARCH = $ARCH" >> $config_mak
421 echo "PLATFORM = $platform" >> $config_mak
422 echo "BUILTIN_GPU = $builtin_gpu" >> $config_mak
423 echo "SOUND_DRIVERS = $sound_drivers" >> $config_mak
424 if [ "$ARCH" = "arm" ]; then
425 echo "PLUGINS = $plugins" >> $config_mak
427 echo -n "PLUGINS =" >> $config_mak
428 for p in $plugins; do
429 echo -n " ${p}.${ARCH}" >> $config_mak
433 if [ "$have_armv6" = "yes" ]; then
434 echo "HAVE_ARMV6 = 1" >> $config_mak
436 if [ "$have_armv7" = "yes" ]; then
437 echo "HAVE_ARMV7 = 1" >> $config_mak
439 if [ "$have_arm_neon" = "yes" ]; then
440 echo "HAVE_NEON = 1" >> $config_mak
442 if [ "$have_tslib" = "yes" ]; then
443 echo "HAVE_TSLIB = 1" >> $config_mak
445 if [ "$enable_dynarec" = "yes" ]; then
446 echo "USE_DYNAREC = 1" >> $config_mak
448 if [ "$drc_cache_base" = "yes" ]; then
449 echo "DRC_CACHE_BASE = 1" >> $config_mak
452 # use pandora's skin (for now)
453 test -e skin || ln -s frontend/pandora/skin skin
455 # vim:shiftwidth=2:expandtab