Makefile 14.2 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.31 2010/03/23 17:16:27 tforb Exp $
thomas.forbriger's avatar
thomas.forbriger committed
4
5
6
7
# 
# Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) 
# 
# libaff is the "Array Friederich Forbriger", a container for numbers
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
# ----
24
25
26
27
28
29
30
31
32
33
34
35
36
#     
# A note on header files:
# We extensively comment class declarations within the header files. The
# reduce compilation time when using the library code, comments will be
# stripped from the header files that are exportet. These stripped versions
# are placed in the source code path with name *.h.strip and will be linked to
# INCINSTALLPATH with name *.h.
#
# Although comment stripping could be done by perl with an elaborate regular
# expression, we prefer the remcmmnt command by Jari Laaksonen. You can find
# the code at 
#   http://www.eti.pg.gda.pl/KATEDRY/kecs/lab-cpp/snippets/
# If it is not available to you, you should set REMCMMNT=cat (see below)
thomas.forbriger's avatar
thomas.forbriger committed
37
38
39
# 
# REVISIONS and CHANGES 
#    06/12/2002   V1.0   Thomas Forbriger
40
#    27/12/2002   V1.1   doxygen reads Fortran code and files generated by f2c
41
#    03/01/2003   V1.2   improved white-space-eating awk-script
42
#    04/01/2003   V1.3   corrected yesterday's change 
thomas.forbriger's avatar
thomas.forbriger committed
43
#    28/03/2006   V1.4   provide a package
thomas.forbriger's avatar
thomas.forbriger committed
44
45
46
#    11/12/2007   V1.5   library and test programs compile well on a 64bit
#                        systems; the Fortran interface was tested with g77
#                        and f2c (not yet with gfortran)
thomas.forbriger's avatar
thomas.forbriger committed
47
48
49
# 
# ============================================================================
#
50
51
52
53
54
55
56
57
58
59
60
61
62
# environment variables
# ---------------------
#
# You will like to set the following environment variables:
#
# LOCINCLUDEDIR         Defines the path where header files will be copied for
#                       usage in your own projects. You will pass this path to
#                       the precompiler with the -I option.
# LOCLIBDIR             Defines the path where the binary library will be
#                       placed.
# WWWBASEDIR            Defines the path to your personal homepage. That's the
#                       place where doxygen output will be written too (see
#                       below).
63
64
#
# You will find the installed library header files in $(LOCINCLUDEDIR)/aff
65

thomas.forbriger's avatar
thomas.forbriger committed
66
67
all: install doxydoc
install: install-include libaff.a 
68
69
70
71
72
73
74
75
76
77

# files
# -----

# all header files used within this project
HEADERS=$(shell find . -name \*.h)
# all source code to be compiled to object files and to be included
# in the binary version of the library
# (see below for the configuration of a preinstantiated version of template
# code)
thomas.forbriger's avatar
thomas.forbriger committed
78
SRC=lib/error.cc dump.cc lib/strided.cc lib/stridedstepper.cc \
thomas.forbriger's avatar
thomas.forbriger committed
79
    lib/seriesstepper.cc fortranshape.cc
