/[pdpsoft]/nl.nikhef.pdp.lrms-py-generic/branches/RB-2.2.1/Makefile
ViewVC logotype

Contents of /nl.nikhef.pdp.lrms-py-generic/branches/RB-2.2.1/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2260 - (show annotations) (download)
Tue Apr 5 13:29:37 2011 UTC (11 years, 1 month ago) by templon
File size: 9803 byte(s)
changed installation paths, updated version num and documentation

1 #
2 # $Id$
3 # Version: $Rev: 1993 $
4 # LastMod: $Date: 2010-10-08 12:12:18 +0200 (Fri, 08 Oct 2010) $
5 # Source: $URL$
6 #
7
8 #######################################################
9 #
10 # General settings
11 #
12 #######################################################
13
14 .PHONY: release minorversion majorversion tagversion
15 .PHONY: pack rpm pkg prep clean dist userdoc apidoc check
16 .PHONY: checkmndfiles checkcfgtags checkdprfiles
17 .PHONY: checksrctags header help tagstable markobsolete
18
19 ####################################################################
20 # Linux specific settings
21 ####################################################################
22 #
23 #
24
25 _rpmbuild := $(shell [ -x /usr/bin/rpmbuild ] && echo rpmbuild || echo rpm)
26 _builddir := $(shell rpm --eval %_builddir)
27 _specdir := $(shell rpm --eval %_specdir)
28 _sourcedir := $(shell rpm --eval %_sourcedir)
29 _srcrpmdir := $(shell rpm --eval %_srcrpmdir)
30 _rpmdir := $(shell rpm --eval %_rpmdir)
31
32 CFG_MK = config.mk
33 include $(CFG_MK)
34 _module = $(NAME)
35 _vpfx = $(NAME)_
36 _vtag = $(subst -,_,$(subst .,_,$(_vpfx)$(VERSION)$(BRANCH)))
37 _prodname = $(NAME)-$(VERSION)$(BRANCH)
38 _prodtar = $(_prodname).src.tgz
39
40 # if INSTALLPREFIX is defined, install files go there.
41 # Otherwise use TARGPREFIX also as place to install files.
42
43 ifeq ($(INSTALLPREFIX),)
44 INSTALLPREFIX := $(TARGPREFIX)
45 endif
46
47 # determine location for python files
48 MODPATH := $(shell python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib(prefix="$(INSTALLPREFIX)"))')
49
50 _rpm := $(_rpmbuild) --quiet
51 ifneq ($(RPM_VERB),)
52 _rpm := $(_rpmbuild)
53 endif
54
55 _os := $(shell uname -s)
56 _date := $(shell date '+%d/%m/%y %H:%M')
57
58 ###############################################################################
59 # Macros
60 ###############################################################################
61
62 # _error, message
63 # _warn, message
64 # _fatal,err msg,exit code: print "err msg" and quit with "exit code" (the if
65 # clause is just used to group the commands)
66 _fatal = if true; then echo "[FATAL] $(1)">&2; exit $(2); fi
67 _error = echo "[ERROR] $(1)">&2
68 _warn = echo "[WARN] $(1)">&2
69
70 ###############################################################################
71 # SVN
72 ###############################################################################
73 _SVN_BRNCH_SDIR := branches
74 _SVN_TAG_SDIR := tags
75 _SVN_TRNK_SDIR := trunk
76 _SVN_ROOT_PATH := $(shell svn info | grep 'Repository Root' | awk '{print $$NF}')
77
78 ###################################################################
79 # Create linux specific build directories
80 ###################################################################
81
82 envdir:: $(_srcrpmdir) $(_rpmdir)
83 $(_srcrpmdir):
84 mkdir -p $(_srcrpmdir)
85 $(_rpmdir):
86 mkdir -p $(_rpmdir)
87
88 ####################################################################
89 # Create new release/version/majorversion
90 ####################################################################
91 #
92 # These targets update the X.Y.Z components of the version in the
93 # config file and then commit the current version, tagging all
94 # files with the release number from the config file. Also
95 # wires the current date and time into the config file. Also
96 # adds an entry to the ChangeLog.
97
98 # check that the requested operation is allowed:
99 # - refuse to run if SVN passwords/credentials caching is off
100 # - forbid committing in tags/ directory
101
102 release:
103 @echo 'Please figure out what release number you want to use'
104 @echo 'Suppose it is x.y.z'
105 @echo 'Issue the following command:'
106 @echo 'svn copy -m "Creating Release Branch x.y.z" ${_SVN_ROOT_PATH}/${PROJECT}/trunk ${_SVN_ROOT_PATH}/${PROJECT}/branches/RB-x.y.z'
107 @echo 'then to work on this branch, do the following command:'
108 @echo 'svn switch ${_SVN_ROOT_PATH}/${PROJECT}/branches/RB-x.y.z'
109
110 config.tmp: $(CFG_MK)
111 @sed <$(CFG_MK) >config.tmp '/^DATE=/d'
112 @echo 'DATE=$(_date)' >>config.tmp
113 @cp $(CFG_MK) $(CFG_MK)~
114
115 ####################################################################
116 # Build distributions in tar & RPM/PKG format
117 ####################################################################
118 #
119 # These targets make distribution tar files and PKGs/RPMs from the
120 # CVS repository, using the version declared in the config file.
121 # The checked-out files in the current directory are neither
122 # modified, nor read (apart from the config file).
123 #
124 # "pack" and "rpm" built from the sources in the current directory.
125 #
126 #
127 # The prep:: target allows the including makefile to specify actions
128 # required to process the files at distribution pack time.
129 #
130 # These targets make distribution tar files and PKGs/RPMs based on the
131 # checked-out sources in the current directory. No connection to
132 # the CVS repository is required, and the files do not need to be
133 # committed. The RPM version numbers are generated from the
134 # version number specified in the config file.
135 #
136
137 pack: envdir
138 @echo packing distribution...
139 @rm -rf $(_builddir)/$(_prodname)
140 @rm -f $(_sourcedir)/$(_prodtar)
141 @mkdir -p $(_builddir)/$(_prodname)
142 @find . -path '*CVS*' -prune -o -type f -print >files.tmp
143 @tar cfT - files.tmp |(cd $(_builddir)/$(_prodname) ; tar xf -)
144 @rm -f files.tmp
145 @[ ! -f specfile.spec -a -f specfile.cin ] \
146 && cp specfile.cin \
147 $(_builddir)/$(_prodname)/specfile.spec \
148 || : ;
149 @cp cl2rpm \
150 $(_builddir)/$(_prodname)/ > /dev/null 2>&1 \
151 || : ;
152 @cd $(_builddir)/$(_prodname) ; \
153 sed <$(CFG_MK) >config.tmp \
154 -e 's%^RELEASE=\(.*\)%RELEASE=\1%' \
155 -e 's%^VERSION=.*%&$(BRANCH)%' ; \
156 mv config.tmp $(CFG_MK) ; \
157 echo 'TARFILE=$(_prodtar)' >>$(CFG_MK) ; \
158 echo 'PROD=\#' >>$(CFG_MK) ; \
159 $(MAKE) config.sh ;\
160 $(MAKE) prep ;\
161 test -n "$(_test_dep)" && rm -f $(_test_dep) ;\
162 rm -f config.sh
163 @cd $(_builddir) ; tar czf $(_sourcedir)/$(_prodtar) $(_prodname)
164
165 filelist:
166 #
167 # ---- DO NOT MODIFY BELOW THIS LINE --- NEEDED FOR SPECFILE
168 #
169 @find $(INSTALLPREFIX) -type d | sed -e 's^$(INSTALLPREFIX)g' -e 's/^/%dir /' >> $(INSTALLPREFIX)/.filelist
170 @find $(INSTALLPREFIX) ! -type d -a ! -name ".filelist" | sed -e 's^$(INSTALLPREFIX)g' >> $(INSTALLPREFIX)/.filelist
171 @echo File found in distribution
172 @cat $(INSTALLPREFIX)/.filelist
173
174 spec: pack
175 @echo generating specfile.spec ...
176 @cd $(_builddir)/$(_prodname) ; \
177 $(MAKE) config.sh ;\
178 ./config.sh <specfile.spec >$(_specdir)/$(_prodname).spec
179 @test -f ChangeLog && \
180 cl2rpm ChangeLog \
181 >>$(_specdir)/$(_prodname).spec || true
182
183 rpm: spec
184 @echo building rpm ...
185 @cd $(_specdir) ; $(_rpmbuild) -ba $(_specdir)/$(_prodname).spec
186
187 pkg: spec
188 @echo building pkg ...
189 @cd $(_specdir) ; $(_pkgbuild) -f $(_specdir)/$(_prodname).spec
190
191 prep::
192
193 #####################################################################
194 # Create substitution script
195 ####################################################################
196 #
197 # This target reads the config file and creates a shell script which
198 # can substitute variables of the form @VAR@ for all config
199 # variables VAR. The messing around with the temporary makefile is
200 # to ensure that any recursive or external references in the
201 # variable values are evaluated by "make" in the same context as
202 # when the config file is included in the makefile.
203
204 config.sh: Makefile $(_test_dep)
205 @cp /dev/null makefile.tmp
206 @echo include $(CFG_MK) >>makefile.tmp
207 @echo dumpvars: >>makefile.tmp
208 @cat $(CFG_MK) paths.mk | \
209 perl >>makefile.tmp -e 'my $$fmt = "\t\@echo \"-e \\\"s\@%s\@\$$(%s)g\\\" \\\\\"" ; while (<>) { $$v{$$1}=1 if /^([A-Za-z0-9_]+)\s*:?=.*$$/; } map { printf "$$fmt >>config.sh\n", $$_, $$_; } sort(keys(%v)); print "\n"; '
210 @echo '#!/bin/sh' >config.sh
211 @echo 'sed \' >>config.sh
212 @$(MAKE) -f makefile.tmp dumpvars >/dev/null
213 @echo ' -e "s/\@MSG\@/ ** Generated file : do not edit **/"'>>config.sh
214 @chmod oug+x config.sh
215 @rm makefile.tmp
216
217 ####################################################################
218 # Configure
219 ####################################################################
220
221 %:: %.cin config.sh
222 @echo configuring $@ ...
223 @rm -f $@ ; cp $< $@
224 @./config.sh <$< >$@ ; chmod oug-w $@
225
226 %.$(MANSECT):: %.$(MANSECT).man.cin
227 @echo creating $@ ...
228 @./config.sh <$< >$@ ; chmod oug-w $@
229
230 configure: $(shell find . -name \*\.cin 2>/dev/null | sed -e 's/.cin//' || echo)
231
232 ####################################################################
233 # Install
234 ####################################################################
235
236 install: configure
237 @echo installing in $(INSTALLPREFIX) ...
238 #
239 # MODIFY location of installed scripts/binaries here
240 #
241
242 ifdef MYMODS
243 @mkdir -p $(MODPATH)
244 for i in $(MYMODS) ; do \
245 install -m 0444 $$i $(MODPATH) ; \
246 done || :
247 endif
248
249 ifdef MYDOCS
250 @mkdir -p $(INSTALLPREFIX)/$(DOCSUFFIX)
251 for i in $(MYDOCS) ; do \
252 install -m 0444 $$i $(INSTALLPREFIX)/$(DOCSUFFIX) ; \
253 done || :
254 endif
255
256 ifdef MYCONFIGS
257 @mkdir -p $(INSTALLPREFIX)/$(CONFIGSUFFIX)
258 @for i in $(MYCONFIGS) ; do \
259 install -m 0444 $$i $(INSTALLPREFIX)/$(CONFIGSUFFIX) ; \
260 done || :
261 endif
262
263 ifdef MYSCRIPTS
264 @mkdir -p $(INSTALLPREFIX)/$(SCRIPTSUFFIX)
265 @for i in $(MYSCRIPTS) ; do \
266 install -m 0555 $$i $(INSTALLPREFIX)/$(SCRIPTSUFFIX) ; \
267 done || :
268 endif
269
270 ifdef MYTESTFILES
271 @mkdir -p $(INSTALLPREFIX)/$(TESTSUFFIX)
272 @for i in $(MYTESTFILES) ; do \
273 install -m 0555 $$i $(INSTALLPREFIX)/$(TESTSUFFIX) ; \
274 done || :
275 endif
276
277 ifdef MYPLUGINS
278 @mkdir -p $(INSTALLPREFIX)/$(PLUGINSUFFIX)
279 @for i in $(MYPLUGINS) ; do \
280 install -m 0555 $$i $(INSTALLPREFIX)/$(PLUGINSUFFIX) ; \
281 done || :
282 endif
283
284 ####################################################################
285
286 clean::
287 @echo cleaning common files ...
288 @rm -f config.sh config.tex
289 @rm -f `find . -name '*~'`
290 @rm -f `find . -name '*#'`
291 @rm -f `find . -name '*.tmp'`
292 @rm -f `find . -name \*\.cin 2>/dev/null | sed -e 's/.cin//'`
293 dist: pack
294
295
296

Properties

Name Value
svn:keywords Id URL

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28