revive GP2X build, update
[picodrive.git] / configure
index 9af719f..097a276 100755 (executable)
--- a/configure
+++ b/configure
@@ -2,9 +2,9 @@
 # some elements originated from qemu configure
 set -e
 
-TMPC="/tmp/pcsx-conf-${RANDOM}-$$-${RANDOM}.c"
-TMPO="/tmp/pcsx-conf-${RANDOM}-$$-${RANDOM}.o"
-TMPB="/tmp/pcsx-conf-${RANDOM}-$$-${RANDOM}"
+TMPC="/tmp/picodrive-conf-${RANDOM}-$$-${RANDOM}.c"
+TMPO="/tmp/picodrive-conf-${RANDOM}-$$-${RANDOM}.o"
+TMPB="/tmp/picodrive-conf-${RANDOM}-$$-${RANDOM}"
 trap "rm -f $TMPC $TMPO $TMPB" EXIT INT QUIT TERM
 rm -f config.log
 
@@ -17,7 +17,7 @@ compile_object()
 
 compile_binary()
 {
-  c="$CC $CFLAGS $TMPC -o $TMPB $LDFLAGS $MAIN_LDLIBS $@"
+  c="$CC $CFLAGS $TMPC -o $TMPB $LDFLAGS $@"
   echo $c >> config.log
   $c >> config.log 2>&1
 }
@@ -31,7 +31,7 @@ check_define()
 # setting options to "yes" or "no" will make that choice default,
 # "" means "autodetect".
 
-platform_list="generic pandora"
+platform_list="generic pandora gp2x"
 platform="generic"
 sound_driver_list="oss alsa sdl"
 sound_drivers=""
@@ -40,12 +40,12 @@ have_armv6=""
 have_armv7=""
 have_arm_neon=""
 have_libavcodec=""
-enable_dynarec="yes"
 need_sdl="no"
 need_xlib="no"
 # these are for known platforms
 optimize_cortexa8="no"
 optimize_arm926ej="no"
+optimize_arm920="no"
 
 # hardcoded stuff
 CC="${CC-${CROSS_COMPILE}gcc}"
@@ -72,6 +72,16 @@ set_platform()
     optimize_cortexa8="yes"
     have_arm_neon="yes"
     ;;
+  gp2x)
+    sound_drivers="oss"
+    optimize_arm920="yes"
+    CFLAGS="$CFLAGS -D__GP2X__"
+    if [ "$CROSS_COMPILE" = "arm-linux-" ]; then
+      # still using static, dynamic linking slows Wiz 1-10%
+      # also libm on F100 is not compatible
+      MAIN_LDLIBS="$MAIN_LDLIBS -static"
+    fi
+    ;;
   *)
     fail "unsupported platform: $platform"
     ;;
@@ -87,12 +97,6 @@ for opt do
   ;;
   --sound-drivers=*) sound_drivers="$optarg"
   ;;
-  --enable-neon) have_arm_neon="yes"
-  ;;
-  --disable-neon) have_arm_neon="no"
-  ;;
-  --disable-dynarec) enable_dynarec="no"
-  ;;
   *) echo "ERROR: unknown option $opt"; show_help="yes"
   ;;
   esac
@@ -105,10 +109,6 @@ if [ "$show_help" = "yes" ]; then
   echo "                           available: $platform_list"
   echo "  --sound-drivers=LIST     sound output drivers [guessed]"
   echo "                           available: $sound_driver_list"
-  echo "  --enable-neon"
-  echo "  --disable-neon           enable/disable ARM NEON optimizations [guessed]"
-  echo "  --disable-dynarec        disable dynamic recompiler"
-  echo "                           (dynarec is only available and enabled on ARM)"
   echo "influential environment variables:"
   echo "  CROSS_COMPILE CC CXX AS CFLAGS ASFLAGS LDFLAGS LDLIBS"
   exit 1
@@ -158,6 +158,10 @@ arm*)
     CFLAGS="$CFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s"
     ASFLAGS="$ASFLAGS -mcpu=arm926ej-s -mfloat-abi=softfp"
   fi
