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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:keywords Id URL

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