Makefile 7.07 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
# 
# 05/06/2001 by Thomas Forbriger (IMGF Frankfurt)
# 
# C++ interface for PGPLOT
thomas.forbriger's avatar
GPLed    
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
# ----
thomas.forbriger's avatar
thomas.forbriger committed
24
25
26
# 
# REVISIONS and CHANGES
#    05/06/2001   V1.0   Thomas Forbriger
thomas.forbriger's avatar
thomas.forbriger committed
27
#    14/11/2002   V1.1   place docu on the WWW
thomas.forbriger's avatar
thomas.forbriger committed
28
29
#    28/12/2008   v1.2   reorganized Makefile and provide separate
#                        subdirectory for header files
thomas.forbriger's avatar
thomas.forbriger committed
30
31
32
33
34
35
#    18/09/2010   V1.3   start migration to SVN scheme
#                        - check variables
#                        - copy headers (no symbolic links)
#                        - new doxygen definitions
#                        - package creation not yet implemented
#                        - set TF_REMCMMNT to cat if not defined
thomas.forbriger's avatar
thomas.forbriger committed
36
37
38
# 
# ============================================================================
# 
thomas.forbriger's avatar
thomas.forbriger committed
39

thomas.forbriger's avatar
thomas.forbriger committed
40
41
42
all: install example doxydoc
install: install-include libpgplotCpp.a

43
44
45
46
47
48
49
# ============================================================================
#
CHECKVAR=$(if $($(1)),,$(error ERROR: missing variable $(1)))
CHECKVARS=$(foreach var,$(1),$(call CHECKVAR,$(var)))
#

$(call CHECKVARS,LOCINCLUDEDIR LOCLIBDIR)
50
$(call CHECKVARS,TF_BROWSER TF_WWWBASEDIR TF_LINK_PGPLOT TF_LINK_FORTRAN)
51

thomas.forbriger's avatar
thomas.forbriger committed
52
PGPLOTLIB=-lpgplotCpp -lcpgplot \
thomas.forbriger's avatar
thomas.forbriger committed
53
          $(TF_LINK_PGPLOT)  \
thomas.forbriger's avatar
thomas.forbriger committed
54
          -L$(LOCLIBDIR)
thomas.forbriger's avatar
thomas.forbriger committed
55

thomas.forbriger's avatar
thomas.forbriger committed
56
57
58
# root headers are those that must be installed in the root of the include
# directory hierarchy for historical reasons
ROOTHEADERS=pgplotCpp.h spcpgplotCpp.h xpgplotCpp.h affpgplot.h
thomas.forbriger's avatar
thomas.forbriger committed
59
60
HEADERS=$(ROOTHEADERS) pghandle.h
# only library source code
thomas.forbriger's avatar
thomas.forbriger committed
61
SRC=xpgplotCpp.cc affpgplot.cc pgplotCpp.cc
thomas.forbriger's avatar
thomas.forbriger committed
62
63
# example and test source code
EXSRC=pgtestxx.cc XpgplotCpp.cc
thomas.forbriger's avatar
thomas.forbriger committed
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

ROOTINCINSTALLPATH=$(LOCINCLUDEDIR)
INCINSTALLPATH=$(ROOTINCINSTALLPATH)/pgplotxx
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)))
INSTROOTHEADER=$(addprefix $(ROOTINCINSTALLPATH)/,$(notdir $(ROOTHEADERS)))

# 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
thomas.forbriger's avatar
thomas.forbriger committed
81
82
83
ifndef TF_REMCMMNT
TF_REMCMMNT=cat
endif
thomas.forbriger's avatar
thomas.forbriger committed
84

85
86
87
88
FLAGS+=$(MYFLAGS)
CXXFLAGS+=$(FLAGS) 
LDFLAGS+=-L$(LOCLIBDIR)
CPPFLAGS+=-I$(LOCINCLUDEDIR) -I$(SERVERINCLUDEDIR) $(FLAGS)
thomas.forbriger's avatar
thomas.forbriger committed
89

90
flist: Makefile $(HEADERS) $(SRC) doxydoc.cfg $(EXSRC)
thomas.forbriger's avatar
thomas.forbriger committed
91
92
93
94
95
	echo $^ | tr ' ' '\n' | sort > $@

.PHONY: edit
edit: flist; vim $<

thomas.forbriger's avatar
thomas.forbriger committed
96
97
98
99
100
101
102
103
.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 \*.hd | xargs --no-run-if-empty /bin/rm -v
	-/bin/rm -vf flist *.o install-include *.strip libtpgplotCpp.a
	-/bin/rm -fv XpgplotCpp
thomas.forbriger's avatar
thomas.forbriger committed
104

thomas.forbriger's avatar
thomas.forbriger committed
105
106
107
#======================================================================
# dependencies
# ------------
thomas.forbriger's avatar
thomas.forbriger committed
108

