Index: configure
===================================================================
--- configure	(revision 590)
+++ configure	(working copy)
@@ -64,8 +64,101 @@
 
 EXE=""
 
+AR="ar"
+AROPTS="rc"
+RANLIB="ranlib"
+
 MACHINE="$(./config.guess)"
 
+# parse options
+
+for opt do
+    optarg="${opt#*=}"
+    case "$opt" in
+	--crosscompile=*)
+            CROSS="$optarg"
+            CC="$CROSS-gcc"
+            AR="$CROSS-ar"
+            RANLIB="$CROSS-ranlib"
+            MACHINE="`echo $CROSS | sed -e 's/-/-x-/g'`"
+	    ;;
+        --prefix=*)
+            prefix="$optarg"
+            ;;
+        --exec-prefix=*)
+            exec_prefix="$optarg"
+            ;;
+        --bindir=*)
+            bindir="$optarg"
+            ;;
+        --libdir=*)
+            libdir="$optarg"
+            ;;
+        --includedir=*)
+            includedir="$optarg"
+            ;;
+        --enable-avis-input)
+            avis_input="yes"
+            ;;
+        --disable-avis-input)
+            avis_input="no"
+            ;;
+        --enable-mp4-output)
+            mp4_output="yes"
+            ;;
+        --disable-mp4-output)
+            mp4_output="no"
+            ;;
+        --extra-asflags=*)
+            ASFLAGS="$ASFLAGS ${opt#--extra-asflags=}"
+            ;;
+        --extra-cflags=*)
+            CFLAGS="$CFLAGS ${opt#--extra-cflags=}"
+            ;;
+        --extra-ldflags=*)
+            LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}"
+            ;;
+        --enable-pthread)
+            pthread="yes"
+            ;;
+        --disable-pthread)
+            pthread="no"
+            ;;
+        --enable-debug)
+            debug="yes"
+            ;;
+        --enable-gprof)
+            CFLAGS="$CFLAGS -pg"
+            LDFLAGS="$LDFLAGS -pg"
+            gprof="yes"
+            ;;
+        --enable-pic)
+            pic="yes"
+            ;;
+        --enable-gtk)
+            gtk="yes"
+            ;;
+        --disable-gtk)
+            gtk="no"
+            ;;
+        --enable-shared)
+            shared="yes"
+            if [ $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" ] ; then
+                pic="yes"
+            fi
+            ;;
+        --enable-visualize)
+            LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11"
+            CFLAGS="$CFLAGS -DVISUALIZE=1"
+            vis="yes"
+            ;;
+        *)
+            echo "Unknown option $opt, ignored"
+            ;;
+    esac
+done
+
+
 case "${MACHINE#*-*-}" in
   beos*)
     SYS="BEOS"
@@ -178,88 +271,6 @@
 esac
 
 CFLAGS="$CFLAGS -DARCH_$ARCH -DSYS_$SYS"
-
-# parse options
-
-for opt do
-    optarg="${opt#*=}"
-    case "$opt" in
-        --prefix=*)
-            prefix="$optarg"
-            ;;
-        --exec-prefix=*)
-            exec_prefix="$optarg"
-            ;;
-        --bindir=*)
-            bindir="$optarg"
-            ;;
-        --libdir=*)
-            libdir="$optarg"
-            ;;
-        --includedir=*)
-            includedir="$optarg"
-            ;;
-        --enable-avis-input)
-            avis_input="yes"
-            ;;
-        --disable-avis-input)
-            avis_input="no"
-            ;;
-        --enable-mp4-output)
-            mp4_output="yes"
-            ;;
-        --disable-mp4-output)
-            mp4_output="no"
-            ;;
-        --extra-asflags=*)
-            ASFLAGS="$ASFLAGS ${opt#--extra-asflags=}"
-            ;;
-        --extra-cflags=*)
-            CFLAGS="$CFLAGS ${opt#--extra-cflags=}"
-            ;;
-        --extra-ldflags=*)
-            LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}"
-            ;;
-        --enable-pthread)
-            pthread="yes"
-            ;;
-        --disable-pthread)
-            pthread="no"
-            ;;
-        --enable-debug)
-            debug="yes"
-            ;;
-        --enable-gprof)
-            CFLAGS="$CFLAGS -pg"
-            LDFLAGS="$LDFLAGS -pg"
-            gprof="yes"
-            ;;
-        --enable-pic)
-            pic="yes"
-            ;;
-        --enable-gtk)
-            gtk="yes"
-            ;;
-        --disable-gtk)
-            gtk="no"
-            ;;
-        --enable-shared)
-            shared="yes"
-            if [ $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" ] ; then
-                pic="yes"
-            fi
-            ;;
-        --enable-visualize)
-            LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11"
-            CFLAGS="$CFLAGS -DVISUALIZE=1"
-            vis="yes"
-            ;;
-        *)
-            echo "Unknown option $opt, ignored"
-            ;;
-    esac
-done
-
 # autodetect options that weren't forced nor disabled
 
 if test "$pthread" = "auto" ; then
@@ -349,6 +360,9 @@
 ASFLAGS=$ASFLAGS
 GTK=$gtk
 EXE=$EXE
+AR=$AR 
+AROPTS=$AROPTS 
+RANLIB=$RANLIB 
 VIS=$vis
 HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
 DEVNULL=$DEVNULL
Index: Makefile
===================================================================
--- Makefile	(revision 590)
+++ Makefile	(working copy)
@@ -66,8 +66,8 @@
 default: $(DEP) x264$(EXE)
 
 libx264.a: .depend $(OBJS) $(OBJASM)
-	ar rc libx264.a $(OBJS) $(OBJASM)
-	ranlib libx264.a
+	$(AR) rc libx264.a $(OBJS) $(OBJASM)
+	$(RANLIB) libx264.a
 
 $(SONAME): .depend $(OBJS) $(OBJASM)
 	$(CC) -shared -o $@ $(OBJS) $(OBJASM) -Wl,-soname,$(SONAME) $(LDFLAGS)
@@ -138,14 +138,14 @@
 	rm -f config.mak config.h x264.pc
 	$(MAKE) -C gtk distclean
 
-install: x264 $(SONAME)
+install: x264$(EXE)
 	install -d $(DESTDIR)$(bindir) $(DESTDIR)$(includedir)
 	install -d $(DESTDIR)$(libdir) $(DESTDIR)$(libdir)/pkgconfig
 	install -m 644 x264.h $(DESTDIR)$(includedir)
 	install -m 644 libx264.a $(DESTDIR)$(libdir)
 	install -m 644 x264.pc $(DESTDIR)$(libdir)/pkgconfig
-	install x264 $(DESTDIR)$(bindir)
-	ranlib $(DESTDIR)$(libdir)/libx264.a
+	install x264$(EXE) $(DESTDIR)$(bindir)
+	$(RANLIB) $(DESTDIR)$(libdir)/libx264.a
 	$(if $(SONAME), ln -sf $(SONAME) $(DESTDIR)$(libdir)/libx264.so)
 	$(if $(SONAME), install -m 755 $(SONAME) $(DESTDIR)$(libdir))
 
