Makefile 8.16 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) 
# 
# C++ interface to gremlin1
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 
# ============================================================================
#
#     
# 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)
# 
# REVISIONS and CHANGES 
#    30/12/2002   V1.0   Thomas Forbriger
43
#    09/02/2010   V1.1   checked for new compiler
44
#    14/01/2011   V1.2   provide reinstall target
thomas.forbriger's avatar
thomas.forbriger committed
45
46
47
48
49
# 
# ============================================================================
#
# You will find the installed library header files in $(LOCINCLUDEDIR)/aff

50
51
.PHONY: all
all: install doxydoc
52

53
54
.PHONY: doc
doc: doxydoc
55

thomas.forbriger's avatar
thomas.forbriger committed
56
57
58
59
60
61
62
63
64
65
66
67
68
# check mandatory environment variable settings
# ---------------------------------------------

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

$(call CHECKVARS,LOCINCLUDEDIR LOCLIBDIR LOCBINDIR)
$(call CHECKVARS,TF_BROWSER TF_WWWBASEDIR)

# compiler and preprocessor flags
FLAGS=
CXXFLAGS=-Wall -pedantic $(FLAGS) -O3
CXXFLAGS=-Wall $(FLAGS) -O3
uqchw's avatar
uqchw committed
69
LDFLAGS=$(addprefix -L,$(LOCLIBDIR) $(subst :, ,$(SERVERLIBDIR)))
thomas.forbriger's avatar
thomas.forbriger committed
70
CPPFLAGS=-I$(LOCINCLUDEDIR) $(FLAGS)
thomas.forbriger's avatar
thomas.forbriger committed
71
72
73
74
75
76
77
78
79
80

# 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
81
SRC=polymodel.cc greenspec.cc srcires.cc
thomas.forbriger's avatar
thomas.forbriger committed
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# test programs are placed in a subdirectory
TESTS=$(wildcard tests/*.cc)
# whereever we find a README, we will use it
README=$(shell find . -name README) 

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

# 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)
INSTHEADER=$(addprefix $(INCINSTALLPATH)/,$(filter-out ./tests/%,$(HEADERS)))

# 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
thomas.forbriger's avatar
thomas.forbriger committed
105
106
107
ifndef TF_REMCMMNT
TF_REMCMMNT=cat
endif
thomas.forbriger's avatar
thomas.forbriger committed
108

thomas.forbriger's avatar
thomas.forbriger committed
109
#----------------------------------------------------------------------
thomas.forbriger's avatar
thomas.forbriger committed
110
111

# files which are to be edited
112
flist: Makefile doxydoc.cfg $(README) $(HEADERS) $(SRC)
thomas.forbriger's avatar
thomas.forbriger committed
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
	echo $^ | 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
	-find . -name \*.h.strip | xargs --no-run-if-empty /bin/rm -v
	-/bin/rm -vf flist *.o install-include libgremlin1xx.a *.xxx junk*

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

libgremlin1xx.a: install-include $(LIBOBS)
	ar rcv $@ $(LIBOBS)
	ranlib $@
142
143

LIBRARIES=libgremlin1xx.a
144
145

$(LOCLIBDIR): ; mkdir -pv $@
146
.PHONY: install
147
148
149
150
install: $(LOCLIBDIR)
	$(MAKE) install-include
	$(MAKE) $(LIBRARIES)
	/bin/mv -fv $(LIBRARIES) $(LOCLIBDIR)
thomas.forbriger's avatar
thomas.forbriger committed
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

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

#======================================================================
# 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; } }' $< > $@
thomas.forbriger's avatar
thomas.forbriger committed
185
	$(TF_REMCMMNT) $< | awk 'BEGIN {hot=0;} \
thomas.forbriger's avatar
thomas.forbriger committed
186
187
188
189
190
191
192
193
194
        /^ *$$/ { if ((hot) && ($(EMPTYPRINT))) { print; } next; } \
        /^#/ { hot=1; } { if (hot) print; }' >> $@

#----------------------------------------------------------------------
.PRECIOUS: %.h.strip
      
$(INCINSTALLPATH)/%.h: %.h.strip
	mkdir -vp $(dir $@)
	-rm -fv $@
thomas.forbriger's avatar
thomas.forbriger committed
195
	/bin/cp -vpd $$(pwd)/$< $@
thomas.forbriger's avatar
thomas.forbriger committed
196
197

# install header files
thomas.forbriger's avatar
thomas.forbriger committed
198
.PHONY: install-include
thomas.forbriger's avatar
thomas.forbriger committed
199
200
201
install-include: $(INSTHEADER)
	echo $^ | tr ' ' '\n'

202
203
204
205
206
207
208
209
210
211
212
213
214
#======================================================================
# 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
215
216
217
218
219
220
221
222
223
224
225
#======================================================================
# 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
thomas.forbriger's avatar
thomas.forbriger committed
226
# make doxyconf         edit the doxygen configuration file
thomas.forbriger's avatar
thomas.forbriger committed
227
#
thomas.forbriger's avatar
thomas.forbriger committed
228
# If you launch "make doxydoc" the documentation will be written to
thomas.forbriger's avatar
thomas.forbriger committed
229
230
231
232
233
# 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
234
$(call CHECKVARS,TF_WWWBASEDIR TF_BROWSER)
thomas.forbriger's avatar
thomas.forbriger committed
235

thomas.forbriger's avatar
thomas.forbriger committed
236
DOXYWWWPATH=$(TF_WWWBASEDIR)/libgremlin1xx
thomas.forbriger's avatar
thomas.forbriger committed
237

thomas.forbriger's avatar
thomas.forbriger committed
238
.PHONY: doxyclean doxyview doxydoc doxyconf
thomas.forbriger's avatar
thomas.forbriger committed
239

thomas.forbriger's avatar
thomas.forbriger committed
240
doxyclean: ;/bin/rm -rfv $(DOXYWWWPATH)
thomas.forbriger's avatar
thomas.forbriger committed
241

thomas.forbriger's avatar
thomas.forbriger committed
242
DOXYSRC=$(README) $(HEADERS) $(SRC) \
thomas.forbriger's avatar
thomas.forbriger committed
243

thomas.forbriger's avatar
thomas.forbriger committed
244
245
246
247
248
# create doxygen intermediate configuration
PWD=$(shell env pwd)
doxydoc.xxx: doxydoc.cfg
	sed 's,<OUTPUTDIRECTORY>,$(DOXYWWWPATH),g;s,<STRIPFROMPATH>,$(PWD),g' \
	  $< > $@
thomas.forbriger's avatar
thomas.forbriger committed
249

thomas.forbriger's avatar
thomas.forbriger committed
250
251
252
$(DOXYWWWPATH)/html/index.html: doxydoc.xxx $(DOXYSRC)
	mkdir -vp $(DOXYWWWPATH)
	doxygen $<
thomas.forbriger's avatar
thomas.forbriger committed
253

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

thomas.forbriger's avatar
thomas.forbriger committed
256
257
doxyview: $(DOXYWWWPATH)/html/index.html
	$(TF_BROWSER) file:$< &
thomas.forbriger's avatar
thomas.forbriger committed
258
259

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