80
81
82
# test programs are placed in a subdirectory
TESTS=$(wildcard tests/*.cc)
# whereever we find a README, we will use it
thomas.forbriger's avatar
thomas.forbriger committed
83
README=$(shell find . -name README) README.changelog
84
85
86
87
88

# place where we will copy header files
INCINSTALLPATH=$(LOCINCLUDEDIR)/aff
# place where we will copy the binary library
LIBINSTALLPATH=$(LOCLIBDIR)
thomas.forbriger's avatar
thomas.forbriger committed
89

90
91
92
93
94
# name of headers with comments stripped off (these are linked to your include
# directory)
STRIPHEADER=$(addsuffix .strip,$(notdir $(HEADERS)))
# name of installed (exported) header files (these are the names in your
# include directory)
95
INSTHEADER=$(addprefix $(INCINSTALLPATH)/,$(filter-out ./tests/%,$(HEADERS)))
thomas.forbriger's avatar
thomas.forbriger committed
96

97
98
99
100
101
102
103
104
105
106
107
# if defined, empty lines are kept in comment-stripped headers
# to synchronize line numbers (necessary during library debugging)
EMPTYPRINT=1
#EMPTYPRINT=0

# define this to be cat in case you do not have remcmmnt available
REMCMMNT=remcmmnt
#REMCMMNT=cat

# compiler and preprocessor flags
FLAGS=
thomas.forbriger's avatar
thomas.forbriger committed
108
FLAGS+=$(MYFLAGS)
thomas.forbriger's avatar
thomas.forbriger committed
109
CXXFLAGS=-Wall $(FLAGS) -O3
110
111
112
113
114
115
116
117
118
119
120
121
LDFLAGS=-L$(LOCLIBDIR)
CPPFLAGS=-I$(LOCINCLUDEDIR) $(FLAGS)

# the following definition is needed to make the dependency command pass
# binarray.cc
TMPPARDEF=-D BIN_TYPE -D BIN_N -D BIN_REPR -D BIN_SUBS

# targets
# -------

# files which are to be edited
flist: Makefile tests/Makefile doxybrief.cfg doxyfull.cfg $(README) \
thomas.forbriger's avatar
thomas.forbriger committed
122
123
124
125
126
       $(HEADERS) $(SRC) $(TESTS) $(wildcard doxy*.cfg) \
       tests/f77common.inc tests/f77procs.f
	echo $(filter-out lib/% tests/%,$^) | tr ' ' '\n' | sort > $@
	echo $(filter lib/%,$^) | tr ' ' '\n' | sort >> $@
	echo $(filter tests/%,$^) | tr ' ' '\n' | sort >> $@
thomas.forbriger's avatar
thomas.forbriger committed
127

128
129
# Offers you a list of files to edit (ask Thomas for appropriate vim
# configuration).
thomas.forbriger's avatar
thomas.forbriger committed
130
131
132
.PHONY: edit
edit: flist; vim $<

133
134
# Target clean removes everything except the source code, headers and
# documentation. (See also doxyclean)
thomas.forbriger's avatar
thomas.forbriger committed
135
136
137
.PHONY: clean
clean: ; 
	-find . -name \*.bak | xargs --no-run-if-empty /bin/rm -v
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
	-find . -name \*.o | xargs --no-run-if-empty /bin/rm -v
	-find . -name \*.d | xargs --no-run-if-empty /bin/rm -v
	-find . -name \*.h.strip | xargs --no-run-if-empty /bin/rm -v
	-/bin/rm -vf flist *.o install-include libcontxx.a *.xxx junk*
	cd tests; $(MAKE) clean

#======================================================================
# library part
# ============
#
# These are code fragments from libcontxx. They are the framework for
# generating a binary library with preinstantiated template code.
# Until we make full use of this feature, the fragments are just waiting here.
#
# basic set of patterns - containing all dimensionalities
LIBPATBASIC=_TYPE_1_REPR_SUBS_ \
         _TYPE_2_REPR_SUBS_ \
         _TYPE_3_REPR_SUBS_ \
         _TYPE_4_REPR_SUBS_ \
         _TYPE_5_REPR_SUBS_ 
#
# all element type
LIBPATTYPE=$(patsubst _TYPE_%,_float_%,$(LIBPATBASIC)) \
        $(patsubst _TYPE_%,_double_%,$(LIBPATBASIC)) \
        $(patsubst _TYPE_%,_int_%,$(LIBPATBASIC)) \
        $(patsubst _TYPE_%,_zdouble_%,$(LIBPATBASIC)) \
        $(patsubst _TYPE_%,_cfloat_%,$(LIBPATBASIC)) 
#
# add const element types
LIBPATCTYPE=$(LIBPATTYPE) $(patsubst _%,_C%,$(LIBPATTYPE)) 
#
# add representations
LIBPATREPR=$(patsubst %_REPR_SUBS_,%_sheap_SUBS_,$(LIBPATCTYPE))
#
# add shapes
LIBPATSUBS=$(patsubst %_SUBS_,%_srep,$(LIBPATREPR)) \
           $(patsubst %_SUBS_,%_dsrep,$(LIBPATREPR))
#
# create object file patterns
LIBPATFILES=$(addprefix binarray,$(LIBPATSUBS))
ALLOBS=$(addsuffix .o,$(LIBPATFILES))

# macro definitions
macro_float.xxx:    ; echo "-D BIN_TYPE=float" > $@
macro_double.xxx:   ; echo "-D BIN_TYPE=double" > $@
macro_int.xxx:      ; echo "-D BIN_TYPE=int" > $@
macro_zdouble.xxx:  ; echo "-D BIN_TYPE=\"std::complex<double>\"" > $@
macro_cfloat.xxx:   ; echo "-D BIN_TYPE=\"std::complex<float>\"" > $@
macro_Cfloat.xxx:   ; echo "-D BIN_TYPE=\"const float\"" > $@
macro_Cdouble.xxx:  ; echo "-D BIN_TYPE=\"const double\"" > $@
macro_Cint.xxx:     ; echo "-D BIN_TYPE=\"const int\"" > $@
macro_Czdouble.xxx: ; echo "-D BIN_TYPE=\"const std::complex<double>\"" > $@
macro_Ccfloat.xxx:  ; echo "-D BIN_TYPE=\"const std::complex<float>\"" > $@

macro_%_1.xxx: macro_%.xxx; cat $< > $@; echo "-D BIN_N=1" >> $@
macro_%_2.xxx: macro_%.xxx; cat $< > $@; echo "-D BIN_N=2" >> $@
macro_%_3.xxx: macro_%.xxx; cat $< > $@; echo "-D BIN_N=3" >> $@
macro_%_4.xxx: macro_%.xxx; cat $< > $@; echo "-D BIN_N=4" >> $@
macro_%_5.xxx: macro_%.xxx; cat $< > $@; echo "-D BIN_N=5" >> $@

macro_%_sheap.xxx: macro_%.xxx
	cat $< > $@; echo "-D BIN_REPR=contxx::prebuilt::representation::SharedHeap" >> $@

macro_%_srep.xxx: macro_%.xxx
	cat $< > $@; echo "-D BIN_SUBS=contxx::prebuilt::subscriptor::StridedRepresentation" >> $@
macro_%_dsrep.xxx: macro_%.xxx
	cat $< > $@; echo "-D BIN_SUBS=contxx::prebuilt::subscriptor::DenseStridedRepresentation" >> $@

binarray%.o: binarray.cc macro%.xxx
	/bin/cat $(word 2,$^)
	$(CXX) -o $@ -c $< $(CPPFLAGS) $(CXXFLAGS) $(shell /bin/cat $(word 2,$^))

#----------------------------------------------------------------------
# create the binary library
# -------------------------
213
214
LIBOBS=$(ALLOBS) $(patsubst %.cc,%.o,$(SRC))
LIBOBS=$(patsubst %.cc,%.o,$(SRC))
215

216
217
libaff.a: install-include $(LIBOBS)
	ar rcv $@ $(LIBOBS)
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
	ranlib $@
	cp -vpf $@ $(LIBINSTALLPATH)

#======================================================================
# dependencies
# ------------
#
# The compiler is used to create dependency files, which are included below.

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

binarray_%.d: binarray.cc
	echo $(patsubst %.d,%.o,$@) $@: $< > $@

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

# this include will be used once we initiate the precompiled library version
# until then it's just waiting here
#-include $(patsubst %.o,%.d,$(ALLOBS))

#======================================================================
# header files
# ------------
#
# Since we extensively document the class structures within the header files,
# these should be stripped for the production version (otherwise the compiler
# has to scan all comments on each compile). Stripping is done by the rule
# below and is controlled by the variables REMCMMNT and EMPTYPRINT (see
# above).

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

# awk rule assumes that the first non-comment line starts with '#'
# and that the first (copyright) comment end with pattern "^ */"
%.h.strip: %.h
	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;} \
