frontend: in_sdl: preliminary joystick support
[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"
7trap "rm -f $TMPC $TMPO" EXIT INT QUIT TERM
8rm -f config.log
9
10compile_object()
11{
12 c="$CC $CFLAGS -c $TMPC -o $TMPO $1"
13 echo $c >> config.log
14 $c >> config.log 2>&1
15}
16
17check_define()
18{
19 echo "" > $TMPC
20 $CC -E -dD $CFLAGS $TMPC | grep -q $1 || return 1
21 return 0
22}
23
24# setting options to "yes" or "no" will make that choice default,
25# "" means "autodetect".
26
27platform_list="generic pandora maemo caanoo"
28platform="generic"
29sound_driver_list="oss alsa none"
30sound_driver="alsa"
dd4d5a35 31plugins="plugins/spunull/spunull.so \
32plugins/dfxvideo/gpu_peops.so plugins/gpu_unai/gpu_unai.so"
4132e8ca 33ram_fixed="no"
34drc_cache_base="no"
35have_armv6=""
36have_armv7=""
37have_arm_neon=""
38have_tslib=""
39enable_dynarec="yes"
40# these are for known platforms
41optimize_cortexa8="no"
42optimize_arm926ej="no"
43
44# hardcoded stuff
45CC="${CC-${CROSS_COMPILE}gcc}"
ac6575cd 46CXX="${CXX-${CROSS_COMPILE}g++}"
4132e8ca 47AS="${AS-${CROSS_COMPILE}as}"
48AR="${AS-${CROSS_COMPILE}ar}"
49config_mak="config.mak"
50
51# call during arg parsing, so that cmd line can override platform defaults
52set_platform()
53{
54 platform=$1
55 case "$platform" in
56 generic)
57 ;;
58 pandora)
59 sound_driver="oss"
60 ram_fixed="yes"
61 drc_cache_base="yes"
62 optimize_cortexa8="yes"
63 have_arm_neon="yes"
64 ;;
65 maemo)
66 ram_fixed="yes"
67 drc_cache_base="yes"
68 optimize_cortexa8="yes"
69 have_arm_neon="yes"
70 ;;
71 caanoo)
72 sound_driver="oss"
73 ram_fixed="yes"
74 drc_cache_base="yes"
75 optimize_arm926ej="yes"
76 ;;
77 *)
78 echo "unsupported platform: $platform"
79 exit 1
80 ;;
81 esac
82}
83
84for opt do
85 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'` || true
86 case "$opt" in
87 --help|-h) show_help="yes"
88 ;;
89 --platform=*) set_platform "$optarg"
90 ;;
91 --sound-driver=*) sound_driver="$optarg"
92 ;;
93 --enable-neon) have_arm_neon="yes"
94 ;;
95 --disable-neon) have_arm_neon="no"
96 ;;
97 --disable-dynarec) enable_dynarec="no"
98 ;;
99 *) echo "ERROR: unknown option $opt"; show_help="yes"
100 ;;
101 esac
102done
103
104if [ "$show_help" = "yes" ]; then
105 echo "options:"
106 echo " --help print this message"
107 echo " --platform=NAME target platform [$platform]"
108 echo " available: $platform_list"
109 echo " --sound-driver=NAME sound output driver [$sound_driver]"
110 echo " available: $sound_driver_list"
111 echo " --enable-neon"
112 echo " --disable-neon enable/disable ARM NEON optimizations [guessed]"
113 echo " --disable-dynarec disable dynamic recompiler"
114 echo " (dynarec is only available and enabled on ARM)"
115 echo "influential environment variables:"
ac6575cd 116 echo " CROSS_COMPILE CC CXX AS AR CFLAGS ASFLAGS LDFLAGS LDLIBS"
4132e8ca 117 exit 1
118fi
119
120case "$sound_driver" in
121oss|alsa|none)
122 ;;
123*)
124 echo "unsupported sound driver: $sound_driver"
125 exit 1
126 ;;
127esac
128
129if [ -z "$ARCH" ]; then
130 ARCH=`$CC -v 2>&1 | grep -i 'target:' | awk '{print $2}' \
131 | awk -F '-' '{print $1}'`
132fi
133
134# ARM stuff
135if [ "$ARCH" = "arm" ]; then
136 if [ "$optimize_cortexa8" = "yes" ]; then
137 # both: -mfpu=neon
138 CFLAGS="$CFLAGS -mcpu=cortex-a8 -mtune=cortex-a8"
139 ASFLAGS="$ASFLAGS -mcpu=cortex-a8"
140 fi
141 if [ "$optimize_arm926ej" = "yes" ]; then
142 CFLAGS="$CFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s"
143 ASFLAGS="$ASFLAGS -mcpu=arm926ej-s -mfloat-abi=softfp"
144 fi
145
146 if [ "x$have_arm_neon" = "x" ]; then
147 # detect NEON from user-supplied cflags to enable asm code
148 have_arm_neon=`check_define __ARM_NEON__ && echo yes` || true
149 fi
150 if [ "x$have_armv6" = "x" ]; then
151 have_armv6=`check_define __ARM_ARCH_6 && echo yes` || true
152 fi
153 if [ "x$have_armv7" = "x" ]; then
154 if check_define __ARM_ARCH_7A__; then
155 have_armv6="yes"
156 have_armv7="yes"
157 fi
158 fi
159
160 # set mfpu and mfloat-abi if they are not set
161 if [ "$have_arm_neon" = "yes" ]; then
162 echo "$CFLAGS" | grep -q -- '-mfpu=' || CFLAGS="$CFLAGS -mfpu=neon"
163 echo "$ASFLAGS" | grep -q -- '-mfpu=' || ASFLAGS="$ASFLAGS -mfpu=neon"
164 elif [ "$have_armv6" = "yes" ]; then
165 echo "$CFLAGS" | grep -q -- '-mfpu=' || CFLAGS="$CFLAGS -mfpu=vfp"
166 echo "$ASFLAGS" | grep -q -- '-mfpu=' || ASFLAGS="$ASFLAGS -mfpu=vfp"
167 fi
168 if [ "$have_armv6" = "yes" ]; then
169 echo "$CFLAGS" | grep -q -- '-mfloat-abi=' || CFLAGS="$CFLAGS -mfloat-abi=softfp"
170 echo "$ASFLAGS" | grep -q -- '-mfloat-abi=' || ASFLAGS="$ASFLAGS -mfloat-abi=softfp"
171 fi
172
173 if [ "$have_armv7" = "yes" ]; then
174 ASFLAGS="$ASFLAGS --defsym HAVE_ARMV7=1"
175 else
176 ASFLAGS="$ASFLAGS --defsym HAVE_ARMV7=0"
177 fi
178else
179 # dynarec only available on ARM
180 enable_dynarec="no"
181fi
182
183if [ "$ARCH" = "x86_64" ]; then
184 # currently we are full of 32bit assumptions,
185 # at least savestate compatibility will break without these
186 CFLAGS="$CFLAGS -m32"
187 LDFLAGS="$LDFLAGS -m32"
188fi
189
190# supposedly we can avoid -fPIC on armv5 for slightly better performace?
191if [ "$ARCH" != "arm" -o "$have_armv6" = "yes" ]; then
192 PLUGIN_CFLAGS="$PLUGIN_CFLAGS -fPIC"
193fi
194
195if [ "$ram_fixed" = "yes" ]; then
196 CFLAGS="$CFLAGS -DRAM_FIXED"
197fi
198
7badc935 199if [ "$platform" = "generic" ]; then
200 generic_cflags=`sdl-config --cflags`
201 generic_ldlibs=`sdl-config --libs`
202 CFLAGS="$CFLAGS $generic_cflags"
203 LDFLAGS="$LDFLAGS $generic_ldlibs"
204elif [ "$platform" = "maemo" ]; then
4132e8ca 205 maemo_cflags=`pkg-config --cflags hildon-1`
206 maemo_ldlibs=`pkg-config --libs hildon-1`
207 CFLAGS="$CFLAGS -DMAEMO -DMAEMO_CHANGES $maemo_cflags"
208 LDFLAGS="$LDFLAGS $maemo_ldlibs"
209fi
210
211# check for tslib (only headers needed)
212if [ "x$have_tslib" = "x" ]; then
213 cat > $TMPC <<EOF
214 #include <tslib.h>
215 void test(struct ts_sample sample) {}
216EOF
217 if compile_object; then
218 have_tslib="yes"
219 else
220 have_tslib="no"
221 fi
222fi
223
dd4d5a35 224# check for GLES headers
225cat > $TMPC <<EOF
226#include <GLES/gl.h>
227#include <GLES/glext.h>
228#include <EGL/egl.h>
229void *test(void) {
230 return eglGetDisplay( (EGLNativeDisplayType)0 );
231}
232EOF
233if compile_object; then
234 plugins="$plugins plugins/gpu-gles/gpu_gles.so"
235fi
236
237# short plugin list for display
238for p in $plugins; do
239 p1=`basename $p`
240 plugins_short="$p1 $plugins_short"
241done
242
4132e8ca 243# set things that failed to autodetect to "no"
244test "x$have_armv6" != "x" || have_armv6="no"
245test "x$have_armv7" != "x" || have_armv7="no"
246test "x$have_arm_neon" != "x" || have_arm_neon="no"
247
248echo "architecture $ARCH"
249echo "platform $platform"
250echo "sound driver $sound_driver"
dd4d5a35 251echo "plugins $plugins_short"
4132e8ca 252echo "C compiler $CC"
253echo "C compiler flags $CFLAGS"
7badc935 254echo "linker flags $LDFLAGS"
4132e8ca 255echo "enable dynarec $enable_dynarec"
256echo "ARMv7 optimizations $have_armv7"
257echo "enable ARM NEON $have_arm_neon"
258echo "tslib support $have_tslib"
259
260echo "# Automatically generated by configure" > $config_mak
261printf "# Configured with:" >> $config_mak
262printf " '%s'" "$0" "$@" >> $config_mak
263echo >> $config_mak
264
265echo "CC = $CC" >> $config_mak
ac6575cd 266echo "CXX = $CXX" >> $config_mak
4132e8ca 267echo "AS = $AS" >> $config_mak
268echo "CFLAGS += $CFLAGS" >> $config_mak
269echo "ASFLAGS += $ASFLAGS" >> $config_mak
270echo "LDFLAGS += $LDFLAGS" >> $config_mak
271echo "LDLIBS += $LDLIBS" >> $config_mak
272echo "PLUGIN_CFLAGS += $PLUGIN_CFLAGS" >> $config_mak
273echo >> $config_mak
274
275echo "ARCH = $ARCH" >> $config_mak
276echo "PLATFORM = $platform" >> $config_mak
277case "$sound_driver" in
278oss)
279 echo "USE_OSS = 1" >> $config_mak
280 ;;
281alsa)
282 echo "USE_ALSA = 1" >> $config_mak
283 ;;
284none)
285 echo "USE_NO_SOUND = 1" >> $config_mak
286 ;;
287esac
dd4d5a35 288if [ "$ARCH" = "arm" ]; then
289 echo "PLUGINS = $plugins" >> $config_mak
290else
291 echo -n "PLUGINS =" >> $config_mak
292 for p in $plugins; do
293 echo -n " ${p}.${ARCH}" >> $config_mak
294 done
295 echo >> $config_mak
296fi
4132e8ca 297if [ "$have_armv6" = "yes" ]; then
298 echo "HAVE_ARMV6 = 1" >> $config_mak
299fi
300if [ "$have_armv7" = "yes" ]; then
301 echo "HAVE_ARMV7 = 1" >> $config_mak
302fi
303if [ "$have_arm_neon" = "yes" ]; then
304 echo "HAVE_NEON = 1" >> $config_mak
305fi
306if [ "$have_tslib" = "yes" ]; then
307 echo "HAVE_TSLIB = 1" >> $config_mak
308fi
309if [ "$enable_dynarec" = "yes" ]; then
310 echo "USE_DYNAREC = 1" >> $config_mak
311fi
312if [ "$drc_cache_base" = "yes" ]; then
313 echo "DRC_CACHE_BASE = 1" >> $config_mak
314fi
315
2e6189bc 316# use pandora's skin (for now)
317test -e skin || ln -s frontend/pandora/skin skin
318
4132e8ca 319# vim:shiftwidth=2:expandtab