Makefile 9.58 KB
Newer Older
1
2
3
4
5
6
# this is <Makefile>
# ----------------------------------------------------------------------------
# 
# Copyright (c) 2005 by Thomas Forbriger (BFO Schiltach) 
# 
# time series waveform filters
thomas.forbriger's avatar
thomas.forbriger committed
7
#
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# ----
# 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
# ----
#
#
thomas.forbriger's avatar
thomas.forbriger committed
25
26
# Makefile fuer tools /src/ts/wf
#
thomas.forbriger's avatar
thomas.forbriger committed
27
# 22/01/2001      introduced smoos and did some "tidy up"
thomas.forbriger's avatar
thomas.forbriger committed
28
# 24/10/2001      introduced siggen
thomas.forbriger's avatar
thomas.forbriger committed
29
# 24/05/2001      introduced tsfilt
30
31
# 
# REVISIONS and CHANGES 
32
#    11/07/2005   V1.0   Thomas Forbriger (thof)
thomas.forbriger's avatar
thomas.forbriger committed
33
#    07/12/2007   V1.1   default Fortran compiler now is g77
34
#    17/12/2007   V1.2   moved to gfortran
thomas.forbriger's avatar
thomas.forbriger committed
35
36
37
#    08/10/2010   V1.3   migrate to new SVN environment
#                        - discard f2c fallback
#                        - use FFTW3
38
#    10/02/2011   V1.4   distinguish between compilation and installation
39
#    24/06/2011   V1.5   moved tests to distinguished Makefiles
40
#    25/05/2012   V1.6	 link siggen against libfapidxx (damb)
41
42
43
#    03/06/2012   V1.7   to be consistent with other programs: distinguish
#                        siggen and siggenx (being linked against libsff and
#                        libfapidxx, respectively)
thomas.forbriger's avatar
thomas.forbriger committed
44
#    11/01/2013   V1.8   added sigscale to program targets
45
#    17/04/2013   V1.9   lisousi has its own place now (moved source code)
thomas.forbriger's avatar
thomas.forbriger committed
46
47
#    28/10/2013   V1.10  implemented libfapidxx-version of suseix
#    02/01/2014   V1.11  removed signal generators, added tisli suspect
48
49
#    01/02/2014 thof:    rewrite all linker rules with libraries in
#                        proper order
50
#    19/03/2016 thof:    tidofi requires libgsl for filter GaussianNoise
51
#    25/12/2018 thof:    add new program croposp
52
#    06/02/2019 thof:    move croposp to dedicated directory
53
54
# 
# ============================================================================
thomas.forbriger's avatar
thomas.forbriger committed
55

thomas.forbriger's avatar
thomas.forbriger committed
56
57
58
PROGRAMS=tsfilt stufi rotate coro xyz2uvw susei suseix evelo \
  smoos dise foutra teseco resaseda gatherdiff \
  autocorr cross tidofi sigfit noisymize sigval fidasexx soutifu \
59
  deconv geophone sigscale tisli suspect evelox 
thomas.forbriger's avatar
thomas.forbriger committed
60

61
62
63
.PHONY: all
all: install doc

thomas.forbriger's avatar
thomas.forbriger committed
64
65
66
.PHONY: list-programs
list-programs:
	echo $(PROGRAMS) | tr ' ' '\n' | sort
67

68
69
70
71
.PHONY: doc
doc: doxydoc

.PHONY: install
72
73
74
75
install: $(addprefix $(LOCBINDIR)/,$(PROGRAMS))
$(LOCBINDIR)/%: %
	mkdir -pv $(LOCBINDIR)
	/bin/mv -fv $< $(LOCBINDIR)
thomas.forbriger's avatar
thomas.forbriger committed
76
77
78
79
80

CHECKVAR=$(if $($(1)),,$(error ERROR: missing variable $(1)))
CHECKVARS=$(foreach var,$(1),$(call CHECKVAR,$(var)))

$(call CHECKVARS,LOCINCLUDEDIR LOCLIBDIR LOCBINDIR)
81
$(call CHECKVARS,TF_LINK_FORTRAN TF_LINK_PGPLOT)
thomas.forbriger's avatar
thomas.forbriger committed
82

83
FORTRANLIB=$(TF_LINK_FORTRAN)
84

