summaryrefslogtreecommitdiff
path: root/doc/Makefile
blob: 2bdecc996ee145cdd6e54f59ffa74d8cc4ca2bc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#----------------------------------------------------------------------------
#
# PostgreSQL documentation installation makefile
#
# Copyright (c) 1994, Regents of the University of California
#
# $Header: /cvsroot/pgsql/doc/Makefile,v 1.25 2003/08/04 20:52:48 tgl Exp $
#
#----------------------------------------------------------------------------

# This makefile is responsible for installing the documentation. The
# files to be installed are prepared specially and are placed in this
# directory during distribution bundling. In CVS-based trees these
# files don't exist, so we skip the installation in that case.
#
# Before we install the man pages, we massage the section numbers to
# follow the local conventions.
#
# To actually build the documenation, look into the src/ and src/sgml
# subdirectories.

subdir = doc
top_builddir = ..
include $(top_builddir)/src/Makefile.global

.NOTPARALLEL:

ifneq ($(wildcard $(srcdir)/postgres.tar.gz),)
found_html := yes
endif

ifneq ($(wildcard $(srcdir)/man.tar.gz),)
# SCO OpenServer's man system is sufficiently different to not bother.
ifneq ($(PORTNAME), sco)
found_man := yes
endif
endif


ifdef found_man
ifndef sqlmansect
sqlmansect = 7
endif
sqlmansectnum = $(shell expr X'$(sqlmansect)' : X'\([0-9]\)')

all: man1/.timestamp man$(sqlmansectnum)/.timestamp

man1/.timestamp: man$(sqlmansect_dummy)/.timestamp
	@echo timestamp >$@

man$(sqlmansect_dummy)/.timestamp: man.tar.gz
	gzip -d -c $< | $(TAR) xf -
	for file in man1/*.1; do \
	  mv $$file $$file.bak && \
	  sed -e 's/\\fR($(sqlmansect_dummy))/\\fR($(sqlmansectnum))/' $$file.bak >$$file && \
	  rm -f $$file.bak || exit; \
	done
	@echo timestamp >$@

man$(sqlmansectnum)/.timestamp: man$(sqlmansect_dummy)/.timestamp
	$(mkinstalldirs) man$(sqlmansectnum)
	for file in man$(sqlmansect_dummy)/*.$(sqlmansect_dummy); do \
	  sed -e '/^\.TH/s/"$(sqlmansect_dummy)"/"$(sqlmansect)"/'   \
              -e 's/\\fR($(sqlmansect_dummy))/\\fR($(sqlmansectnum))/' \
	      $$file >man$(sqlmansectnum)/`basename $$file | sed 's/.$(sqlmansect_dummy)$$/.$(sqlmansect)/'` || exit; \
	done
	@echo timestamp >$@
endif # found_man


install: all installdirs
ifdef found_html
	gzip -d -c $(srcdir)/postgres.tar.gz | ( cd $(DESTDIR)$(docdir)/html && $(TAR) xf - )
endif
ifdef found_man
	for file in man1/*.1 man$(sqlmansectnum)/*.$(sqlmansect) ; do \
	  $(INSTALL_DATA) $$file $(DESTDIR)$(mandir)/$$file || exit; \
	done
endif


installdirs:
ifdef found_html
	$(mkinstalldirs) $(DESTDIR)$(docdir)/html
endif
ifdef found_man
	$(mkinstalldirs) $(addprefix $(DESTDIR)$(mandir)/man, 1 $(sqlmansectnum))
endif


uninstall:
ifdef found_html
	-rm -f $(addprefix $(DESTDIR)$(docdir)/html/, $(shell gunzip -c $(srcdir)/postgres.tar.gz | tar tf -))
endif
ifdef found_man
	-rm -f $(addprefix $(DESTDIR)$(mandir)/, $(shell gunzip -c $(srcdir)/man.tar.gz | tar tf - | sed -e 's,man$(sqlmansect_dummy)/,man$(sqlmansectnum)/,' -e 's/.$(sqlmansect_dummy)$$/.$(sqlmansect)/'))
endif


clean distclean maintainer-clean:
	rm -rf man1/ man$(sqlmansectnum)/ man$(sqlmansect_dummy)/
	$(MAKE) -C src $@