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

Contents of /nl.nikhef.pdp.dynsched-pbs-plugin/trunk/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2012 - (show annotations) (download)
Fri Oct 8 13:11:04 2010 UTC (11 years, 11 months ago) by templon
File size: 9727 byte(s)
first checkin, copied from old tree

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

Properties

Name Value
svn:eol-style native
svn:keywords Id URL

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