Makefile 10.2 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
52
# 
# ============================================================================
thomas.forbriger's avatar
thomas.forbriger committed
53

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

59
60
61
.PHONY: all
all: install doc

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

66
67
68
69
.PHONY: doc
doc: doxydoc

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

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

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

81
FORTRANLIB=$(TF_LINK_FORTRAN)
82

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

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

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

thomas.forbriger's avatar
thomas.forbriger committed
102
# the frame of doxygen documentation is placed in text files
103
104
105
DOXYTXT=$(shell find . -name doxygen\*.txt)  

EDITFILES=Makefile README $(wildcard *.cfg) COPYING $(DOXYTXT)
106
EDITSRC=$(wildcard *.cc *.h *.c *.f *.gpt *.inc)
107
108
109
EDITTESTS=$(wildcard testcases/*.par) $(wildcard testcases/*.tpl) \
    $(TESTCASEMAKE) $(wildcard testcases/*.gpt)

110
flist: $(wildcard *.txt *.c *.f *.h *.inc *_text.txt Makefile *.cc *.gpt) \
111
  doxydoc.cfg README COPYING $(DOXYTXT)\
thomas.forbriger's avatar
thomas.forbriger committed
112
  $(wildcard testcases/*.par) $(wildcard testcases/*.tpl) \
113
114
  $(TESTCASEMAKE) $(wildcard testcases/*.gpt) $(TF_EDIT)
	echo $(filter $(EDITFILES),$^) | tr ' ' '\n' | sort > $@
115
	echo "---- source code ----" >> $@
116
	echo $(filter $(EDITSRC),$^) | tr ' ' '\n' | sort >> $@
117
118
119
120
121
	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 ----" >> $@
122
123
124
125
	echo $(sort $(filter $(EDITTESTS),$^)) | tr ' ' '\n' >> $@
	echo "----" >> $@
	echo $(filter-out $(EDITFILES) $(EDITSRC) $(EDITTESTS),$^) \
	  | tr ' ' '\n' | sort >> $@
126

thomas.forbriger's avatar
thomas.forbriger committed
127
128
.PHONY: edit
edit: flist; vim $<
thomas.forbriger's avatar
thomas.forbriger committed
129
130
#----------------------------------------------------------------------
# pattern rules
thomas.forbriger's avatar
thomas.forbriger committed
131

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

134
135
#----------------------------------------------------------------------
# description and online texts
136
%.cc %.h: %_help.txt
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
	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 $@'

158
include $(patsubst %.txt,%.d,$(wildcard *_help.txt)) 
159
160
include $(patsubst %.cc,%.d,$(wildcard *.cc)) 

161
162
163
164
165
166
#----------------------------------------------------------------------
# typical combinations of libraries
LIBDATRWXX=-ldatrwxx -lsffxx -ltime++ -lgsexx -laff
LIBFAPIDXX=-lfapidxx $(LIBDATRWXX)
LIBTSIOXX=-ltsioxx -ltsxx -ltfxx $(LIBDATRWXX)

thomas.forbriger's avatar
thomas.forbriger committed
167
#----------------------------------------------------------------------
168
169
170
171
172
173
# binary executable targets
# -------------------------
#
# Fortran programs
# ----------------
#
174

175
176
177
178
179
180
181
182
183
184
185
186
187
188
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
# ----------------------------------------
189

190
evelox suseix: %x: %.o
191
192
	$(LINK.f) $^ $(LOADLIBES) $(LDLIBS) -o $@ \
	  -ltf  $(LIBFAPIDXX) 
193
194
195
#
# C++ programs
# ------------
196
197
198
199
200
201
202
203
204

sigval sigscale geophone gatherdiff cross autocorr: \
  %: %.o
	$(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $@ \
	  $(LIBDATRWXX) -ltfxx

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

fidasexx: \
  %: %.o
	$(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $@ \
210
	  -llinearxx -lpgplotxx -lcpgplot \
211
212
213
214
215
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
	  $(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 $@ \
	  $(LIBTSIOXX) -lgsl -lgslcblas

fregra foutra deconv: \
  %: %.o
	$(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $@ \
	  -lfourierxx $(LIBTSIOXX) -lfftw3

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

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

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

thomas.forbriger's avatar
thomas.forbriger committed
294
295
296
297
#======================================================================
# create package
# --------------
# is delegated to Makefile.packages
thomas.forbriger's avatar
thomas.forbriger committed
298
# pass PACKAGESRCONLY=yes for a source code package
thomas.forbriger's avatar
thomas.forbriger committed
299
ifdef TF_MAKEPKG
300
301
export PACKAGENEEDSPGPLOT=yes
export PACKAGELINKSFORTRAN=yes
thomas.forbriger's avatar
thomas.forbriger committed
302
303
304
305
306
307
308
309
.PHONY: package
package: $(TF_MAKEPKG)
	$(MAKE) -f $< \
        PACKAGE=tswf \
        PACKAGEEXPORT="trunk/src/ts/wf:src" \
        PACKAGETARGETS="src:all" \
        PACKAGELIBS="-"
.PHONY: fullpackage
uqchw's avatar
uqchw committed
310
311
312
313
314
fullpackage: $(TF_MAKEPKG)
	$(MAKE) -f $< \
        PACKAGE=tswfwithlibs \
        PACKAGEEXPORT="trunk/src/ts/wf:src" \
        PACKAGETARGETS="src:all" \
315
316
317
318
319
320
	  PACKAGELIBS="libtfxx:\
	    libgsexx:libaff:libtime:libsffxx:libdatrwxx:libfapidxx:\
	    libfourier:\
	    liblinearxx:libpgplot++: \
	    libseife:libsff:libsffu:libtf:libstfinv:\
	    libtsxx:libtsioxx"
thomas.forbriger's avatar
thomas.forbriger committed
321
322
endif

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