Makefile 7.26 KB
Newer Older
thomas.forbriger's avatar
thomas.forbriger committed
1
2
# this is <Makefile>
# ----------------------------------------------------------------------------
thomas.forbriger's avatar
thomas.forbriger committed
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
# 
# ============================================================================
#

HEADERS=$(wildcard *.h */*.h)
38
HEADERS=datread.h bonjer.h bonjer/readbonjer.h readany.h error.h \
thomas.forbriger's avatar
thomas.forbriger committed
39
  pdas.h pdas/pdasread.h pdas/pdasflags.h mseed/seedstructdump.h \
thomas.forbriger's avatar
thomas.forbriger committed
40
  sff.h mseed.h mseed/mseedread.h mseed/seedstructs.h \
thomas.forbriger's avatar
thomas.forbriger committed
41
  hpmo.h hpmo/readhpmo.h hpmo/hpmodata.h util.h sac.h sac/sacread.h \
thomas.forbriger's avatar
thomas.forbriger committed
42
  bytesex.h debug.h gse.h gse/gseread.h tracereader.h \
43
44
  tsoft/tsoftdata.h tsoft/tsoftreader.h tsoft.h \
  tsoft/channeltranslation.h tsoft/tsoftsffcontainer.h
45

thomas.forbriger's avatar
thomas.forbriger committed
46
47
48
#SRC=misc/fortranio.cc misc/commandline.cc misc/ioswap.cc misc/error.cc \
#  misc/blitzfortranio.cc hacks/hack_blitztogrepg.cc
LIBSRC=$(wildcard *.cc */*.cc)
49
LIBSRC=datread.cc bonjer/bonjer.cc bonjer/readbonjer.cc readany.cc error.cc \
thomas.forbriger's avatar
thomas.forbriger committed
50
  pdas/pdas.cc pdas/pdasread.cc mseed/seedstructdump.cc \
thomas.forbriger's avatar
thomas.forbriger committed
51
52
  sff/sff.cc mseed/mseedread.cc mseed/mseed.cc mseed/seedstructs.cc \
  hpmo/hpmo.cc hpmo/readhpmo.cc hpmo/hpmodata.cc \
thomas.forbriger's avatar
thomas.forbriger committed
53
  util.cc sac/sac.cc sac/sacread.cc bytesex.cc gse/gseread.cc gse/gse.cc \
thomas.forbriger's avatar
thomas.forbriger committed
54
  tracereader.cc \
55
56
  tsoft/tsoftdata.cc tsoft/tsoftreader.cc \
  tsoft/tsoft.cc tsoft/tsoftsffcontainer.cc tsoft/channeltranslation.cc
thomas.forbriger's avatar
thomas.forbriger committed
57

thomas.forbriger's avatar
thomas.forbriger committed
58
TESTSRC=tests/hpmotest.cc tests/pdastest.cc tests/mseedtest.cc \
thomas.forbriger's avatar
thomas.forbriger committed
59
  tests/sfftest.cc tests/sactest.cc tests/tsofttest.cc
thomas.forbriger's avatar
thomas.forbriger committed
60

thomas.forbriger's avatar
thomas.forbriger committed
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
INCINSTALLPATH=$(LOCINCLUDEDIR)/datreadxx
LIBINSTALLPATH=$(LOCLIBDIR)

# name of headers with comments stripped off
STRIPHEADER=$(addsuffix .strip,$(notdir $(HEADERS)))
# name of installed (exported) header files
INSTHEADER=$(addprefix $(INCINSTALLPATH)/,$(notdir $(HEADERS)))

# 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
REMCMMNT=remcmmnt
#REMCMMNT=cat

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

FLAGS=
CXXFLAGS=-fhonor-std -Wall $(FLAGS)
CXXFLAGS=-Wall $(FLAGS)
LDFLAGS=-L$(LOCLIBDIR)
CPPFLAGS=-I$(LOCINCLUDEDIR) $(FLAGS)

thomas.forbriger's avatar
thomas.forbriger committed
89
90
all: install doxybrief doxyfull
install: install-include libdatreadxx.a
thomas.forbriger's avatar
thomas.forbriger committed
91