262
        /^ *$$/ { if ((hot) && ($(EMPTYPRINT))) { print ""; } next; } \
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
        /^#/ { hot=1; } { if (hot) print; }' >> $@

#----------------------------------------------------------------------
.PRECIOUS: %.h.strip
      
$(INCINSTALLPATH)/%.h: %.h.strip
	mkdir -vp $(dir $@)
	-rm -fv $@
	ln -svf $$(pwd)/$< $@

# install header files
install-include: $(INSTHEADER)
	echo $^ | tr ' ' '\n'
	touch $@

#======================================================================
# 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 doxyfullconf     edit the doxygen configuration file
#
# The targets are prepared for two documentation configurations. There is a
# "full" configuration defined in doxyfull.cfg and a "brief" configuration in
# doxybrief.cfg. However doxygen itself does not really support to distinguish
# between brief and full just due to the config-file. So just use the doxyfull
# target.
#
# If you launch "make doxyfull" 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.
#
DOXYWWWPATH=$(WWWBASEDIR)/libaff

.PHONY: doxyclean doxyview doxybriefview doxyfullconf doxybriefconf

doxyclean: ;/bin/rm -rfv docfull/* docbrief docfull

308
309
310
DOXYSRC=$(README) $(HEADERS) $(SRC) \
  tests/f77procs.P tests/f77procs.f \
  tests/f77common.inc tests/f77common_com.P
311
312
313
314
315
316
317
318
319
320
321
322
323

doc%/html/index.html: doxy%.cfg $(DOXYSRC)
	mkdir -vp $(DOXYWWWPATH)
	ln -sfv $(DOXYWWWPATH) $(patsubst doxy%.cfg,doc%,$<)
	doxygen $<

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

doxyfull doxybrief: doxy%: doxyclean doc%/html/index.html
doxydoc: doxyfull

doxyfullview doxybriefview: doxy%view: doxy%
324
	$(TF_BROWSER) file:$(DOXYWWWPATH)/html/index.html &
325
326
doxyview: doxydoc doxyfullview

thomas.forbriger's avatar
thomas.forbriger committed
327
328
329
330
KDOCDIR=$(HOME)/tmp/affkdoc
kdoc: 
	mkdir -p $(KDOCDIR)
	kdoc -f html -d $(KDOCDIR) -n libaff -p -P -I$(LOCINCLUDEDIR) $(HEADERS)
331
kdocview: kdoc; $(TF_BROWSER) file:$(KDOCDIR)/index.html &
thomas.forbriger's avatar
thomas.forbriger committed
332
	
333
334
showsections: $(README)
	egrep -n '\\subsection|\\section|\\page' $^
thomas.forbriger's avatar
thomas.forbriger committed
335

336
337
338
339
#======================================================================
# delegate test targets
# ---------------------

thomas.forbriger's avatar
thomas.forbriger committed
340
341
342
tests/%.P: 
	cd tests; echo "#############################"; $(MAKE) $(notdir $@)

343
344
345
tests/f2ctest: tests/f77test.cc install-include libaff.a
	cd tests; echo "#############################"; $(MAKE) $(notdir $@)

346
tests/%: tests/%.cc install-include libaff.a
347
348
	cd tests; echo "#############################"; $(MAKE) $(notdir $@)

349
tests/bin%: tests/bin%.cc install-include libaff.a
350
	cd tests; echo "#############################"; $(MAKE) $(notdir $@)
thomas.forbriger's avatar
thomas.forbriger committed
351

352
353
354
tests/%.run: tests/%
	echo "#############################"
	$< $(ARG)
355
	/bin/rm -fv $< $<.o
thomas.forbriger's avatar
thomas.forbriger committed
356

357
358
359
360
361
# after each modification to the library this target should be used
compile-tests: \
  tests/shapetest.run \
  tests/reprtest.run \
  tests/arraytest.run \
thomas.forbriger's avatar
thomas.forbriger committed
362
  tests/operatortest.run \
363
364
365
  tests/helpertest.run \
  tests/f77test.run 

thomas.forbriger's avatar
thomas.forbriger committed
366
367
368
369
370
371
372
#======================================================================
# create package
# --------------
VERSIONCODE=$(shell date +'%Y%m%d')
PACKAGE=libaff$(VERSIONCODE)
PUBLICATIONPATH=$(HOME)/public_html/download/software
TMPPATH=$(HOME)/tmp/$(PACKAGE)
thomas.forbriger's avatar
thomas.forbriger committed
373
CVSSERVER=cvsserver:/home/tforb/CVSff
thomas.forbriger's avatar
thomas.forbriger committed
374
package:
thomas.forbriger's avatar
thomas.forbriger committed
375
	/bin/rm -rfv $(TMPPATH); mkdir -pv $(TMPPATH)
thomas.forbriger's avatar
thomas.forbriger committed
376
	cd $(TMPPATH)/..; cvs -d $(CVSSERVER) \
thomas.forbriger's avatar
thomas.forbriger committed
377
378
379
380
        export -r HEAD -d $(PACKAGE) libaff
	cd $(TMPPATH)/..; cvs export -r HEAD -d $(PACKAGE) thof/src/LICENSE.GPL
	cd $(TMPPATH)/..; cvs export -r HEAD \
        -d $(PACKAGE) thof/src/README.compile
381
382
	cd $(TMPPATH)/..; cvs export -r HEAD \
        -d $(PACKAGE) thof/src/README.1st
thomas.forbriger's avatar
thomas.forbriger committed
383
	/bin/bash -c 'cd $(TMPPATH); \
thomas.forbriger's avatar
thomas.forbriger committed
384
        export LOCINCLUDEDIR=include; export LOCLIBDIR=binlib; \
thomas.forbriger's avatar
thomas.forbriger committed
385
        export WWWBASEDIR=doxydoc; export LOCBINDIR=bin; \
thomas.forbriger's avatar
thomas.forbriger committed
386
        mkdir -vp include binlib bin doxydoc; \
thomas.forbriger's avatar
thomas.forbriger committed
387
        make all; make clean; /bin/rm -rfv include binlib bin'
thomas.forbriger's avatar
thomas.forbriger committed
388
389
390
391
392
	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

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