/[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 1965 - (show annotations) (download)
Tue Sep 28 12:22:22 2010 UTC (11 years, 7 months ago) by templon
File size: 9604 byte(s)
deleted all the subversion crap.

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

Properties

Name Value
svn:keywords Id Rev Date URL

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