--- Makefile.orig	2009-04-22 20:54:48.000000000 +0200
+++ Makefile	2009-12-08 11:38:10.000000000 +0100
@@ -521,15 +521,22 @@
 
 ifeq ($(PLATFORM),freebsd)
 
-  ifneq (,$(findstring alpha,$(shell uname -m)))
-    ARCH=axp
-  else #default to i386
-    ARCH=i386
-  endif #alpha test
-
-
-  BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \
-    -DUSE_ICON $(shell sdl-config --cflags)
+   ifndef HOMEPATH
+     HOMEPATH = /.ioquake3
+   endif
+ 
+   ifndef DEFAULT_LIBDIR
+     DEFAULT_LIBDIR = /usr/local/lib/ioquake3
+   endif
+ 
+   BASE_CFLAGS = $(shell env MACHINE_ARCH=$(ARCH) make -f /dev/null -VCFLAGS) \
+     -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \
+     -DUSE_ICON -DMAP_ANONYMOUS=MAP_ANON \
+     -DHOMEPATH=\\\"$(HOMEPATH)\\\" \
+     -DDEFAULT_LIBDIR=\\\"$(DEFAULT_LIBDIR)\\\"
+   CLIENT_CFLAGS = $(SDL_CFLAGS)
+   SERVER_CFLAGS = 
+   HAVE_VM_COMPILED = true
 
   ifeq ($(USE_OPENAL),1)
     BASE_CFLAGS += -DUSE_OPENAL
@@ -542,24 +549,6 @@
     BASE_CFLAGS += -DUSE_CODEC_VORBIS
   endif
 
-  ifeq ($(ARCH),axp)
-    BASE_CFLAGS += -DNO_VM_COMPILED
-    RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 -ffast-math -funroll-loops \
-      -fomit-frame-pointer -fexpensive-optimizations
-  else
-  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
-    HAVE_VM_COMPILED=true
-  else
-    BASE_CFLAGS += -DNO_VM_COMPILED
-  endif
-  endif
-
-  DEBUG_CFLAGS=$(BASE_CFLAGS) -g
-
   SHLIBEXT=so
   SHLIBCFLAGS=-fPIC
   SHLIBLDFLAGS=-shared $(LDFLAGS)
@@ -582,6 +571,27 @@
     CLIENT_LIBS += -lvorbisfile -lvorbis -logg
   endif
 
+  ifeq ($(ARCH),i386)
+    ifeq ($(CROSS_COMPILING),1)
+      BASE_CFLAGS += -m32
+    endif
+  endif
+  ifeq ($(ARCH),amd64)
+    ifeq ($(CROSS_COMPILING),1)
+      BASE_CFLAGS += -m64
+    endif
+  endif
+
+  ifeq ($(BUILD_CLIENT),1)
+    BASE_CFLAGS += $(CLIENT_CFLAGS)
+  endif
+
+  RELEASE_CFLAGS = $(BASE_CFLAGS) -DNDEBUG -O3 -fomit-frame-pointer \
+    -ffast-math -falign-loops=2 -falign-jumps=2 -falign-functions=2 \
+    -funroll-loops -fstrength-reduce
+
+  DEBUG_CFLAGS = $(BASE_CFLAGS) -g
+
 else # ifeq freebsd
 
 #############################################################################
@@ -1442,6 +1452,9 @@
   ifeq ($(ARCH),x86_64)
     Q3OBJ += $(B)/client/vm_x86_64.o $(B)/client/vm_x86_64_assembler.o
   endif
+  ifeq ($(ARCH),amd64)
+    Q3OBJ += $(B)/client/vm_x86_64.o $(B)/client/vm_x86_64_assembler.o
+  endif
   ifeq ($(ARCH),ppc)
     Q3OBJ += $(B)/client/vm_powerpc.o $(B)/client/vm_powerpc_asm.o
   endif
@@ -1591,6 +1604,9 @@
   ifeq ($(ARCH),x86_64)
     Q3DOBJ += $(B)/ded/vm_x86_64.o $(B)/ded/vm_x86_64_assembler.o
   endif
+  ifeq ($(ARCH),amd64)
+    Q3DOBJ += $(B)/ded/vm_x86_64.o $(B)/ded/vm_x86_64_assembler.o
+  endif
   ifeq ($(ARCH),ppc)
     Q3DOBJ += $(B)/ded/vm_powerpc.o $(B)/ded/vm_powerpc_asm.o
   endif
