Makefile 12.1 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) 
# 
# 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
#     
# 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/
36
# If it is not available to you, you should set TF_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)
47
#    17/08/2010   V1.6   prepare for new environment settings
48
#    18/09/2010   V1.7   TF_WWWBASEDIR and TF_REMCMMNT must be used
49
#    10/11/2010   V1.8   removed fragments for binarry
50
#    17/01/2011   V1.9   distinguish library creation and installation
thomas.forbriger's avatar
thomas.forbriger committed
51
52
53
# 
# ============================================================================
#
54
55
56
57
58
59
60
61
62
63
# 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.
64
# TF_WWWBASEDIR         Defines the path to your personal homepage. That's the
65
66
#                       place where doxygen output will be written too (see
#                       below).
67
68
#
# You will find the installed library header files in $(LOCINCLUDEDIR)/aff
69

70
71
72
73
74
75
76
77
.PHONY: all
all: install doc

.PHONY: doc
doc: doxydoc

LIBRARIES=libaff.a libaff.so
.PHONY: install
78
79
80
install: 
	$(MAKE) install-include 
	$(MAKE) $(LIBRARIES)
81
	/bin/mv -fv $(LIBRARIES) $(LOCLIBDIR)
82
83
84
85
86
87
88
	 
# ============================================================================
# a variable definition to check variable settings
# ------------------------------------------------

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

90
91
92
93
94
95
# check for required variables
$(call CHECKVARS,LOCINCLUDEDIR LOCLIBDIR TF_WWWBASEDIR)

#======================================================================
# files and paths
# ---------------
96
97
98
99
100
101
102

# 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
103
SRC=lib/error.cc dump.cc lib/strided.cc lib/stridedstepper.cc \
thomas.forbriger's avatar
thomas.forbriger committed
104
    lib/seriesstepper.cc fortranshape.cc 
