1#=============================================================================
2#
3# Maintainer stuff; don't even LOOK at this - and when you E-mail me
4# about it you'll get blacklisted }:-).
5#
6# I added it only here for other GNU maintainers to look at.
7# In order to use this as-is, you'll need the following utilities:
8#
9# GNU make
10# GNU which-2.x
11# GNU awk
12# GNU date
13# GNU groff
14# texinfo2man.c (I'll make this available via my home page)
15# texi2html
16# cvs2html (archived on https://github.com/CarloWood/cvs2html)
17# rcs2log
18# cut
19# grep
20# egrep
21# test
22# sed
23# head
24# tail
25#
26# This maintainer Makefile provides the following functionality:
27#
28# Targets
29# -------
30#
31# - release
32#	Creates everything and puts it all in the release directory $(WWWDIR)
33#       This target calls all of the below targets.
34#	Note: You must `cvs commit' *before* calling this target!
35#
36# The remaining targets can be used to test a part of the distribution process,
37# but are not really useful on their own otherwise.
38#
39# - cvslog
40#	Generates html-ized ChangeLog from the CVS repository log.
41#
42# - html
43#	Generates html-ized man page(s) (from @PACKAGE@.texi) and
44#	the release front page index.html. index.html is generated by
45#	replacing "!VERSION!" in index.html.in by @VERSION@ and the
46#	word "CHANGELOGLIST" by a list of links the cvslog change logs
47#	(also from previous releases).
48#
49# - @PACKAGE@.lsm
50#	Generates an LSM file for distribution via the web page.
51#	It does this by simply replacing "!VERSION!" by @VERSION@.
52#
53# - README
54#	Generate README file by replacing "!VERSION!" in README.in by
55#	@VERSION@.
56#
57# - @PACKAGE@.1
58#	Generate man page from @PACKAGE@.texi.
59#
60# - ChangeLog
61#	Generates the `ChangeLog' file from the CVS repository logs.
62
63WWWDIR=/home/carlo/www/@PACKAGE@
64TARGET=i386
65REL=1
66AUTHOR=Carlo Wood <carlo@gnu.org>
67TAG:=${shell echo "V@VERSION@" | sed -e 's/\./_/g'}
68PREVTAG:=${shell test -f $(srcdir)/.prevtag && cat $(srcdir)/.prevtag}
69CVSREADACCESS:=${shell if test -f $(srcdir)/CVS/Entries; then echo "yes"; else echo "no"; fi}
70
71test-values:
72	@echo "WWWDIR        = \"$(WWWDIR)\""
73	@echo "TARGET        = \"$(TARGET)\""
74	@echo "REL           = \"$(REL)\""
75	@echo "AUTHOR        = \"$(AUTHOR)\""
76	@echo "TAG           = \"$(TAG)\""
77	@echo "PREVTAG       = \"$(PREVTAG)\""
78	@echo "PACKAGE       = \"@PACKAGE@\""
79	@echo "VERSION       = \"@VERSION@\""
80	@echo "CVSREADACCESS = \"$(CVSREADACCESS)\""
81
82## Make sure the ChangeLog is up to date in maintainer mode
83.PHONY: release tar cvslog html ChangeLog
84
85@PACKAGE@.1: $(srcdir)/@PACKAGE@.1.in $(srcdir)/@PACKAGE@.texi texinfo2man $(srcdir)/configure.ac
86	./texinfo2man $(srcdir)/@PACKAGE@.1.in $(srcdir)/@PACKAGE@.texi > @PACKAGE@.1
87
88texinfo2man: ../indent/texinfo2man.c
89	$(CC) -g -o texinfo2man ../indent/texinfo2man.c
90
91@PACKAGE@.lsm: $(srcdir)/@PACKAGE@.lsm.in $(srcdir)/configure.ac
92	sed -e 's%!VERSION!%'`grep 's,@VERSION' config.status | cut -d, -f3 | sed -e 's/|.*|//'`'%g' $(srcdir)/@PACKAGE@.lsm.in > @PACKAGE@.lsm
93
94reconfig: $(top_builddir)/config.status
95	$(top_builddir)/config.status --recheck
96	$(top_builddir)/config.status
97
98cvslog:
99	@( \
100	   cd $(srcdir); \
101	   D1=`cat .release_second`; \
102	   D2=`date +%s`; \
103	   DD=`echo "$$D1 $$D2" | awk '{ printf("%d\n", ($$2 - $$1)/86400) }'`; \
104	   echo "Last release was $$DD days ago."; \
105	   /usr/src/cvs2html/cvs2html -e -r$(PREVTAG):HEAD -o cvslog-@VERSION@; \
106	 )
107
108ChangeLog:
109	if test $(CVSREADACCESS) = yes; then \
110	echo "`which --skip-dot cvs` \`echo \"\$$*\" | sed -e 's%1970%1990%'\`" > cvs; \
111	chmod 755 cvs; \
112	  here=`pwd`; \
113	  (cd $(srcdir); PATH="$$here:$$PATH" /usr/share/cvs/contrib/rcs2log) | sed -e 's/author.*<author@.*>/$(AUTHOR)/;s/ </  </' > ChangeLog; \
114	  rm cvs; \
115	else \
116	  touch ChangeLog; \
117	fi
118
119release: dist cvslog html @PACKAGE@.lsm NEWS
120	install -m 644 index.html $(WWWDIR)
121	install -m 644 @PACKAGE@.lsm $(WWWDIR)
122	install -m 644 `ls $(srcdir)/cvslog-@VERSION@*.html` $(WWWDIR)
123	install -m 644 $(srcdir)/NEWS $(WWWDIR)
124	install -m 644 @PACKAGE@-@VERSION@.tar.gz $(WWWDIR)
125	gpg -b @PACKAGE@-@VERSION@.tar.gz
126	echo "version: 1.1" > @PACKAGE@-@VERSION@.tar.gz.directive
127	echo "directory: which" >> @PACKAGE@-@VERSION@.tar.gz.directive
128	echo "filename: @PACKAGE@-@VERSION@.tar.gz" >> @PACKAGE@-@VERSION@.tar.gz.directive
129	echo "comment: release of @VERSION@" >> @PACKAGE@-@VERSION@.tar.gz.directive
130	gpg --clearsign @PACKAGE@-@VERSION@.tar.gz.directive
131	rm $(srcdir)/cvslog-@VERSION@*.html
132	cvs tag $(TAG)
133	echo "$(TAG)" > $(srcdir)/.prevtag
134	date +%s > $(srcdir)/.release_second
135	@echo "*** To upload run: ncftpput ftp-upload.gnu.org /incoming/ftp @PACKAGE@-@VERSION@.tar.gz @PACKAGE@-@VERSION@.tar.gz.sig @PACKAGE@-@VERSION@.tar.gz.directive.asc"
136
137##-----------------------------------------------------------------------------
138## `which' specific generation:
139
140html: EXAMPLES $(srcdir)/index.html.in $(srcdir)/configure.ac
141	grep -B2000 '^CHANGELOGLIST' $(srcdir)/index.html.in \
142	    | sed -e 's%!VERSION!%@VERSION@%g' \
143	    | grep -v '^CHANGELOGLIST' > index.html
144	( \
145	  VER=`echo "@VERSION@" | cut -d. -f1`; \
146	  PATCHLEVEL=`echo "@VERSION@" | cut -d. -f2`; \
147	  while test "$$PATCHLEVEL" != "-1" ; do \
148	    echo "<LI><A HREF="cvslog-$$VER.$$PATCHLEVEL.html">Version $$VER.$$PATCHLEVEL</A>" >> index.html; \
149	    PATCHLEVEL=`echo "$$PATCHLEVEL" | awk '{ printf("%d", $$1 - 1); }'`; \
150	  done \
151	)
152	grep -A2000 '^CHANGELOGLIST' $(srcdir)/index.html.in | grep -v '^CHANGELOGLIST' | grep -B2000 '^MANPAGE' | grep -v '^MANPAGE' >> index.html
153	groff -man -Tascii which.1 | sed -e 's/.//g' | head -n 61 | tail -n 58 >> index.html
154	groff -man -Tascii which.1 | sed -e 's/.//g' | head -n 123 | tail -n 51 | grep -B2000 '^ ' >> index.html
155	grep -A2000 '^MANPAGE' $(srcdir)/index.html.in | grep -v '^MANPAGE' | grep -B2000 '^EXAMPLES' | grep -v '^EXAMPLES' >> index.html
156	cat EXAMPLES >> index.html
157	grep -A2000 '^EXAMPLES' $(srcdir)/index.html.in | grep -v '^EXAMPLES' >> index.html
158
159EXAMPLES: which
160	( cd test; ../$(srcdir)/test/whichtest check; ) || exit -1;
161	( cd test; ../$(srcdir)/test/whichtest generate; )
162
163README: which.1 $(srcdir)/README.in $(srcdir)/configure.ac
164	sed -e 's%!VERSION!%'`grep 's,@VERSION' config.status | cut -d, -f3`'%g' $(srcdir)/README.in > README
165	groff -man -Tascii which.1 | sed -e 's/.//g' | head -n 61 | tail -n 58 >> README
166	groff -man -Tascii which.1 | sed -e 's/.//g' | head -n 123 | tail -n 51 | grep -B2000 '^ ' >> README
167