/[pdpsoft]/trunk/nl.nikhef.ndpf.tools/nikhef-apel/Makefile
ViewVC logotype

Contents of /trunk/nl.nikhef.ndpf.tools/nikhef-apel/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2121 - (show annotations) (download)
Fri Dec 24 10:54:00 2010 UTC (11 years, 1 month ago) by davidg
File size: 11813 byte(s)
With sources

1 #
2 # @(#)$Id: Makefile,v 1.1 2008/02/05 16:58:12 davidg Exp $
3 #
4
5 .PHONY: release minorversion majorversion tagversion
6 .PHONY: pack rpm pkg prep clean dist userdoc apidoc check
7
8 _os := $(shell uname -s)
9 _date := $(shell date '+%d/%m/%y %H:%M')
10
11 #######################################################
12 #
13 # General settings
14 #
15 #######################################################
16
17 ####################################################################
18 # Linux specific settings
19 ####################################################################
20 #
21 #
22
23 _rpmbuild := $(shell [ -x /usr/bin/rpmbuild ] && echo rpmbuild || echo rpm)
24 _builddir := $(shell rpm --eval %_builddir)
25 _specdir := $(shell rpm --eval %_specdir)
26 _sourcedir := $(shell rpm --eval %_sourcedir)
27 _srcrpmdir := $(shell rpm --eval %_srcrpmdir)
28 _rpmdir := $(shell rpm --eval %_rpmdir)
29
30
31 include config.mk
32 _module = $(NAME)
33 _vpfx = $(NAME)_
34 _vtag = $(subst -,_,$(subst .,_,$(_vpfx)$(VERSION)$(BRANCH)))
35 _prodname = $(NAME)-$(VERSION)$(BRANCH)
36 _prodtar = $(_prodname).src.tgz
37
38 JAVAC = /usr/lib/jvm/java/bin/javac
39
40 SOURCES = ApelTool.java CommandLineSupport.java
41
42 CLASSPATH = .:./activation-1.1.jar:./activemq-console-5.4.1.jar:./activemq-core-5.4.1.jar:./activemq-jaas-5.4.1.jar:./activemq-protobuf-1.1.jar:./activemq-web-5.4.1.jar:./commons-logging-1.1.jar:./geronimo-j2ee-management_1.1_spec-1.0.1.jar:./geronimo-jms_1.1_spec-1.1.1.jar
43
44
45
46
47 ###################################################################
48 # Create linux specific build directories
49 ###################################################################
50
51 envdir:: $(_srcrpmdir) $(_rpmdir)
52 $(_srcrpmdir):
53 mkdir -p $(_srcrpmdir)
54 $(_rpmdir):
55 mkdir -p $(_rpmdir)
56
57 ####################################################################
58 # Create new release/version/majorversion
59 ####################################################################
60 #
61 # These targets update the X.Y.Z components of the version in the
62 # config file and then commit the current version, tagging all
63 # files with the release number from the config file. Also
64 # wires the current date and time into the config file. Also
65 # adds an entry to the ChangeLog.
66
67
68 release: config.tmp
69 @echo 'increasing release number x.x.<X> and timestamp..'
70 @perl <config.tmp >config.mk -e 'while (<>) { s/^(VERSION=\d+\.\d+\.)(\d+)(.*)$$/$$1.($$2+1).$$3/e; s/^(RELEASE=)(\d+)(.*)$$/$$1."1".$$3/e; print; }'
71 @$(MAKE) tagversion
72
73 minorversion: config.tmp
74 @echo 'increasing minorversion number x.<X>.x and timestamp..'
75 @perl <config.tmp >config.mk -e 'while (<>) { s/^(VERSION=\d+\.)(\d+)(\..*)$$/$$1.($$2+1).".0"/e; s/^(RELEASE=)(\d+)(.*)$$/$$1."1".$$3/e; print; }'
76 @$(MAKE) tagversion
77
78 majorversion: config.tmp
79 @echo 'increasing majorversion number <X>.x.x and timestamp..'
80 @perl <config.tmp >config.mk -e 'while (<>) \
81 { s/^(VERSION=)(\d+)(\..*)$$/$$1.($$2+1).".0.0"/e; \
82 s/^(RELEASE=)(\d+)(.*)$$/$$1."1".$$3/e; print; }'
83 @$(MAKE) tagversion
84
85 config.tmp: config.mk
86 @cvs update .
87 @sed <config.mk >config.tmp '/^DATE=/d'
88 @echo 'DATE=$(_date)' >>config.tmp
89 @cp config.mk config.mk~
90
91 tagversion:
92 @echo cvs tagging new release: $(VERSION)
93 @rm -f config.tmp
94 @echo Enter ChangeLog comment or hit return key:
95 @perl -e '$$cl=<STDIN>; chomp($$cl); $$date=`date +%Y-%m-%d`; \
96 chomp($$date); \
97 $$login=getlogin(); \
98 $$logstr="<unknown>"; \
99 $$logstr=(getpwnam($$login))[6] if defined $$login; \
100 print $$date." $$logstr\n\n"; \
101 print " * Release: $(VERSION)\n"; \
102 print " - ".$$cl."\n" unless ($$cl eq ""); \
103 print "\n"; ' >ChangeLog.tmp
104 @if [ ! -r ChangeLog ] ; then touch ChangeLog ; cvs add ChangeLog ; fi
105 @cat ChangeLog >>ChangeLog.tmp
106 @mv ChangeLog.tmp ChangeLog
107 @cvs commit -m "Release: $(VERSION)"
108 @cvs tag -F -c `echo $(_vtag) |sed -e s/\\\./_/g -e s/-/_/g`
109 @cvs tag -F -c latest
110
111 ####################################################################
112 # Build distributions in tar & RPM/PKG format
113 ####################################################################
114 #
115 # These targets make distribution tar files and PKGs/RPMs from the
116 # CVS repository, using the version declared in the config file.
117 # The checked-out files in the current directory are neither
118 # modified, nor read (apart from the config file).
119 #
120 # "pack" and "rpm" built from the sources in the current directory.
121 #
122 #
123 # The prep:: target allows the including makefile to specify actions
124 # required to process the files at distribution pack time.
125 #
126 # These targets make distribution tar files and PKGs/RPMs based on the
127 # checked-out sources in the current directory. No connection to
128 # the CVS repository is required, and the files do not need to be
129 # committed. The RPM version numbers are generated from the
130 # version number specified in the config file.
131 #
132
133 pack: envdir
134 @echo packing distribution...
135 @rm -rf $(_builddir)/$(_prodname)
136 @rm -f $(_sourcedir)/$(_prodtar)
137 @mkdir -p $(_builddir)/$(_prodname)
138 @find . -path '*CVS*' -prune -o -type f -print >files.tmp
139 @tar cfT - files.tmp |(cd $(_builddir)/$(_prodname) ; tar xf -)
140 @rm -f files.tmp
141 @[ ! -f specfile.spec -a -f specfile.cin ] \
142 && cp specfile.cin \
143 $(_builddir)/$(_prodname)/specfile.spec \
144 || : ;
145 @cp cl2rpm \
146 $(_builddir)/$(_prodname)/ > /dev/null 2>&1 \
147 || : ;
148 @cd $(_builddir)/$(_prodname) ; \
149 sed <config.mk >config.tmp \
150 -e 's%^RELEASE=\(.*\)%RELEASE=\1%' \
151 -e 's%^VERSION=.*%&$(BRANCH)%' ; \
152 mv config.tmp config.mk ; \
153 echo 'TARFILE=$(_prodtar)' >>config.mk ; \
154 echo 'PROD=\#' >>config.mk ; \
155 $(MAKE) config.sh ;\
156 $(MAKE) prep ;\
157 test -n "$(_test_dep)" && rm -f $(_test_dep) ;\
158 rm -f config.sh
159 @cd $(_builddir) ; tar czf $(_sourcedir)/$(_prodtar) $(_prodname)
160 @cp -p $(_sourcedir)/$(_prodtar) .
161
162 spec: pack
163 @echo generating specfile.spec ...
164 @cd $(_builddir)/$(_prodname) ; \
165 $(MAKE) config.sh ;\
166 ./config.sh <specfile.spec >$(_specdir)/$(_prodname).spec
167 @test -f ChangeLog && \
168 cl2rpm ChangeLog \
169 >>$(_specdir)/$(_prodname).spec 2>/dev/null || true
170
171 rpm: spec
172 @echo building rpm ...
173 @cd $(_specdir) ; $(_rpmbuild) -ba $(_specdir)/$(_prodname).spec
174 @if [ -f $(_srcrpmdir)/$(_prodname)-$(RELEASE).src.rpm ] ; then \
175 mv $(_srcrpmdir)/$(_prodname)-$(RELEASE).src.rpm . ; \
176 fi
177 @if [ -f $(_rpmdir)/i386/$(_prodname)-$(RELEASE).i386.rpm ] ; then \
178 mv $(_rpmdir)/i386/$(_prodname)-$(RELEASE).i386.rpm . ; \
179 fi
180 @if [ -f $(_rpmdir)/i686/$(_prodname)-$(RELEASE).i686.rpm ] ; then \
181 mv $(_rpmdir)/i686/$(_prodname)-$(RELEASE).i686.rpm . ; \
182 fi
183 @if [ -f $(_rpmdir)/x86_64/$(_prodname)-$(RELEASE).x86_64.rpm ] ; then \
184 mv $(_rpmdir)/x86_64/$(_prodname)-$(RELEASE).x86_64.rpm . ; \
185 fi
186 @if [ -f $(_rpmdir)/athlon/$(_prodname)-$(RELEASE).athlon.rpm ] ; then \
187 mv $(_rpmdir)/athlon/$(_prodname)-$(RELEASE).athlon.rpm . ; \
188 fi
189 @if [ -f $(_rpmdir)/ia64/$(_prodname)-$(RELEASE).ia64.rpm ] ; then \
190 mv $(_rpmdir)/ia64/$(_prodname)-$(RELEASE).ia64.rpm . ; \
191 fi
192 @if [ -f $(_rpmdir)/noarch/$(_prodname)-$(RELEASE).noarch.rpm ] ; then \
193 mv $(_rpmdir)/noarch/$(_prodname)-$(RELEASE).noarch.rpm . ; \
194 fi
195
196 pkg: spec
197 @echo building pkg ...
198 @cd $(_specdir) ; $(_pkgbuild) -f $(_specdir)/$(_prodname).spec
199
200 prep::
201
202 #####################################################################
203 # Create substitution script
204 ####################################################################
205 #
206 # This target reads the config file and creates a shell script which
207 # can substitute variables of the form @VAR@ for all config
208 # variables VAR. The messing around with the temporary makefile is
209 # to ensure that any recursive or external references in the
210 # variable values are evaluated by "make" in the same context as
211 # when the config file is included in the makefile.
212
213 config.sh: Makefile $(_test_dep)
214 @cp /dev/null makefile.tmp
215 @echo include config.mk >>makefile.tmp
216 @echo dumpvars: >>makefile.tmp
217 @cat config.mk | \
218 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"; '
219 @echo '#!/bin/sh' >config.sh
220 @echo 'sed \' >>config.sh
221 @$(MAKE) -f makefile.tmp dumpvars >/dev/null
222 @echo ' -e "s/\@MSG\@/ ** Generated file : do not edit **/"'>>config.sh
223 @chmod oug+x config.sh
224 @rm makefile.tmp
225
226 ####################################################################
227 # Configure
228 ####################################################################
229
230 %:: %.cin config.sh
231 @echo configuring $@ ...
232 @rm -f $@ ; cp $< $@
233 @./config.sh <$< >$@ ; chmod oug-w $@
234
235 %.$(MANSECT):: %.$(MANSECT).man.cin
236 @echo creating $@ ...
237 @./config.sh <$< >$@ ; chmod oug-w $@
238
239 ApelTool.class: ApelTool.java
240 $(JAVAC) -cp $(CLASSPATH) $<
241
242 CommandLineSupport.class: CommandLineSupport.java
243 $(JAVAC) -cp $(CLASSPATH) $<
244
245 configure: $(shell find . -name \*\.cin 2>/dev/null | sed -e 's/.cin//' || echo)
246
247 default-install:
248 @[ -f MAINTAINER ] && install -D -m 0644 MAINTAINER $(PREFIX)$(DOCDIR)/MAINTAINER || :
249 @[ -f CHANGES ] && install -D -m 0644 CHANGES $(PREFIX)$(DOCDIR)/CHANGES || :
250 @[ -f ChangeLog ] && install -D -m 0644 ChangeLog $(PREFIX)$(DOCDIR)/ChangeLog || :
251 @[ -f README ] && install -D -m 0644 README $(PREFIX)$(DOCDIR)/README || :
252 @[ -f INSTALL ] && install -D -m 0644 INSTALL $(PREFIX)$(DOCDIR)/INSTALL || :
253 @[ -f LICENSE ] && install -D -m 0644 LICENSE $(PREFIX)$(DOCDIR)/LICENSE || :
254 @[ -d doc ] && cd doc && for i in * ; do \
255 test `expr match $$i .\*\.cin\$$` -eq 0 && install -m 0444 $$i $(PREFIX)/$(DOCDIR)/$$i ; \
256 done || :
257
258
259 ####################################################################
260 # Install
261 ####################################################################
262
263 install: configure default-install ApelTool.class CommandLineSupport.class
264 @echo installing in $(PREFIX) ...
265 #
266 # MODIFY location of installed scripts/binaries here
267 #
268 @mkdir -p $(PREFIX)/$(BINDIR)
269 @mkdir -p $(PREFIX)/$(EXECDIR)
270 install -m 0644 activation-1.1.jar $(PREFIX)/$(EXECDIR)/activation-1.1.jar
271 install -m 0644 activemq-camel-5.4.1.jar $(PREFIX)/$(EXECDIR)/activemq-camel-5.4.1.jar
272 install -m 0644 activemq-console-5.4.1.jar $(PREFIX)/$(EXECDIR)/activemq-console-5.4.1.jar
273 install -m 0644 activemq-core-5.4.1.jar $(PREFIX)/$(EXECDIR)/activemq-core-5.4.1.jar
274 install -m 0644 activemq-jaas-5.4.1.jar $(PREFIX)/$(EXECDIR)/activemq-jaas-5.4.1.jar
275 install -m 0644 activemq-protobuf-1.1.jar $(PREFIX)/$(EXECDIR)/activemq-protobuf-1.1.jar
276 install -m 0644 activemq-web-5.4.1.jar $(PREFIX)/$(EXECDIR)/activemq-web-5.4.1.jar
277 install -m 0644 commons-logging-1.1.jar $(PREFIX)/$(EXECDIR)/commons-logging-1.1.jar
278 install -m 0644 geronimo-j2ee-management_1.1_spec-1.0.1.jar $(PREFIX)/$(EXECDIR)/geronimo-j2ee-management_1.1_spec-1.0.1.jar
279 install -m 0644 geronimo-jms_1.1_spec-1.1.1.jar $(PREFIX)/$(EXECDIR)/geronimo-jms_1.1_spec-1.1.1.jar
280
281 install -m 0644 ApelTool.class $(PREFIX)/$(EXECDIR)/ApelTool.class
282 install -m 0644 CommandLineSupport.class $(PREFIX)/$(EXECDIR)/CommandLineSupport.class
283 install -m 0644 apel.jks $(PREFIX)/$(EXECDIR)/apel.jks
284 install -m 0755 nikhef-apel $(PREFIX)/$(BINDIR)/nikhef-apel
285
286 ####################################################################
287
288 filelist: install
289 @find $(PREFIX) -type d | sed -e 's^$(PREFIX)g' -e 's/^/%dir /' >> $(FILELIST)
290 @find $(PREFIX) ! -type d -a ! -name ".filelist" | sed -e 's^$(PREFIX)g' >> $(FILELIST)
291 @echo Files found in distribution listing $(FILELIST)
292 @cat $(FILELIST)
293
294
295 clean::
296 @echo cleaning common files ...
297 @rm -f config.sh config.tex
298 @rm -f `find . -name '*~'`
299 @rm -f `find . -name '*#'`
300 @rm -f `find . -name '*.tmp'`
301 @rm -f $(_prodtar)
302 @rm -f `find . -name '$(_prodname)-$(RELEASE).*.rpm'`
303
304 dist: pack
305
306
307

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