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"
38 # these are for known platforms
39 optimize_cortexa8="no"
40 optimize_arm926ej="no"
43 CC="${CC-${CROSS_COMPILE}gcc}"
44 CXX="${CXX-${CROSS_COMPILE}g++}"
45 AS="${AS-${CROSS_COMPILE}as}"
46 AR="${AS-${CROSS_COMPILE}ar}"
47 config_mak="config.mak"
49 # call during arg parsing, so that cmd line can override platform defaults
60 optimize_cortexa8="yes"
66 optimize_cortexa8="yes"
73 optimize_arm926ej="yes"
76 echo "unsupported platform: $platform"
83 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'` || true
85 --help|-h) show_help="yes"
87 --platform=*) set_platform "$optarg"
89 --sound-driver=*) sound_driver="$optarg"
91 --enable-neon) have_arm_neon="yes"
93 --disable-neon) have_arm_neon="no"
95 --disable-dynarec) enable_dynarec="no"
97 *) echo "ERROR: unknown option $opt"; show_help="yes"
102 if [ "$show_help" = "yes" ]; then
104 echo " --help print this message"
105 echo " --platform=NAME target platform [$platform]"
106 echo " available: $platform_list"
107 echo " --sound-driver=NAME sound output driver [$sound_driver]"
108 echo " available: $sound_driver_list"
109 echo " --enable-neon"
110 echo " --disable-neon enable/disable ARM NEON optimizations [guessed]"
111 echo " --disable-dynarec disable dynamic recompiler"
112 echo " (dynarec is only available and enabled on ARM)"
113 echo "influential environment variables:"
114 echo " CROSS_COMPILE CC CXX AS AR CFLAGS ASFLAGS LDFLAGS LDLIBS"
118 case "$sound_driver" in
122 echo "unsupported sound driver: $sound_driver"
127 if [ -z "$ARCH" ]; then
128 ARCH=`$CC -v 2>&1 | grep -i 'target:' | awk '{print $2}' \
129 | awk -F '-' '{print $1}'`
133 if [ "$ARCH" = "arm" ]; then
134 if [ "$optimize_cortexa8" = "yes" ]; then
136 CFLAGS="$CFLAGS -mcpu=cortex-a8 -mtune=cortex-a8"
137 ASFLAGS="$ASFLAGS -mcpu=cortex-a8"
139 if [ "$optimize_arm926ej" = "yes" ]; then
140 CFLAGS="$CFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s"
141 ASFLAGS="$ASFLAGS -mcpu=arm926ej-s -mfloat-abi=softfp"
144 if [ "x$have_arm_neon" = "x" ]; then
145 # detect NEON from user-supplied cflags to enable asm code
146 have_arm_neon=`check_define __ARM_NEON__ && echo yes` || true
148 if [ "x$have_armv6" = "x" ]; then
149 have_armv6=`check_define __ARM_ARCH_6 && echo yes` || true
151 if [ "x$have_armv7" = "x" ]; then
152 if check_define __ARM_ARCH_7A__; then
158 # set mfpu and mfloat-abi if they are not set
159 if [ "$have_arm_neon" = "yes" ]; then
160 echo "$CFLAGS" | grep -q -- '-mfpu=' || CFLAGS="$CFLAGS -mfpu=neon"
161 echo "$ASFLAGS" | grep -q -- '-mfpu=' || ASFLAGS="$ASFLAGS -mfpu=neon"
162 elif [ "$have_armv6" = "yes" ]; then
163 echo "$CFLAGS" | grep -q -- '-mfpu=' || CFLAGS="$CFLAGS -mfpu=vfp"
164 echo "$ASFLAGS" | grep -q -- '-mfpu=' || ASFLAGS="$ASFLAGS -mfpu=vfp"
166 if [ "$have_armv6" = "yes" ]; then
167 echo "$CFLAGS" | grep -q -- '-mfloat-abi=' || CFLAGS="$CFLAGS -mfloat-abi=softfp"
168 echo "$ASFLAGS" | grep -q -- '-mfloat-abi=' || ASFLAGS="$ASFLAGS -mfloat-abi=softfp"
171 if [ "$have_armv7" = "yes" ]; then
172 ASFLAGS="$ASFLAGS --defsym HAVE_ARMV7=1"
174 ASFLAGS="$ASFLAGS --defsym HAVE_ARMV7=0"
177 # dynarec only available on ARM
181 if [ "$ARCH" = "x86_64" ]; then
182 # currently we are full of 32bit assumptions,
183 # at least savestate compatibility will break without these
184 CFLAGS="$CFLAGS -m32"
185 LDFLAGS="$LDFLAGS -m32"
188 # supposedly we can avoid -fPIC on armv5 for slightly better performace?
189 if [ "$ARCH" != "arm" -o "$have_armv6" = "yes" ]; then
190 PLUGIN_CFLAGS="$PLUGIN_CFLAGS -fPIC"
193 if [ "$ram_fixed" = "yes" ]; then
194 CFLAGS="$CFLAGS -DRAM_FIXED"
197 if [ "$platform" = "generic" ]; then
198 generic_cflags=`sdl-config --cflags`
199 generic_ldlibs=`sdl-config --libs`
200 CFLAGS="$CFLAGS $generic_cflags"
201 LDFLAGS="$LDFLAGS $generic_ldlibs"
202 elif [ "$platform" = "maemo" ]; then
203 maemo_cflags=`pkg-config --cflags hildon-1`
204 maemo_ldlibs=`pkg-config --libs hildon-1`
205 CFLAGS="$CFLAGS -DMAEMO -DMAEMO_CHANGES $maemo_cflags"
206 LDFLAGS="$LDFLAGS $maemo_ldlibs"
209 # check for tslib (only headers needed)
210 if [ "x$have_tslib" = "x" ]; then
213 void test(struct ts_sample sample) {}
215 if compile_object; then
222 # set things that failed to autodetect to "no"
223 test "x$have_armv6" != "x" || have_armv6="no"
224 test "x$have_armv7" != "x" || have_armv7="no"
225 test "x$have_arm_neon" != "x" || have_arm_neon="no"
227 echo "architecture $ARCH"
228 echo "platform $platform"
229 echo "sound driver $sound_driver"
230 echo "C compiler $CC"
231 echo "C compiler flags $CFLAGS"
232 echo "linker flags $LDFLAGS"
233 echo "enable dynarec $enable_dynarec"
234 echo "ARMv7 optimizations $have_armv7"
235 echo "enable ARM NEON $have_arm_neon"
236 echo "tslib support $have_tslib"
238 echo "# Automatically generated by configure" > $config_mak
239 printf "# Configured with:" >> $config_mak
240 printf " '%s'" "$0" "$@" >> $config_mak
243 echo "CC = $CC" >> $config_mak
244 echo "CXX = $CXX" >> $config_mak
245 echo "AS = $AS" >> $config_mak
246 echo "CFLAGS += $CFLAGS" >> $config_mak
247 echo "ASFLAGS += $ASFLAGS" >> $config_mak
248 echo "LDFLAGS += $LDFLAGS" >> $config_mak
249 echo "LDLIBS += $LDLIBS" >> $config_mak
250 echo "PLUGIN_CFLAGS += $PLUGIN_CFLAGS" >> $config_mak
253 echo "ARCH = $ARCH" >> $config_mak
254 echo "PLATFORM = $platform" >> $config_mak
255 case "$sound_driver" in
257 echo "USE_OSS = 1" >> $config_mak
260 echo "USE_ALSA = 1" >> $config_mak
263 echo "USE_NO_SOUND = 1" >> $config_mak
266 if [ "$have_armv6" = "yes" ]; then
267 echo "HAVE_ARMV6 = 1" >> $config_mak
269 if [ "$have_armv7" = "yes" ]; then
270 echo "HAVE_ARMV7 = 1" >> $config_mak
272 if [ "$have_arm_neon" = "yes" ]; then
273 echo "HAVE_NEON = 1" >> $config_mak
275 if [ "$have_tslib" = "yes" ]; then
276 echo "HAVE_TSLIB = 1" >> $config_mak
278 if [ "$enable_dynarec" = "yes" ]; then
279 echo "USE_DYNAREC = 1" >> $config_mak
281 if [ "$drc_cache_base" = "yes" ]; then
282 echo "DRC_CACHE_BASE = 1" >> $config_mak
285 # vim:shiftwidth=2:expandtab