$NetBSD: patch-ac,v 1.3 2013/10/28 23:45:59 joerg Exp $

--- Makefile.orig	2009-04-22 18:54:48.000000000 +0000
+++ Makefile
@@ -261,16 +261,13 @@ ifeq ($(PLATFORM),linux)
   OPTIMIZE = -O3 -ffast-math -funroll-loops -fomit-frame-pointer
 
   ifeq ($(ARCH),x86_64)
-    OPTIMIZE = -O3 -fomit-frame-pointer -ffast-math -funroll-loops \
-      -falign-loops=2 -falign-jumps=2 -falign-functions=2 \
-      -fstrength-reduce
+    OPTIMIZE = -O3 -fomit-frame-pointer -ffast-math -funroll-loops
     # experimental x86_64 jit compiler! you need GNU as
     HAVE_VM_COMPILED = true
   else
   ifeq ($(ARCH),i386)
     OPTIMIZE = -O3 -march=i586 -fomit-frame-pointer -ffast-math \
-      -funroll-loops -falign-loops=2 -falign-jumps=2 \
-      -falign-functions=2 -fstrength-reduce
+      -funroll-loops
     HAVE_VM_COMPILED=true
   else
   ifeq ($(ARCH),ppc)
@@ -457,10 +454,7 @@ ifeq ($(PLATFORM),mingw32)
     BASE_CFLAGS += -DUSE_CODEC_VORBIS
   endif
 
-  OPTIMIZE = -O3 -march=i586 -fno-omit-frame-pointer -ffast-math \
-    -falign-loops=2 -funroll-loops -falign-jumps=2 -falign-functions=2 \
-    -fstrength-reduce
-
+  OPTIMIZE = -O3 -march=i586 -fno-omit-frame-pointer -ffast-math
   HAVE_VM_COMPILED = true
 
   SHLIBEXT=dll
@@ -550,8 +544,7 @@ ifeq ($(PLATFORM),freebsd)
   ifeq ($(ARCH),i386)
     RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 -mtune=pentiumpro \
       -march=pentium -fomit-frame-pointer -pipe -ffast-math \
-      -falign-loops=2 -falign-jumps=2 -falign-functions=2 \
-      -funroll-loops -fstrength-reduce
+      -funroll-loops
     HAVE_VM_COMPILED=true
   else
     BASE_CFLAGS += -DNO_VM_COMPILED
@@ -611,8 +604,7 @@ ifeq ($(PLATFORM),openbsd)
   BASE_CFLAGS += -DNO_VM_COMPILED -I/usr/X11R6/include -I/usr/local/include
   RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 \
     -march=pentium -fomit-frame-pointer -pipe -ffast-math \
-    -falign-loops=2 -falign-jumps=2 -falign-functions=2 \
-    -funroll-loops -fstrength-reduce
+    -funroll-loops
   HAVE_VM_COMPILED=false
 
   DEBUG_CFLAGS=$(BASE_CFLAGS) -g
@@ -648,28 +640,211 @@ ifeq ($(PLATFORM),netbsd)
 
   ifeq ($(shell uname -m),i386)
     ARCH=i386