92
flist: Makefile $(wildcard *.cfg contrib/*.h) $(HEADERS) $(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
thomas.forbriger's avatar
thomas.forbriger committed
104
	-find . -name \*.strip | xargs --no-run-if-empty /bin/rm -v
thomas.forbriger's avatar
thomas.forbriger committed
105
	-/bin/rm -vf flist 
thomas.forbriger's avatar
thomas.forbriger committed
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120

#======================================================================
# 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
121
-include $(patsubst %.cc,%.d,$(LIBSRC) $(TESTSRC))
thomas.forbriger's avatar
thomas.forbriger committed
122
123
124
125

libdatreadxx.a: $(patsubst %.cc,%.o,$(LIBSRC))
	ar rcv $@ $^
	ranlib $@
thomas.forbriger's avatar
thomas.forbriger committed
126
	/bin/mv -fv $@ $(LOCLIBDIR)
thomas.forbriger's avatar
thomas.forbriger committed
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157

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

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

-include $(patsubst %.h,%.hd,$(HEADERS))

# 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; } }' $< > $@
	$(REMCMMNT) $< | awk 'BEGIN {hot=0;} \
        /^ *$$/ { if ((hot) && ($(EMPTYPRINT))) { print; } next; } \
        /^#/ { hot=1; } { if (hot) print; }' >> $@

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

$(INCINSTALLPATH)/%.h: %.h.strip
	mkdir -p $(INCINSTALLPATH)
	-rm -fv $@
	ln -svf $$(pwd)/$< $@

install-include: $(INSTHEADER)
	touch $@

#======================================================================
# documentation part
# ------------------
thomas.forbriger's avatar
thomas.forbriger committed
158
DOXYWWWPATH=$(WWWBASEDIR)/libdatreadxx
thomas.forbriger's avatar
thomas.forbriger committed
159
160
.PHONY: doxyclean doxyview doxybriefview doxyfullconf doxybriefconf

161
doxyclean: ;/bin/rm -rfv doc/* docbrief/* doc docbrief
thomas.forbriger's avatar
thomas.forbriger committed
162

163
DOXYSRC=$(LIBSRC) $(HEADERS) README
thomas.forbriger's avatar
thomas.forbriger committed
164
165
166

doc/%: doxyfull.cfg $(DOXYSRC)
	mkdir -vp $(DOXYWWWPATH)
167
	/bin/rm -rfv doc/* doc
thomas.forbriger's avatar
thomas.forbriger committed
168
169
170
171
172
173
174
175
176
177
178
179
	ln -sfv $(DOXYWWWPATH) doc
	doxygen $<

docbrief/%: doxybrief.cfg $(DOXYSRC); doxygen $<

doxybriefconf doxyfullconf: doxy%conf: 
	doxywizard $(patsubst doxy%conf,doxy%.cfg,$@)

doxybrief: docbrief/html/index.html
doxyfull: doc/html/index.html
doxydoc: doxybrief doxyfull

thomas.forbriger's avatar
thomas.forbriger committed
180
181
doxyfullview: doxyfull; $(TF_BROWSER) file:$(DOXYWWWPATH)/html/index.html &
doxybriefview: doxybrief; $(TF_BROWSER) file:/docbrief/html/index.html &
thomas.forbriger's avatar
thomas.forbriger committed
182
183
184
185
186
187
doxyview: doxyfullview doxybrief

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

thomas.forbriger's avatar
thomas.forbriger committed
188
189
sactest hpmotest mseedtest pdastest \
  tsofttest sfftest: %: tests/%.o libdatreadxx.a
thomas.forbriger's avatar
thomas.forbriger committed
190
	$(CXX) $(FLAGS) -o $@ $< -I$(LOCINCLUDEDIR) \
thomas.forbriger's avatar
thomas.forbriger committed
191
192
        -ldatreadxx -lsffxx -lgsexx -ltsxx -ltfxx -laff -ltime++ \
        -L$(LOCLIBDIR)
thomas.forbriger's avatar
thomas.forbriger committed
193
	/bin/mv -fv $@ $(LOCBINDIR)
thomas.forbriger's avatar
thomas.forbriger committed
194

thomas.forbriger's avatar
thomas.forbriger committed
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#======================================================================
# create package
# --------------
LIBRARYNAME=libdatreadxx
VERSIONCODE=$(shell date +'%Y%m%d')
PACKAGE=$(LIBRARYNAME)$(VERSIONCODE)
PUBLICATIONPATH=$(HOME)/public_html/download/software
TMPPATH=$(HOME)/tmp/$(PACKAGE)
package:
	/bin/rm -rfv $(TMPPATH); mkdir -pv $(TMPPATH)
	cd $(TMPPATH)/..; cvs export -r HEAD \
        -d $(PACKAGE) thof/src/libs/$(LIBRARYNAME)
	cd $(TMPPATH)/..; cvs export -r HEAD -d $(PACKAGE) thof/src/LICENSE.GPL
	cd $(TMPPATH)/..; cvs export -r HEAD \
        -d $(PACKAGE) thof/src/README.compile
thomas.forbriger's avatar
thomas.forbriger committed
210
211
	cd $(TMPPATH)/..; cvs export -r HEAD \
        -d $(PACKAGE) thof/src/README.1st
thomas.forbriger's avatar
thomas.forbriger committed
212
213
214
215
216
217
218
219
220
221
	/bin/bash -c 'cd $(TMPPATH); \
        export WWWBASEDIR=doxydoc; \
        mkdir -v inctmp; \
        make INCINSTALLPATH=inctmp all; make clean; /bin/rm -rfv inctmp'
	cd $(TMPPATH)/..; tar cvf $(PUBLICATIONPATH)/$(PACKAGE).tar $(PACKAGE)
	gzip --force -9 $(PUBLICATIONPATH)/$(PACKAGE).tar
	cd $(TMPPATH)/..; tar cvf $(PUBLICATIONPATH)/$(PACKAGE).tar $(PACKAGE)
	bzip2 -f $(PUBLICATIONPATH)/$(PACKAGE).tar
	$(MAKE) install

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