/[pdpsoft]/nl.nikhef.pdp.dynsched/trunk/Makefile
ViewVC logotype

Contents of /nl.nikhef.pdp.dynsched/trunk/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2294 - (show annotations) (download)
Mon May 23 10:06:06 2011 UTC (11 years, 1 month ago) by templon
File size: 10517 byte(s)
changes to get system defined python module path per EMI

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

Properties

Name Value
svn:eol-style native

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