Makefile 9.89 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) 2002 by Thomas Forbriger (IMG Frankfurt) 
# 
# tf class library
8
#
thomas.forbriger's avatar
thomas.forbriger committed
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
# ----
#
25
26
27
# TF++, Miscellaneous classes and modules in C++
# ==============================================
#
28
29
30
# Please have a look at the README file coming along with the source code in
# this directory for further notes regarding provided functionality,
# prerequisites and installation.
31
#
thomas.forbriger's avatar
thomas.forbriger committed
32
33
# REVISIONS and CHANGES 
#    15/11/2002   V1.0   Thomas Forbriger
thomas.forbriger's avatar
thomas.forbriger committed
34
#    24/06/2003   V1.1   disabled blitz part of the code
thomas.forbriger's avatar
thomas.forbriger committed
35
#    28/03/2006   V1.2   provide a package
thomas.forbriger's avatar
thomas.forbriger committed
36
#    29/03/2006   V1.3   temporary header install path for package creation
thomas.forbriger's avatar
thomas.forbriger committed
37
38
39
#    05/12/2007   V1.4   migration:
#                        - provide regexx wrapper class
#                        - use new environment variables
40
41
42
43
44
45
46
#    18/09/2010   V1.5   start migration to SVN scheme
#                        - check variables
#                        - copy headers (no symbolic links)
#                        - new doxygen definitions
#                        - package creation not yet implemented
#                        - set TF_REMCMMNT to cat if not defined
#                        - remove REGEXX options
47
48
49
50
#    01/12/2010   V1.6   disabled newly invented shared library
#                        linking to libtfxx.so also requires 
#                        libgsl and libboost in cases where the main program
#                        doesn't need them; this is a linker issue
51
#    17/01/2011   V1.7   distinguish library creation and installation
52
#    25/03/2013   V1.8   added comments and package creation
53
#    26/03/2013   V1.9   fullpackage source code tar-ball is tested
thomas.forbriger's avatar
thomas.forbriger committed
54
55
56
57
# 
# ============================================================================
#

58
59
60
61
62
63
64
.PHONY: all
all: install doc

.PHONY: doc
doc: doxydoc

LIBRARIES=libtfxx.a
65
#shared: libtfxx.so
66

67
.PHONY: install
68
69
70
71
install: $(addprefix $(LOCLIBDIR)/,$(LIBRARIES))
$(LOCLIBDIR)/%: install-include %
	mkdir -pv $(LOCLIBDIR)
	/bin/mv -fv $(word 2,$^) $(LOCLIBDIR)
72

73
74
75
76
77
78
79
80
81
82
83
# ============================================================================
#
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)

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

84
#HEADERS=$(shell find . -name \*.h)
85
DIRSTOINCLUDE= ./cmdline ./misc ./affio ./containers \
thomas.forbriger's avatar
thomas.forbriger committed
86
  ./strings ./fileio ./num ./fs
