Makefile 9.57 KB
Newer Older
Tilman Steinweg's avatar
Tilman Steinweg committed
1 2 3 4 5 6 7 8
# this is <Makefile>
# ----------------------------------------------------------------------------
# 
# Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) 
# 
# Fourier coefficients library
#
# ----
9
# libfourier is free software; you can redistribute it and/or modify
Tilman Steinweg's avatar
Tilman Steinweg committed
10 11 12 13 14 15 16 17 18 19 20 21 22 23
# 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
# ----
#
24 25
# Fourier library: Operations in the Fourier domain
# =================================================
Tilman Steinweg's avatar
Tilman Steinweg committed
26
#
27 28 29
# Please have a look at the README file coming along with the source code in
# this directory for further notes regarding provided functionality,
# prerequisites and installation.
Tilman Steinweg's avatar
Tilman Steinweg committed
30 31
# 
# REVISIONS and CHANGES 
32
#    07/11/2002   V1.0   Thomas Forbriger (thof)
Tilman Steinweg's avatar
Tilman Steinweg committed
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
#    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
#    29/01/2013   V1.9   added tarball rules
53
#    26/01/2014          (thof): no longer strip comments from header files
Tilman Steinweg's avatar
Tilman Steinweg committed
54 55 56 57
# 
# ============================================================================
#

58 59
CONTRIBDIR=..
include $(CONTRIBDIR)/Makefile_var
Tilman Steinweg's avatar
Tilman Steinweg committed
60 61 62 63 64

.PHONY: all
all: install doc

.PHONY: doc
65
doc: doxydoc
Tilman Steinweg's avatar
Tilman Steinweg committed
66

67
LIBRARIES=libfourierxx.a
Tilman Steinweg's avatar
Tilman Steinweg committed
68 69 70 71 72 73 74 75 76 77
#shared: libfourierxx.so

.PHONY: install
install: $(addprefix $(LOCLIBDIR)/,$(LIBRARIES))
$(LOCLIBDIR)/%: install-include %
	mkdir -pv $(LOCLIBDIR)
	/bin/mv -fv $(word 2,$^) $(LOCLIBDIR)

#----------------------------------------------------------------------

78 79
DOXYTXT=$(wildcard doxygen*txt)

80 81
flist: Makefile $(wildcard *.f *.inc *.h *.cc *.c README *.cfg) COPYING \
	$(DOXYTXT)
Tilman Steinweg's avatar
Tilman Steinweg committed
82 83 84 85 86 87 88
	echo $^ | tr ' ' '\n' | sort > $@

.PHONY: edit
edit: flist; vim $<

.PHONY: clean
clean:
89
	-/bin/rm -fv *.o *.bak *.o77 flist *.of2c
Tilman Steinweg's avatar
Tilman Steinweg committed
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
	-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
	-/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) $@

# ============================================================================
# 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) 
163 164
# the frame of doxygen documentation is palced in text files 
DOXYTXT=$(shell find . -name doxygen\*.txt) 
Tilman Steinweg's avatar
Tilman Steinweg committed
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203

# place where we will copy header files
INCINSTALLPATH=$(LOCINCLUDEDIR)/fourier
# place where we will copy the binary library
LIBINSTALLPATH=$(LOCLIBDIR)

# name of installed (exported) header files (these are the names in your
# include directory)
INSTHEADER=$(addprefix $(INCINSTALLPATH)/,$(filter-out ./tests/%,$(HEADERS)))

# 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 $@'

Florian Wittkamp's avatar
Florian Wittkamp committed
204
ifneq ($(MAKECMDGOALS),clean)
Tilman Steinweg's avatar
Tilman Steinweg committed
205
include $(patsubst %.cc,%.d,$(SRC)) 
Florian Wittkamp's avatar
Florian Wittkamp committed
206
endif
Tilman Steinweg's avatar
Tilman Steinweg committed
207 208 209 210 211

#======================================================================
# header files
# ------------
      
212 213 214
$(INCINSTALLPATH)/%.h: %.h
	@mkdir -vp $(dir $@)
	-@rm -fv $@
215
	@/bin/cp -vp $< $@
Tilman Steinweg's avatar
Tilman Steinweg committed
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276

# 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 -laff $(FFTWLIB) -lm \
        $(CPPFLAGS) $(LDFLAGS)

cxxfftwartest: cxxfftwartest.cc libfourierxx.a
	$(CXX) -o $@ $^ -ldatrwxx -lsffxx -lgsexx -ltime++ \
	  -ltfxx -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

277
DOXYSRC=$(DOXYTXT) $(HEADERS) $(SRC) 
Tilman Steinweg's avatar
Tilman Steinweg committed
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317

# create doxygen intermediate configuration
PWD=$(shell env pwd)
doxydoc.xxx: doxydoc.cfg
	sed 's,<OUTPUTDIRECTORY>,$(DOXYWWWPATH),g;s,<STRIPFROMPATH>,$(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
# --------------
ifdef TF_MAKEPKG
.PHONY: package
package: $(TF_MAKEPKG)
	$(MAKE) -f $< \
        PACKAGE=libfourier \
        PACKAGEEXPORT="trunk/src/libs/libfourier:src" \
        PACKAGETARGETS="src:install: src:doc:" \
        PACKAGELIBS="-"
.PHONY: fullpackage
fullpackage: $(TF_MAKEPKG)
	$(MAKE) -f $< \
        PACKAGE=libfourierwithlibs \
        PACKAGEEXPORT="trunk/src/libs/libfourier:src" \
        PACKAGETARGETS="src:install: src:doc:" \
        PACKAGELIBS="libaff"
endif

# ----- END OF Makefile -----