/[pdpsoft]/nl.nikhef.pdp.lrms-py-generic/trunk/Makefile
ViewVC logotype

Annotation of /nl.nikhef.pdp.lrms-py-generic/trunk/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2263 - (hide annotations) (download)
Tue Apr 5 13:43:02 2011 UTC (11 years, 6 months ago) by templon
File size: 10259 byte(s)
add some lines to remind how to release, tag, merge into Makefile


1 templon 1951 #
2 templon 1962 # $Id$
3 templon 2023 # Version: $Rev: 1993 $
4 templon 2263 # LastMod: $Date: 2011/04/05 13:42:38 $
5 templon 1960 # Source: $URL$
6 templon 1951 #
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 templon 1966 _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 templon 1951 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 templon 2262 # determine location for python files
48     MODPATH := $(shell python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib(prefix="$(INSTALLPREFIX)"))')
49 templon 1966
50     _rpm := $(_rpmbuild) --quiet
51     ifneq ($(RPM_VERB),)
52     _rpm := $(_rpmbuild)
53     endif
54    
55 templon 1951 _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 templon 1965 _SVN_ROOT_PATH := $(shell svn info | grep 'Repository Root' | awk '{print $$NF}')
77 templon 1951
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 templon 1965 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 templon 1973 @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 templon 1965 @echo 'then to work on this branch, do the following command:'
108 templon 1975 @echo 'svn switch ${_SVN_ROOT_PATH}/${PROJECT}/branches/RB-x.y.z'
109 templon 2263 @echo 'when done, make a tag:'
110     @echo 'svn copy -m "Creating Release Branch x.y.z" ${_SVN_ROOT_PATH}/${PROJECT}/branches/RB-x.y.z ${_SVN_ROOT_PATH}/${PROJECT}/tags/REL-x.y.z'
111     @echo 'then finally merge the changes back into the trunk except when not relevant:'
112     @echo 'svn switch ${_SVN_ROOT_PATH}/${PROJECT}/trunk'
113     @echo 'svn merge ${_SVN_ROOT_PATH}/${PROJECT}/trunk ${_SVN_ROOT_PATH}/${PROJECT}/tags/REL-x.y.z'
114     @echo 'svn ci -m "Merge release x.y.z changes back into trunk"'
115 templon 1951
116     config.tmp: $(CFG_MK)
117     @sed <$(CFG_MK) >config.tmp '/^DATE=/d'
118     @echo 'DATE=$(_date)' >>config.tmp
119     @cp $(CFG_MK) $(CFG_MK)~
120    
121     ####################################################################
122     # Build distributions in tar & RPM/PKG format
123     ####################################################################
124     #
125     # These targets make distribution tar files and PKGs/RPMs from the
126     # CVS repository, using the version declared in the config file.
127     # The checked-out files in the current directory are neither
128     # modified, nor read (apart from the config file).
129     #
130     # "pack" and "rpm" built from the sources in the current directory.
131     #
132     #
133     # The prep:: target allows the including makefile to specify actions
134     # required to process the files at distribution pack time.
135     #
136     # These targets make distribution tar files and PKGs/RPMs based on the
137     # checked-out sources in the current directory. No connection to
138     # the CVS repository is required, and the files do not need to be
139     # committed. The RPM version numbers are generated from the
140     # version number specified in the config file.
141     #
142    
143     pack: envdir
144     @echo packing distribution...
145     @rm -rf $(_builddir)/$(_prodname)
146     @rm -f $(_sourcedir)/$(_prodtar)
147     @mkdir -p $(_builddir)/$(_prodname)
148     @find . -path '*CVS*' -prune -o -type f -print >files.tmp
149     @tar cfT - files.tmp |(cd $(_builddir)/$(_prodname) ; tar xf -)
150     @rm -f files.tmp
151     @[ ! -f specfile.spec -a -f specfile.cin ] \
152     && cp specfile.cin \
153     $(_builddir)/$(_prodname)/specfile.spec \
154     || : ;
155     @cp cl2rpm \
156     $(_builddir)/$(_prodname)/ > /dev/null 2>&1 \
157     || : ;
158     @cd $(_builddir)/$(_prodname) ; \
159     sed <$(CFG_MK) >config.tmp \
160     -e 's%^RELEASE=\(.*\)%RELEASE=\1%' \
161     -e 's%^VERSION=.*%&$(BRANCH)%' ; \
162     mv config.tmp $(CFG_MK) ; \
163     echo 'TARFILE=$(_prodtar)' >>$(CFG_MK) ; \
164     echo 'PROD=\#' >>$(CFG_MK) ; \
165     $(MAKE) config.sh ;\
166     $(MAKE) prep ;\
167     test -n "$(_test_dep)" && rm -f $(_test_dep) ;\
168     rm -f config.sh
169     @cd $(_builddir) ; tar czf $(_sourcedir)/$(_prodtar) $(_prodname)
170    
171 templon 2023 filelist:
172 templon 1951 #
173     # ---- DO NOT MODIFY BELOW THIS LINE --- NEEDED FOR SPECFILE
174     #
175     @find $(INSTALLPREFIX) -type d | sed -e 's^$(INSTALLPREFIX)g' -e 's/^/%dir /' >> $(INSTALLPREFIX)/.filelist
176     @find $(INSTALLPREFIX) ! -type d -a ! -name ".filelist" | sed -e 's^$(INSTALLPREFIX)g' >> $(INSTALLPREFIX)/.filelist
177     @echo File found in distribution
178     @cat $(INSTALLPREFIX)/.filelist
179    
180     spec: pack
181     @echo generating specfile.spec ...
182     @cd $(_builddir)/$(_prodname) ; \
183     $(MAKE) config.sh ;\
184     ./config.sh <specfile.spec >$(_specdir)/$(_prodname).spec
185     @test -f ChangeLog && \
186     cl2rpm ChangeLog \
187     >>$(_specdir)/$(_prodname).spec || true
188    
189     rpm: spec
190     @echo building rpm ...
191     @cd $(_specdir) ; $(_rpmbuild) -ba $(_specdir)/$(_prodname).spec
192    
193     pkg: spec
194     @echo building pkg ...
195     @cd $(_specdir) ; $(_pkgbuild) -f $(_specdir)/$(_prodname).spec
196    
197     prep::
198    
199     #####################################################################
200     # Create substitution script
201     ####################################################################
202     #
203     # This target reads the config file and creates a shell script which
204     # can substitute variables of the form @VAR@ for all config
205     # variables VAR. The messing around with the temporary makefile is
206     # to ensure that any recursive or external references in the
207     # variable values are evaluated by "make" in the same context as
208     # when the config file is included in the makefile.
209    
210     config.sh: Makefile $(_test_dep)
211     @cp /dev/null makefile.tmp
212     @echo include $(CFG_MK) >>makefile.tmp
213     @echo dumpvars: >>makefile.tmp
214     @cat $(CFG_MK) paths.mk | \
215     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"; '
216     @echo '#!/bin/sh' >config.sh
217     @echo 'sed \' >>config.sh
218     @$(MAKE) -f makefile.tmp dumpvars >/dev/null
219     @echo ' -e "s/\@MSG\@/ ** Generated file : do not edit **/"'>>config.sh
220     @chmod oug+x config.sh
221     @rm makefile.tmp
222    
223     ####################################################################
224     # Configure
225     ####################################################################
226    
227     %:: %.cin config.sh
228     @echo configuring $@ ...
229     @rm -f $@ ; cp $< $@
230     @./config.sh <$< >$@ ; chmod oug-w $@
231    
232     %.$(MANSECT):: %.$(MANSECT).man.cin
233     @echo creating $@ ...
234     @./config.sh <$< >$@ ; chmod oug-w $@
235    
236     configure: $(shell find . -name \*\.cin 2>/dev/null | sed -e 's/.cin//' || echo)
237    
238     ####################################################################
239     # Install
240     ####################################################################
241    
242     install: configure
243     @echo installing in $(INSTALLPREFIX) ...
244     #
245     # MODIFY location of installed scripts/binaries here
246     #
247    
248     ifdef MYMODS
249 templon 2262 @mkdir -p $(MODPATH)
250 templon 1951 for i in $(MYMODS) ; do \
251 templon 2262 install -m 0444 $$i $(MODPATH) ; \
252 templon 1951 done || :
253     endif
254    
255     ifdef MYDOCS
256     @mkdir -p $(INSTALLPREFIX)/$(DOCSUFFIX)
257     for i in $(MYDOCS) ; do \
258     install -m 0444 $$i $(INSTALLPREFIX)/$(DOCSUFFIX) ; \
259     done || :
260     endif
261    
262     ifdef MYCONFIGS
263     @mkdir -p $(INSTALLPREFIX)/$(CONFIGSUFFIX)
264     @for i in $(MYCONFIGS) ; do \
265     install -m 0444 $$i $(INSTALLPREFIX)/$(CONFIGSUFFIX) ; \
266     done || :
267     endif
268    
269     ifdef MYSCRIPTS
270     @mkdir -p $(INSTALLPREFIX)/$(SCRIPTSUFFIX)
271     @for i in $(MYSCRIPTS) ; do \
272     install -m 0555 $$i $(INSTALLPREFIX)/$(SCRIPTSUFFIX) ; \
273     done || :
274     endif
275    
276     ifdef MYTESTFILES
277     @mkdir -p $(INSTALLPREFIX)/$(TESTSUFFIX)
278     @for i in $(MYTESTFILES) ; do \
279     install -m 0555 $$i $(INSTALLPREFIX)/$(TESTSUFFIX) ; \
280     done || :
281     endif
282    
283     ifdef MYPLUGINS
284     @mkdir -p $(INSTALLPREFIX)/$(PLUGINSUFFIX)
285     @for i in $(MYPLUGINS) ; do \
286     install -m 0555 $$i $(INSTALLPREFIX)/$(PLUGINSUFFIX) ; \
287     done || :
288     endif
289    
290     ####################################################################
291    
292     clean::
293     @echo cleaning common files ...
294     @rm -f config.sh config.tex
295     @rm -f `find . -name '*~'`
296     @rm -f `find . -name '*#'`
297     @rm -f `find . -name '*.tmp'`
298     @rm -f `find . -name \*\.cin 2>/dev/null | sed -e 's/.cin//'`
299     dist: pack
300    
301    
302    

Properties

Name Value
svn:keywords Id URL

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