+  else
+  ifeq ($(shell uname -m),amd64)
+    ARCH=x86_64
+  endif
+  endif
+
+  USE_MUMBLE=0
+
+  BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \
+    -pipe -DUSE_ICON $(shell sdl-config --cflags)
+
+  ifeq ($(USE_OPENAL),1)
+    BASE_CFLAGS += -DUSE_OPENAL
+    ifeq ($(USE_OPENAL_DLOPEN),1)
+      BASE_CFLAGS += -DUSE_OPENAL_DLOPEN
+    endif
+  endif
+
+  ifeq ($(USE_CURL),1)
+    BASE_CFLAGS += -DUSE_CURL
+    ifeq ($(USE_CURL_DLOPEN),1)
+      BASE_CFLAGS += -DUSE_CURL_DLOPEN
+    endif
+  endif
+
+  ifeq ($(USE_CODEC_VORBIS),1)
+    BASE_CFLAGS += -DUSE_CODEC_VORBIS
+  endif
+
+  OPTIMIZE = -O3 -ffast-math -funroll-loops -fomit-frame-pointer
+
+  ifeq ($(ARCH),x86_64)
+    OPTIMIZE = -O3 -fomit-frame-pointer -ffast-math -funroll-loops
+    # experimental x86_64 jit compiler! you need GNU as
+    HAVE_VM_COMPILED = true
+  else
+  ifeq ($(ARCH),i386)
+    OPTIMIZE = -O3 -march=i586 -fomit-frame-pointer -ffast-math \
+      -funroll-loops
+    HAVE_VM_COMPILED=true
+  else
+  ifeq ($(ARCH),ppc)
+    BASE_CFLAGS += -maltivec
+    HAVE_VM_COMPILED=true
+  endif
+  ifeq ($(ARCH),ppc64)
+    BASE_CFLAGS += -maltivec
+    HAVE_VM_COMPILED=true
+  endif
+  endif
+  endif
+
+  ifneq ($(HAVE_VM_COMPILED),true)
+    BASE_CFLAGS += -DNO_VM_COMPILED
   endif
 
-  LIBS=-lm
   SHLIBEXT=so
   SHLIBCFLAGS=-fPIC
   SHLIBLDFLAGS=-shared $(LDFLAGS)
+
   THREAD_LIBS=-lpthread
+  LIBS=-lm
 
-  BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes
+  CLIENT_LIBS=$(shell sdl-config --libs) -lGL
 
-  ifneq ($(ARCH),i386)
-    BASE_CFLAGS += -DNO_VM_COMPILED
+  ifeq ($(USE_OPENAL),1)
+    ifneq ($(USE_OPENAL_DLOPEN),1)
+      CLIENT_LIBS += -lopenal
+    endif
   endif
 
-  DEBUG_CFLAGS=$(BASE_CFLAGS) -g
+  ifeq ($(USE_CURL),1)
+    ifneq ($(USE_CURL_DLOPEN),1)
+      CLIENT_LIBS += -lcurl
+    endif
+  endif
 
-  BUILD_CLIENT = 0
-  BUILD_GAME_QVM = 0
+  ifeq ($(USE_CODEC_VORBIS),1)
+    CLIENT_LIBS += -lvorbisfile -lvorbis -logg
+  endif
+
+  ifeq ($(USE_MUMBLE),1)
+    CLIENT_LIBS += -lrt
+  endif
+
+  ifeq ($(USE_LOCAL_HEADERS),1)
+    BASE_CFLAGS += -I$(SDLHDIR)/include
+  endif
+
+  ifeq ($(ARCH),i386)
+    # linux32 make ...
+    BASE_CFLAGS += -m32
+  else
+  ifeq ($(ARCH),ppc64)
+    BASE_CFLAGS += -m64
+  endif
+  endif
+
+  DEBUG_CFLAGS = $(BASE_CFLAGS) -g -O0
+  RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG $(OPTIMIZE)
 
 else # ifeq netbsd
 
 #############################################################################
