1# Make Autoconf man pages.
2
3## Copyright (C) 2001, 2004, 2005, 2006 Free Software Foundation, Inc.
4
5## This program is free software; you can redistribute it and/or modify
6## it under the terms of the GNU General Public License as published by
7## the Free Software Foundation; either version 2, or (at your option)
8## any later version.
9
10## This program is distributed in the hope that it will be useful,
11## but WITHOUT ANY WARRANTY; without even the implied warranty of
12## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13## GNU General Public License for more details.
14
15## You should have received a copy of the GNU General Public License
16## along with this program; if not, write to the Free Software
17## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18## 02110-1301, USA.
19
20dist_man_MANS = \
21	$(srcdir)/autoconf.1 \
22	$(srcdir)/autoheader.1 \
23	$(srcdir)/autom4te.1 \
24	$(srcdir)/autoreconf.1 \
25	$(srcdir)/autoscan.1 \
26	$(srcdir)/autoupdate.1 \
27	$(srcdir)/ifnames.1 \
28	$(srcdir)/config.guess.1 \
29	$(srcdir)/config.sub.1
30
31EXTRA_DIST = $(dist_man_MANS:.1=.x) common.x
32MAINTAINERCLEANFILES = $(dist_man_MANS)
33
34# Depend on configure.ac to get version number changes.
35common_dep = $(top_srcdir)/configure.ac $(srcdir)/common.x
36binsrcdir = $(top_srcdir)/bin
37$(srcdir)/autoconf.1:   $(common_dep) $(binsrcdir)/autoconf.as
38$(srcdir)/autoheader.1: $(common_dep) $(binsrcdir)/autoheader.in
39$(srcdir)/autom4te.1:   $(common_dep) $(binsrcdir)/autom4te.in
40$(srcdir)/autoreconf.1: $(common_dep) $(binsrcdir)/autoreconf.in
41$(srcdir)/autoscan.1:   $(common_dep) $(binsrcdir)/autoscan.in
42$(srcdir)/autoupdate.1: $(common_dep) $(binsrcdir)/autoupdate.in
43$(srcdir)/ifnames.1:    $(common_dep) $(binsrcdir)/ifnames.in
44
45# Independent from this package.
46$(srcdir)/config.guess.1: $(top_srcdir)/build-aux/config.guess
47$(srcdir)/config.sub.1:   $(top_srcdir)/build-aux/config.sub
48
49remove_time_stamp = 's/^\(\.TH[^"]*"[^"]*"[^"]*\)"[^"]*"/\1/'
50
51MOSTLYCLEANFILES = $(srcdir)/*.t
52
53SUFFIXES = .x .1
54
55.x.1:
56	@program=`expr "/$*" : '.*/\(.*\)'` && \
57	case $$program in \
58	config.*) ;; \
59	*) \
60	  for dir in $(top_builddir)/bin $(top_builddir)/tests; do \
61	    echo cd $$dir '&&' $(MAKE) $(AM_MAKEFLAGS) $$program && \
62	    (cd $$dir && $(MAKE) $(AM_MAKEFLAGS) $$program) || exit; \
63	  done;; \
64	esac
65	echo "Updating man page $@"
66	PATH="$(top_builddir)/tests$(PATH_SEPARATOR)$(top_srcdir)/build-aux$(PATH_SEPARATOR)$$PATH"; \
67	export PATH; \
68	$(HELP2MAN) \
69	    --include=$*.x \
70	    --include=$(srcdir)/common.x \
71	    --output=$@.t `echo '$*' | sed 's,.*/,,'`
72	if sed $(remove_time_stamp) $@ >$@a.t 2>/dev/null && \
73	   sed $(remove_time_stamp) $@.t | cmp $@a.t - >/dev/null 2>&1; then \
74		touch $@; \
75	else \
76		mv $@.t $@; \
77	fi
78	rm -f $@*.t
79