Makefile 9.86 KB
Newer Older
Tilman Steinweg's avatar
Tilman Steinweg committed
1
2
# this is <Makefile>
# ----------------------------------------------------------------------------
3
# $Id$
Tilman Steinweg's avatar
Tilman Steinweg committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 
# Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) 
# 
# libaff is the "Array Friederich Forbriger", a container for numbers
#
# It is published under terms of the GNU General Public License.
#
# ----
# 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
# ----
#     
27
28
29
# 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.
Tilman Steinweg's avatar
Tilman Steinweg committed
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#
# REVISIONS and CHANGES 
#    06/12/2002   V1.0   Thomas Forbriger
#    27/12/2002   V1.1   doxygen reads Fortran code and files generated by f2c
#    03/01/2003   V1.2   improved white-space-eating awk-script
#    04/01/2003   V1.3   corrected yesterday's change 
#    28/03/2006   V1.4   provide a package
#    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)
#    17/08/2010   V1.6   prepare for new environment settings
#    18/09/2010   V1.7   TF_WWWBASEDIR and TF_REMCMMNT must be used
#    10/11/2010   V1.8   removed fragments for binarry
#    17/01/2011   V1.9   distinguish library creation and installation
#    27/07/2011   V1.10  give precedence to $LOCINCLUDEDIR over 
#                        $SERVERINCLUDEDIR 
46
#    26/01/2014          eliminate comment stripping 
Tilman Steinweg's avatar
Tilman Steinweg committed
47
48
49
# 
# ============================================================================

50
51
CONTRIBDIR=..
include $(CONTRIBDIR)/Makefile_var
Tilman Steinweg's avatar
Tilman Steinweg committed
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


.PHONY: all
all: install doc

.PHONY: doc
doc: doxydoc

LIBRARIES=libaff.a

.PHONY: install
install: $(addprefix $(LOCLIBDIR)/,$(LIBRARIES))
$(LOCLIBDIR)/%: install-include %
	mkdir -pv $(LOCLIBDIR)
	/bin/mv -fv $(word 2,$^) $(LOCLIBDIR)
	 
# ============================================================================
# a variable definition to check variable settings
# ------------------------------------------------

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

# check for required variables
$(call CHECKVARS,LOCINCLUDEDIR LOCLIBDIR TF_WWWBASEDIR)

#======================================================================
# files and paths
# ---------------

# 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)
SRC=lib/error.cc dump.cc lib/strided.cc lib/stridedstepper.cc \
    lib/seriesstepper.cc fortranshape.cc 
# test programs are placed in a subdirectory
TESTS=$(wildcard tests/*.cc)
# whereever we find a README, we will use it
93
94
95
README=$(shell find . -name README) 
# the frame of doxygen documentation is palced in text files
DOXYTXT=$(shell find . -name doxygen\*.txt) 
Tilman Steinweg's avatar
Tilman Steinweg committed
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

# place where we will copy header files
INCINSTALLPATH=$(LOCINCLUDEDIR)/aff
# place where we will copy the binary library
LIBINSTALLPATH=$(LOCLIBDIR)

# name of installed (exported) header files (these are the names in your
# include directory)
INSTHEADER=$(addprefix $(INCINSTALLPATH)/,$(filter-out ./tests/%,$(HEADERS)))

#======================================================================
# compiler and preprocessor flags
# -------------------------------
FLAGS=
FLAGS+=$(MYFLAGS) -fPIC
CXXFLAGS+=-Wall $(FLAGS) -O3
LDFLAGS=$(addprefix -L,$(LOCLIBDIR) $(subst :, ,$(SERVERLIBDIR)))
CPPFLAGS=$(addprefix -I,$(LOCINCLUDEDIR) $(subst :, ,$(SERVERINCLUDEDIR))) \
     $(FLAGS)

#======================================================================
# targets
# -------

# files which are to be edited
flist: Makefile tests/Makefile doxydoc.cfg $(README) COPYING \
122
123
       $(HEADERS) $(SRC) $(TESTS) $(wildcard doxy*.cfg) $(DOXYTXT) \
       tests/f77common.inc tests/f77procs.f $(TF_EDIT)
Tilman Steinweg's avatar
Tilman Steinweg committed
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
	echo $(filter-out lib/% tests/%,$^) | tr ' ' '\n' | sort > $@
	echo $(filter lib/%,$^) | tr ' ' '\n' | sort >> $@
	echo $(filter tests/%,$^) | tr ' ' '\n' | sort >> $@

# Offers you a list of files to edit (ask Thomas for appropriate vim
# configuration).
.PHONY: edit
edit: flist; vim $<

# Target clean removes everything except the source code, headers and
# documentation. (See also doxyclean)
.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
140
	-/bin/rm -vf flist *.o install-include *.xxx junk* *.a *.so
Tilman Steinweg's avatar
Tilman Steinweg committed
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
	cd tests; $(MAKE) clean

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

libaff.a: $(INSTHEADER) $(LIBOBS)
	ar rcv $@ $(LIBOBS)
	ranlib $@

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

#======================================================================
# 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 $@'

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
# ------------
      
$(call CHECKVAR,INCINSTALLPATH)
182
183
184
185
$(INCINSTALLPATH)/%.h: %.h
	@mkdir -vp $(dir $@)
	-@rm -fv $@
	@/bin/cp -vpd $< $@
Tilman Steinweg's avatar
Tilman Steinweg committed
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230

# install header files
.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)/libaff

.PHONY: doxyclean doxyview doxydoc doxyconf

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

231
DOXYSRC=$(DOXYTXT) $(HEADERS) $(SRC) \
Tilman Steinweg's avatar
Tilman Steinweg committed
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
262
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
308
309
  tests/f77procs.P tests/f77procs.f \
  tests/f77common.inc tests/f77common_com.P

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

#----------------------------------------------------------------------
# kdoc (http://sirtaj.net/projects/kdoc/)
# added by Daniel
KDOCDIR=$(HOME)/tmp/affkdoc
kdoc: 
	mkdir -p $(KDOCDIR)
	kdoc -f html -d $(KDOCDIR) -n libaff -p -P -I$(LOCINCLUDEDIR) $(HEADERS)
kdocview: kdoc; $(TF_BROWSER) file:$(KDOCDIR)/index.html &
	
showsections: $(README)
	egrep -n '\\subsection|\\section|\\page' $^

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

tests/%.P: 
	cd tests; echo "#############################"; $(MAKE) $(notdir $@)

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

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

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

tests/%.run: tests/%
	echo "#############################"
	$< $(ARG)
	/bin/rm -fv $< $<.o

# after each modification to the library this target should be used
compile-tests: \
  tests/shapetest.run \
  tests/reprtest.run \
  tests/arraytest.run \
  tests/operatortest.run \
  tests/helpertest.run \
  tests/f77test.run 

#======================================================================
# create package
# --------------
# is delegated to Makefile.packages
# which still has to be coded
ifdef TF_MAKEPKG
package:
	$(MAKE) -f $(TF_MAKEPKG) \
        PACKAGE=libaff \
	  PACKAGETARGETS="src:all:" \
	  PACKAGELIBS="-" \
	  PACKAGEEXPORT="trunk/src/libs/libaff:src"
endif

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