Makefile 6.83 KB
Newer Older
thomas.forbriger's avatar
thomas.forbriger committed
1
2
# this is <Makefile>
# ----------------------------------------------------------------------------
3
# $Id$
thomas.forbriger's avatar
thomas.forbriger committed
4
5
6
7
# 
# Copyright (c) 2004 by Thomas Forbriger (BFO Schiltach) 
# 
# Makefile for libdatreadxx
thomas.forbriger's avatar
thomas.forbriger committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
# ----
# 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
24
25
#
# Other libraries that are required to compile libdatreadxx:
26
# libaff, libgsexx, libtime, libsffxx
thomas.forbriger's avatar
thomas.forbriger committed
27
28
29
# 
# REVISIONS and CHANGES 
#    30/03/2004   V1.0   Thomas Forbriger
thomas.forbriger's avatar
thomas.forbriger committed
30
#    29/06/2007   V1.1   included SAC binary reading
31
#    19/09/2007   V1.2   included raw GSE reading
thomas.forbriger's avatar
thomas.forbriger committed
32
#    08/07/2008   V1.3   started tracereader
thomas.forbriger's avatar
thomas.forbriger committed
33
34
35
36
37
#    18/09/2010   V1.4   start migration to SVN scheme
#                        - check variables
#                        - copy headers (no symbolic links)
#                        - new doxygen definitions
#                        - package creation not yet implemented
38
#    14/10/2010   V1.5   included tfascii reading
thomas.forbriger's avatar
thomas.forbriger committed
39
40
41
42
# 
# ============================================================================
#

thomas.forbriger's avatar
thomas.forbriger committed
43
44
45
46
47
48
49
50
51
52
all: install doxydoc
install: install-include libdatreadxx.a
# ============================================================================
#
CHECKVAR=$(if $($(1)),,$(error ERROR: missing variable $(1)))
CHECKVARS=$(foreach var,$(1),$(call CHECKVAR,$(var)))
#

$(call CHECKVARS,LOCINCLUDEDIR LOCLIBDIR LOCBINDIR)
$(call CHECKVARS,TF_BROWSER TF_WWWBASEDIR)
53

