Makefile 6.09 KB
Newer Older
1
2
# this is <Makefile>
# ----------------------------------------------------------------------------
3
# $Id$
4
5
6
7
# 
# Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) 
# 
# GSE++ library to read and write GSE waveforms
thomas.forbriger's avatar
thomas.forbriger committed
8
# 
thomas.forbriger's avatar
thomas.forbriger committed
9
# ----
thomas.forbriger's avatar
thomas.forbriger committed
10
11
12
13
14
15
16
17
18
19
20
21
22
# 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
23
# ----
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
#
# Installation instructions
# -------------------------
#
# To install the library use target install
#
# To instell the library together with the doxygen documentation,
# use target all. Note that this requires doxygen to be installed.
#
# Look at gsexx_write_example.cc for a brief example on using the code.
#
# The binary library libgsexx.a will be placed in $(LOCLIBDIR). The prototype
# file gsexx.h will be linked to a copy in $(LOCINCLUDEDIR). If these 
# variables are not set in your environment, they will be set to reasonable
# values below. Please check.
#
# The doxygen documentation will be placed in $(DOXYWWWPATH). In case
# $(LOCLIBDIR) is not set in your environment, this will be set to a default
# value too.
thomas.forbriger's avatar
thomas.forbriger committed
43
44
#
# The library code itself depends only on common system libraries.
45
46
47
# 
# REVISIONS and CHANGES 
#    16/03/2002   V1.0   Thomas Forbriger
thomas.forbriger's avatar
thomas.forbriger committed
48
#    14/11/2002   V1.1   place doxygen docu on WWW
thomas.forbriger's avatar
thomas.forbriger committed
49
50
51
#    25/01/2006   V1.2   - added target gsexx_write_example
#                        - reorganized installation procedure and
#                          installation path definitions
52
#    18/09/2010   V1.3   start migration to SVN scheme
thomas.forbriger's avatar
thomas.forbriger committed
53
54
55
56
#                        - check variables
#                        - copy headers (no symbolic links)
#                        - new doxygen definitions
#                        - package creation not yet implemented
57
58
59
60
61
# 
# ============================================================================
# general part
# ------------
#
62

thomas.forbriger's avatar
thomas.forbriger committed
63
all: install doxydoc
64
65
66
install: install-include libgsexx.a

# ============================================================================
thomas.forbriger's avatar
thomas.forbriger committed
67
68
# a variable definition to check variable settings
# ------------------------------------------------
69
70
71
72
73
#
#
CHECKVAR=$(if $($(1)),,$(error ERROR: missing variable $(1)))
CHECKVARS=$(foreach var,$(1),$(call CHECKVAR,$(var)))
#
74

thomas.forbriger's avatar
thomas.forbriger committed
75
76
77
78
79
$(call CHECKVARS,LOCINCLUDEDIR LOCLIBDIR LOCBINDIR)
$(call CHECKVARS,TF_BROWSER TF_WWWBASEDIR)

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

80
FLAGS=
thomas.forbriger's avatar
thomas.forbriger committed
81
FLAGS+=$(MYFLAGS)
thomas.forbriger's avatar
thomas.forbriger committed
82
83
84
CXXFLAGS+=-Wall $(FLAGS)
LDFLAGS+=-L$(LOCLIBDIR)
CPPFLAGS+=-I$(LOCINCLUDEDIR) $(FLAGS)
85
86
87
88
89
90
91
92
93
94

flist: Makefile README $(wildcard *.h *.cc *.cfg)
	echo $^ | tr ' ' '\n' | sort > $@

.PHONY: edit
edit: flist; vim $<

.PHONY: clean
clean: ; 
	-find . -name \*.bak | xargs --no-run-if-empty /bin/rm -v
95
	-/bin/rm -vf flist *.d *.o gsexx_tests
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110

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

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

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

thomas.forbriger's avatar
thomas.forbriger committed
111
112
113
LIBSRC=gsexx.cc gsexx_TCHK2.cc gsexx_TWID2.cc gsexx_TSTA2.cc gsexx_TDAT2.cc \
       gsexx_cm6.cc
INCSRC=gsexx.h gsexx_diff.h gsexx_TDAT2.h
114
115
116

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

thomas.forbriger's avatar
thomas.forbriger committed
117
118
119
120
$(LOCLIBDIR) $(LOCINCLUDEDIR): ; mkdir -pv $@

libgsexx.a: $(patsubst %.cc,%.o,$(LIBSRC)) $(LOCLIBDIR)
	ar rcv $@ $(patsubst %.cc,%.o,$(LIBSRC))
121
	ranlib $@
thomas.forbriger's avatar
thomas.forbriger committed
122
	/bin/mv -fv $@ $(LOCLIBDIR)
123

thomas.forbriger's avatar
thomas.forbriger committed
124
install-include: $(LOCINCLUDEDIR)
thomas.forbriger's avatar
thomas.forbriger committed
125
	/bin/cp -fv gsexx.h $<
126
127
128
129

#======================================================================
# documentation part
# ------------------
thomas.forbriger's avatar
thomas.forbriger committed
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#
# 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)/libgsexx
149

thomas.forbriger's avatar
thomas.forbriger committed
150
151
152
.PHONY: doxyclean doxyview doxydoc doxyconf

doxyclean: ;/bin/rm -rfv $(DOXYWWWPATH)
153

thomas.forbriger's avatar
thomas.forbriger committed
154
DOXYSRC=README $(LIBSRC) $(INCSRC) gsexx_tests.cc gsexx_write_example.cc
155

thomas.forbriger's avatar
thomas.forbriger committed
156
157
158
159
160
161
# create doxygen intermediate configuration
doxydoc.xxx: doxydoc.cfg
	sed 's,<OUTPUTDIRECTORY>,$(DOXYWWWPATH),g;s,<STRIPFROMPATH>,$(PWD),g' \
	  $< > $@

$(DOXYWWWPATH)/html/index.html: doxydoc.xxx $(DOXYSRC)
thomas.forbriger's avatar
thomas.forbriger committed
162
163
164
	mkdir -vp $(DOXYWWWPATH)
	doxygen $<

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

thomas.forbriger's avatar
thomas.forbriger committed
167
168
doxyview: $(DOXYWWWPATH)/html/index.html
	$(TF_BROWSER) file:$< &
thomas.forbriger's avatar
thomas.forbriger committed
169
170
171
172

#======================================================================
# create package
# --------------
thomas.forbriger's avatar
thomas.forbriger committed
173
174
175
176
177
178
# is delegated to Makefile.packages
# which still has to be coded
PACKAGE=libaff
#ifdef TF_MAKEPKG
#include $(TF_MAKEPKG)
#endif
179

180
181
182
183
#======================================================================
# test code
# ---------

thomas.forbriger's avatar
thomas.forbriger committed
184
gsexx_write_example gsexx_tests: %: %.cc
thomas.forbriger's avatar
thomas.forbriger committed
185
	$(CXX) -o $@ $< -I$(LOCINCLUDEDIR) -lgsexx -L$(LOCLIBDIR)
thomas.forbriger's avatar
thomas.forbriger committed
186
tests: gsexx_tests; $<; rm -fv $<
187

thomas.forbriger's avatar
thomas.forbriger committed
188
189
190
191
192
193
194
# Target examples requires SFF programs gse2sff and stuplo to be installed
# to plot the data. Use gsexx_write_example separately to check GSE
# data by other means.
examples: gsexx_write_example
	$<; gse2sff example.gse example.sff -o; stuplo example.sff
	rm -fv $< example.gse example.sff

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