+  if [ "$optimize_arm920" = "yes" ]; then
+    CFLAGS="$CFLAGS -mcpu=arm920t -mtune=arm920t"
+    ASFLAGS="$ASFLAGS -mcpu=arm920t -mfloat-abi=soft"
+  fi
 
   if [ "x$have_arm_neon" = "x" ]; then
     # detect NEON from user-supplied cflags to enable asm code
@@ -202,7 +206,7 @@ arm*)
   fi
 
   # warn about common mistakes
-  if [ "$have_armv5" != "yes" ]; then
+  if [ "$platform" != "gp2x" -a "$have_armv5" != "yes" ]; then
     if ! echo "$CFLAGS" | grep -q -- '-mcpu=\|-march='; then
       echo "Warning: compiling for ARMv4, is that really what you want?"
       echo "You probably should specify -mcpu= or -march= like this:"
@@ -216,8 +220,6 @@ arm*)
   fi
   ;;
 *)
-  # dynarec only available on ARM
-  enable_dynarec="no"
   ;;
 esac
 
@@ -243,7 +245,8 @@ check_libpng()
   #include <png.h>
   void main() { png_init_io(0, 0); }
 EOF
-  compile_binary
+#  compile_binary
+  compile_object
 }
 
 check_oss()
@@ -315,7 +318,7 @@ else
   fi
   if echo $sound_drivers | grep -q "\<alsa\>"; then
     MAIN_LDLIBS="-lasound $MAIN_LDLIBS"
-    check_alsa || fail "please install libasound2-dev"
+    check_alsa -lasound || fail "please install libasound2-dev"
   fi
 fi
 
@@ -324,7 +327,7 @@ if [ "$need_sdl" = "yes" ]; then
     fail "sdl-config is missing; please install libsdl (libsdl1.2-dev)"
   CFLAGS="$CFLAGS `sdl-config --cflags`"
   MAIN_LDLIBS="`sdl-config --libs` $MAIN_LDLIBS"
-  check_sdl || fail "please install libsdl (libsdl1.2-dev)"
+  check_sdl `sdl-config --libs` || fail "please install libsdl (libsdl1.2-dev)"
 fi
 
 cat > $TMPC <<EOF
@@ -337,7 +340,6 @@ fi
 # set things that failed to autodetect to "no"
 test "x$have_armv6" != "x" || have_armv6="no"
 test "x$have_armv7" != "x" || have_armv7="no"
-test "x$have_arm_neon" != "x" || have_arm_neon="no"
 test "x$have_libavcodec" != "x" || have_libavcodec="no"
 
 echo "architecture        $ARCH"
@@ -348,9 +350,7 @@ echo "C compiler flags    $CFLAGS"
 echo "libraries           $MAIN_LDLIBS"
 echo "linker flags        $LDFLAGS"
 echo "libavcodec (mp3)    $have_libavcodec"
-echo "enable dynarec      $enable_dynarec"
 # echo "ARMv7 optimizations $have_armv7"
-# echo "enable ARM NEON     $have_arm_neon"
 
 echo "# Automatically generated by configure" > $config_mak
 printf "# Configured with:" >> $config_mak
@@ -372,11 +372,14 @@ echo "SOUND_DRIVERS = $sound_drivers" >> $config_mak
 if [ "$have_libavcodec" = "yes" ]; then
   echo "HAVE_LIBAVCODEC = 1" >> $config_mak
 fi
-if [ "$have_arm_neon" = "yes" ]; then
-  echo "HAVE_NEON = 1" >> $config_mak
-fi
-if [ "$enable_dynarec" = "yes" ]; then
-  echo "USE_DYNAREC = 1" >> $config_mak
+
+# GP2X toolchains are too old for UAL asm,
+# so add this here to not litter main Makefile
+if [ "$platform" = "g1p2x" ]; then
+  echo >> $config_mak
+  echo "%.o: %.S" >> $config_mak
+  echo "        $(CC) $(CFLAGS) -E -c $^ -o /tmp/$(notdir $@).s" >> $config_mak
+  echo "        $(AS) $(ASFLAGS) /tmp/$(notdir $@).s -o $@" >> $config_mak
 fi
 
 # use pandora's skin (for now)