54
LIBHEADERS=$(wildcard *.h sff/*.h tsoft/*.h tfascii/*.h)
55
56
LIBHEADERS+=$(wildcard bonjer/*.h pdas/*.h mseed/*.h hpmo/*.h sac/*.h gse/*.h)

57
LIBSRC=$(wildcard *.cc sff/*.cc tsoft/*.cc tfascii/*.cc)
58
59
60
61
LIBSRC+=$(wildcard bonjer/*.cc pdas/*.cc mseed/*.cc hpmo/*.cc sac/*.cc gse/*.cc)

TESTHEADERS=$(wildcard tests/*.h)
TESTSRC=$(wildcard tests/*.cc)
thomas.forbriger's avatar
thomas.forbriger committed
62

thomas.forbriger's avatar
thomas.forbriger committed
63
64
65
66
INCINSTALLPATH=$(LOCINCLUDEDIR)/datreadxx
LIBINSTALLPATH=$(LOCLIBDIR)

# name of headers with comments stripped off
67
STRIPHEADER=$(addsuffix .strip,$(notdir $(LIBHEADERS)))
thomas.forbriger's avatar
thomas.forbriger committed
68
# name of installed (exported) header files
69
INSTHEADER=$(addprefix $(INCINSTALLPATH)/,$(notdir $(LIBHEADERS)))
thomas.forbriger's avatar
thomas.forbriger committed
70
71
72
73
74
75
76

# if defined, empty lines are kept in stripped comment headers
# to synchronize line numbers
EMPTYPRINT=1
#EMPTYPRINT=0

# define this to be cat in case you do not have remcmmnt available
thomas.forbriger's avatar
thomas.forbriger committed
77
78
79
ifndef TF_REMCMMNT
TF_REMCMMNT=cat
endif
thomas.forbriger's avatar
thomas.forbriger committed
80
81
82
83
84
85
86

#
# general part
# ------------
#

FLAGS=
87
FLAGS+=$(MYFLAGS)
thomas.forbriger's avatar
thomas.forbriger committed
88
89
90
CXXFLAGS+=-Wall $(FLAGS)
LDFLAGS+=-L$(LOCLIBDIR)
CPPFLAGS+=-I$(LOCINCLUDEDIR) $(FLAGS)
thomas.forbriger's avatar
thomas.forbriger committed
91

92
flist: Makefile $(wildcard *.cfg contrib/*.h) $(LIBHEADERS) $(LIBSRC) \
thomas.forbriger's avatar
thomas.forbriger committed
93
         $(TESTSRC) README
thomas.forbriger's avatar
thomas.forbriger committed
94
95
96
97
98
99
100
101
	echo $^ | tr ' ' '\n' | sort > $@

.PHONY: edit
edit: flist; vim $<

.PHONY: clean
clean: ; 
	-find . -name \*.bak | xargs --no-run-if-empty /bin/rm -v
thomas.forbriger's avatar
thomas.forbriger committed
102
103
	-find . -name \*.o | xargs --no-run-if-empty /bin/rm -v
	-find . -name \*.d | xargs --no-run-if-empty /bin/rm -v
104
	-find . -name \*.hd | xargs --no-run-if-empty /bin/rm -v
thomas.forbriger's avatar
thomas.forbriger committed
105
	-find . -name \*.strip | xargs --no-run-if-empty /bin/rm -v
thomas.forbriger's avatar
thomas.forbriger committed
106
	-/bin/rm -vf flist 
thomas.forbriger's avatar
thomas.forbriger committed
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121

#======================================================================
# pattern rules
# -------------

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

#======================================================================
# library part
# ------------

thomas.forbriger's avatar
thomas.forbriger committed
122
-include $(patsubst %.cc,%.d,$(LIBSRC) $(TESTSRC))
thomas.forbriger's avatar
thomas.forbriger committed
123
124
125
126

libdatreadxx.a: $(patsubst %.cc,%.o,$(LIBSRC))
	ar rcv $@ $^
	ranlib $@
thomas.forbriger's avatar
thomas.forbriger committed
127
	/bin/mv -fv $@ $(LOCLIBDIR)
thomas.forbriger's avatar
thomas.forbriger committed
128
129
130
131
132
133

#----------------------------------------------------------------------
# comment stripping

%.hd: %.h; echo $(notdir $<.strip): $< > $@

134
-include $(patsubst %.h,%.hd,$(LIBHEADERS) $(TESTHEADERS))
thomas.forbriger's avatar
thomas.forbriger committed
135
136
137
138
139
140
141

# first awk rule assumes that the first non-comment line starts with '#'
# and that the first (copyright) comment end with pattern "^ */"
%.h.strip:
	awk 'BEGIN {hot=1;} /^ \*\// { if (hot) { hot=2; print; next;} }\
        /^#/ { hot=0; } \
        { if (hot==2) { print ""; } else if (hot) { print; } }' $< > $@
thomas.forbriger's avatar
thomas.forbriger committed
142
	$(TF_REMCMMNT) $< | awk 'BEGIN {hot=0;} \
thomas.forbriger's avatar
thomas.forbriger committed
143
144
145
146
147
148
149
150
        /^ *$$/ { if ((hot) && ($(EMPTYPRINT))) { print; } next; } \
        /^#/ { hot=1; } { if (hot) print; }' >> $@

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

$(INCINSTALLPATH)/%.h: %.h.strip
	mkdir -p $(INCINSTALLPATH)
	-rm -fv $@
thomas.forbriger's avatar
thomas.forbriger committed
151
	/bin/cp -vpd $< $@
thomas.forbriger's avatar
thomas.forbriger committed
152

153
.PHONY: install-include
thomas.forbriger's avatar
thomas.forbriger committed
154
155
156
157
158
install-include: $(INSTHEADER)

#======================================================================
# documentation part
# ------------------
thomas.forbriger's avatar
thomas.forbriger committed
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#
# 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)
thomas.forbriger's avatar
thomas.forbriger committed
176

thomas.forbriger's avatar
thomas.forbriger committed
177
178
179
180
181
DOXYWWWPATH=$(TF_WWWBASEDIR)/libdatreadxx

.PHONY: doxyclean doxyview doxydoc doxyconf

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

183
DOXYSRC=$(LIBSRC) $(HEADERS) README
thomas.forbriger's avatar
thomas.forbriger committed
184

thomas.forbriger's avatar
thomas.forbriger committed
185
186
187
188
189
PWD=$(shell env pwd)
# create doxygen intermediate configuration
doxydoc.xxx: doxydoc.cfg
	sed 's,<OUTPUTDIRECTORY>,$(DOXYWWWPATH),g;s,<STRIPFROMPATH>,$(PWD),g' \
	  $< > $@
190
191
192
# create commented version of doxygen configuration
doxycomm.xxx: doxydoc.cfg
	/bin/cp -vf $< $@; doxygen -u $@
thomas.forbriger's avatar
thomas.forbriger committed
193
194

$(DOXYWWWPATH)/html/index.html: doxydoc.xxx $(DOXYSRC)
thomas.forbriger's avatar
thomas.forbriger committed
195
196
197
	mkdir -vp $(DOXYWWWPATH)
	doxygen $<

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

thomas.forbriger's avatar
thomas.forbriger committed
200
201
doxyview: $(DOXYWWWPATH)/html/index.html
	$(TF_BROWSER) file:$< &
thomas.forbriger's avatar
thomas.forbriger committed
202

thomas.forbriger's avatar
thomas.forbriger committed
203
204
205
206
207
208
209
210
211
#======================================================================
# create package
# --------------
# is delegated to Makefile.packages
# which still has to be coded
PACKAGE=libdatreadxx
#ifdef TF_MAKEPKG
#include $(TF_MAKEPKG)
#endif
thomas.forbriger's avatar
thomas.forbriger committed
212
213
214
215
216

#======================================================================
# test code
# ---------

217
sactest hpmotest mseedtest pdastest tfasciitest\
thomas.forbriger's avatar
thomas.forbriger committed
218
  tsofttest sfftest: %: tests/%.o libdatreadxx.a
thomas.forbriger's avatar
thomas.forbriger committed
219
	$(CXX) $(FLAGS) -o $@ $< -I$(LOCINCLUDEDIR) \
thomas.forbriger's avatar
thomas.forbriger committed
220
221
        -ldatreadxx -lsffxx -lgsexx -ltsxx -ltfxx -laff -ltime++ \
        -L$(LOCLIBDIR)
thomas.forbriger's avatar
thomas.forbriger committed
222
	/bin/mv -fv $@ $(LOCBINDIR)
thomas.forbriger's avatar
thomas.forbriger committed
223
224

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