105
106
107
# test programs are placed in a subdirectory
TESTS=$(wildcard tests/*.cc)
# whereever we find a README, we will use it
108
README=$(shell find . -name README) README.changelog README.groups
109
110
111
112
113

# 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
114

115
116
117
118
119
# 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)
120
INSTHEADER=$(addprefix $(INCINSTALLPATH)/,$(filter-out ./tests/%,$(HEADERS)))
thomas.forbriger's avatar
thomas.forbriger committed
121

122
123
124
125
#======================================================================
# comments can be removed from headers
# ------------------------------------
 
126
127
128
129
130
131
# 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
132
133
ifndef TF_REMCMMNT
TF_REMCMMNT=cat
134
135
endif
#REMCMMNT=remcmmnt
136
137
#REMCMMNT=cat

138
#======================================================================
139
# compiler and preprocessor flags
140
# -------------------------------
141
FLAGS=
142
FLAGS+=$(MYFLAGS) -fPIC
143
144
145
CXXFLAGS+=-Wall $(FLAGS) -O3
LDFLAGS+=-L$(LOCLIBDIR)
CPPFLAGS+=-I$(LOCINCLUDEDIR) $(FLAGS)
146

147
#======================================================================
148
149
150
151
# targets
# -------

# files which are to be edited
152
flist: Makefile tests/Makefile doxydoc.cfg $(README) \
thomas.forbriger's avatar
thomas.forbriger committed
153
154
155
156
157
       $(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
158

159
160
# Offers you a list of files to edit (ask Thomas for appropriate vim
# configuration).
thomas.forbriger's avatar
thomas.forbriger committed
161
162
163
.PHONY: edit
edit: flist; vim $<

164
165
# Target clean removes everything except the source code, headers and
# documentation. (See also doxyclean)
thomas.forbriger's avatar
thomas.forbriger committed
166
167
168
.PHONY: clean
clean: ; 
	-find . -name \*.bak | xargs --no-run-if-empty /bin/rm -v
169
170
171
	-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
172
	-/bin/rm -vf flist *.o install-include libcontxx.a *.xxx junk* *.a *.so
173
174
175
176
177
178
179
180
	cd tests; $(MAKE) clean

#======================================================================
# library part
# ============
#
# create the binary library
# -------------------------
181
182
LIBOBS=$(ALLOBS) $(patsubst %.cc,%.o,$(SRC))
LIBOBS=$(patsubst %.cc,%.o,$(SRC))
183

184
libaff.a: $(INSTHEADER) $(LIBOBS)
185
	ar rcv $@ $(LIBOBS)
186
187
	ranlib $@

188
189
190
libaff.so: $(INSTHEADER) $(LIBOBS)
	$(CXX) $(CXXFLAGS) -shared -o $@ $(LIBOBS)

191
192
193
194
195
196
197
198
199
200
201
202
#======================================================================
# 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 $@'

203
include $(patsubst %.cc,%.d,$(SRC)) 
204
205
206
207
208
209
210
211
212
213
214
215

# 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
216
# below and is controlled by the variables TF_REMCMMNT and EMPTYPRINT (see
217
218
219
220
# above).

# comment stripping
# -----------------
221
$(call CHECKVARS,TF_REMCMMNT EMPTYPRINT)
222
223
224
225
226
227
228

# 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; } }' $< > $@
229
	$(TF_REMCMMNT) $< | awk 'BEGIN {hot=0;} \
230
        /^ *$$/ { if ((hot) && ($(EMPTYPRINT))) { print ""; } next; } \
231
232
233
234
235
        /^#/ { hot=1; } { if (hot) print; }' >> $@

#----------------------------------------------------------------------
.PRECIOUS: %.h.strip
      
236
$(call CHECKVAR,INCINSTALLPATH)
237
238
239
$(INCINSTALLPATH)/%.h: %.h.strip
	mkdir -vp $(dir $@)
	-rm -fv $@
240
	/bin/cp -vpd $< $@
241
242

# install header files
243
.PHONY: install-include
244
245
install-include: $(INSTHEADER)

246
247
248
249
250
251
252
253
254
255
256
257
258
#======================================================================
# 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

259
260
261
262
263
264
265
266
267
268
269
#======================================================================
# 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
270
# make doxyconf         edit the doxygen configuration file
271
#
272
# If you launch "make doxydoc" the documentation will be written to
273
274
275
276
# DOXYWWWPATH (see below). This is meant to export the documentation through
# your homepage. The doxyfull directory is just a symbolic link to this
# directory.
#
277

278
$(call CHECKVARS,TF_WWWBASEDIR TF_BROWSER)
279

280
DOXYWWWPATH=$(TF_WWWBASEDIR)/libaff
281

282
.PHONY: doxyclean doxyview doxydoc doxyconf
283

284
doxyclean: ;/bin/rm -rfv $(TF_WWWBASEDIR)/libaff doxydoc.xxx
285

286
287
288
DOXYSRC=$(README) $(HEADERS) $(SRC) \
  tests/f77procs.P tests/f77procs.f \
  tests/f77common.inc tests/f77common_com.P
289

290
# create doxygen intermediate configuration
291
PWD=$(shell env pwd)
292
293
294
doxydoc.xxx: doxydoc.cfg
	sed 's,<OUTPUTDIRECTORY>,$(DOXYWWWPATH),g;s,<STRIPFROMPATH>,$(PWD),g' \
	  $< > $@
295
296
297
# create commented version of doxygen configuration
doxycomm.xxx: doxydoc.cfg
	/bin/cp -vf $< $@; doxygen -u $@
298
299

$(DOXYWWWPATH)/html/index.html: doxydoc.xxx $(DOXYSRC)
300
301
302
	mkdir -vp $(DOXYWWWPATH)
	doxygen $<

303
doxydoc: $(DOXYWWWPATH)/html/index.html
304

305
306
doxyview: $(DOXYWWWPATH)/html/index.html
	$(TF_BROWSER) file:$< &
307

308
309
310
#----------------------------------------------------------------------
# kdoc (http://sirtaj.net/projects/kdoc/)
# added by Daniel
thomas.forbriger's avatar
thomas.forbriger committed
311
312
313
314
KDOCDIR=$(HOME)/tmp/affkdoc
kdoc: 
	mkdir -p $(KDOCDIR)
	kdoc -f html -d $(KDOCDIR) -n libaff -p -P -I$(LOCINCLUDEDIR) $(HEADERS)
315
kdocview: kdoc; $(TF_BROWSER) file:$(KDOCDIR)/index.html &
thomas.forbriger's avatar
thomas.forbriger committed
316
	
317
318
showsections: $(README)
	egrep -n '\\subsection|\\section|\\page' $^
thomas.forbriger's avatar
thomas.forbriger committed
319

320
321
322
323
#======================================================================
# delegate test targets
# ---------------------

thomas.forbriger's avatar
thomas.forbriger committed
324
325
326
tests/%.P: 
	cd tests; echo "#############################"; $(MAKE) $(notdir $@)

327
328
329
tests/f2ctest: tests/f77test.cc install-include libaff.a
	cd tests; echo "#############################"; $(MAKE) $(notdir $@)

330
tests/%: tests/%.cc install-include libaff.a
331
332
	cd tests; echo "#############################"; $(MAKE) $(notdir $@)

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

336
337
338
tests/%.run: tests/%
	echo "#############################"
	$< $(ARG)
339
	/bin/rm -fv $< $<.o
thomas.forbriger's avatar
thomas.forbriger committed
340

341
342
343
344
345
# 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
346
  tests/operatortest.run \
347
348
349
  tests/helpertest.run \
  tests/f77test.run 

thomas.forbriger's avatar
thomas.forbriger committed
350
351
352
#======================================================================
# create package
# --------------
353
354
# is delegated to Makefile.packages
# which still has to be coded
355
356
357
358
359
360
361
362
ifdef TF_MAKEPKG
package:
	$(MAKE) -f $(TF_MAKEPKG) \
        PACKAGE=libaff \
	  PACKAGECONTENTS="l" \
	  PACKAGETARGETS="l" \
	  PACKAGEEXPORT=trunk/src/libs/libaff
endif
thomas.forbriger's avatar
thomas.forbriger committed
363

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