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

Contents of /trunk/nl.nikhef.ndpf.tools/mkgroup-sshlpk/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3196 - (show annotations) (download)
Fri Jun 16 11:58:28 2017 UTC (4 years, 7 months ago) by davidg
File size: 12127 byte(s)
tgz is debian specific

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 2>/dev/null)
25 _specdir := $(shell rpm --eval %_specdir 2>/dev/null)
26 _sourcedir := $(shell rpm --eval %_sourcedir 2>/dev/null)
27 _srcrpmdir := $(shell rpm --eval %_srcrpmdir 2>/dev/null)
28 _rpmdir := $(shell rpm --eval %_rpmdir 2>/dev/null)
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 debtgz:
130 @rm -rf /tmp/pkging/$(_prodname)
131 @mkdir -p /tmp/pkging/$(_prodname)
132 @find . -path '*CVS*' -prune -o -path '*.svn*' -prune -o -type f -print >files.tmp
133 @tar cfT - files.tmp |(cd /tmp/pkging/$(_prodname) ; tar xf -)
134 @rm -f files.tmp
135 @cd /tmp/pkging/$(_prodname) ; \
136 sed <config.mk >config.tmp \
137 -e 's%^RELEASE=\(.*\)%RELEASE=\1%' \
138 -e 's%^VERSION=.*%&$(BRANCH)%' ; \
139 mv config.tmp config.mk ; \
140 echo 'TARFILE=$(_prodtar)' >>config.mk ; \
141 echo 'PROD=\#' >>config.mk ; \
142 $(MAKE) config.sh ;\
143 $(MAKE) prep ;\
144 test -n "$(_test_dep)" && rm -f $(_test_dep) ;\
145 rm -f config.sh
146 @cd /tmp/pkging ; tar czf /tmp/pkging/$(_prodtar) $(_prodname)
147 @cp -p /tmp/pkging/$(_prodtar) .
148
149 deb: control debtgz
150 @rm -rf /tmp/pkging/$(NAME)_$(VERSION)$(BRANCH)-$(RELEASE) 2>/dev/null
151 @mkdir -p /tmp/pkging/$(NAME)_$(VERSION)$(BRANCH)-$(RELEASE)
152 @make PREFIX=/tmp/pkging/$(NAME)_$(VERSION)$(BRANCH)-$(RELEASE) install
153 @mkdir -p /tmp/pkging/$(NAME)_$(VERSION)$(BRANCH)-$(RELEASE)/DEBIAN
154 @cp control /tmp/pkging/$(NAME)_$(VERSION)$(BRANCH)-$(RELEASE)/DEBIAN/
155 @cd /tmp/pkging/; \
156 tar zcf $(NAME)_$(VERSION)$(BRANCH)-$(RELEASE).tgz \
157 $(NAME)_$(VERSION)$(BRANCH)-$(RELEASE)
158 @mv /tmp/pkging/$(NAME)_$(VERSION)$(BRANCH)-$(RELEASE).tgz .
159 @tar zxf $(NAME)_$(VERSION)$(BRANCH)-$(RELEASE).tgz
160 @dpkg-deb --build $(NAME)_$(VERSION)$(BRANCH)-$(RELEASE)
161 @rm -rf $(NAME)_$(VERSION)$(BRANCH)-$(RELEASE)
162
163 pack: envdir
164 @echo packing distribution...
165 @rm -rf $(_builddir)/$(_prodname)
166 @rm -f $(_sourcedir)/$(_prodtar)
167 @mkdir -p $(_builddir)/$(_prodname)
168 @find . -path '*CVS*' -prune -o -path '*.svn*' -prune -o -type f -print >files.tmp
169 @tar cfT - files.tmp |(cd $(_builddir)/$(_prodname) ; tar xf -)
170 @rm -f files.tmp
171 @[ ! -f specfile.spec -a -f specfile.cin ] \
172 && cp specfile.cin \
173 $(_builddir)/$(_prodname)/specfile.spec \
174 || : ;
175 @cp cl2rpm \
176 $(_builddir)/$(_prodname)/ > /dev/null 2>&1 \
177 || : ;
178 @cd $(_builddir)/$(_prodname) ; \
179 sed <config.mk >config.tmp \
180 -e 's%^RELEASE=\(.*\)%RELEASE=\1%' \
181 -e 's%^VERSION=.*%&$(BRANCH)%' ; \
182 mv config.tmp config.mk ; \
183 echo 'TARFILE=$(_prodtar)' >>config.mk ; \
184 echo 'PROD=\#' >>config.mk ; \
185 $(MAKE) config.sh ;\
186 $(MAKE) prep ;\
187 test -n "$(_test_dep)" && rm -f $(_test_dep) ;\
188 rm -f config.sh
189 @cd $(_builddir) ; tar czf $(_sourcedir)/$(_prodtar) $(_prodname)
190 @cp -p $(_sourcedir)/$(_prodtar) .
191
192 spec: pack
193 @echo generating specfile.spec ...
194 @cd $(_builddir)/$(_prodname) ; \
195 $(MAKE) config.sh ;\
196 ./config.sh <specfile.spec >$(_specdir)/$(_prodname).spec
197 @test -f ChangeLog && \
198 cl2rpm ChangeLog \
199 >>$(_specdir)/$(_prodname).spec 2>/dev/null || true
200
201 rpm: spec
202 @echo building rpm ...
203 @cd $(_specdir) ; $(_rpmbuild) -ba $(_specdir)/$(_prodname).spec
204 @if [ -f $(_srcrpmdir)/$(_prodname)-$(RELEASE).src.rpm ] ; then \
205 mv $(_srcrpmdir)/$(_prodname)-$(RELEASE).src.rpm . ; \
206 fi
207 @if [ -f $(_rpmdir)/i386/$(_prodname)-$(RELEASE).i386.rpm ] ; then \
208 mv $(_rpmdir)/i386/$(_prodname)-$(RELEASE).i386.rpm . ; \
209 fi
210 @if [ -f $(_rpmdir)/i686/$(_prodname)-$(RELEASE).i686.rpm ] ; then \
211 mv $(_rpmdir)/i686/$(_prodname)-$(RELEASE).i686.rpm . ; \
212 fi
213 @if [ -f $(_rpmdir)/x86_64/$(_prodname)-$(RELEASE).x86_64.rpm ] ; then \
214 mv $(_rpmdir)/x86_64/$(_prodname)-$(RELEASE).x86_64.rpm . ; \
215 fi
216 @if [ -f $(_rpmdir)/athlon/$(_prodname)-$(RELEASE).athlon.rpm ] ; then \
217 mv $(_rpmdir)/athlon/$(_prodname)-$(RELEASE).athlon.rpm . ; \
218 fi
219 @if [ -f $(_rpmdir)/ia64/$(_prodname)-$(RELEASE).ia64.rpm ] ; then \
220 mv $(_rpmdir)/ia64/$(_prodname)-$(RELEASE).ia64.rpm . ; \
221 fi
222 @if [ -f $(_rpmdir)/noarch/$(_prodname)-$(RELEASE).noarch.rpm ] ; then \
223 mv $(_rpmdir)/noarch/$(_prodname)-$(RELEASE).noarch.rpm . ; \
224 fi
225
226 pkg: spec
227 @echo building pkg ...
228 @cd $(_specdir) ; $(_pkgbuild) -f $(_specdir)/$(_prodname).spec
229
230 prep::
231
232 #####################################################################
233 # Create substitution script
234 ####################################################################
235 #
236 # This target reads the config file and creates a shell script which
237 # can substitute variables of the form @VAR@ for all config
238 # variables VAR. The messing around with the temporary makefile is
239 # to ensure that any recursive or external references in the
240 # variable values are evaluated by "make" in the same context as
241 # when the config file is included in the makefile.
242
243 config.sh: Makefile $(_test_dep)
244 @cp /dev/null makefile.tmp
245 @echo include config.mk >>makefile.tmp
246 @echo dumpvars: >>makefile.tmp
247 @cat config.mk | \
248 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"; '
249 @echo '#!/bin/sh' >config.sh
250 @echo 'sed \' >>config.sh
251 @$(MAKE) -f makefile.tmp dumpvars >/dev/null
252 @echo ' -e "s/\@MSG\@/ ** Generated file : do not edit **/"'>>config.sh
253 @chmod oug+x config.sh
254 @rm makefile.tmp
255
256 ####################################################################
257 # Configure
258 ####################################################################
259
260 %:: %.cin config.sh
261 @echo configuring $@ ...
262 @rm -f $@ ; cp $< $@
263 @./config.sh <$< >$@ ; chmod oug-w $@
264
265 %.$(MANSECT):: %.$(MANSECT).man.cin
266 @echo creating $@ ...
267 @./config.sh <$< >$@ ; chmod oug-w $@
268
269 configure: $(shell find . -name \*\.cin 2>/dev/null | sed -e 's/.cin//' || echo)
270
271 default-install:
272 @[ -f MAINTAINER ] && install -D -m 0644 MAINTAINER $(PREFIX)$(DOCDIR)/MAINTAINER || :
273 @[ -f CHANGES ] && install -D -m 0644 CHANGES $(PREFIX)$(DOCDIR)/CHANGES || :
274 @[ -f ChangeLog ] && install -D -m 0644 ChangeLog $(PREFIX)$(DOCDIR)/ChangeLog || :
275 @[ -f README ] && install -D -m 0644 README $(PREFIX)$(DOCDIR)/README || :
276 @[ -f INSTALL ] && install -D -m 0644 INSTALL $(PREFIX)$(DOCDIR)/INSTALL || :
277 @[ -f LICENSE ] && install -D -m 0644 LICENSE $(PREFIX)$(DOCDIR)/LICENSE || :
278 @[ -d doc ] && cd doc && for i in * ; do \
279 test `expr match $$i .\*\.cin\$$` -eq 0 && install -m 0444 $$i $(PREFIX)/$(DOCDIR)/$$i ; \
280 done || :
281
282
283 ####################################################################
284 # Install
285 ####################################################################
286
287 install: configure default-install
288 @echo installing in $(PREFIX) ...
289 #
290 # MODIFY location of installed scripts/binaries here
291 #
292 @mkdir -p $(PREFIX)/$(DOCDIR)
293 @mkdir -p $(PREFIX)/$(BINDIR)
294 install -m 0755 mkgroup-sshlpk $(PREFIX)/$(BINDIR)/mkgroup-sshlpk
295 install -m 0755 sshlpk-akfgen $(PREFIX)/$(BINDIR)/sshlpk-akfgen
296 install -m 0755 mkhomedir-sshlpk $(PREFIX)/$(BINDIR)/mkhomedir-sshlpk
297 install -m 0644 openssh-lpk.schema $(PREFIX)/$(DOCDIR)/openssh-lpk.schema
298 install -m 0644 README.txt $(PREFIX)/$(DOCDIR)/README.txt
299
300
301 ####################################################################
302
303 filelist: install
304 @find $(PREFIX) -type d | sed -e 's^$(PREFIX)g' -e 's/^/%dir /' >> $(FILELIST)
305 @find $(PREFIX) ! -type d -a ! -name ".filelist" | sed -e 's^$(PREFIX)g' >> $(FILELIST)
306 @echo Files found in distribution listing $(FILELIST)
307 @cat $(FILELIST)
308
309
310 clean::
311 @echo cleaning common files ...
312 @rm -f config.sh config.tex control
313 @rm -f `find . -name '*~'`
314 @rm -f `find . -name '*#'`
315 @rm -f `find . -name '*.tmp'`
316 @rm -f $(_prodtar)
317 @rm -f `find . -name '$(_prodname)-$(RELEASE).*.rpm'`
318 @rm -f $(NAME)_$(VERSION)$(BRANCH)-$(RELEASE).tgz
319 @rm -f $(NAME)_$(VERSION)$(BRANCH)-$(RELEASE).deb
320 @rm -rf $(NAME)_$(VERSION)$(BRANCH)-$(RELEASE)
321
322 dist: pack
323
324
325

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