thomas.forbriger's avatar
thomas.forbriger committed
85
86
# use STATIC=-static to produce statically linked binaries
STATIC=
87
88
89
90
FLAGS += $(MYFLAGS)
CPPFLAGS=$(addprefix -I,$(LOCINCLUDEDIR) $(subst :, ,$(SERVERINCLUDEDIR))) \
  $(FLAGS)
FFLAGS += -ff2c -Wall -ffixed-line-length-0 -fno-backslash $(FLAGS)
91
CXXFLAGS+=-Wall $(FLAGS)
92
LDFLAGS=$(addprefix -L,$(LOCLIBDIR) $(subst :, ,$(SERVERLIBDIR))) $(STATIC)
93

thomas.forbriger's avatar
thomas.forbriger committed
94
95
#----------------------------------------------------------------------
# standard edit targets
96
97
98
.PHONY: clean
clean: ; 
	-find . -name \*.bak | xargs --no-run-if-empty /bin/rm -v
uqchw's avatar
uqchw committed
99
100
	-find . -name \*.d | xargs --no-run-if-empty /bin/rm -v
	-/bin/rm -vf flist *.o *.xxx *.ps *~ $(PROGRAMS)
101

102
TESTCASEMAKE=$(filter-out %.bak,$(wildcard testcases/Makefile*))
103

thomas.forbriger's avatar
thomas.forbriger committed
104
# the frame of doxygen documentation is placed in text files
105
DOXYTXT=$(wildcard doxygen*.txt */doxygen*txt)  
106

107
108
EDITFILES=Makefile README $(wildcard *.cfg) COPYING $(DOXYTXT) \
	    $(filter-out %.bak,$(wildcard */README*))
