Makefile 8.77 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
10
11
12
# 
# Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) 
# 
# Fourier coefficients library
#
# provide Fourier coefficients of filter responses etc.
# 
# REVISIONS and CHANGES 
#    07/11/2002   V1.0   Thomas Forbriger
thomas.forbriger's avatar
thomas.forbriger committed
13
14
15
16
#    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
17
#    17/12/2007   V1.2   move to gfortran and 64bit compilation
thomas.forbriger's avatar
new  
thomas.forbriger committed
18
19
20
# 
# ============================================================================
#
thomas.forbriger's avatar
thomas.forbriger committed
21
22
23
#  NOTICE: fallback solution (f2c is default) can be activated by the
#          environment variable TF_FALLBACK
#          This option will disappear somewhere in the future!
thomas.forbriger's avatar
new  
thomas.forbriger committed
24

thomas.forbriger's avatar
thomas.forbriger committed
25
26
all: install libfourier.doc
install: install-include libfourier.a libfourierxx.a
thomas.forbriger's avatar
new  
thomas.forbriger committed
27

28
flist: Makefile $(wildcard *.f *.inc *.h *.cc *.c README *.cfg)
thomas.forbriger's avatar
new  
thomas.forbriger committed
29
30
31
32
33
34
35
	echo $^ | tr ' ' '\n' | sort > $@

.PHONY: edit
edit: flist; vim $<

.PHONY: clean

thomas.forbriger's avatar
thomas.forbriger committed
36
37
38
AR=ar
AS=as
RANLIB=ranlib
thomas.forbriger's avatar
new  
thomas.forbriger committed
39
40
41

F2CLIB=-lm -lf2c -L${SERVERLIBDIR}
F2CFLAGS=-f -u
thomas.forbriger's avatar
thomas.forbriger committed
42
43
44
CFLAGS += -O2 -I${SERVERINCLUDEDIR} -I${LOCINCLUDEDIR}
CPPFLAGS += -O2 -I${SERVERINCLUDEDIR} -I${LOCINCLUDEDIR}
FFLAGS += -ff2c -Wall -ffixed-line-length-0 -fno-backslash $(FLAGS)
thomas.forbriger's avatar
new  
thomas.forbriger committed
45

thomas.forbriger's avatar
thomas.forbriger committed
46
LIBSRC=$(wildcard *.f)
thomas.forbriger's avatar
new  
thomas.forbriger committed
47
LIBOBS=$(patsubst %.f,%.o,$(LIBSRC))
thomas.forbriger's avatar
thomas.forbriger committed
48
DOCS=libfourier.doc
thomas.forbriger's avatar
new  
thomas.forbriger committed
49
50
51

docs: $(DOCS)

thomas.forbriger's avatar
thomas.forbriger committed
52
ifeq ($(TF_FALLBACK),yes)
thomas.forbriger's avatar
thomas.forbriger committed
53
%.of2c: %.f
thomas.forbriger's avatar
new  
thomas.forbriger committed
54
	f2c $(F2CFLAGS) $<
thomas.forbriger's avatar
thomas.forbriger committed
55
	$(CC) $(CFLAGS) $(<:.f=.c) -c -o $@
thomas.forbriger's avatar
new  
thomas.forbriger committed
56
57
58
59
	@rm  $(<:.f=.c)

%.o77: %.f
	$(FC) $(FFLAGS) -c -o $@ $<
thomas.forbriger's avatar
thomas.forbriger committed
60
61
62
63
else
%.o: %.f
	$(FC) $(FFLAGS) -c -o $@ $<
endif
thomas.forbriger's avatar
new  
thomas.forbriger committed
64

thomas.forbriger's avatar
thomas.forbriger committed
65
.PHONY: clean
thomas.forbriger's avatar
new  
thomas.forbriger committed
66
clean:
thomas.forbriger's avatar
thomas.forbriger committed
67
	-/bin/rm -fv *.o *.bak *.doc *.o77 flist *.of2c