thomas.forbriger's avatar
thomas.forbriger committed
109
110
111
112
113
%.d: %.cc
	$(SHELL) -ec '$(CXX) -M $(CPPFLAGS) $< \
      | sed '\''s,\($(notdir $*)\)\.o[ :]*,$(dir $@)\1.o $@ : ,g'\'' \
        > $@; \
      [ -s $@ ] || rm -f $@'
thomas.forbriger's avatar
thomas.forbriger committed
114

thomas.forbriger's avatar
thomas.forbriger committed
115
-include $(patsubst %.cc,%.d,$(SRC) $(EXSRC))
thomas.forbriger's avatar
thomas.forbriger committed
116
117
118
119
120
121
122


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

libpgplotCpp.a: $(SRC:.cc=.o)
thomas.forbriger's avatar
thomas.forbriger committed
123
124
	ar rcv $@ $^
	ranlib $@
thomas.forbriger's avatar
thomas.forbriger committed
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
	/bin/mv -vf $@ $(LIBINSTALLPATH)

#----------------------------------------------------------------------
# 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; } }' $< > $@
thomas.forbriger's avatar
thomas.forbriger committed
140
	$(TF_REMCMMNT) $< | awk 'BEGIN {hot=0;} \
thomas.forbriger's avatar
thomas.forbriger committed
141
142
143
144
145
146
147
148
        /^ *$$/ { if ((hot) && ($(EMPTYPRINT))) { print; } next; } \
        /^#/ { hot=1; } { if (hot) print; }' >> $@

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

$(INCINSTALLPATH)/%.h: %.h.strip
	mkdir -p $(INCINSTALLPATH)
	-rm -fv $@
thomas.forbriger's avatar
thomas.forbriger committed
149
	/bin/cp -vpd $< $@
thomas.forbriger's avatar
thomas.forbriger committed
150
151
152
153

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

156
.PHONY: install-include
thomas.forbriger's avatar
thomas.forbriger committed
157
install-include: $(INSTHEADER) $(INSTROOTHEADER)
thomas.forbriger's avatar
thomas.forbriger committed
158
159
160
161

#----------------------------------------------------------------------
# eaxmple and test code

162
163
164
165
XpgplotCpp: XpgplotCpp.o install; $(CXX) $< -o $@ $(PGPLOTLIB) -laff \
  $(TF_LINK_FORTRAN)
pgtestxx: pgtestxx.o install; $(CXX) $< -o $@ $(PGPLOTLIB) -laff -ltfxx \
  $(TF_LINK_FORTRAN)
thomas.forbriger's avatar
thomas.forbriger committed
166

thomas.forbriger's avatar
thomas.forbriger committed
167
pgtestxx.run: pgtestxx; pgtestxx -all; /bin/rm -fv pgtestxx
thomas.forbriger's avatar
thomas.forbriger committed
168

thomas.forbriger's avatar
thomas.forbriger committed
169
example: install XpgplotCpp; XpgplotCpp; rm -fv XpgplotCpp XpgplotCpp.o
thomas.forbriger's avatar
thomas.forbriger committed
170

thomas.forbriger's avatar
thomas.forbriger committed
171
172
173
#======================================================================
# documentation part
# ------------------
thomas.forbriger's avatar
thomas.forbriger committed
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#
# 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)/libpgplotxx

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

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

thomas.forbriger's avatar
thomas.forbriger committed
198
DOXYSRC=$(CODE) $(HEADERS)
thomas.forbriger's avatar
thomas.forbriger committed
199

thomas.forbriger's avatar
thomas.forbriger committed
200
201
202
203
204
# create doxygen intermediate configuration
PWD=$(shell env pwd)
doxydoc.xxx: doxydoc.cfg
	sed 's,<OUTPUTDIRECTORY>,$(DOXYWWWPATH),g;s,<STRIPFROMPATH>,$(PWD),g' \
	  $< > $@
205
206
207
# create commented version of doxygen configuration
doxycomm.xxx: doxydoc.cfg
	/bin/cp -vf $< $@; doxygen -u $@
thomas.forbriger's avatar
thomas.forbriger committed
208

thomas.forbriger's avatar
thomas.forbriger committed
209
210
211
$(DOXYWWWPATH)/html/index.html: doxydoc.xxx $(DOXYSRC)
	mkdir -vp $(DOXYWWWPATH)
	doxygen $<
thomas.forbriger's avatar
thomas.forbriger committed
212

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

thomas.forbriger's avatar
thomas.forbriger committed
215
216
doxyview: $(DOXYWWWPATH)/html/index.html
	$(TF_BROWSER) file:$< &
thomas.forbriger's avatar
thomas.forbriger committed
217

thomas.forbriger's avatar
thomas.forbriger committed
218
219
220
221
222
223
224
225
226
#======================================================================
# create package
# --------------
# is delegated to Makefile.packages
# which still has to be coded
PACKAGE=libpgplotxx
#ifdef TF_MAKEPKG
#include $(TF_MAKEPKG)
#endif
thomas.forbriger's avatar
thomas.forbriger committed
227

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