$NetBSD: patch-aa,v 1.22 2016/01/24 14:34:11 ryoon 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	2016-01-23 21:45:04.000000000 +0000
+++ configure
@@ -578,6 +578,10 @@ case $host_os in
         SYS="FREEBSD"
         libm="-lm"
         ;;
+    dragonfly*)
+        SYS="DRAGONFLY"
+        LDFLAGS="$LDFLAGS -lm"
+        ;;
     kfreebsd*-gnu)
         SYS="FREEBSD"
         define HAVE_MALLOC_H
@@ -678,7 +682,7 @@ case $host_cpu in
             ASFLAGS="$ASFLAGS -f elf32"
         fi
         ;;
-    x86_64)
+    x86_64|amd64)
         ARCH="X86_64"
         AS="${AS-yasm}"
         AS_EXT=".asm"
@@ -702,14 +706,15 @@ case $host_cpu in
         fi
         ;;
     powerpc*)
-        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
@@ -891,7 +896,7 @@ ASFLAGS="$ASFLAGS -DSTACK_ALIGNMENT=$sta
 CPU_ENDIAN="little-endian"
 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
         CPU_ENDIAN="big-endian"
@@ -913,7 +918,7 @@ fi
 
 # autodetect options that weren't forced nor disabled
 
-libpthread=""
+libpthread="$PTHREAD_LDFLAGS $PTHREAD_LIBS"
 if [ "$SYS" = "WINDOWS" -a "$thread" = "posix" ] ; then
     if [ "$gpl" = "no" ] ; then
         echo "Warning: pthread-win32 is LGPL and is therefore not supported with --disable-gpl"
@@ -1124,10 +1129,10 @@ fi
 cc_check "stdint.h" "" "uint32_t test_vec __attribute__ ((vector_size (16))) = {0,1,2,3};" && define HAVE_VECTOREXT
 
 if [ "$pic" = "yes" ] ; then
-    [ "$SYS" != WINDOWS -a "$SYS" != CYGWIN ] && CFLAGS="$CFLAGS -fPIC"
+    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
 
@@ -1141,8 +1146,6 @@ fi
 
 if [ "$debug" = "yes" ]; then
     CFLAGS="-O1 -g $CFLAGS"
-else
-    CFLAGS="-O3 -ffast-math $CFLAGS"
 fi
 
 if cc_check '' -fno-tree-vectorize ; then
@@ -1271,7 +1274,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)"
