psx_gpu: use different uvrgb phase for enhancement
[pcsx_rearmed.git] / configure
CommitLineData
4132e8ca 1#!/bin/sh
2# some elements originated from qemu configure
3set -e
4
5TMPC="/tmp/pcsx-conf-${RANDOM}-$$-${RANDOM}.c"
6TMPO="/tmp/pcsx-conf-${RANDOM}-$$-${RANDOM}.o"
07c13dfd 7TMPB="/tmp/pcsx-conf-${RANDOM}-$$-${RANDOM}"
8trap "rm -f $TMPC $TMPO $TMPB" EXIT INT QUIT TERM
4132e8ca 9rm -f config.log
10
11compile_object()
12{
07c13dfd 13 c="$CC $CFLAGS -c $TMPC -o $TMPO $@"
14 echo $c >> config.log
15 $c >> config.log 2>&1
16}
17
18compile_binary()
19{
20 c="$CC $CFLAGS $TMPC -o $TMPB $LDFLAGS $MAIN_LDLIBS $@"
4132e8ca 21 echo $c >> config.log
22 $c >> config.log 2>&1
23}
24
25check_define()
26{
27 echo "" > $TMPC
28 $CC -E -dD $CFLAGS $TMPC | grep -q $1 || return 1
29 return 0
30}
31
32# setting options to "yes" or "no" will make that choice default,
33# "" means "autodetect".
34
38c2028e 35platform_list="generic pandora maemo caanoo libretro"
4132e8ca 36platform="generic"
61bc6d40 37builtin_gpu_list="peops unai neon"
38builtin_gpu=""
07c13dfd 39sound_driver_list="oss alsa sdl pulseaudio libretro"
40sound_drivers=""
dd4d5a35 41plugins="plugins/spunull/spunull.so \
42plugins/dfxvideo/gpu_peops.so plugins/gpu_unai/gpu_unai.so"
4132e8ca 43ram_fixed="no"
44drc_cache_base="no"
45have_armv6=""
46have_armv7=""
47have_arm_neon=""
48have_tslib=""
49enable_dynarec="yes"
f89fa2d9 50need_sdl="no"
4132e8ca 51# these are for known platforms
52optimize_cortexa8="no"
53optimize_arm926ej="no"
54
55# hardcoded stuff
56CC="${CC-${CROSS_COMPILE}gcc}"
ac6575cd 57CXX="${CXX-${CROSS_COMPILE}g++}"
4132e8ca 58AS="${AS-${CROSS_COMPILE}as}"
59AR="${AS-${CROSS_COMPILE}ar}"
f89fa2d9 60MAIN_LDLIBS="$LDLIBS -ldl -lm"
4132e8ca 61config_mak="config.mak"
62
07c13dfd 63fail()
64{
65 echo "$@"
66 exit 1
67}
68
4132e8ca 69# call during arg parsing, so that cmd line can override platform defaults
70set_platform()
71{
72 platform=$1
73 case "$platform" in
74 generic)
75 ;;
76 pandora)
07c13dfd 77 sound_drivers="oss alsa"
4132e8ca 78 ram_fixed="yes"
79 drc_cache_base="yes"
80 optimize_cortexa8="yes"
81 have_arm_neon="yes"
82 ;;
83 maemo)
84 ram_fixed="yes"
85 drc_cache_base="yes"
86 optimize_cortexa8="yes"
87 have_arm_neon="yes"
88 ;;
89 caanoo)
07c13dfd 90 sound_drivers="oss"
4132e8ca 91 ram_fixed="yes"
92 drc_cache_base="yes"
93 optimize_arm926ej="yes"
94 ;;
38c2028e 95 libretro)
07c13dfd 96 sound_drivers="libretro"
38c2028e 97 ;;
4132e8ca 98 *)
07c13dfd 99 fail "unsupported platform: $platform"
4132e8ca 100 ;;
101 esac
102}
103
104for opt do
105 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'` || true
106 case "$opt" in
107 --help|-h) show_help="yes"
108 ;;
109 --platform=*) set_platform "$optarg"
110 ;;
61bc6d40 111 --gpu=*) builtin_gpu="$optarg"
112 ;;
07c13dfd 113 --sound-drivers=*) sound_drivers="$optarg"
4132e8ca 114 ;;
115 --enable-neon) have_arm_neon="yes"
116 ;;
117 --disable-neon) have_arm_neon="no"
118 ;;
119 --disable-dynarec) enable_dynarec="no"
120 ;;
121 *) echo "ERROR: unknown option $opt"; show_help="yes"
122 ;;
123 esac
124done
125
126if [ "$show_help" = "yes" ]; then
127 echo "options:"
128 echo " --help print this message"
129 echo " --platform=NAME target platform [$platform]"
130 echo " available: $platform_list"
61bc6d40 131 echo " --gpu=NAME builtin gpu plugin [guessed]"
132 echo " available: $builtin_gpu_list"
07c13dfd 133 echo " --sound-drivers=LIST sound output drivers [guessed]"
4132e8ca 134 echo " available: $sound_driver_list"
135 echo " --enable-neon"
136 echo " --disable-neon enable/disable ARM NEON optimizations [guessed]"
137 echo " --disable-dynarec disable dynamic recompiler"
138 echo " (dynarec is only available and enabled on ARM)"
139 echo "influential environment variables:"
ac6575cd 140 echo " CROSS_COMPILE CC CXX AS AR CFLAGS ASFLAGS LDFLAGS LDLIBS"
4132e8ca 141 exit 1
142fi
143
07c13dfd 144# validate selections
61bc6d40 145if [ "x$builtin_gpu" != "x" ]; then
07c13dfd 146 if ! echo $builtin_gpu_list | grep -q "\<$builtin_gpu\>"; then
147 fail "unsupported builtin gpu plugin: $builtin_gpu"
148 fi
61bc6d40 149fi
150
07c13dfd 151if [ "x$sound_drivers" != "x" ]; then
152 for d in $sound_drivers; do
153 if ! echo $sound_driver_list | grep -q "\<$d\>"; then
154 fail "unsupported sound driver: $sound_driver"
155 fi
156 done
157fi
4132e8ca 158
159if [ -z "$ARCH" ]; then
160 ARCH=`$CC -v 2>&1 | grep -i 'target:' | awk '{print $2}' \
161 | awk -F '-' '{print $1}'`
162fi
163
164# ARM stuff
165if [ "$ARCH" = "arm" ]; then
166 if [ "$optimize_cortexa8" = "yes" ]; then
4132e8ca 167 CFLAGS="$CFLAGS -mcpu=cortex-a8 -mtune=cortex-a8"
168 ASFLAGS="$ASFLAGS -mcpu=cortex-a8"
169 fi
170 if [ "$optimize_arm926ej" = "yes" ]; then
171 CFLAGS="$CFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s"
172 ASFLAGS="$ASFLAGS -mcpu=arm926ej-s -mfloat-abi=softfp"
173 fi
174
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
178 fi
179 if [ "x$have_armv6" = "x" ]; then
180 have_armv6=`check_define __ARM_ARCH_6 && echo yes` || true
181 fi
182 if [ "x$have_armv7" = "x" ]; then
183 if check_define __ARM_ARCH_7A__; then
184 have_armv6="yes"
185 have_armv7="yes"
186 fi
187 fi
188
61bc6d40 189 if [ "x$builtin_gpu" = "x" ]; then
190 if [ "$have_arm_neon" = "yes" ]; then
191 builtin_gpu="neon"
192 elif [ "$have_armv7" != "yes" ]; then
193 # pre-ARMv7 hardware is usually not fast enough for peops
194 builtin_gpu="unai"
195 else
196 builtin_gpu="peops"
197 fi
198 fi
199
e795af9e 200 # automatically set mfpu and mfloat-abi if they are not set
4132e8ca 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"
207 fi
9f704290 208 floatabi_set_by_gcc=`$CC -v 2>&1 | grep -q -- --with-float= && echo yes` || true
e795af9e 209 if [ "$floatabi_set_by_gcc" != "yes" -a "$have_armv6" = "yes" ]; then
4132e8ca 210 echo "$CFLAGS" | grep -q -- '-mfloat-abi=' || CFLAGS="$CFLAGS -mfloat-abi=softfp"
211 echo "$ASFLAGS" | grep -q -- '-mfloat-abi=' || ASFLAGS="$ASFLAGS -mfloat-abi=softfp"
212 fi
213
9f704290 214 # must disable thumb as recompiler can't handle it
96751f36 215 if check_define __thumb__; then
9f704290 216 CFLAGS="$CFLAGS -marm"
96751f36 217 fi
218
4132e8ca 219 if [ "$have_armv7" = "yes" ]; then
220 ASFLAGS="$ASFLAGS --defsym HAVE_ARMV7=1"
221 else
222 ASFLAGS="$ASFLAGS --defsym HAVE_ARMV7=0"
223 fi
224else
225 # dynarec only available on ARM
226 enable_dynarec="no"
227fi
228
61bc6d40 229if [ "x$builtin_gpu" = "x" ]; then
230 builtin_gpu="peops"
231fi
232
791f6e3e 233#if [ "$ARCH" = "x86_64" ]; then
4132e8ca 234 # currently we are full of 32bit assumptions,
235 # at least savestate compatibility will break without these
791f6e3e
T
236# CFLAGS="$CFLAGS -m32"
237# LDFLAGS="$LDFLAGS -m32"
238#fi
4132e8ca 239
240# supposedly we can avoid -fPIC on armv5 for slightly better performace?
241if [ "$ARCH" != "arm" -o "$have_armv6" = "yes" ]; then
242 PLUGIN_CFLAGS="$PLUGIN_CFLAGS -fPIC"
243fi
244
245if [ "$ram_fixed" = "yes" ]; then
246 CFLAGS="$CFLAGS -DRAM_FIXED"
247fi
248
38c2028e 249case "$platform" in
250generic)
f89fa2d9 251 need_sdl="yes"
38c2028e 252 ;;
253maemo)
4132e8ca 254 maemo_cflags=`pkg-config --cflags hildon-1`
255 maemo_ldlibs=`pkg-config --libs hildon-1`
256 CFLAGS="$CFLAGS -DMAEMO -DMAEMO_CHANGES $maemo_cflags"
07c13dfd 257 MAIN_LDLIBS="$MAIN_LDLIBS $maemo_ldlibs"
38c2028e 258 ;;
259libretro)
260 CFLAGS="$CFLAGS -fPIC"
261 LDFLAGS="$LDFLAGS -shared"
262 ;;
263esac
4132e8ca 264
07c13dfd 265# header/library presence tests
266check_zlib()
267{
268 cat > $TMPC <<EOF
269 #include <zlib.h>
791f6e3e 270 int main(void) { uncompress(0, 0, 0, 0); }
07c13dfd 271EOF
272 compile_binary
273}
274
275check_bzlib()
276{
277 cat > $TMPC <<EOF
278 #include <bzlib.h>
279 void main() { BZ2_bzBuffToBuffDecompress(0, 0, 0, 0, 0, 0); }
280EOF
281 compile_object
282}
283
284check_libpng()
285{
286 cat > $TMPC <<EOF
287 #include <png.h>
288 void main() { png_init_io(0, 0); }
289EOF
290 compile_binary
291}
292
293check_oss()
294{
295 cat > $TMPC <<EOF
296 #include <sys/soundcard.h>
297 #include <sys/ioctl.h>
298 void main() { int a=0; ioctl(0, SNDCTL_DSP_SETFMT, &a); }
299EOF
300 compile_binary
301}
302
303check_alsa()
304{
305 cat > $TMPC <<EOF
306 #include <alsa/asoundlib.h>
307 void main() { snd_pcm_open(0, 0, 0, 0); }
308EOF
309 compile_binary "$@"
310}
311
312check_sdl()
313{
314 cat > $TMPC <<EOF
315 #include <SDL.h>
316 void main() { SDL_OpenAudio(0, 0); }
317EOF
318 compile_binary "$@"
319}
320
f89fa2d9 321MAIN_LDLIBS="$MAIN_LDLIBS -lz"
9f704290 322check_zlib || fail "please install zlib (libz-dev)"
f89fa2d9 323
9f704290 324check_bzlib || fail "please install bz2lib (libbz2-dev)"
f89fa2d9 325
326MAIN_LDLIBS="-lpng $MAIN_LDLIBS"
9f704290 327check_libpng || fail "please install libpng (libpng-dev)"
07c13dfd 328
329# find what audio support we can compile
330if [ "x$sound_drivers" = "x" ]; then
331 if check_oss; then sound_drivers="$sound_drivers oss"; fi
f89fa2d9 332 if check_alsa -lasound; then
333 sound_drivers="$sound_drivers alsa"
334 MAIN_LDLIBS="-lasound $MAIN_LDLIBS"
335 fi
9f704290 336 if [ "$need_sdl" = "yes" ] || check_sdl `sdl-config --cflags --libs`; then
f89fa2d9 337 sound_drivers="$sound_drivers sdl"
338 need_sdl="yes"
339 fi
340else
341 if echo $sound_drivers | grep -q "\<oss\>"; then
342 check_oss || fail "oss support is missing"
343 fi
344 if echo $sound_drivers | grep -q "\<alsa\>"; then
345 MAIN_LDLIBS="-lasound $MAIN_LDLIBS"
346 check_alsa || fail "please install libasound2-dev"
347 fi
07c13dfd 348fi
349
9f704290 350if [ "$need_sdl" = "yes" ]; then
351 which sdl-config > /dev/null || \
352 fail "sdl-config is missing; please install libsdl (libsdl1.2-dev)"
f89fa2d9 353 CFLAGS="$CFLAGS `sdl-config --cflags`"
354 MAIN_LDLIBS="`sdl-config --libs` $MAIN_LDLIBS"
9f704290 355 check_sdl || fail "please install libsdl (libsdl1.2-dev)"
07c13dfd 356fi
357
4132e8ca 358# check for tslib (only headers needed)
359if [ "x$have_tslib" = "x" ]; then
360 cat > $TMPC <<EOF
361 #include <tslib.h>
362 void test(struct ts_sample sample) {}
363EOF
364 if compile_object; then
365 have_tslib="yes"
366 else
367 have_tslib="no"
368 fi
369fi
370
dd4d5a35 371# check for GLES headers
372cat > $TMPC <<EOF
373#include <GLES/gl.h>
374#include <GLES/glext.h>
375#include <EGL/egl.h>
376void *test(void) {
377 return eglGetDisplay( (EGLNativeDisplayType)0 );
378}
379EOF
380if compile_object; then
381 plugins="$plugins plugins/gpu-gles/gpu_gles.so"
382fi
383
61bc6d40 384if [ "$have_arm_neon" = "yes" -a "$builtin_gpu" != "neon" ]; then
385 plugins="$plugins plugins/gpu_neon/gpu_neon.so"
386fi
387
9f704290 388cat > $TMPC <<EOF
389void test(void *f, void *d) { fread(d, 1, 1, f); }
390EOF
391if compile_object -Wno-unused-result; then
392 CFLAGS="$CFLAGS -Wno-unused-result"
393fi
394
dd4d5a35 395# short plugin list for display
396for p in $plugins; do
397 p1=`basename $p`
398 plugins_short="$p1 $plugins_short"
399done
400
4132e8ca 401# set things that failed to autodetect to "no"
402test "x$have_armv6" != "x" || have_armv6="no"
403test "x$have_armv7" != "x" || have_armv7="no"
404test "x$have_arm_neon" != "x" || have_arm_neon="no"
405
406echo "architecture $ARCH"
407echo "platform $platform"
61bc6d40 408echo "built-in GPU $builtin_gpu"
07c13dfd 409echo "sound drivers $sound_drivers"
dd4d5a35 410echo "plugins $plugins_short"
4132e8ca 411echo "C compiler $CC"
412echo "C compiler flags $CFLAGS"
07c13dfd 413echo "libraries $MAIN_LDLIBS"
7badc935 414echo "linker flags $LDFLAGS"
4132e8ca 415echo "enable dynarec $enable_dynarec"
416echo "ARMv7 optimizations $have_armv7"
417echo "enable ARM NEON $have_arm_neon"
418echo "tslib support $have_tslib"
419
420echo "# Automatically generated by configure" > $config_mak
421printf "# Configured with:" >> $config_mak
422printf " '%s'" "$0" "$@" >> $config_mak
423echo >> $config_mak
424
425echo "CC = $CC" >> $config_mak
ac6575cd 426echo "CXX = $CXX" >> $config_mak
4132e8ca 427echo "AS = $AS" >> $config_mak
428echo "CFLAGS += $CFLAGS" >> $config_mak
429echo "ASFLAGS += $ASFLAGS" >> $config_mak
430echo "LDFLAGS += $LDFLAGS" >> $config_mak
07c13dfd 431echo "MAIN_LDLIBS += $MAIN_LDLIBS" >> $config_mak
4132e8ca 432echo "PLUGIN_CFLAGS += $PLUGIN_CFLAGS" >> $config_mak
433echo >> $config_mak
434
38c2028e 435if [ "$platform" = "libretro" ]; then
436 echo "TARGET = libretro.so" >> $config_mak
437fi
4132e8ca 438echo "ARCH = $ARCH" >> $config_mak
439echo "PLATFORM = $platform" >> $config_mak
61bc6d40 440echo "BUILTIN_GPU = $builtin_gpu" >> $config_mak
07c13dfd 441echo "SOUND_DRIVERS = $sound_drivers" >> $config_mak
dd4d5a35 442if [ "$ARCH" = "arm" ]; then
443 echo "PLUGINS = $plugins" >> $config_mak
444else
445 echo -n "PLUGINS =" >> $config_mak
446 for p in $plugins; do
447 echo -n " ${p}.${ARCH}" >> $config_mak
448 done
449 echo >> $config_mak
450fi
4132e8ca 451if [ "$have_armv6" = "yes" ]; then
452 echo "HAVE_ARMV6 = 1" >> $config_mak
453fi
454if [ "$have_armv7" = "yes" ]; then
455 echo "HAVE_ARMV7 = 1" >> $config_mak
456fi
457if [ "$have_arm_neon" = "yes" ]; then
458 echo "HAVE_NEON = 1" >> $config_mak
459fi
460if [ "$have_tslib" = "yes" ]; then
461 echo "HAVE_TSLIB = 1" >> $config_mak
462fi
463if [ "$enable_dynarec" = "yes" ]; then
464 echo "USE_DYNAREC = 1" >> $config_mak
465fi
466if [ "$drc_cache_base" = "yes" ]; then
467 echo "DRC_CACHE_BASE = 1" >> $config_mak
468fi
469
2e6189bc 470# use pandora's skin (for now)
471test -e skin || ln -s frontend/pandora/skin skin
472
4132e8ca 473# vim:shiftwidth=2:expandtab