2 # some elements originated from qemu configure
5 TMPC="/tmp/pcsx-conf-${RANDOM}-$$-${RANDOM}.c"
6 TMPO="/tmp/pcsx-conf-${RANDOM}-$$-${RANDOM}.o"
7 trap "rm -f $TMPC $TMPO" EXIT INT QUIT TERM
12 c="$CC $CFLAGS -c $TMPC -o $TMPO $1"
20 $CC -E -dD $CFLAGS $TMPC | grep -q $1 || return 1
24 # setting options to "yes" or "no" will make that choice default,
25 # "" means "autodetect".
27 platform_list="generic pandora maemo caanoo libretro"
29 builtin_gpu_list="peops unai neon"
31 sound_driver_list="oss alsa libretro none"
33 plugins="plugins/spunull/spunull.so \
34 plugins/dfxvideo/gpu_peops.so plugins/gpu_unai/gpu_unai.so"
42 # these are for known platforms
43 optimize_cortexa8="no"
44 optimize_arm926ej="no"
47 CC="${CC-${CROSS_COMPILE}gcc}"
48 CXX="${CXX-${CROSS_COMPILE}g++}"
49 AS="${AS-${CROSS_COMPILE}as}"
50 AR="${AS-${CROSS_COMPILE}ar}"
51 config_mak="config.mak"
53 # call during arg parsing, so that cmd line can override platform defaults
64 optimize_cortexa8="yes"
70 optimize_cortexa8="yes"
77 optimize_arm926ej="yes"
80 sound_driver="libretro"
83 echo "unsupported platform: $platform"
90 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'` || true
92 --help|-h) show_help="yes"
94 --platform=*) set_platform "$optarg"
96 --gpu=*) builtin_gpu="$optarg"
98 --sound-driver=*) sound_driver="$optarg"
100 --enable-neon) have_arm_neon="yes"
102 --disable-neon) have_arm_neon="no"
104 --disable-dynarec) enable_dynarec="no"
106 *) echo "ERROR: unknown option $opt"; show_help="yes"
111 if [ "$show_help" = "yes" ]; then
113 echo " --help print this message"
114 echo " --platform=NAME target platform [$platform]"
115 echo " available: $platform_list"
116 echo " --gpu=NAME builtin gpu plugin [guessed]"
117 echo " available: $builtin_gpu_list"
118 echo " --sound-driver=NAME sound output driver [$sound_driver]"
119 echo " available: $sound_driver_list"
120 echo " --enable-neon"
121 echo " --disable-neon enable/disable ARM NEON optimizations [guessed]"
122 echo " --disable-dynarec disable dynamic recompiler"
123 echo " (dynarec is only available and enabled on ARM)"
124 echo "influential environment variables:"
125 echo " CROSS_COMPILE CC CXX AS AR CFLAGS ASFLAGS LDFLAGS LDLIBS"
129 if [ "x$builtin_gpu" != "x" ]; then
130 case "$builtin_gpu" in
134 echo "unsupported builtin gpu plugin: $builtin_gpu"
140 case "$sound_driver" in
141 oss|alsa|libretro|none)
144 echo "unsupported sound driver: $sound_driver"
149 if [ -z "$ARCH" ]; then
150 ARCH=`$CC -v 2>&1 | grep -i 'target:' | awk '{print $2}' \
151 | awk -F '-' '{print $1}'`
155 if [ "$ARCH" = "arm" ]; then
156 if [ "$optimize_cortexa8" = "yes" ]; then
158 CFLAGS="$CFLAGS -mcpu=cortex-a8 -mtune=cortex-a8"
159 ASFLAGS="$ASFLAGS -mcpu=cortex-a8"
161 if [ "$optimize_arm926ej" = "yes" ]; then
162 CFLAGS="$CFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s"
163 ASFLAGS="$ASFLAGS -mcpu=arm926ej-s -mfloat-abi=softfp"
166 if [ "x$have_arm_neon" = "x" ]; then
167 # detect NEON from user-supplied cflags to enable asm code
168 have_arm_neon=`check_define __ARM_NEON__ && echo yes` || true
170 if [ "x$have_armv6" = "x" ]; then
171 have_armv6=`check_define __ARM_ARCH_6 && echo yes` || true
173 if [ "x$have_armv7" = "x" ]; then
174 if check_define __ARM_ARCH_7A__; then
180 if [ "x$builtin_gpu" = "x" ]; then
181 if [ "$have_arm_neon" = "yes" ]; then
183 elif [ "$have_armv7" != "yes" ]; then
184 # pre-ARMv7 hardware is usually not fast enough for peops
191 # set mfpu and mfloat-abi if they are not set
192 if [ "$have_arm_neon" = "yes" ]; then
193 echo "$CFLAGS" | grep -q -- '-mfpu=' || CFLAGS="$CFLAGS -mfpu=neon"
194 echo "$ASFLAGS" | grep -q -- '-mfpu=' || ASFLAGS="$ASFLAGS -mfpu=neon"
195 elif [ "$have_armv6" = "yes" ]; then
196 echo "$CFLAGS" | grep -q -- '-mfpu=' || CFLAGS="$CFLAGS -mfpu=vfp"
197 echo "$ASFLAGS" | grep -q -- '-mfpu=' || ASFLAGS="$ASFLAGS -mfpu=vfp"
199 if [ "$have_armv6" = "yes" ]; then
200 echo "$CFLAGS" | grep -q -- '-mfloat-abi=' || CFLAGS="$CFLAGS -mfloat-abi=softfp"
201 echo "$ASFLAGS" | grep -q -- '-mfloat-abi=' || ASFLAGS="$ASFLAGS -mfloat-abi=softfp"
204 # must disable -mthumb as recompiler can't handle it
205 if check_define __thumb__; then
206 CFLAGS="$CFLAGS -mno-thumb"
209 if [ "$have_armv7" = "yes" ]; then
210 ASFLAGS="$ASFLAGS --defsym HAVE_ARMV7=1"
212 ASFLAGS="$ASFLAGS --defsym HAVE_ARMV7=0"
215 # dynarec only available on ARM
219 if [ "x$builtin_gpu" = "x" ]; then
223 if [ "$ARCH" = "x86_64" ]; then
224 # currently we are full of 32bit assumptions,
225 # at least savestate compatibility will break without these
226 CFLAGS="$CFLAGS -m32"
227 LDFLAGS="$LDFLAGS -m32"
230 # supposedly we can avoid -fPIC on armv5 for slightly better performace?
231 if [ "$ARCH" != "arm" -o "$have_armv6" = "yes" ]; then
232 PLUGIN_CFLAGS="$PLUGIN_CFLAGS -fPIC"
235 if [ "$ram_fixed" = "yes" ]; then
236 CFLAGS="$CFLAGS -DRAM_FIXED"
241 generic_cflags=`sdl-config --cflags`
242 generic_ldlibs=`sdl-config --libs`
243 CFLAGS="$CFLAGS $generic_cflags"
244 LDFLAGS="$LDFLAGS $generic_ldlibs"
247 maemo_cflags=`pkg-config --cflags hildon-1`
248 maemo_ldlibs=`pkg-config --libs hildon-1`
249 CFLAGS="$CFLAGS -DMAEMO -DMAEMO_CHANGES $maemo_cflags"
250 LDFLAGS="$LDFLAGS $maemo_ldlibs"
253 CFLAGS="$CFLAGS -fPIC"
254 LDFLAGS="$LDFLAGS -shared"
258 # check for tslib (only headers needed)
259 if [ "x$have_tslib" = "x" ]; then
262 void test(struct ts_sample sample) {}
264 if compile_object; then
271 # check for GLES headers
274 #include <GLES/glext.h>
277 return eglGetDisplay( (EGLNativeDisplayType)0 );
280 if compile_object; then
281 plugins="$plugins plugins/gpu-gles/gpu_gles.so"
284 if [ "$have_arm_neon" = "yes" -a "$builtin_gpu" != "neon" ]; then
285 plugins="$plugins plugins/gpu_neon/gpu_neon.so"
288 # short plugin list for display
289 for p in $plugins; do
291 plugins_short="$p1 $plugins_short"
294 # set things that failed to autodetect to "no"
295 test "x$have_armv6" != "x" || have_armv6="no"
296 test "x$have_armv7" != "x" || have_armv7="no"
297 test "x$have_arm_neon" != "x" || have_arm_neon="no"
299 echo "architecture $ARCH"
300 echo "platform $platform"
301 echo "built-in GPU $builtin_gpu"
302 echo "sound driver $sound_driver"
303 echo "plugins $plugins_short"
304 echo "C compiler $CC"
305 echo "C compiler flags $CFLAGS"
306 echo "linker flags $LDFLAGS"
307 echo "enable dynarec $enable_dynarec"
308 echo "ARMv7 optimizations $have_armv7"
309 echo "enable ARM NEON $have_arm_neon"
310 echo "tslib support $have_tslib"
312 echo "# Automatically generated by configure" > $config_mak
313 printf "# Configured with:" >> $config_mak
314 printf " '%s'" "$0" "$@" >> $config_mak
317 echo "CC = $CC" >> $config_mak
318 echo "CXX = $CXX" >> $config_mak
319 echo "AS = $AS" >> $config_mak
320 echo "CFLAGS += $CFLAGS" >> $config_mak
321 echo "ASFLAGS += $ASFLAGS" >> $config_mak
322 echo "LDFLAGS += $LDFLAGS" >> $config_mak
323 echo "LDLIBS += $LDLIBS" >> $config_mak
324 echo "PLUGIN_CFLAGS += $PLUGIN_CFLAGS" >> $config_mak
327 if [ "$platform" = "libretro" ]; then
328 echo "TARGET = libretro.so" >> $config_mak
330 echo "ARCH = $ARCH" >> $config_mak
331 echo "PLATFORM = $platform" >> $config_mak
332 echo "BUILTIN_GPU = $builtin_gpu" >> $config_mak
333 echo "SOUND_DRIVER = $sound_driver" >> $config_mak
334 if [ "$ARCH" = "arm" ]; then
335 echo "PLUGINS = $plugins" >> $config_mak
337 echo -n "PLUGINS =" >> $config_mak
338 for p in $plugins; do
339 echo -n " ${p}.${ARCH}" >> $config_mak
343 if [ "$have_armv6" = "yes" ]; then
344 echo "HAVE_ARMV6 = 1" >> $config_mak
346 if [ "$have_armv7" = "yes" ]; then
347 echo "HAVE_ARMV7 = 1" >> $config_mak
349 if [ "$have_arm_neon" = "yes" ]; then
350 echo "HAVE_NEON = 1" >> $config_mak
352 if [ "$have_tslib" = "yes" ]; then
353 echo "HAVE_TSLIB = 1" >> $config_mak
355 if [ "$enable_dynarec" = "yes" ]; then
356 echo "USE_DYNAREC = 1" >> $config_mak
358 if [ "$drc_cache_base" = "yes" ]; then
359 echo "DRC_CACHE_BASE = 1" >> $config_mak
362 # use pandora's skin (for now)
363 test -e skin || ln -s frontend/pandora/skin skin
365 # vim:shiftwidth=2:expandtab