#Copyright 2001,2002 Matt Flax <flatmax@ieee.org>
#This file is part of the MFFM FFTw Wrapper library.
#
#MFFM MFFM FFTw Wrapper library is free software; you can 
#redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#MFFM FFTw Wrapper library is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You have received a copy of the GNU General Public License
#along with the MFFM FFTw Wrapper library

LIB     = $(DESTDIR)/usr/lib
INC     = $(DESTDIR)/usr/include/mffm
DOCS     = $(DESTDIR)/usr/share/doc/mffm-fftw-dev

CC=g++ -O3
.cc.o:
	$(CC) -fPIC -c $<
.C.o:
	$(CC) -fPIC -c $<
MAKELIB=$(CC) -shared -Wl,-soname
#EXAMPLES= complexFFTExample real2DFFTExample realFFTExample
SRC= realFFT.cc realFFTData.cc complexFFT.cc
SRC2D= real2DFFT.cc
OBJ=$(SRC:.cc=.o)
OBJ2D=$(SRC2D:.cc=.o)

all: $(OBJ) \
	$(OBJ2D) \
	libs \
	docs \
	ex

docs:
	doxygen

libs:
	$(MAKELIB),libfft.so.1 -o libfft.so.1 $(OBJ)
	$(MAKELIB),lib2Dfft.so.1 -o lib2Dfft.so.1 $(OBJ2D)

ex:
#fftw V2
#	$(CC) *.o -lrfftw -lfftw complexFFTExample.cc -o complexFFTExample
#	$(CC) *.o -lrfftw -lfftw real2DFFTExample.cc -o real2DFFTExample
#	$(CC) *.o -lrfftw -lfftw realFFTExample.cc -o realFFTExample
#fftw V3
#	$(CC) *.o -lfftw3 complexFFTExample.cc -o complexFFTExample
#	$(CC) *.o -lfftw3 real2DFFTExample.cc -o real2DFFTExample
#	$(CC) *.o -lfftw3 realFFTExample.cc -o realFFTExample

install: $(OBJ) \
	$(OBJ2D) \
	libs \
	docs
	install --directory $(LIB) $(INC) $(DOCS)/html $(DOCS)/examples
	install lib* $(LIB)
	install -m 644 *.H $(INC)
	install html/* $(DOCS)/html
	install -m 644 complexFFTExample.cc real2DFFTExample.cc realFFTExample.cc sine.1000Hz.dat $(DOCS)/examples

clean:
	rm -f $(EXAMPLES) *.o a.out *~ *.txt lib*.so.* complexFFTExample realFFTExample real2DFFTExample


