Makefile 6.33 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) 2004 by Thomas Forbriger (BFO Schiltach) 
# 
# provide access to LAPACK for AFF modules
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
# ----
thomas.forbriger's avatar
thomas.forbriger committed
24
25
26
# 
# REVISIONS and CHANGES 
#    07/02/2004   V1.0   Thomas Forbriger
27
28
29
30
31
32
#    18/09/2010   V1.1   start migration to SVN scheme
#                        - check variables
#                        - copy headers (no symbolic links)
#                        - set TF_REMCMMNT to cat if not defined
#                        - new doxygen definitions
#                        - package creation not yet implemented
thomas.forbriger's avatar
thomas.forbriger committed
33
34
35
36
# 
# ============================================================================
#

37
38
39
40
41
42
43
44
45
46
47
48
49
50
all: install doxydoc
install: install-include liblinearxx.a

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

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

51
HEADERS=$(wildcard *.h lapack/*.h)
thomas.forbriger's avatar
thomas.forbriger committed
52
53
#SRC=misc/fortranio.cc misc/commandline.cc misc/ioswap.cc misc/error.cc \
#  misc/blitzfortranio.cc hacks/hack_blitztogrepg.cc
thomas.forbriger's avatar
thomas.forbriger committed
54
55
56
57
LIBSRC=error.cc lapack/dposv_if.cc operators/dot.cc operators/transpose.cc \
  operators/checknxn.cc

TESTSRC=lapacktest.cc matrixtest.cc
thomas.forbriger's avatar
thomas.forbriger committed
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

INCINSTALLPATH=$(LOCINCLUDEDIR)/linearxx
LIBINSTALLPATH=$(LOCLIBDIR)

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

# 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
73
74
75
ifndef TF_REMCMMNT
TF_REMCMMNT=cat
endif
thomas.forbriger's avatar
thomas.forbriger committed
76
77
78
79
80
81
82

#
# general part
# ------------
#

FLAGS=
83
84
85
CXXFLAGS+=-Wall $(FLAGS)
LDFLAGS+=-L$(LOCLIBDIR) $(TF_LINK_FORTRAN)
CPPFLAGS+=-I$(LOCINCLUDEDIR) $(FLAGS)
thomas.forbriger's avatar
thomas.forbriger committed
86

thomas.forbriger's avatar
thomas.forbriger committed
87
88
flist: Makefile $(wildcard *.cfg contrib/*.h) \
       $(HEADERS) $(LIBSRC) $(TESTSRC)
thomas.forbriger's avatar
thomas.forbriger committed
89
90
91
92
93
94
95
96
	echo $^ | tr ' ' '\n' | sort > $@

.PHONY: edit
edit: flist; vim $<

.PHONY: clean
clean: ; 
	-find . -name \*.bak | xargs --no-run-if-empty /bin/rm -v
97
	-/bin/rm -vf flist *.d *.o */*.o */*.d *.strip */*.strip
thomas.forbriger's avatar
thomas.forbriger committed
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114

#======================================================================
# pattern rules
# -------------

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

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

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

115
liblinearxx.a: $(patsubst %.cc,%.o,$(LIBSRC))
thomas.forbriger's avatar
thomas.forbriger committed
116
117
	ar rcv $@ $^
	ranlib $@
thomas.forbriger's avatar
thomas.forbriger committed
118
	/bin/mv -fv $@ $(LOCLIBDIR)
thomas.forbriger's avatar
thomas.forbriger committed
119
120
121
122
123
124
125
126
127
128
129
130
131
132

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

%.hd: %.h; echo $(notdir $<.strip): $< > $@

-include $(patsubst %.h,%.hd,$(HEADERS))

# first awk rule assumes that the first non-comment line starts with '#'
# and that the first (copyright) comment end with pattern "^ */"
%.h.strip:
	awk 'BEGIN {hot=1;} /^ \*\// { if (hot) { hot=2; print; next;} }\
        /^#/ { hot=0; } \
        { if (hot==2) { print ""; } else if (hot) { print; } }' $< > $@
133
	$(TF_REMCMMNT) $< | awk 'BEGIN {hot=0;} \
thomas.forbriger's avatar
thomas.forbriger committed
134
135
136
137
138
139
140
141
        /^ *$$/ { if ((hot) && ($(EMPTYPRINT))) { print; } next; } \
        /^#/ { hot=1; } { if (hot) print; }' >> $@

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

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

144
.PHONY: install-include
thomas.forbriger's avatar
thomas.forbriger committed
145
146
147
148
149
install-include: $(INSTHEADER)

#======================================================================
# documentation part
# ------------------
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#
# 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)
thomas.forbriger's avatar
thomas.forbriger committed
167

168
169
170
171
172
DOXYWWWPATH=$(TF_WWWBASEDIR)/liblinearxx

.PHONY: doxyclean doxyview doxydoc doxyconf

doxyclean: ;/bin/rm -rfv $(DOXYWWWPATH)
thomas.forbriger's avatar
thomas.forbriger committed
173
174
175

DOXYSRC=$(LIBSRC) $(HEADERS)

176
177
178
179
180
# create doxygen intermediate configuration
PWD=$(shell env pwd)
doxydoc.xxx: doxydoc.cfg
	sed 's,<OUTPUTDIRECTORY>,$(DOXYWWWPATH),g;s,<STRIPFROMPATH>,$(PWD),g' \
	  $< > $@
181
182
183
# create commented version of doxygen configuration
doxycomm.xxx: doxydoc.cfg
	/bin/cp -vf $< $@; doxygen -u $@
184
185

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

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

191
192
doxyview: $(DOXYWWWPATH)/html/index.html
	$(TF_BROWSER) file:$< &
thomas.forbriger's avatar
thomas.forbriger committed
193

194
195
196
197
198
199
200
201
202
#======================================================================
# create package
# --------------
# is delegated to Makefile.packages
# which still has to be coded
PACKAGE=liblinearxx
#ifdef TF_MAKEPKG
#include $(TF_MAKEPKG)
#endif
thomas.forbriger's avatar
thomas.forbriger committed
203
204
205
206
207

#======================================================================
# test code
# ---------

thomas.forbriger's avatar
thomas.forbriger committed
208
matrixtest lapacktest: %: %.cc
thomas.forbriger's avatar
thomas.forbriger committed
209
210
211
212
	$(CXX) -o $@ $< -ltfxx -llinearxx -lgsl -llapack -lblas \
        -lgslcblas -laff \
        $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS)
tests: lapacktest; ./$< -v; rm -fv $<
thomas.forbriger's avatar
thomas.forbriger committed
213
214

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