thomas.forbriger's avatar
thomas.forbriger committed
68
69
70
71
72
	-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*
thomas.forbriger's avatar
new  
thomas.forbriger committed
73

thomas.forbriger's avatar
thomas.forbriger committed
74
libfourier.doc: $(LIBSRC) $(wildcard *.inc)
thomas.forbriger's avatar
new  
thomas.forbriger committed
75
76
77
	makefdoc.pl $@ $^


thomas.forbriger's avatar
thomas.forbriger committed
78
ifeq ($(TF_FALLBACK),yes)
thomas.forbriger's avatar
new  
thomas.forbriger committed
79
libfourier77.a: $(patsubst %.o,%.o77,$(LIBOBS))
thomas.forbriger's avatar
thomas.forbriger committed
80
libfourier.a: $(patsubst %.o,%.of2c,$(LIBOBS))
thomas.forbriger's avatar
thomas.forbriger committed
81
82
83
else
libfourier.a: $(LIBOBS)
endif
thomas.forbriger's avatar
new  
thomas.forbriger committed
84
85
86
87

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

thomas.forbriger's avatar
thomas.forbriger 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
# ============================================================================
#
#     
# 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 REMCMMNT=cat (see below)
# 
# REVISIONS and CHANGES 
#    30/12/2002   V1.0   Thomas Forbriger
# 
# ============================================================================
#
# 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.
# 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

# 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
160
161
162
163
164
# 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
REMCMMNT=remcmmnt
#REMCMMNT=cat

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

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

libfourierxx.a: install-include $(LIBOBSXX)
thomas.forbriger's avatar
thomas.forbriger committed
173
	ar rcv $@ $(LIBOBSXX)
thomas.forbriger's avatar
thomas.forbriger committed
174
	ranlib $@
thomas.forbriger's avatar
thomas.forbriger committed
175
	/bin/mv -fv $@ $(LOCLIBDIR)
thomas.forbriger's avatar
thomas.forbriger committed
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226

#======================================================================
# 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 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; } }' $< > $@
	$(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 $@
	ln -svf $$(pwd)/$< $@

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

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

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

cxxfftwtest: cxxfftwtest.cc
thomas.forbriger's avatar
thomas.forbriger committed
235
	$(CXX) -o $@ $< -ltfxx -ldrfftw -ldfftw -lm $(CPPFLAGS) $(LDFLAGS)
thomas.forbriger's avatar
tests    
thomas.forbriger committed
236

thomas.forbriger's avatar
thomas.forbriger committed
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
#======================================================================
# 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 doxyfullconf     edit the doxygen configuration file
#
# The targets are prepared for two documentation configurations. There is a
# "full" configuration defined in doxyfull.cfg and a "brief" configuration in
# doxybrief.cfg. However doxygen itself does not really support to distinguish
# between brief and full just due to the config-file. So just use the doxyfull
# target.
#
# If you launch "make doxyfull" 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.
#
DOXYWWWPATH=$(WWWBASEDIR)/libfourier

.PHONY: doxyclean doxyview doxybriefview doxyfullconf doxybriefconf

265
doxyclean: ;/bin/rm -rfv doc/* doc
thomas.forbriger's avatar
thomas.forbriger committed
266
267
268

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

269
doc/html/index.html: doxyfull.cfg $(DOXYSRC)
thomas.forbriger's avatar
thomas.forbriger committed
270
	mkdir -vp $(DOXYWWWPATH)
271
	ln -sfv $(DOXYWWWPATH) doc
thomas.forbriger's avatar
thomas.forbriger committed
272
273
	doxygen $<

274
doxyfullconf: doxy%conf: 
thomas.forbriger's avatar
thomas.forbriger committed
275
276
	doxywizard $(patsubst doxy%conf,doxy%.cfg,$@)

277
doxyfull: doxy%: doxyclean doc/html/index.html
thomas.forbriger's avatar
thomas.forbriger committed
278
279
doxydoc: doxyfull

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

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