Merge branch 'minor'
[automake.git] / lib / am / mans.am
blob59d9dd4a2f2cac88e57e3178c71e6038829b7d53
1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 1998-2017 Free Software Foundation, Inc.
4 ## This program is free software; you can redistribute it and/or modify
5 ## it under the terms of the GNU General Public License as published by
6 ## the Free Software Foundation; either version 2, or (at your option)
7 ## any later version.
9 ## This program is distributed in the hope that it will be useful,
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 ## GNU General Public License for more details.
14 ## You should have received a copy of the GNU General Public License
15 ## along with this program.  If not, see <https://www.gnu.org/licenses/>.
17 include inst-vars.am
18 man%SECTION%dir = $(mandir)/man%SECTION%
20 ## ------------ ##
21 ## Installing.  ##
22 ## ------------ ##
24 ## MANS primary are always installed in mandir, hence install-data
25 ## is hard coded.
27 .PHONY: install-man
28 ?INSTALL-MAN?install-data-am: install-man
29 ?INSTALL-MAN?am__installdirs += "$(DESTDIR)$(man%SECTION%dir)"
30 .PHONY install-man: install-man%SECTION%
31 install-man%SECTION%: %DEPS%
32         @$(NORMAL_INSTALL)
33 if %?NOTRANS_MANS%
34 ## Handle MANS with notrans_ prefix
35         @list1='%NOTRANS_SECT_LIST%'; \
36 ?!HAVE_NOTRANS? list2=''; \
37 ?HAVE_NOTRANS?  list2='%NOTRANS_LIST%'; \
38         test -n "$(man%SECTION%dir)" \
39           && test -n "`echo $$list1$$list2`" \
40           || exit 0; \
41         echo " $(MKDIR_P) '$(DESTDIR)$(man%SECTION%dir)'"; \
42         $(MKDIR_P) "$(DESTDIR)$(man%SECTION%dir)" || exit 1; \
43         { for i in $$list1; do echo "$$i"; done;  \
44 ## Extract all items from notrans_man_MANS that should go in this section.
45 ## This must be done dynamically to support conditionals.
46         if test -n "$$list2"; then \
47           for i in $$list2; do echo "$$i"; done \
48 ## Accept for 'man1' files like 'foo.1c' but not 'sub.1/foo.2' or 'foo-2.1.4'.
49             | sed -n '/\.%SECTION%[a-z]*$$/p'; \
50         fi; \
51 ## Extract basename of manpage, change the extension if needed.
52         } | while read p; do \
53 ## Find the file.
54           if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
55           echo "$$d$$p"; echo "$$p"; \
56         done | \
57 ## Extract the basename of the man page and change the extension if needed.
58         sed 'n;s,.*/,,;p;s,\.[^%SECTION%][0-9a-z]*$$,.%SECTION%,' | \
59         sed 'N;N;s,\n, ,g' | { \
60 ## We now have a list "sourcefile basename installed-name".
61         list=; while read file base inst; do \
62           if test "$$base" = "$$inst"; then list="$$list $$file"; else \
63             echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
64             $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man%SECTION%dir)/$$inst" || exit $$?; \
65           fi; \
66         done; \
67         for i in $$list; do echo "$$i"; done | $(am__base_list) | \
68         while read files; do \
69           test -z "$$files" || { \
70             echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man%SECTION%dir)'"; \
71             $(INSTALL_DATA) $$files "$(DESTDIR)$(man%SECTION%dir)" || exit $$?; }; \
72         done; }
73 endif %?NOTRANS_MANS%
74 if %?TRANS_MANS%
75 ## Handle MANS without notrans_ prefix
76         @list1='%TRANS_SECT_LIST%'; \
77 ?!HAVE_TRANS?   list2=''; \
78 ?HAVE_TRANS?    list2='%TRANS_LIST%'; \
79         test -n "$(man%SECTION%dir)" \
80           && test -n "`echo $$list1$$list2`" \
81           || exit 0; \
82         echo " $(MKDIR_P) '$(DESTDIR)$(man%SECTION%dir)'"; \
83         $(MKDIR_P) "$(DESTDIR)$(man%SECTION%dir)" || exit 1; \
84         { for i in $$list1; do echo "$$i"; done;  \
85 ## Extract all items from notrans_man_MANS that should go in this section.
86 ## This must be done dynamically to support conditionals.
87         if test -n "$$list2"; then \
88           for i in $$list2; do echo "$$i"; done \
89 ## Accept for 'man1' files like `foo.1c' but not 'sub.1/foo.2' or 'foo-2.1.4'.
90             | sed -n '/\.%SECTION%[a-z]*$$/p'; \
91         fi; \
92 ## Extract basename of manpage, change the extension if needed.
93         } | while read p; do \
94 ## Find the file.
95           if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
96           echo "$$d$$p"; echo "$$p"; \
97         done | \
98 ## Extract the basename of the man page and change the extension if needed.
99         sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^%SECTION%][0-9a-z]*$$,%SECTION%,;x' \
100               -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
101         sed 'N;N;s,\n, ,g' | { \
102 ## We now have a list "sourcefile basename installed-name".
103         list=; while read file base inst; do \
104           if test "$$base" = "$$inst"; then list="$$list $$file"; else \
105             echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
106             $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man%SECTION%dir)/$$inst" || exit $$?; \
107           fi; \
108         done; \
109         for i in $$list; do echo "$$i"; done | $(am__base_list) | \
110         while read files; do \
111           test -z "$$files" || { \
112             echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man%SECTION%dir)'"; \
113             $(INSTALL_DATA) $$files "$(DESTDIR)$(man%SECTION%dir)" || exit $$?; }; \
114         done; }
115 endif %?TRANS_MANS%
118 ## -------------- ##
119 ## Uninstalling.  ##
120 ## -------------- ##
122 .PHONY: uninstall-man
123 ?INSTALL-MAN?uninstall-am: uninstall-man
124 .PHONY uninstall-man: uninstall-man%SECTION%
125 uninstall-man%SECTION%:
126         @$(NORMAL_UNINSTALL)
127 if %?NOTRANS_MANS%
128 ## Handle MANS with notrans_ prefix
129         @list='%NOTRANS_SECT_LIST%'; test -n "$(man%SECTION%dir)" || exit 0; \
130         files=`{ for i in $$list; do echo "$$i"; done; \
131 ## Extract all items from notrans_man_MANS that should go in this section.
132 ## This must be done dynamically to support conditionals.
133 ?HAVE_NOTRANS?  l2='%NOTRANS_LIST%'; for i in $$l2; do echo "$$i"; done | \
134 ## Accept for 'man1' files like 'foo.1c' but not 'sub.1/foo.2' or 'foo-2.1.4'.
135 ?HAVE_NOTRANS?    sed -n '/\.%SECTION%[a-z]*$$/p'; \
136 ## Extract basename of manpage, change the extension if needed.
137         } | sed 's,.*/,,;s,\.[^%SECTION%][0-9a-z]*$$,.%SECTION%,'`; \
138         dir='$(DESTDIR)$(man%SECTION%dir)'; $(am__uninstall_files_from_dir)
139 endif %?NOTRANS_MANS%
140 if %?TRANS_MANS%
141 ## Handle MANS without notrans_ prefix
142         @list='%TRANS_SECT_LIST%'; test -n "$(man%SECTION%dir)" || exit 0; \
143         files=`{ for i in $$list; do echo "$$i"; done; \
144 ## Extract all items from man_MANS that should go in this section.
145 ## This must be done dynamically to support conditionals.
146 ?HAVE_TRANS?    l2='%TRANS_LIST%'; for i in $$l2; do echo "$$i"; done | \
147 ## Accept for 'man1' files like 'foo.1c' but not 'sub.1/foo.2' or 'foo-2.1.4'.
148 ?HAVE_TRANS?      sed -n '/\.%SECTION%[a-z]*$$/p'; \
149 ## Extract basename of manpage, run it through the program rename
150 ## transform, and change the extension if needed.
151         } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^%SECTION%][0-9a-z]*$$,%SECTION%,;x' \
152               -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
153         dir='$(DESTDIR)$(man%SECTION%dir)'; $(am__uninstall_files_from_dir)
154 endif %?TRANS_MANS%