diff --git a/configure b/configure
index 53afe7c18d9ce8dd59b9c49b52cda5e733106daf..dc20f6e8bb175ca53fbae59d1f53de6bafdc63b0 100755
--- a/configure
+++ b/configure
@@ -419,6 +419,17 @@ if test $tune != "generic"; then
     esac
 fi
 
+# AltiVec flags: The FSF version of GCC differs from the Darwin version 
+if test $cpu = "powerpc"; then
+    if test $altivec = "yes"; then
+        if test "$darwin" = "yes"; then
+            CFLAGS="$CFLAGS -faltivec"
+        else
+            CFLAGS="$CFLAGS -maltivec -mabi=altivec"
+        fi
+    fi
+fi
+
 # See if we have <altivec.h>
 cat > $TMPC << EOF
 #include <altivec.h>
@@ -426,7 +437,7 @@ int main( void ) { return 0; }
 EOF
 
 _altivec_h="no"
-if $cc -o $TMPE $TMPC 2> /dev/null ; then
+if $cc $CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
 _altivec_h="yes"
 fi
 
@@ -450,11 +461,7 @@ int main(void) {
 }
 EOF
 fi
-if test "$darwin" = "yes"; then
-$cc -o $TMPE $TMPC -faltivec 2> /dev/null || altivec="no"
-else
-$cc -o $TMPE $TMPC -maltivec -mabi=altivec 2> /dev/null || altivec="no"
-fi
+$cc $CFLAGS -o $TMPE $TMPC 2> /dev/null || altivec="no"
 fi
 
 # Can only do mmi on mips
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index de2b970f188215d6bba40613a1ab600739c13992..1d90426d76023cbd6ce290eb1f694618c02edaa0 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -127,11 +127,6 @@ OBJS += ps2/dsputil_mmi.o ps2/idct_mmi.o ps2/mpegvideo_mmi.o
 endif
 
 ifeq ($(TARGET_ALTIVEC),yes)
-ifeq ($(TARGET_OS),Darwin)
-CFLAGS += -faltivec
-else
-CFLAGS += -maltivec -mabi=altivec
-endif
 OBJS += ppc/dsputil_altivec.o ppc/mpegvideo_altivec.o ppc/idct_altivec.o \
         ppc/fft_altivec.o ppc/gmc_altivec.o
 endif