Makefile 9.24 KB
Newer Older
thomas.forbriger's avatar
new  
thomas.forbriger committed
1
2
# this is <Makefile>
# ----------------------------------------------------------------------------
thomas.forbriger's avatar
thomas.forbriger committed
3
# $Id$
thomas.forbriger's avatar
new  
thomas.forbriger committed
4
5
6
7
8
9
# 
# Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) 
# 
# Fourier coefficients library
#
# provide Fourier coefficients of filter responses etc.
10
11
12
#
# this library make use of libtfxx
# libtfxx must be installed first
thomas.forbriger's avatar
new  
thomas.forbriger committed
13
14
15
# 
# REVISIONS and CHANGES 
#    07/11/2002   V1.0   Thomas Forbriger
thomas.forbriger's avatar
thomas.forbriger committed
16
17
18
19
#    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
thomas.forbriger's avatar
thomas.forbriger committed
20
#    17/12/2007   V1.2   move to gfortran and 64bit compilation
21
22
23
24
25
26
27
#    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
thomas.forbriger's avatar
thomas.forbriger committed
28
#    07/10/2010   V1.4   - migrate to FFTW3
thomas.forbriger's avatar
new  
thomas.forbriger committed
29
30
31
32
# 
# ============================================================================
#

33
all: install libfourier.doc doxydoc
thomas.forbriger's avatar
thomas.forbriger committed
34
install: install-include libfourier.a libfourierxx.a
thomas.forbriger's avatar
new  
thomas.forbriger committed
35

36
flist: Makefile $(wildcard *.f *.inc *.h *.cc *.c README *.cfg)
thomas.forbriger's avatar
new  
thomas.forbriger committed
37
38
39
40
41
42
	echo $^ | tr ' ' '\n' | sort > $@

.PHONY: edit
edit: flist; vim $<

.PHONY: clean
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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*

# ============================================================================
#
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)
thomas.forbriger's avatar
new  
thomas.forbriger committed
59

thomas.forbriger's avatar
thomas.forbriger committed
60
61
62
AR=ar
AS=as
RANLIB=ranlib
thomas.forbriger's avatar
new  
thomas.forbriger committed
63

thomas.forbriger's avatar
thomas.forbriger committed
64
65
66
67
68
69
70
71
#----------------------------------------------------------------------
# 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
#----------------------------------------------------------------------


thomas.forbriger's avatar
thomas.forbriger committed
72
CFLAGS += -O2 -I${SERVERINCLUDEDIR} -I${LOCINCLUDEDIR}
thomas.forbriger's avatar
thomas.forbriger committed
73
74
CPPFLAGS += -O2 -I${SERVERINCLUDEDIR} -I${LOCINCLUDEDIR} \
            $(FFTWFALLBACK)
thomas.forbriger's avatar
thomas.forbriger committed
75
FFLAGS += -ff2c -Wall -ffixed-line-length-0 -fno-backslash $(FLAGS)
thomas.forbriger's avatar
new  
thomas.forbriger committed
76

thomas.forbriger's avatar
thomas.forbriger committed
77
LIBSRC=$(wildcard *.f)
thomas.forbriger's avatar
new  
thomas.forbriger committed
78
LIBOBS=$(patsubst %.f,%.o,$(LIBSRC))
thomas.forbriger's avatar
thomas.forbriger committed
79
DOCS=libfourier.doc
thomas.forbriger's avatar
new  
thomas.forbriger committed
80
81
82

docs: $(DOCS)

thomas.forbriger's avatar
thomas.forbriger committed
83
84
%.o: %.f
	$(FC) $(FFLAGS) -c -o $@ $<
thomas.forbriger's avatar
new  
thomas.forbriger committed
85

thomas.forbriger's avatar
thomas.forbriger committed
86
libfourier.doc: $(LIBSRC) $(wildcard *.inc)
thomas.forbriger's avatar
new  
thomas.forbriger committed
87
88
	makefdoc.pl $@ $^

thomas.forbriger's avatar
thomas.forbriger committed
89
libfourier.a: $(LIBOBS)
thomas.forbriger's avatar
new  
thomas.forbriger committed
90
91
92
93

%.a: 
	$(AR) rcv $@ $^
	$(RANLIB) $@
thomas.forbriger's avatar
thomas.forbriger committed
94
	/bin/mv -fv $@ $(LOCLIBDIR)
thomas.forbriger's avatar
new  
thomas.forbriger committed
95

thomas.forbriger's avatar
thomas.forbriger committed
96
97
98
99
100
101
102
103
104
105
106
107
108
# ============================================================================
#     
# 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/
109
# If it is not available to you, you should set TF_REMCMMNT=cat (see below)
thomas.forbriger's avatar
thomas.forbriger committed
110
111
112
113
114
115
116
117
118
119
120
121
122
# 
# ============================================================================
#
# 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.
123
# TF_WWWBASEDIR         Defines the path to your personal homepage. That's the
thomas.forbriger's avatar
thomas.forbriger committed
124
125
126
127
128
129
130
131
132
133
134
135
#                       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)
thomas.forbriger's avatar
thomas.forbriger committed
136
SRC=fcommand.cc filter.cc polesnzeroes.cc fftwaff.cc error.cc
thomas.forbriger's avatar
thomas.forbriger committed
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# 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
160
161
162
ifndef TF_REMCMMNT
TF_REMCMMNT=cat
endif
thomas.forbriger's avatar
thomas.forbriger committed
163
164
165

