Makefile 4.3 KB
Newer Older
thomas.forbriger's avatar
thomas.forbriger committed
1
2
# this is <Makefile>
# ----------------------------------------------------------------------------
thomas.forbriger's avatar
thomas.forbriger committed
3
# $Id: Makefile,v 1.11 2004-09-24 13:03:57 tforb Exp $
thomas.forbriger's avatar
thomas.forbriger committed
4
5
6
7
8
9
10
11
12
13
14
15
# 
# Copyright (c) 2004 by Thomas Forbriger (BFO Schiltach) 
# 
# Makefile for libdatreadxx
# 
# REVISIONS and CHANGES 
#    30/03/2004   V1.0   Thomas Forbriger
# 
# ============================================================================
#

HEADERS=$(wildcard *.h */*.h)
16
HEADERS=datread.h bonjer.h bonjer/readbonjer.h readany.h error.h \
17
  pdas.h pdas/pdasread.h pdas/pdasflags.h \
thomas.forbriger's avatar
thomas.forbriger committed
18
  sff.h mseed.h mseed/mseedread.h mseed/seedstructs.h
19

thomas.forbriger's avatar
thomas.forbriger committed
20
21
22
#SRC=misc/fortranio.cc misc/commandline.cc misc/ioswap.cc misc/error.cc \
#  misc/blitzfortranio.cc hacks/hack_blitztogrepg.cc
LIBSRC=$(wildcard *.cc */*.cc)
23
LIBSRC=datread.cc bonjer/bonjer.cc bonjer/readbonjer.cc readany.cc error.cc \
thomas.forbriger's avatar
thomas.forbriger committed
24
  pdas/pdas.cc pdas/pdasread.cc tests/pdastest.cc \
thomas.forbriger's avatar
thomas.forbriger committed
25
  sff/sff.cc mseed/mseedread.cc mseed/mseed.cc tests/mseedtest.cc
thomas.forbriger's avatar
thomas.forbriger committed
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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
89
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
136
137
138
139
140
141
142
143
144
145
146
147

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)

all: libdatreadxx.a doxybrief doxyfull

flist: Makefile $(wildcard *.cfg contrib/*.h) $(HEADERS) $(LIBSRC)
	echo $^ | tr ' ' '\n' | sort > $@

.PHONY: edit
edit: flist; vim $<

.PHONY: clean
clean: ; 
	-find . -name \*.bak | xargs --no-run-if-empty /bin/rm -v
	-/bin/rm -vf flist *.d *.o tsxx_tests

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

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

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

-include $(patsubst %.cc,%.d,$(LIBSRC))

libdatreadxx.a: $(patsubst %.cc,%.o,$(LIBSRC))
	ar rcv $@ $^
	ranlib $@
	newlib $@

#----------------------------------------------------------------------
# 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
# ------------------
DOXYWWWPATH=$(HOME)/public_html/txt/cxx/libdatreadxx
.PHONY: doxyclean doxyview doxybriefview doxyfullconf doxybriefconf

doxyclean: ;/bin/rm -rfv doc docbrief

DOXYSRC=$(LIBSRC) $(HEADERS)

doc/%: doxyfull.cfg $(DOXYSRC)
	mkdir -vp $(DOXYWWWPATH)
	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

doxyfullview: doxyfull; mozilla file:$(DOXYWWWPATH)/html/index.html &
doxybriefview: doxybrief; mozilla file:/docbrief/html/index.html &
doxyview: doxyfullview doxybrief

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

thomas.forbriger's avatar
thomas.forbriger committed
148
mseedtest pdastest: %: tests/%.o libdatreadxx.a
149
	$(CXX) -o $@ $< -I$(LOCINCLUDEDIR) \
thomas.forbriger's avatar
thomas.forbriger committed
150
151
        -ldatreadxx -lsffxx -lgsexx -ltsxx -ltfxx -laff -ltime++ \
        -L$(LOCLIBDIR)
152
	newprog $@
thomas.forbriger's avatar
thomas.forbriger committed
153
154

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