# this is # ---------------------------------------------------------------------------- # $Id$ # # Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) # # libaff is the "Array Friederich Forbriger", a container for numbers # # ---- # This program 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. # # This program 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 should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # ---- # # 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) # # REVISIONS and CHANGES # 06/12/2002 V1.0 Thomas Forbriger # 27/12/2002 V1.1 doxygen reads Fortran code and files generated by f2c # 03/01/2003 V1.2 improved white-space-eating awk-script # 04/01/2003 V1.3 corrected yesterday's change # 28/03/2006 V1.4 provide a package # 11/12/2007 V1.5 library and test programs compile well on a 64bit # systems; the Fortran interface was tested with g77 # and f2c (not yet with gfortran) # 17/08/2010 V1.6 prepare for new environment settings # 18/09/2010 V1.7 TF_WWWBASEDIR and TF_REMCMMNT must be used # 10/11/2010 V1.8 removed fragments for binarry # 17/01/2011 V1.9 distinguish library creation and installation # # ============================================================================ # # 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). # # You will find the installed library header files in $(LOCINCLUDEDIR)/aff .PHONY: all all: install doc .PHONY: doc doc: doxydoc LIBRARIES=libaff.a libaff.so .PHONY: install install: $(MAKE) install-include $(MAKE) $(LIBRARIES) /bin/mv -fv $(LIBRARIES) $(LOCLIBDIR) # ============================================================================ # a variable definition to check variable settings # ------------------------------------------------ CHECKVAR=$(if $($(1)),,$(error ERROR: missing variable $(1))) CHECKVARS=$(foreach var,$(1),$(call CHECKVAR,$(var))) # check for required variables $(call CHECKVARS,LOCINCLUDEDIR LOCLIBDIR TF_WWWBASEDIR) #====================================================================== # files and paths # --------------- # 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=lib/error.cc dump.cc lib/strided.cc lib/stridedstepper.cc \ lib/seriesstepper.cc fortranshape.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) README.changelog README.groups # place where we will copy header files INCINSTALLPATH=$(LOCINCLUDEDIR)/aff # 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))) #====================================================================== # comments can be removed from 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 #REMCMMNT=remcmmnt #REMCMMNT=cat #====================================================================== # compiler and preprocessor flags # ------------------------------- FLAGS= FLAGS+=$(MYFLAGS) -fPIC CXXFLAGS+=-Wall $(FLAGS) -O3 LDFLAGS+=-L$(LOCLIBDIR) CPPFLAGS+=-I$(LOCINCLUDEDIR) $(FLAGS) #====================================================================== # targets # ------- # files which are to be edited flist: Makefile tests/Makefile doxydoc.cfg $(README) \ $(HEADERS) $(SRC) $(TESTS) $(wildcard doxy*.cfg) \ tests/f77common.inc tests/f77procs.f echo $(filter-out lib/% tests/%,$^) | tr ' ' '\n' | sort > $@ echo $(filter lib/%,$^) | tr ' ' '\n' | sort >> $@ echo $(filter tests/%,$^) | tr ' ' '\n' | sort >> $@ # Offers you a list of files to edit (ask Thomas for appropriate vim # configuration). .PHONY: edit edit: flist; vim $< # Target clean removes everything except the source code, headers and # documentation. (See also doxyclean) .PHONY: clean clean: ; -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 libcontxx.a *.xxx junk* *.a *.so cd tests; $(MAKE) clean #====================================================================== # library part # ============ # # create the binary library # ------------------------- LIBOBS=$(ALLOBS) $(patsubst %.cc,%.o,$(SRC)) LIBOBS=$(patsubst %.cc,%.o,$(SRC)) libaff.a: $(INSTHEADER) $(LIBOBS) ar rcv $@ $(LIBOBS) ranlib $@ libaff.so: $(INSTHEADER) $(LIBOBS) $(CXX) $(CXXFLAGS) -shared -o $@ $(LIBOBS) #====================================================================== # 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)) # this include will be used once we initiate the precompiled library version # until then it's just waiting here #-include $(patsubst %.o,%.d,$(ALLOBS)) #====================================================================== # 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 # ----------------- $(call CHECKVARS,TF_REMCMMNT EMPTYPRINT) # 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 $(call CHECKVAR,INCINSTALLPATH) $(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 #====================================================================== # 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)/libaff .PHONY: doxyclean doxyview doxydoc doxyconf doxyclean: ;/bin/rm -rfv $(TF_WWWBASEDIR)/libaff doxydoc.xxx DOXYSRC=$(README) $(HEADERS) $(SRC) \ tests/f77procs.P tests/f77procs.f \ tests/f77common.inc tests/f77common_com.P # 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:$< & #---------------------------------------------------------------------- # kdoc (http://sirtaj.net/projects/kdoc/) # added by Daniel KDOCDIR=$(HOME)/tmp/affkdoc kdoc: mkdir -p $(KDOCDIR) kdoc -f html -d $(KDOCDIR) -n libaff -p -P -I$(LOCINCLUDEDIR) $(HEADERS) kdocview: kdoc; $(TF_BROWSER) file:$(KDOCDIR)/index.html & showsections: $(README) egrep -n '\\subsection|\\section|\\page' $^ #====================================================================== # delegate test targets # --------------------- tests/%.P: cd tests; echo "#############################"; $(MAKE) $(notdir $@) tests/f2ctest: tests/f77test.cc install-include libaff.a cd tests; echo "#############################"; $(MAKE) $(notdir $@) tests/%: tests/%.cc install-include libaff.a cd tests; echo "#############################"; $(MAKE) $(notdir $@) tests/bin%: tests/bin%.cc install-include libaff.a cd tests; echo "#############################"; $(MAKE) $(notdir $@) tests/%.run: tests/% echo "#############################" $< $(ARG) /bin/rm -fv $< $<.o # after each modification to the library this target should be used compile-tests: \ tests/shapetest.run \ tests/reprtest.run \ tests/arraytest.run \ tests/operatortest.run \ tests/helpertest.run \ tests/f77test.run #====================================================================== # create package # -------------- # is delegated to Makefile.packages # which still has to be coded ifdef TF_MAKEPKG package: $(MAKE) -f $(TF_MAKEPKG) \ PACKAGE=libaff \ PACKAGECONTENTS="l" \ PACKAGETARGETS="l" \ PACKAGEEXPORT=trunk/src/libs/libaff endif # ----- END OF Makefile -----