87
88
89
90
#./hacks
#./blitzio
HEADERS=$(wildcard $(addsuffix /*.h,$(DIRSTOINCLUDE)))
SRC=$(wildcard $(addsuffix /*.cc,$(DIRSTOINCLUDE)))
91
#TESTS=$(filter-out tests/blitztest,$(wildcard tests/*.cc))
thomas.forbriger's avatar
thomas.forbriger committed
92
TESTS=tests/commandlinetest.cc tests/fortraniotest.cc \
thomas.forbriger's avatar
thomas.forbriger committed
93
  tests/stringtest.cc tests/handletest.cc tests/regextest.cc \
thomas.forbriger's avatar
thomas.forbriger committed
94
95
  tests/filetest.cc tests/rangetest.cc tests/fstest.cc \
  tests/exceptiontest.cc
96
#tests/blitztest.cc
thomas.forbriger's avatar
thomas.forbriger committed
97
FTESTS=$(wildcard tests/*.f)
98
DOXYTXT=$(wildcard doxygen*.txt)
thomas.forbriger's avatar
thomas.forbriger committed
99
100
101

INCINSTALLPATH=$(LOCINCLUDEDIR)/tfxx

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

107
108
109
110
111
112
# 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
113
114
115
ifndef TF_REMCMMNT
TF_REMCMMNT=cat
endif
116

thomas.forbriger's avatar
thomas.forbriger committed
117
118
119
120
121
122
# set switch flag for regexx
ifeq ($(TF_LIBREGEXX),yes) 
  REGEXXFLAG=-DOLDLIBREGEXX
else
  REGEXXFLAG=
endif
123

124
FLAGS=-fPIC $(MYFLAGS)
thomas.forbriger's avatar
thomas.forbriger committed
125
CXXFLAGS=-fhonor-std -Wall $(FLAGS) 
thomas.forbriger's avatar
thomas.forbriger committed
126
CXXFLAGS=$(FLAGS) 
127
LDFLAGS=-L$(LOCLIBDIR) $(TF_LINK_REGEXX)
thomas.forbriger's avatar
thomas.forbriger committed
128
CPPFLAGS=-I$(LOCINCLUDEDIR) $(FLAGS) $(REGEXXFLAG)
thomas.forbriger's avatar
thomas.forbriger committed
129
#CPPFLAGS=-I$(LOCINCLUDEDIR) $(FLAGS) -I$(BLITZINCLUDE)
thomas.forbriger's avatar
thomas.forbriger committed
130

131
132
133
134
135
136
137
138
139
140
141
142
CODEFILES=$(SRC) $(HEADERS)
TESTFILES=$(TESTS) $(FTESTS)
OTHERFILES=Makefile tests/Makefile doxydoc.cfg COPYING README $(DOXYTXT)
flist: $(CODEFILES) $(OTHERFILES) $(TF_EDIT) $(TESTFILES)
	echo $(OTHERFILES) | tr ' ' '\n' | sort > $@
	echo '----' >> $@
	echo $(CODEFILES) | tr ' ' '\n' | sort >> $@
	echo '----' >> $@
	echo $(TESTFILES) | tr ' ' '\n' | sort >> $@
	echo '----' >> $@
	echo $(filter-out $(CODEFILES) $(TESTFILES) $(OTHERFILES),$^) \
	  | tr ' ' '\n' | sort >> $@
thomas.forbriger's avatar
thomas.forbriger committed
143
144
145
146
147
148
149
150

.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
151
	-find . -name \*.d | xargs --no-run-if-empty /bin/rm -v
thomas.forbriger's avatar
thomas.forbriger committed
152
	-find . -name \*.hd | xargs --no-run-if-empty /bin/rm -v
153
	-/bin/rm -vf flist *.o install-include *.strip libtfxx.a *.a *.so *.xxx
thomas.forbriger's avatar
thomas.forbriger committed
154
	cd tests; $(MAKE) clean
thomas.forbriger's avatar
thomas.forbriger committed
155
156
157
158
159
160
161
162
163
164
165

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

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

166
include $(patsubst %.cc,%.d,$(SRC) $(TESTS))
thomas.forbriger's avatar
thomas.forbriger committed
167

thomas.forbriger's avatar
thomas.forbriger committed
168

thomas.forbriger's avatar
thomas.forbriger committed
169
170
171
172
173
174
175
176
#======================================================================
# library part
# ------------

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

177
178
179
180
libtfxx.so: $(SRC:.cc=.o)
	$(CXX) $(CXXFLAGS) -shared -o $@ $^ -lgsl -lboost_regex -lgslcblas \
	   -ltsxx -L$(LOCLIBDIR)

thomas.forbriger's avatar
thomas.forbriger committed
181
#----------------------------------------------------------------------
182
# comment stripping
thomas.forbriger's avatar
thomas.forbriger committed
183

thomas.forbriger's avatar
thomas.forbriger committed
184
%.hd: %.h; echo $(notdir $<.strip): $< > $@
thomas.forbriger's avatar
thomas.forbriger committed
185

186
include $(patsubst %.h,%.hd,$(HEADERS))
187

188
189
# first awk rule assumes that the first non-comment line starts with '#'
# and that the first (copyright) comment end with pattern "^ */"
190
%.h.strip: 
191
192
193
	awk 'BEGIN {hot=1;} /^ \*\// { if (hot) { hot=2; print; next;} }\
        /^#/ { hot=0; } \
        { if (hot==2) { print ""; } else if (hot) { print; } }' $< > $@
194
	$(TF_REMCMMNT) $< | awk 'BEGIN {hot=0;} \
195
196
        /^ *$$/ { if ((hot) && ($(EMPTYPRINT))) { print; } next; } \
        /^#/ { hot=1; } { if (hot) print; }' >> $@
197
198
199
200

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

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

205
.PHONY: install-include
206
install-include: $(INSTHEADER)
thomas.forbriger's avatar
thomas.forbriger committed
207

208
209
210
211
212
213
214
215
216
217
218
219
220
#======================================================================
# 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

thomas.forbriger's avatar
thomas.forbriger committed
221
222
223
#======================================================================
# documentation part
# ------------------
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#
# 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.
#
thomas.forbriger's avatar
thomas.forbriger committed
239

240
241
242
243
244
245
$(call CHECKVARS,TF_WWWBASEDIR TF_BROWSER)

DOXYWWWPATH=$(TF_WWWBASEDIR)/libtfxx

.PHONY: doxyclean doxyview doxydoc doxyconf

246
doxyclean: ;/bin/rm -rfv $(DOXYWWWPATH) doxydoc.xxx
thomas.forbriger's avatar
thomas.forbriger committed
247

248
DOXYSRC=$(DOXYTXT) $(HEADERS) $(SRC)
thomas.forbriger's avatar
thomas.forbriger committed
249

250
251
252
253
254
# create doxygen intermediate configuration
PWD=$(shell env pwd)
doxydoc.xxx: doxydoc.cfg
	sed 's,<OUTPUTDIRECTORY>,$(DOXYWWWPATH),g;s,<STRIPFROMPATH>,$(PWD),g' \
	  $< > $@
255
256
257
# create commented version of doxygen configuration
doxycomm.xxx: doxydoc.cfg
	/bin/cp -vf $< $@; doxygen -u $@
258
259
260

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

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

265
266
doxyview: $(DOXYWWWPATH)/html/index.html
	$(TF_BROWSER) file:$< &
thomas.forbriger's avatar
thomas.forbriger committed
267

268
269
270
271
#======================================================================
# create package
# --------------
# is delegated to Makefile.packages
272
273
274
275
276
ifdef TF_MAKEPKG
.PHONY: package
package: $(TF_MAKEPKG)
	$(MAKE) -f $< \
	  PACKAGE=libtfxx \
thomas.forbriger's avatar
thomas.forbriger committed
277
	  PACKAGEEXPORT="trunk/src/libs/libtfxx:src" \
uqchw's avatar
uqchw committed
278
	  PACKAGETARGETS="src:install:-i src:doc" \
279
	  PACKAGELIBS="-"
280
281
282
283

# 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
284
285
286
287
.PHONY: fullpackage
fullpackage: $(TF_MAKEPKG)
	$(MAKE) -f $< \
	  PACKAGE=libtfxxwithlibs \
288
289
290
	  PACKAGEEXPORT="trunk/src/libs/libtfxx:src trunk/src/libs/libtsxx:contrib/libtsxx" \
	  PACKAGETARGETS="contrib/libtsxx:install:-i src:install:-i contrib/libtsxx:reinstall contrib/libtsxx:doc:-i src:all" \
	  PACKAGELIBS="libgsexx:libtime:libsffxx:libaff:libseife:libdatrwxx"
291
endif
thomas.forbriger's avatar
thomas.forbriger committed
292
293
294
295
296

#======================================================================
# delegate test targets
# ---------------------

297
tests/%: tests/%.cc install-include libtfxx.a
thomas.forbriger's avatar
thomas.forbriger committed
298
299
	cd tests; echo "#############################"; $(MAKE) $(notdir $@)

300
301
302
tests/%: tests/%.f 
	cd tests; echo "#############################"; $(MAKE) $(notdir $@)

303
304
305
tests/%.run: tests/%
	cd tests; echo "#############################"; $(MAKE) $(notdir $@)

306
307
308
309
tests/%.remake: 
	/bin/rm -fv $(patsubst %.remake,%,$@)
	/bin/rm -fv $(patsubst %.remake,%.o,$@)
	$(MAKE) $(patsubst %.remake,%,$@)
310

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