--- a/src/Makefile_unix
+++ b/src/Makefile_unix
@@ -1,9 +1,30 @@
-# Use GNU Make to process this file
+# To run this makefile, you must provide the ARCH and MATLABROOT
+# variables on the command line, i.e. as in
 #
-# REAMRK: No dependency is resolved here!
+# make -f Makefile_unix MATLABROOT=/usr/local/MATLAB/R2011a ARCH=glnxa64
+
+ifndef MATLABROOT
+  $(warning MATLABROOT variable is udefined. Using default MATLABROOT="/usr/local/MATLAB/R2011a/")
+  MATLABROOT=/usr/local/MATLAB/R2011a/
+endif
+
+ifndef ARCH
+  $(warning ARCH variable is udefined. Using default ARCH=glnxa64 )
+  ARCH=glnxa64
+endif
+
+ifndef DFFTW
+   DFFTW=-lfftw3
+endif
+
+ifndef SFFTW
+   SFFTW=-lfftw3f
+endif
 
 
 CFLAGS=-O3 -fPIC -std=c99 -Ithirdparty 
+SHARED_FLAGS=-shared -Wl,--no-undefined -lc -lm -L"$(MATLABROOT)/bin/$(ARCH)" \
+			 -lmwblas -lmwlapack $(DFFTW) $(SFFTW)
 
 include filedefs.mk
 
@@ -12,10 +33,12 @@
 DFILES = $(addprefix d,$(toCompile)) $(files_notypechange)
 SFILES = $(addprefix s,$(toCompile))
 
-#files_unix = $(addprefix d,$(toCompile)) $(addprefix s,$(toCompile)) $(files_notypechange)
-#files_matlab = $(files) $(files_blaslapack) dltfat_blaslapack_matlab.o sltfat_blaslapack_matlab.o
 
-all: double_static single_static
+all: static
+
+static: double_static single_static
+
+shared: double_shared single_shared
 
 double_static: $(DFILES) Makefile_unix
 	ar rvu libltfat.a $(DFILES) 
@@ -28,12 +51,10 @@
 	cp -f libltfatf.a ../lib
 
 double_shared: $(DFILES) Makefile_unix
-	$(CC) -shared $(DFILES) -o libltfat.so
-	cp -f libltfat.so ../lib
+	$(CC) $(SHARED_FLAGS) $(DFILES) -o ../lib/libltfat.so
 
 single_shared: $(SFILES) Makefile_unix
-	$(CC) -shared $(SFILES) -o libltfatf.so
-	cp -f libltfatf.so ../lib
+	$(CC) $(SHARED_FLAGS) $(SFILES) -o ../lib/libltfatf.so
 
 sltfat_blaslapack_matlab.o: ltfat_blaslapack.c config.h
 	$(CC) $(CFLAGS) -DLTFAT_SINGLE -DMATLABFORTRAN -c $< -o $*.o