+# SETUP AND BUILD -- DRAGONFLY
+#############################################################################
+
+ifeq ($(PLATFORM),dragonfly)
+
+  ifeq ($(shell uname -m),i386)
+    ARCH=i386
+  else
+  ifeq ($(shell uname -m),amd64)
+    ARCH=x86_64
+  endif
+  endif
+
+  USE_MUMBLE=0
+
+  BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \
+    -pipe -DUSE_ICON $(shell sdl-config --cflags)
+
+  ifeq ($(USE_OPENAL),1)
+    BASE_CFLAGS += -DUSE_OPENAL
+    ifeq ($(USE_OPENAL_DLOPEN),1)
+      BASE_CFLAGS += -DUSE_OPENAL_DLOPEN
+    endif
+  endif
+
+  ifeq ($(USE_CURL),1)
+    BASE_CFLAGS += -DUSE_CURL
+    ifeq ($(USE_CURL_DLOPEN),1)
+      BASE_CFLAGS += -DUSE_CURL_DLOPEN
+    endif
+  endif
+
+  ifeq ($(USE_CODEC_VORBIS),1)
+    BASE_CFLAGS += -DUSE_CODEC_VORBIS
+  endif
+
+  OPTIMIZE = -O3 -ffast-math -funroll-loops -fomit-frame-pointer
+
+  ifeq ($(ARCH),x86_64)
+    OPTIMIZE = -O3 -fomit-frame-pointer -ffast-math -funroll-loops
+    # experimental x86_64 jit compiler! you need GNU as
+    HAVE_VM_COMPILED = true
+  else
+  ifeq ($(ARCH),i386)
+    OPTIMIZE = -O3 -march=i586 -fomit-frame-pointer -ffast-math \
+      -funroll-loops
+    HAVE_VM_COMPILED=true
+  endif
+  endif
+
+  ifneq ($(HAVE_VM_COMPILED),true)
+    BASE_CFLAGS += -DNO_VM_COMPILED
+  endif
+
+  SHLIBEXT=so
+  SHLIBCFLAGS=-fPIC
+  SHLIBLDFLAGS=-shared $(LDFLAGS)
+
+  THREAD_LIBS=-lpthread
+  LIBS=-lm
+  CLIENT_LIBS = $(shell sdl-config --libs) -lGL
+
+  ifeq ($(USE_OPENAL),1)
+    ifneq ($(USE_OPENAL_DLOPEN),1)
+      CLIENT_LIBS += -lopenal
+    endif
+  endif
+
+  ifeq ($(USE_CURL),1)
+    ifneq ($(USE_CURL_DLOPEN),1)
+      CLIENT_LIBS += -lcurl
+    endif
+  endif
+
+  ifeq ($(USE_CODEC_VORBIS),1)
+    CLIENT_LIBS += -lvorbisfile -lvorbis -logg
+  endif
+
+  ifeq ($(USE_MUMBLE),1)
+    CLIENT_LIBS += -lrt
+  endif
+
+  ifeq ($(USE_LOCAL_HEADERS),1)
+    BASE_CFLAGS += -I$(SDLHDIR)/include
+  endif
+
+  ifeq ($(ARCH),i386)
+    # linux32 make ...
+    BASE_CFLAGS += -m32
+  else
+  ifeq ($(ARCH),ppc64)
+    BASE_CFLAGS += -m64
+  endif
+  endif
+
+  DEBUG_CFLAGS = $(BASE_CFLAGS) -g -O0
+  RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG $(OPTIMIZE)
+
+else # ifeq dragonfly
+
+#############################################################################
 # SETUP AND BUILD -- IRIX
 #############################################################################
 
@@ -727,14 +902,12 @@ ifeq ($(PLATFORM),sunos)
 
   ifeq ($(ARCH),sparc)
     OPTIMIZE = -O3 -ffast-math \
-      -fstrength-reduce -falign-functions=2 \
       -mtune=ultrasparc3 -mv8plus -mno-faster-structs \
       -funroll-loops #-mv8plus
   else
   ifeq ($(ARCH),i386)
     OPTIMIZE = -O3 -march=i586 -fomit-frame-pointer -ffast-math \
-      -funroll-loops -falign-loops=2 -falign-jumps=2 \
-      -falign-functions=2 -fstrength-reduce
+      -funroll-loops
     HAVE_VM_COMPILED=true
     BASE_CFLAGS += -m32
     BASE_CFLAGS += -I/usr/X11/include/NVIDIA
@@ -780,6 +953,7 @@ endif #mingw32
 endif #FreeBSD
 endif #OpenBSD
 endif #NetBSD
+endif #DragonFly
 endif #IRIX
 endif #SunOS
 
