Makefile 5.22 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
# this is <Makefile>
# ----------------------------------------------------------------------------
# $Id: $
# 
# Copyright (c) 2014 by Thomas Forbriger (BFO Schiltach) 
# 
# Time series input/output functions
# 
# REVISIONS and CHANGES 
#    27/01/2014   Thomas Forbriger (thof)
# 
# ============================================================================
#

.PHONY: all
all: install doc

.PHONY: doc
doc: doxydoc

LIBRARIES=libtsioxx.a

.PHONY: install
install: $(addprefix $(LOCLIBDIR)/,$(LIBRARIES))
$(LOCLIBDIR)/%: install-include %
	mkdir -pv $(LOCLIBDIR)
	/bin/mv -fv $(word 2,$^) $(LOCLIBDIR)

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

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

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

HEADERS=$(wildcard *.h)
SRC=$(wildcard *.cc)

DOXYTXT=$(wildcard doxygen*.txt)

INCINSTALLPATH=$(LOCINCLUDEDIR)/tsioxx

# name of installed (exported) header files
INSTHEADER=$(addprefix $(INCINSTALLPATH)/,$(notdir $(HEADERS)))

FLAGS+=-fPIC $(MYFLAGS)
51
CXXFLAGS+= -Wall $(FLAGS) 
52
CXXFLAGS+=$(FLAGS) 
53
54
LDFLAGS+=-L$(LOCLIBDIR) 
CPPFLAGS+=-I$(LOCINCLUDEDIR) $(FLAGS) 
55

56
57
58
59
60
61
62
63
64
CODEFILES=$(HEADERS) $(SRC)
OTHERFILES=Makefile doxydoc.cfg COPYING README $(DOXYTXT)
flist: $(CODEFILES) $(OTHERFILES) $(TF_EDIT)
	echo $(OTHERFILES) | tr ' ' '\n' | sort > $@
	echo '----' >> $@
	echo $(CODEFILES) | tr ' ' '\n' | sort >> $@
	echo '----' >> $@
	echo $(filter-out $(CODEFILES) $(OTHERFILES),$^) \
	  | tr ' ' '\n' | sort >> $@
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85

.PHONY: edit
edit: flist; vim $<

.PHONY: clean
clean: ; 
	-find . -name \*.bak | xargs --no-run-if-empty /bin/rm -v
	-find . -name \*.o | xargs --no-run-if-empty /bin/rm -v
	-find . -name \*.d | xargs --no-run-if-empty /bin/rm -v
	-/bin/rm -vf flist *.o install-include *.strip libtfxx.a *.a *.so *.xxx

#======================================================================
# dependencies
# ------------

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

86
include $(patsubst %.cc,%.d,$(SRC))
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178

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

libtsioxx.a: $(SRC:.cc=.o)
	ar rcv $@ $^
	ranlib $@

libtsioxx.so: $(SRC:.cc=.o)
	$(CXX) $(CXXFLAGS) -shared -o $@ $^ -L$(LOCLIBDIR)

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

$(call CHECKVARS,INCINSTALLPATH)
$(INCINSTALLPATH)/%.h: %.h
	mkdir -p $(INCINSTALLPATH)
	-rm -fv $@
	/bin/cp -vpd $< $@

.PHONY: install-include
install-include: $(INSTHEADER)

#======================================================================
# reinstall target
# is necessary in case of header file problems (e.g. remcmmnt not installed)
.PHONY: clean-include
clean-include: 
	/bin/rm -fv $(INSTHEADER)

.PHONY: reinstall
reinstall:
	$(MAKE) clean
	$(MAKE) clean-include
	$(MAKE) install

#======================================================================
# 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)/libtsioxx

.PHONY: doxyclean doxyview doxydoc doxyconf

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

DOXYSRC=$(DOXYTXT) $(HEADERS) $(SRC)

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

#======================================================================
# create package
# --------------
# is delegated to Makefile.packages
ifdef TF_MAKEPKG
.PHONY: package
package: $(TF_MAKEPKG)
	$(MAKE) -f $< \
	  PACKAGE=libtsioxx \
179
	  PACKAGEEXPORT="trunk/src/libs/libtsioxx:src" \
180
181
182
183
184
185
186
187
188
189
	  PACKAGETARGETS="src:install:-i src:doc" \
	  PACKAGELIBS="-"

# due to the undesired circular dependency between libtfxx and libtsxx, we
# have to install libtsxx as a primary source in the fullpacke
# see ticket:215 and ticket:10
.PHONY: fullpackage
fullpackage: $(TF_MAKEPKG)
	$(MAKE) -f $< \
	  PACKAGE=libtsioxxwithlibs \
190
191
192
	  PACKAGEEXPORT="trunk/src/libs/libtsioxx:src" \
	  PACKAGETARGETS="src:all" \
	  PACKAGELIBS="libgsexx:libtime:libsffxx:libaff:libseife:libdatrwxx:libtsxx:libtfxx"
193
194
195
endif

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