109
EDITSRC=$(wildcard *.cc *.h *.c *.f *.gpt *.inc)
110
111
112
EDITTESTS=$(wildcard testcases/*.par) $(wildcard testcases/*.tpl) \
    $(TESTCASEMAKE) $(wildcard testcases/*.gpt)

113
flist: $(wildcard *.txt *.c *.f *.h *.inc *_text.txt Makefile *.cc *.gpt) \
114
  doxydoc.cfg README COPYING $(DOXYTXT) $(EDITFILES) \
thomas.forbriger's avatar
thomas.forbriger committed
115
  $(wildcard testcases/*.par) $(wildcard testcases/*.tpl) \
116
117
  $(TESTCASEMAKE) $(wildcard testcases/*.gpt) $(TF_EDIT)
	echo $(filter $(EDITFILES),$^) | tr ' ' '\n' | sort > $@
118
	echo "---- source code ----" >> $@
119
	echo $(filter $(EDITSRC),$^) | tr ' ' '\n' | sort >> $@
120
121
122
123
124
	echo "---- Fortran source files only ----" >> $@
	echo $(sort $(filter %.f,$^)) | tr ' ' '\n' >> $@
	echo "---- C++ source files only ----" >> $@
	echo $(sort $(filter %.cc,$^)) | tr ' ' '\n' >> $@
	echo "---- test cases ----" >> $@
125
126
127
128
	echo $(sort $(filter $(EDITTESTS),$^)) | tr ' ' '\n' >> $@
	echo "----" >> $@
	echo $(filter-out $(EDITFILES) $(EDITSRC) $(EDITTESTS),$^) \
	  | tr ' ' '\n' | sort >> $@
129

thomas.forbriger's avatar
thomas.forbriger committed
130
131
.PHONY: edit
edit: flist; vim $<
thomas.forbriger's avatar
thomas.forbriger committed
132
133
#----------------------------------------------------------------------
# pattern rules
thomas.forbriger's avatar
thomas.forbriger committed
134

thomas.forbriger's avatar
thomas.forbriger committed
135
%.o: %.f; $(FC) -c -o $@ $< $(FFLAGS)
thomas.forbriger's avatar
thomas.forbriger committed
136

137
138
#----------------------------------------------------------------------
# description and online texts
139
%.cc %.h: %_help.txt
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
	echo "// DO NOT EDIT: this file is automatically derived from $<" \
	  > $(patsubst %.txt,%.h,$<)
	echo "extern char $(patsubst %.txt,%,$<)[];" >> $(patsubst %.txt,%.h,$<)
	echo "// DO NOT EDIT: this file is automatically derived from $<" \
	  > $(patsubst %.txt,%.cc,$<)
	echo "#include \"$(patsubst %.txt,%.h,$<)\"" >> $(patsubst %.txt,%.cc,$<)
	echo "char $(patsubst %.txt,%,$<)[]=" >> $(patsubst %.txt,%.cc,$<)
	echo "{" >> $(patsubst %.txt,%.cc,$<)
	cat $< | egrep -v '^#' | sed -e 's/"/\\"/g' \
	  | sed -e 's/$$/\\n"/' | sed -e 's/^/  "/'\
	  >> $(patsubst %.txt,%.cc,$<)
	echo "};" >> $(patsubst %.txt,%.cc,$<)

#----------------------------------------------------------------------
# dependencies
%.d: %.cc
	$(SHELL) -ec '$(CXX) -M $(CPPFLAGS) $< \
      | sed '\''s,\($(notdir $*)\)\.o[ :]*,$(dir $@)\1.o $@ : ,g'\'' \
        > $@; \
      [ -s $@ ] || rm -f $@'

161
include $(patsubst %.txt,%.d,$(wildcard *_help.txt)) 
162
163
include $(patsubst %.cc,%.d,$(wildcard *.cc)) 

164
165
166
167
#----------------------------------------------------------------------
# typical combinations of libraries
LIBDATRWXX=-ldatrwxx -lsffxx -ltime++ -lgsexx -laff
LIBFAPIDXX=-lfapidxx $(LIBDATRWXX)
168
LIBTSIOXX=-ltsioxx -ltsxx -ltfxx $(LIBDATRWXX) -lgsl -lgslcblas
169

thomas.forbriger's avatar
thomas.forbriger committed
170
#----------------------------------------------------------------------
171
172
173
174
175
176
# binary executable targets
# -------------------------
#
# Fortran programs
# ----------------
#
177

178
179
180
181
182
183
184
185
186
187
188
189
190
191
xyz2uvw tisli susei smoos rotate evelo coro: %: %.o
	$(LINK.f) $^ $(LOADLIBES) $(LDLIBS) -o $@ \
	  -lsff -ltf

tsfilt stufi: %: %.o
	$(LINK.f) $^ $(LOADLIBES) $(LDLIBS) -o $@ \
	  -lseife -lsff -ltf

suspect dise: %: %.o
	$(LINK.f) $^ $(LOADLIBES) $(LDLIBS) -o $@ \
	  -lsffu -ltime -lsff -ltf
	 
# Fortran programs with libfapidxx support
# ----------------------------------------
192

193
evelox suseix: %x: %.o
194
195
	$(LINK.f) $^ $(LOADLIBES) $(LDLIBS) -o $@ \
	  -ltf  $(LIBFAPIDXX) 
196
197
198
#
# C++ programs
# ------------
199

200
sigval sigscale geophone gatherdiff autocorr: \
201
202
203
204
205
206
207
  %: %.o
	$(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $@ \
	  $(LIBDATRWXX) -ltfxx

tidofi: \
  %: %.o
	$(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $@ \
208
	  -ltsxx -lcseife $(LIBDATRWXX) -ltfxx -lgsl -lgslcblas
209
210
211
212

fidasexx: \
  %: %.o
	$(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $@ \
213
	  -llinearxx -lpgplotxx -lcpgplot \
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
	  $(LIBDATRWXX) -ltfxx \
	  $(TF_LINK_PGPLOT) $(TF_LINK_FORTRAN) \
	  -llapack

sigfit: \
  %: %.o
	$(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $@ \
	  -llinearxx \
	  $(LIBDATRWXX) -ltfxx \
	  -llapack 

resaseda: \
  %: %.o
	$(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $@ \
	  -ltsxx $(LIBDATRWXX) -ltfxx

teseco: \
  %: %.o
	$(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $@ \
	  $(LIBTSIOXX)

noisymize: \
  %: %.o
	$(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $@ \
238
	  $(LIBTSIOXX) 
239

240
cross fregra foutra deconv: \
241
242
  %: %.o
	$(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $@ \
243
	  -lfourierxx $(LIBTSIOXX) -lfftw3 
244
245
246
247
248

soutifu: \
  %: %.o
	$(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $@ \
	  -lstfinv -lfourierxx $(LIBTSIOXX) -lfftw3
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
#======================================================================
# 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)/tswf

.PHONY: doxyclean doxyview doxydoc doxyconf

doxyclean: ;/bin/rm -rfv $(DOXYWWWPATH)

277
DOXYSRC=$(DOXYTXT) $(wildcard *.h *.cc *.f)
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296

# 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:$< &

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