--- src/Makefile.orig	2007-03-18 20:05:34.000000000 +0100
+++ src/Makefile	2009-09-16 17:49:40.000000000 +0200
@@ -1,8 +1,8 @@
-# Makefile for numlua
+# Makefile for numlua
 # $Id: Makefile,v 1.8 2006-09-11 02:25:38 carvalho Exp $
 
-# linux | win32
-TARGET = linux
+# linux | win32 | darwin
+TARGET = darwin
 
 # atlas | atlas_threaded | blas | custom
 BLAS = custom
@@ -13,13 +13,13 @@
 # Intel's MKL
 #CUSTOMBLAS = -L/opt/intel/mkl/8.0/lib/32 -lmkl_lapack -lmkl_ia32 -lguide -lpthread -lg2c
 # Ubuntu with atlas
-CUSTOMBLAS = -llapack -lblas -lg2c
+CUSTOMBLAS = -faltivec -framework Accelerate -lm -lgfortran
 
 # change LUADIR below to where lua is installed, that is, INSTALL_TOP in lua's
 # main Makefile
-LUADIR = /usr
+LUADIR = @PREFIX@
 
-CC = gcc
+CC = MACOSX_DEPLOYMENT_TARGET="10.3" gcc-mp-4.3
 CFLAGS = -W -Wall -pedantic -fshort-enums
 OPTFLAGS = -fomit-frame-pointer -O2
 
@@ -45,6 +45,10 @@
 endif
 ifeq ($(TARGET), win32)
 LIBS += -L$(LUADIR)/lib -llua
+else
+  ifeq ($(TARGET), darwin)
+LIBS += -L$(LUADIR)/lib -llua
+  endif
 endif
 
 OBJ = luaspfun.o luarng.o luacomplex.o
@@ -56,22 +60,36 @@
 DLIB = $(LIB:.a=.so)
 LMDLIB = $(LMLIB:.a=.so)
 else
+  ifeq ($(TARGET), win32)
 DLIB = $(LIB:.a=.dll)
 LMDLIB = $(LMLIB:.a=.dll)
+  else
+DLIB = $(LIB:.a=.so)
+LMDLIB = $(LMLIB:.a=.so)
+  endif
 endif
 
 OBJFLAGS = -I$(LUADIR)/include/lua5.1
 ifeq ($(TARGET), linux)
 LDFLAGS = -fpic
 endif
+ifeq ($(TARGET), darwin)
+LDFLAGS += -bundle -undefined dynamic_lookup
+else
 LDFLAGS += -shared
+endif
 
 all : $(LIB) $(LMLIB) $(DLIB) $(LMDLIB)
 
 ifeq ($(TARGET), linux)
 $(DLIB) : %.so : %.o
 else
+  ifeq ($(TARGET), win32)
 $(DLIB) : %.dll : %.o
+  else
+$(DLIB) : %.so : %.o
+  endif
+
 endif
 	$(CC) $(CFLAGS) $< $(LDFLAGS) -o $@ $(LIBS)
 #	$(STRIP) $@
