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

Contents of /trunk/nl.nikhef.ndpf.tools/httpd-syslogger/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2737 - (show annotations) (download)
Fri Oct 31 20:16:08 2014 UTC (7 years, 2 months ago) by davidg
File size: 10950 byte(s)
Initial version - sources form www.nikhef.nl

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

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