$NetBSD: patch-aa,v 1.20 2015/01/21 18:15:17 adam Exp $

Add support for DragonFly.
Use 'amd64' as a synonym for 'x86_64'.
Avoid endian test failure for -flto.
Do not force compiler optimisations.

--- configure.orig	2014-11-28 21:45:04.000000000 +0000
+++ configure
@@ -516,6 +516,10 @@ case $host_os in
         SYS="FREEBSD"
         libm="-lm"
         ;;
+    dragonfly*)
+        SYS="DRAGONFLY"
+        LDFLAGS="$LDFLAGS -lm"
+        ;;
     kfreebsd*-gnu)
         SYS="FREEBSD"
         define HAVE_MALLOC_H
@@ -639,7 +643,7 @@ case $host_cpu in
             ASFLAGS="$ASFLAGS -f elf"
         fi
         ;;
-    x86_64)
+    x86_64|amd64)
         ARCH="X86_64"
         AS="yasm"
         AS_EXT=".asm"
@@ -662,14 +666,15 @@ case $host_cpu in
         fi
         ;;
     powerpc|powerpc64)
-        ARCH="PPC"
         if [ $asm = auto ] ; then
             define HAVE_ALTIVEC
             AS="${AS-${CC}}"
             AS_EXT=".c"
             if [ $SYS = MACOSX ] ; then
+                ARCH="POWERPC"
                 CFLAGS="$CFLAGS -faltivec -fastf -mcpu=G4"
             else
+                ARCH="PPC"
                 CFLAGS="$CFLAGS -maltivec -mabi=altivec"
                 define HAVE_ALTIVEC_H
             fi
@@ -817,7 +822,7 @@ ASFLAGS="$ASFLAGS -DSTACK_ALIGNMENT=$sta
 # skip endianness check for Intel Compiler and MSVS, as all supported platforms are little. each have flags that will cause the check to fail as well
 if [ $compiler = GNU ]; then
     echo "int i[2] = {0x42494745,0}; double f[2] = {0x1.0656e6469616ep+102,0};" > conftest.c
-    $CC $CFLAGS conftest.c -c -o conftest.o 2>/dev/null || die "endian test failed"
+    $CC $CPPFLAGS conftest.c -c -o conftest.o 2>/dev/null || die "endian test failed"
     if (${cross_prefix}strings -a conftest.o | grep -q BIGE) && (${cross_prefix}strings -a conftest.o | grep -q FPendian) ; then
         define WORDS_BIGENDIAN
     elif !(${cross_prefix}strings -a conftest.o | grep -q EGIB && ${cross_prefix}strings -a conftest.o | grep -q naidnePF) ; then
@@ -830,7 +835,7 @@ fi
 # pthread-win32 is lgpl, prevent its use if --disable-gpl is specified and targeting windows
 [ "$SYS" = "WINDOWS" -a "$gpl" = "no" -a "$thread" = "auto" ] && thread="win32"
 
-libpthread=""
+libpthread="$PTHREAD_LDFLAGS $PTHREAD_LIBS"
 if [ "$thread" = "auto" ]; then
     thread="no"
     case $SYS in
@@ -1044,10 +1049,11 @@ fi
 cc_check "stdint.h" "" "uint32_t test_vec __attribute__ ((vector_size (16))) = {0,1,2,3};" && define HAVE_VECTOREXT
 
 if [ "$pic" = "yes" ] ; then
-    CFLAGS="$CFLAGS -fPIC"
+    CFLAGS="$CFLAGS"
+    PICFLAG="-prefer-pic"
     ASFLAGS="$ASFLAGS -DPIC"
     # resolve textrels in the x86 asm
-    cc_check stdio.h "-shared -Wl,-Bsymbolic" && SOFLAGS="$SOFLAGS -Wl,-Bsymbolic"
+    cc_check stdio.h "-Wl,-Bsymbolic" && LDFLAGS="$LDFLAGS -Wl,-Bsymbolic"
     [ $SYS = SunOS -a "$ARCH" = "X86" ] && SOFLAGS="$SOFLAGS -mimpure-text"
 fi
 
@@ -1061,8 +1067,6 @@ fi
 
 if [ "$debug" = "yes" ]; then
     CFLAGS="-O1 -g $CFLAGS"
-else
-    CFLAGS="-O3 -ffast-math $CFLAGS"
 fi
 
 if cc_check '' -fno-tree-vectorize ; then
@@ -1154,7 +1158,7 @@ else # gcc/icc
     DEPMM="$DEPMM -g0"
     AR="$AR rc "
     LD="$CC -o "
-    LIBX264=libx264.a
+    LIBX264=libx264.la
     [ -n "$RC" ] && RCFLAGS="$RCFLAGS -I. -o "
 fi
 [ $compiler != GNU ] && CFLAGS="$(cc_cflags $CFLAGS)"
