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 sound_driver_list="oss alsa libretro none"
31 plugins="plugins/spunull/spunull.so \
32 plugins/dfxvideo/gpu_peops.so plugins/gpu_unai/gpu_unai.so"
40 # these are for known platforms
41 optimize_cortexa8="no"
42 optimize_arm926ej="no"
45 CC="${CC-${CROSS_COMPILE}gcc}"
46 CXX="${CXX-${CROSS_COMPILE}g++}"
47 AS="${AS-${CROSS_COMPILE}as}"
48 AR="${AS-${CROSS_COMPILE}ar}"
49 config_mak="config.mak"
51 # call during arg parsing, so that cmd line can override platform defaults
62 optimize_cortexa8="yes"
68 optimize_cortexa8="yes"
75 optimize_arm926ej="yes"
78 sound_driver="libretro"
81 echo "unsupported platform: $platform"
88 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'` || true
90 --help|-h) show_help="yes"
92 --platform=*) set_platform "$optarg"
94 --sound-driver=*) sound_driver="$optarg"
96 --enable-neon) have_arm_neon="yes"
98 --disable-neon) have_arm_neon="no"
100 --disable-dynarec) enable_dynarec="no"
102 *) echo "ERROR: unknown option $opt"; show_help="yes"
107 if [ "$show_help" = "yes" ]; then
109 echo " --help print this message"
110 echo " --platform=NAME target platform [$platform]"
111 echo " available: $platform_list"
112 echo " --sound-driver=NAME sound output driver [$sound_driver]"
113 echo " available: $sound_driver_list"
114 echo " --enable-neon"
115 echo " --disable-neon enable/disable ARM NEON optimizations [guessed]"
116 echo " --disable-dynarec disable dynamic recompiler"
117 echo " (dynarec is only available and enabled on ARM)"
118 echo "influential environment variables:"
119 echo " CROSS_COMPILE CC CXX AS AR CFLAGS ASFLAGS LDFLAGS LDLIBS"
123 case "$sound_driver" in
124 oss|alsa|libretro|none)
127 echo "unsupported sound driver: $sound_driver"
132 if [ -z "$ARCH" ]; then
133 ARCH=`$CC -v 2>&1 | grep -i 'target:' | awk '{print $2}' \
134 | awk -F '-' '{print $1}'`
138 if [ "$ARCH" = "arm" ]; then
139 if [ "$optimize_cortexa8" = "yes" ]; then
141 CFLAGS="$CFLAGS -mcpu=cortex-a8 -mtune=cortex-a8"
142 ASFLAGS="$ASFLAGS -mcpu=cortex-a8"
144 if [ "$optimize_arm926ej" = "yes" ]; then
145 CFLAGS="$CFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s"
146 ASFLAGS="$ASFLAGS -mcpu=arm926ej-s -mfloat-abi=softfp"
149 if [ "x$have_arm_neon" = "x" ]; then
150 # detect NEON from user-supplied cflags to enable asm code
151 have_arm_neon=`check_define __ARM_NEON__ && echo yes` || true
153 if [ "x$have_armv6" = "x" ]; then
154 have_armv6=`check_define __ARM_ARCH_6 && echo yes` || true
156 if [ "x$have_armv7" = "x" ]; then
157 if check_define __ARM_ARCH_7A__; then
163 # set mfpu and mfloat-abi if they are not set
164 if [ "$have_arm_neon" = "yes" ]; then
165 echo "$CFLAGS" | grep -q -- '-mfpu=' || CFLAGS="$CFLAGS -mfpu=neon"
166 echo "$ASFLAGS" | grep -q -- '-mfpu=' || ASFLAGS="$ASFLAGS -mfpu=neon"
167 elif [ "$have_armv6" = "yes" ]; then
168 echo "$CFLAGS" | grep -q -- '-mfpu=' || CFLAGS="$CFLAGS -mfpu=vfp"
169 echo "$ASFLAGS" | grep -q -- '-mfpu=' || ASFLAGS="$ASFLAGS -mfpu=vfp"
171 if [ "$have_armv6" = "yes" ]; then
172 echo "$CFLAGS" | grep -q -- '-mfloat-abi=' || CFLAGS="$CFLAGS -mfloat-abi=softfp"
173 echo "$ASFLAGS" | grep -q -- '-mfloat-abi=' || ASFLAGS="$ASFLAGS -mfloat-abi=softfp"
176 # must disable -mthumb as recompiler can't handle it
177 if check_define __thumb__; then
178 CFLAGS="$CFLAGS -mno-thumb"
181 if [ "$have_armv7" = "yes" ]; then
182 ASFLAGS="$ASFLAGS --defsym HAVE_ARMV7=1"
184 ASFLAGS="$ASFLAGS --defsym HAVE_ARMV7=0"
187 # dynarec only available on ARM
191 if [ "$ARCH" = "x86_64" ]; then
192 # currently we are full of 32bit assumptions,
193 # at least savestate compatibility will break without these
194 CFLAGS="$CFLAGS -m32"
195 LDFLAGS="$LDFLAGS -m32"
198 # supposedly we can avoid -fPIC on armv5 for slightly better performace?
199 if [ "$ARCH" != "arm" -o "$have_armv6" = "yes" ]; then
200 PLUGIN_CFLAGS="$PLUGIN_CFLAGS -fPIC"
203 if [ "$ram_fixed" = "yes" ]; then
204 CFLAGS="$CFLAGS -DRAM_FIXED"
209 generic_cflags=`sdl-config --cflags`
210 generic_ldlibs=`sdl-config --libs`
211 CFLAGS="$CFLAGS $generic_cflags"
212 LDFLAGS="$LDFLAGS $generic_ldlibs"
215 maemo_cflags=`pkg-config --cflags hildon-1`
216 maemo_ldlibs=`pkg-config --libs hildon-1`
217 CFLAGS="$CFLAGS -DMAEMO -DMAEMO_CHANGES $maemo_cflags"
218 LDFLAGS="$LDFLAGS $maemo_ldlibs"
221 CFLAGS="$CFLAGS -fPIC"
222 LDFLAGS="$LDFLAGS -shared"
226 # check for tslib (only headers needed)
227 if [ "x$have_tslib" = "x" ]; then
230 void test(struct ts_sample sample) {}
232 if compile_object; then
239 # check for GLES headers
242 #include <GLES/glext.h>
245 return eglGetDisplay( (EGLNativeDisplayType)0 );
248 if compile_object; then
249 plugins="$plugins plugins/gpu-gles/gpu_gles.so"
252 # short plugin list for display
253 for p in $plugins; do
255 plugins_short="$p1 $plugins_short"
258 # set things that failed to autodetect to "no"
259 test "x$have_armv6" != "x" || have_armv6="no"
260 test "x$have_armv7" != "x" || have_armv7="no"
261 test "x$have_arm_neon" != "x" || have_arm_neon="no"
263 echo "architecture $ARCH"
264 echo "platform $platform"
265 echo "sound driver $sound_driver"
266 echo "plugins $plugins_short"
267 echo "C compiler $CC"
268 echo "C compiler flags $CFLAGS"
269 echo "linker flags $LDFLAGS"
270 echo "enable dynarec $enable_dynarec"
271 echo "ARMv7 optimizations $have_armv7"
272 echo "enable ARM NEON $have_arm_neon"
273 echo "tslib support $have_tslib"
275 echo "# Automatically generated by configure" > $config_mak
276 printf "# Configured with:" >> $config_mak
277 printf " '%s'" "$0" "$@" >> $config_mak
280 echo "CC = $CC" >> $config_mak
281 echo "CXX = $CXX" >> $config_mak
282 echo "AS = $AS" >> $config_mak
283 echo "CFLAGS += $CFLAGS" >> $config_mak
284 echo "ASFLAGS += $ASFLAGS" >> $config_mak
285 echo "LDFLAGS += $LDFLAGS" >> $config_mak
286 echo "LDLIBS += $LDLIBS" >> $config_mak
287 echo "PLUGIN_CFLAGS += $PLUGIN_CFLAGS" >> $config_mak
290 if [ "$platform" = "libretro" ]; then
291 echo "TARGET = libretro.so" >> $config_mak
293 echo "ARCH = $ARCH" >> $config_mak
294 echo "PLATFORM = $platform" >> $config_mak
295 case "$sound_driver" in
297 echo "USE_OSS = 1" >> $config_mak
300 echo "USE_ALSA = 1" >> $config_mak
303 echo "USE_NO_SOUND = 1" >> $config_mak
306 if [ "$ARCH" = "arm" ]; then
307 echo "PLUGINS = $plugins" >> $config_mak
309 echo -n "PLUGINS =" >> $config_mak
310 for p in $plugins; do
311 echo -n " ${p}.${ARCH}" >> $config_mak
315 if [ "$have_armv6" = "yes" ]; then
316 echo "HAVE_ARMV6 = 1" >> $config_mak
318 if [ "$have_armv7" = "yes" ]; then
319 echo "HAVE_ARMV7 = 1" >> $config_mak
321 if [ "$have_arm_neon" = "yes" ]; then
322 echo "HAVE_NEON = 1" >> $config_mak
324 if [ "$have_tslib" = "yes" ]; then
325 echo "HAVE_TSLIB = 1" >> $config_mak
327 if [ "$enable_dynarec" = "yes" ]; then
328 echo "USE_DYNAREC = 1" >> $config_mak
330 if [ "$drc_cache_base" = "yes" ]; then
331 echo "DRC_CACHE_BASE = 1" >> $config_mak
334 # use pandora's skin (for now)
335 test -e skin || ln -s frontend/pandora/skin skin
337 # vim:shiftwidth=2:expandtab