# this is # ---------------------------------------------------------------------------- # $Id$ # # Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) # # Fourier coefficients library # # provide Fourier coefficients of filter responses etc. # # this library makes use of libtfxx # libtfxx must be installed first # # REVISIONS and CHANGES # 07/11/2002 V1.0 Thomas Forbriger # 05/01/2003 V1.1 uuuhhhhhh # had to resolve a specific problem: my library # procuded object files for Fortran code with the same # name of the object files of C++ code # 17/12/2007 V1.2 move to gfortran and 64bit compilation # 18/09/2010 V1.3 start migration to SVN scheme # - discard f2c (fallback) solution # - check variables # - copy headers (no symbolic links) # - new doxygen definitions # - package creation not yet implemented # - set TF_REMCMMNT to cat if not defined # 07/10/2010 V1.4 - migrate to FFTW3 # 15/11/2010 V1.5 - avoid makefdoc.pl # 18.12.2010 V1.6 - shared library does not work satisfactory # 11.01.2011 V1.7 - renamed Fortran source code such that # Fotran object files to not conflict with # C++ object files # 17/01/2011 V1.8 distinguish library creation and installation # # ============================================================================ # .PHONY: all all: install doc .PHONY: doc doc: doxydoc libfourier.doc LIBRARIES=libfourier.a libfourierxx.a #shared: libfourierxx.so .PHONY: install install: $(MAKE) install-include $(MAKE) $(LIBRARIES) /bin/mv -fv $(LIBRARIES) $(LOCLIBDIR) #---------------------------------------------------------------------- flist: Makefile $(wildcard *.f *.inc *.h *.cc *.c README *.cfg) echo $^ | tr ' ' '\n' | sort > $@ .PHONY: edit edit: flist; vim $< .PHONY: clean clean: -/bin/rm -fv *.o *.bak *.doc *.o77 flist *.of2c -find . -name \*.bak | xargs --no-run-if-empty /bin/rm -v -find . -name \*.o | xargs --no-run-if-empty /bin/rm -v -find . -name \*.d | xargs --no-run-if-empty /bin/rm -v -find . -name \*.h.strip | xargs --no-run-if-empty /bin/rm -v -/bin/rm -vf flist *.o install-include *.xxx junk* *.a *.so # ============================================================================ # CHECKVAR=$(if $($(1)),,$(error ERROR: missing variable $(1))) CHECKVARS=$(foreach var,$(1),$(call CHECKVAR,$(var))) # $(call CHECKVARS,LOCINCLUDEDIR LOCLIBDIR) $(call CHECKVARS,TF_BROWSER TF_WWWBASEDIR) AR=ar AS=as RANLIB=ranlib #---------------------------------------------------------------------- # uncomment this to activate the FFTW fallback solution # i.e. to use FFTW instead of FFTW3 # this option will disappear in the near future! Better not use it... #FFTWFALLBACK=-DFFTWFALLBACK #FFTWLIB=-ldrfftw -ldfftw FFTWLIB=-lfftw3 #---------------------------------------------------------------------- FLAGS+=-fPIC FFLAGS+=-ff2c -Wall -ffixed-line-length-0 -fno-backslash $(FLAGS) CFLAGS+=$(FLAGS) CXXFLAGS+=-Wall -fPIC $(FLAGS) LDFLAGS+=-L$(LOCLIBDIR) -fPIC CPPFLAGS+=-I$(LOCINCLUDEDIR) $(FLAGS) LIBSRC=$(wildcard *.f) LIBOBS=$(patsubst %.f,%.o,$(LIBSRC)) DOCS=libfourier.doc docs: $(DOCS) %.o: %.f $(FC) $(FFLAGS) -c -o $@ $< libfourier.doc: $(LIBSRC) $(wildcard *.inc) /usr/bin/awk 'BEGIN{ hot=0; } \ /^cS/ { hot=1; \ print FILENAME; \ print " c\n c"; \ next; } \ /^cE/ { hot=0; } \ { if (hot==1) { print " " $$0; } }' $^ > $@ libfourier.a: $(LIBOBS) %.a: $(AR) rcv $@ $^ $(RANLIB) $@ # ============================================================================ # # A note on header files: # We extensively comment class declarations within the header files. The # reduce compilation time when using the library code, comments will be # stripped from the header files that are exportet. These stripped versions # are placed in the source code path with name *.h.strip and will be linked to # INCINSTALLPATH with name *.h. # # Although comment stripping could be done by perl with an elaborate regular # expression, we prefer the remcmmnt command by Jari Laaksonen. You can find # the code at # http://www.eti.pg.gda.pl/KATEDRY/kecs/lab-cpp/snippets/ # If it is not available to you, you should set TF_REMCMMNT=cat (see below) # # ============================================================================ # # environment variables # --------------------- # # You will like to set the following environment variables: # # LOCINCLUDEDIR Defines the path where header files will be copied for # usage in your own projects. You will pass this path to # the precompiler with the -I option. # LOCLIBDIR Defines the path where the binary library will be # placed. # TF_WWWBASEDIR Defines the path to your personal homepage. That's the # place where doxygen output will be written too (see # below). # files # ----- # all header files used within this project HEADERS=$(shell find . -name \*.h) # all source code to be compiled to object files and to be included # in the binary version of the library # (see below for the configuration of a preinstantiated version of template # code) SRC=fcommand.cc filters.cc polesnzeroes.cc fftwaff.cc error.cc fftwaffar.cc # test programs are placed in a subdirectory TESTS=$(wildcard tests/*.cc) # whereever we find a README, we will use it README=$(shell find . -name README) # place where we will copy header files INCINSTALLPATH=$(LOCINCLUDEDIR)/fourier # place where we will copy the binary library LIBINSTALLPATH=$(LOCLIBDIR) # name of headers with comments stripped off (these are linked to your include # directory) STRIPHEADER=$(addsuffix .strip,$(notdir $(HEADERS))) # name of installed (exported) header files (these are the names in your # include directory) INSTHEADER=$(addprefix $(INCINSTALLPATH)/,$(filter-out ./tests/%,$(HEADERS))) # if defined, empty lines are kept in comment-stripped headers # to synchronize line numbers (necessary during library debugging) EMPTYPRINT=1 #EMPTYPRINT=0 # define this to be cat in case you do not have remcmmnt available ifndef TF_REMCMMNT TF_REMCMMNT=cat endif # compiler and preprocessor flags FLAGS= #CXXFLAGS += -Wall -pedantic $(FLAGS) -O3 CXXFLAGS += -Wall $(FLAGS) -O3 LDFLAGS += -L$(LOCLIBDIR) CPPFLAGS += -I$(LOCINCLUDEDIR) $(FLAGS) LIBOBSXX=$(patsubst %.cc,%.o,$(SRC)) libfourierxx.a: install-include $(LIBOBSXX) ar rcv $@ $(LIBOBSXX) ranlib $@ libfourierxx.so: install-include libfourier.a $(LIBOBSXX) $(CXX) $(CXXFLAGS) -shared -o $@ $(LIBOBSXX) -lfourier \ -L$(LOCLIBDIR) #====================================================================== # dependencies # ------------ # # The compiler is used to create dependency files, which are included below. %.d: %.cc $(SHELL) -ec '$(CXX) -M $(CPPFLAGS) $(TMPPARDEF) $< \ | sed '\''s,\($(notdir $*)\)\.o[ :]*,$(dir $@)\1.o $@ : ,g'\'' \ > $@; \ [ -s $@ ] || rm -f $@' include $(patsubst %.cc,%.d,$(SRC)) #====================================================================== # header files # ------------ # # Since we extensively document the class structures within the header files, # these should be stripped for the production version (otherwise the compiler # has to scan all comments on each compile). Stripping is done by the rule # below and is controlled by the variables TF_REMCMMNT and EMPTYPRINT (see # above). # comment stripping # ----------------- # awk rule assumes that the first non-comment line starts with '#' # and that the first (copyright) comment end with pattern "^ */" %.h.strip: %.h awk 'BEGIN {hot=1;} /^ \*\// { if (hot) { hot=2; print; next;} }\ /^#/ { hot=0; } \ { if (hot==2) { print ""; } else if (hot) { print; } }' $< > $@ $(TF_REMCMMNT) $< | awk 'BEGIN {hot=0;} \ /^ *$$/ { if ((hot) && ($(EMPTYPRINT))) { print ""; } next; } \ /^#/ { hot=1; } { if (hot) print; }' >> $@ #---------------------------------------------------------------------- .PRECIOUS: %.h.strip $(INCINSTALLPATH)/%.h: %.h.strip mkdir -vp $(dir $@) -rm -fv $@ /bin/cp -vpd $< $@ # install header files .PHONY: install-include install-include: $(INSTHEADER) #====================================================================== # reinstall target # is necessary in case of header file problems (e.g. remcmmnt not installed) .PHONY: clean-include clean-include: /bin/rm -fv $(INSTHEADER) .PHONY: reinstall reinstall: $(MAKE) clean $(MAKE) clean-include $(MAKE) install #====================================================================== # tests # ----- cfftwtest: cfftwtest.c $(CC) -o $@ $< -ldrfftw -ldfftw -lm cxxfftwtest: cxxfftwtest.cc libfourierxx.a $(CXX) -o $@ $< -ltfxx -lfourierxx -laff $(FFTWLIB) -lm \ $(CPPFLAGS) $(LDFLAGS) #====================================================================== # documentation part # ------------------ # # targets commonly used: # ---------------------- # # make doxyclean removes all documentation # make doxydoc creates doxygen documentation in the DOXYWWWPATH # make doxyview creates doxygen documentation and launches netscape to # browse in the documentation # make doxyconf edit the doxygen configuration file # # If you launch "make doxydoc" the documentation will be written to # DOXYWWWPATH (see below). This is meant to export the documentation through # your homepage. The doxyfull directory is just a symbolic link to this # directory. # $(call CHECKVARS,TF_WWWBASEDIR TF_BROWSER) DOXYWWWPATH=$(TF_WWWBASEDIR)/libfourier .PHONY: doxyclean doxyview doxydoc doxyconf doxyclean: ;/bin/rm -rfv $(DOXYWWWPATH) doxydoc.xxx DOXYSRC=$(README) $(HEADERS) $(SRC) # create doxygen intermediate configuration PWD=$(shell env pwd) doxydoc.xxx: doxydoc.cfg sed 's,,$(DOXYWWWPATH),g;s,,$(PWD),g' \ $< > $@ # create commented version of doxygen configuration doxycomm.xxx: doxydoc.cfg /bin/cp -vf $< $@; doxygen -u $@ $(DOXYWWWPATH)/html/index.html: doxydoc.xxx $(DOXYSRC) mkdir -vp $(DOXYWWWPATH) doxygen $< doxydoc: $(DOXYWWWPATH)/html/index.html doxyview: $(DOXYWWWPATH)/html/index.html $(TF_BROWSER) file:$< & #====================================================================== # create package # -------------- # is delegated to Makefile.packages # which still has to be coded PACKAGE=libfourier #ifdef TF_MAKEPKG #include $(TF_MAKEPKG) #endif # ----- END OF Makefile -----