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"
29 sound_driver_list="oss alsa 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 echo "unsupported platform: $platform"
85 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'` || true
87 --help|-h) show_help="yes"
89 --platform=*) set_platform "$optarg"
91 --sound-driver=*) sound_driver="$optarg"
93 --enable-neon) have_arm_neon="yes"
95 --disable-neon) have_arm_neon="no"
97 --disable-dynarec) enable_dynarec="no"
99 *) echo "ERROR: unknown option $opt"; show_help="yes"
104 if [ "$show_help" = "yes" ]; then
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:"
116 echo " CROSS_COMPILE CC CXX AS AR CFLAGS ASFLAGS LDFLAGS LDLIBS"
120 case "$sound_driver" in
124 echo "unsupported sound driver: $sound_driver"
129 if [ -z "$ARCH" ]; then
130 ARCH=`$CC -v 2>&1 | grep -i 'target:' | awk '{print $2}' \
131 | awk -F '-' '{print $1}'`
135 if [ "$ARCH" = "arm" ]; then
136 if [ "$optimize_cortexa8" = "yes" ]; then
138 CFLAGS="$CFLAGS -mcpu=cortex-a8 -mtune=cortex-a8"
139 ASFLAGS="$ASFLAGS -mcpu=cortex-a8"
141 if [ "$optimize_arm926ej" = "yes" ]; then
142 CFLAGS="$CFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s"
143 ASFLAGS="$ASFLAGS -mcpu=arm926ej-s -mfloat-abi=softfp"
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
150 if [ "x$have_armv6" = "x" ]; then
151 have_armv6=`check_define __ARM_ARCH_6 && echo yes` || true
153 if [ "x$have_armv7" = "x" ]; then
154 if check_define __ARM_ARCH_7A__; then
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"
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"
173 # must disable -mthumb as recompiler can't handle it
174 if check_define __thumb__; then
175 CFLAGS="$CFLAGS -mno-thumb"
178 if [ "$have_armv7" = "yes" ]; then
179 ASFLAGS="$ASFLAGS --defsym HAVE_ARMV7=1"
181 ASFLAGS="$ASFLAGS --defsym HAVE_ARMV7=0"
184 # dynarec only available on ARM
188 if [ "$ARCH" = "x86_64" ]; then
189 # currently we are full of 32bit assumptions,
190 # at least savestate compatibility will break without these
191 CFLAGS="$CFLAGS -m32"
192 LDFLAGS="$LDFLAGS -m32"
195 # supposedly we can avoid -fPIC on armv5 for slightly better performace?
196 if [ "$ARCH" != "arm" -o "$have_armv6" = "yes" ]; then
197 PLUGIN_CFLAGS="$PLUGIN_CFLAGS -fPIC"
200 if [ "$ram_fixed" = "yes" ]; then
201 CFLAGS="$CFLAGS -DRAM_FIXED"
204 if [ "$platform" = "generic" ]; then
205 generic_cflags=`sdl-config --cflags`
206 generic_ldlibs=`sdl-config --libs`
207 CFLAGS="$CFLAGS $generic_cflags"
208 LDFLAGS="$LDFLAGS $generic_ldlibs"
209 elif [ "$platform" = "maemo" ]; then
210 maemo_cflags=`pkg-config --cflags hildon-1`
211 maemo_ldlibs=`pkg-config --libs hildon-1`
212 CFLAGS="$CFLAGS -DMAEMO -DMAEMO_CHANGES $maemo_cflags"
213 LDFLAGS="$LDFLAGS $maemo_ldlibs"
216 # check for tslib (only headers needed)
217 if [ "x$have_tslib" = "x" ]; then
220 void test(struct ts_sample sample) {}
222 if compile_object; then
229 # check for GLES headers
232 #include <GLES/glext.h>
235 return eglGetDisplay( (EGLNativeDisplayType)0 );
238 if compile_object; then
239 plugins="$plugins plugins/gpu-gles/gpu_gles.so"
242 # short plugin list for display
243 for p in $plugins; do
245 plugins_short="$p1 $plugins_short"
248 # set things that failed to autodetect to "no"
249 test "x$have_armv6" != "x" || have_armv6="no"
250 test "x$have_armv7" != "x" || have_armv7="no"
251 test "x$have_arm_neon" != "x" || have_arm_neon="no"
253 echo "architecture $ARCH"
254 echo "platform $platform"
255 echo "sound driver $sound_driver"
256 echo "plugins $plugins_short"
257 echo "C compiler $CC"
258 echo "C compiler flags $CFLAGS"
259 echo "linker flags $LDFLAGS"
260 echo "enable dynarec $enable_dynarec"
261 echo "ARMv7 optimizations $have_armv7"
262 echo "enable ARM NEON $have_arm_neon"
263 echo "tslib support $have_tslib"
265 echo "# Automatically generated by configure" > $config_mak
266 printf "# Configured with:" >> $config_mak
267 printf " '%s'" "$0" "$@" >> $config_mak
270 echo "CC = $CC" >> $config_mak
271 echo "CXX = $CXX" >> $config_mak
272 echo "AS = $AS" >> $config_mak
273 echo "CFLAGS += $CFLAGS" >> $config_mak
274 echo "ASFLAGS += $ASFLAGS" >> $config_mak
275 echo "LDFLAGS += $LDFLAGS" >> $config_mak
276 echo "LDLIBS += $LDLIBS" >> $config_mak
277 echo "PLUGIN_CFLAGS += $PLUGIN_CFLAGS" >> $config_mak
280 echo "ARCH = $ARCH" >> $config_mak
281 echo "PLATFORM = $platform" >> $config_mak
282 case "$sound_driver" in
284 echo "USE_OSS = 1" >> $config_mak
287 echo "USE_ALSA = 1" >> $config_mak
290 echo "USE_NO_SOUND = 1" >> $config_mak
293 if [ "$ARCH" = "arm" ]; then
294 echo "PLUGINS = $plugins" >> $config_mak
296 echo -n "PLUGINS =" >> $config_mak
297 for p in $plugins; do
298 echo -n " ${p}.${ARCH}" >> $config_mak
302 if [ "$have_armv6" = "yes" ]; then
303 echo "HAVE_ARMV6 = 1" >> $config_mak
305 if [ "$have_armv7" = "yes" ]; then
306 echo "HAVE_ARMV7 = 1" >> $config_mak
308 if [ "$have_arm_neon" = "yes" ]; then
309 echo "HAVE_NEON = 1" >> $config_mak
311 if [ "$have_tslib" = "yes" ]; then
312 echo "HAVE_TSLIB = 1" >> $config_mak
314 if [ "$enable_dynarec" = "yes" ]; then
315 echo "USE_DYNAREC = 1" >> $config_mak
317 if [ "$drc_cache_base" = "yes" ]; then
318 echo "DRC_CACHE_BASE = 1" >> $config_mak
321 # use pandora's skin (for now)
322 test -e skin || ln -s frontend/pandora/skin skin
324 # vim:shiftwidth=2:expandtab