# Compile commands (replace the include paths corresponding to your own)
#JDK_HOME=/usr/lib/jvm/java-1.5.0-sun

DESTDIR=

# Note that the Makefile doesn't support building other platforms than your current

# ARCH=amd64
#
# arch :=  $(shell echo `/bin/arch`)
#
# ifeq (${arch},i686)
#    ARCH=i386
# endif 
LIBDIR=/usr/lib
#LIBDIR=/usr/lib64

# should be the same path as in the ant build.xml, property "build"
CLASSPATH=../../build

# I am not sure where this is meant to live.
# If you have not got it you will need to install fftw
#
# static link
#FFTW_LIB=$(LIBDIR)/libfftw3.a
# dynamic link
FFTW_LIB=`pkg-config --libs fftw3`
FFTW_INC=`pkg-config --variable=includedir fftw3`


all : jfftw3.h libjfftw3.so


jfftw3.h: ${CLASSPATH}/rasmus/fft/fftw/FFTW.class
	javah -classpath ${CLASSPATH} -o jfftw3.h rasmus.fft.fftw.FFTW


jfftw3.o : jfftw3.h jfftw3.cpp
	g++ $(CPPFLAGS) -fPIC -I $(JDK_HOME)/include/ -I $(JDK_HOME)/include/linux -I $(FFTW_INC) -c jfftw3.cpp


libjfftw3.so : jfftw3.o
	g++ $(CPPFLAGS) -shared -fPIC -o libjfftw3.so jfftw3.o ${FFTW_LIB}


# TODO
# Copies to the src folder - since the Java build uses the src folder to build the jar file
# and copy to the bin directory in case you forget to hit refresh.
install: libjfftw3.so
#	cp libjfftw.so ../../src/lib/$(ARCH)/linux/libjfftw.so
#	cp libjfftw.so ../../bin/lib/$(ARCH)/linux/libjfftw.so
#	cp libjfftw.so /usr/lib/libjfftw.so
	mkdir -p ${DESTDIR}%{LIBDIR}
	cp libjfftw3.so ${DESTDIR}%{LIBDIR}/libjfftw3.so


clean:
	rm -f jfftw3.o jfftw3.h libjfftw3.so