# compiler and preprocessor flags
FLAGS=
thomas.forbriger's avatar
thomas.forbriger committed
166
167
168
169
#CXXFLAGS += -Wall -pedantic $(FLAGS) -O3
CXXFLAGS += -Wall $(FLAGS) -O3
LDFLAGS += -L$(LOCLIBDIR)
CPPFLAGS += -I$(LOCINCLUDEDIR) $(FLAGS)
thomas.forbriger's avatar
thomas.forbriger committed
170
171
172
173

LIBOBSXX=$(patsubst %.cc,%.o,$(SRC))

libfourierxx.a: install-include $(LIBOBSXX)
thomas.forbriger's avatar
thomas.forbriger committed
174
	ar rcv $@ $(LIBOBSXX)
thomas.forbriger's avatar
thomas.forbriger committed
175
	ranlib $@
thomas.forbriger's avatar
thomas.forbriger committed
176
	/bin/mv -fv $@ $(LOCLIBDIR)
thomas.forbriger's avatar
thomas.forbriger committed
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198

#======================================================================
# 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
199
# below and is controlled by the variables TF_REMCMMNT and EMPTYPRINT (see
thomas.forbriger's avatar
thomas.forbriger committed
200
201
202
203
204
205
206
207
208
209
210
# 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; } }' $< > $@
211
	$(TF_REMCMMNT) $< | awk 'BEGIN {hot=0;} \
thomas.forbriger's avatar
thomas.forbriger committed
212
213
214
215
216
217
218
219
220
        /^ *$$/ { if ((hot) && ($(EMPTYPRINT))) { print ""; } next; } \
        /^#/ { hot=1; } { if (hot) print; }' >> $@

#----------------------------------------------------------------------
.PRECIOUS: %.h.strip
      
$(INCINSTALLPATH)/%.h: %.h.strip
	mkdir -vp $(dir $@)
	-rm -fv $@
221
	/bin/cp -vpd $< $@
thomas.forbriger's avatar
thomas.forbriger committed
222
223
224
225
226
227

# install header files
install-include: $(INSTHEADER)
	echo $^ | tr ' ' '\n'
	touch $@

thomas.forbriger's avatar
tests    
thomas.forbriger committed
228
229
230
231
232
233
234
235
#======================================================================
# tests
# -----

cfftwtest: cfftwtest.c
	$(CC) -o $@ $< -ldrfftw -ldfftw -lm

cxxfftwtest: cxxfftwtest.cc
236
237
	$(CXX) -o $@ $< -ltfxx -lfourierxx -laff -lfftw3 -lm \
        $(CPPFLAGS) $(LDFLAGS)
thomas.forbriger's avatar
tests    
thomas.forbriger committed
238

thomas.forbriger's avatar
thomas.forbriger committed
239
240
241
242
243
244
245
246
247
248
249
#======================================================================
# 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
250
# make doxyconf         edit the doxygen configuration file
thomas.forbriger's avatar
thomas.forbriger committed
251
#
252
# If you launch "make doxydoc" the documentation will be written to
thomas.forbriger's avatar
thomas.forbriger committed
253
254
255
256
257
# DOXYWWWPATH (see below). This is meant to export the documentation through
# your homepage. The doxyfull directory is just a symbolic link to this
# directory.
#

258
$(call CHECKVARS,TF_WWWBASEDIR TF_BROWSER)
thomas.forbriger's avatar
thomas.forbriger committed
259

260
261
262
263
264
DOXYWWWPATH=$(TF_WWWBASEDIR)/libfourier

.PHONY: doxyclean doxyview doxydoc doxyconf

doxyclean: ;/bin/rm -rfv $(DOXYWWWPATH)
thomas.forbriger's avatar
thomas.forbriger committed
265
266
267

DOXYSRC=$(README) $(HEADERS) $(SRC) 

268
269
270
271
272
273
274
# create doxygen intermediate configuration
PWD=$(shell env pwd)
doxydoc.xxx: doxydoc.cfg
	sed 's,<OUTPUTDIRECTORY>,$(DOXYWWWPATH),g;s,<STRIPFROMPATH>,$(PWD),g' \
	  $< > $@

$(DOXYWWWPATH)/html/index.html: doxydoc.xxx $(DOXYSRC)
thomas.forbriger's avatar
thomas.forbriger committed
275
276
277
	mkdir -vp $(DOXYWWWPATH)
	doxygen $<

278
doxydoc: $(DOXYWWWPATH)/html/index.html
thomas.forbriger's avatar
thomas.forbriger committed
279

280
281
doxyview: $(DOXYWWWPATH)/html/index.html
	$(TF_BROWSER) file:$< &
thomas.forbriger's avatar
thomas.forbriger committed
282

283
284
285
286
287
288
289
290
291
#======================================================================
# create package
# --------------
# is delegated to Makefile.packages
# which still has to be coded
PACKAGE=libfourier
#ifdef TF_MAKEPKG
#include $(TF_MAKEPKG)
#endif
thomas.forbriger's avatar
thomas.forbriger committed
292

thomas.forbriger's avatar
new  
thomas.forbriger committed
293
# ----- END OF Makefile -----