Implement the `notrans_' prefix for untransformed manpages.
[platform/upstream/automake.git] / lib / am / mans.am
1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 1998, 2001, 2003, 2004, 2006, 2008 Free Software
3 ## 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 3, 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, see <http://www.gnu.org/licenses/>.
17
18 man%SECTION%dir = $(mandir)/man%SECTION%
19
20 ## ------------ ##
21 ## Installing.  ##
22 ## ------------ ##
23
24 ## MANS primary are always installed in mandir, hence install-data
25 ## is hard coded.
26
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         test -z "$(man%SECTION%dir)" || $(MKDIR_P) "$(DESTDIR)$(man%SECTION%dir)"
34 if %?NOTRANS_MANS%
35 ## Handle MANS with notrans_ prefix
36         @list='%NOTRANS_SECT_LIST%'; \
37 ## Extract all items from notrans_man_MANS that should go in this section.
38 ## This must be done dynamically to support conditionals.
39 ?HAVE_NOTRANS?  l2='%NOTRANS_LIST%'; \
40 ?HAVE_NOTRANS?  for i in $$l2; do \
41 ?HAVE_NOTRANS?    case "$$i" in \
42 ## Have to accept files like `foo.1c'.
43 ?HAVE_NOTRANS?      *.%SECTION%*) list="$$list $$i" ;; \
44 ?HAVE_NOTRANS?    esac; \
45 ?HAVE_NOTRANS?  done; \
46         for i in $$list; do \
47 ## Find the file.
48           if test -f $$i; then file=$$i; \
49           else file=$(srcdir)/$$i; fi; \
50 ## Change the extension if needed.
51           ext=`echo $$i | sed -e 's/^.*\\.//'`; \
52           case "$$ext" in \
53             %SECTION%*) ;; \
54             *) ext='%SECTION%' ;; \
55           esac; \
56 ## Extract basename of man page and append extension.
57           inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
58           inst=`echo $$inst | sed -e 's/^.*\///'`.$$ext; \
59           echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
60           $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man%SECTION%dir)/$$inst"; \
61         done
62 endif %?NOTRANS_MANS%
63 if %?TRANS_MANS%
64 ## Handle MANS without notrans_ prefix
65         @list='%TRANS_SECT_LIST%'; \
66 ## Extract all items from man_MANS that should go in this section.
67 ## This must be done dynamically to support conditionals.
68 ?HAVE_TRANS?    l2='%TRANS_LIST%'; \
69 ?HAVE_TRANS?    for i in $$l2; do \
70 ?HAVE_TRANS?      case "$$i" in \
71 ## Have to accept files like `foo.1c'.
72 ?HAVE_TRANS?        *.%SECTION%*) list="$$list $$i" ;; \
73 ?HAVE_TRANS?      esac; \
74 ?HAVE_TRANS?    done; \
75         for i in $$list; do \
76 ## Find the file.
77           if test -f $$i; then file=$$i; \
78           else file=$(srcdir)/$$i; fi; \
79 ## Change the extension if needed.
80           ext=`echo $$i | sed -e 's/^.*\\.//'`; \
81           case "$$ext" in \
82             %SECTION%*) ;; \
83             *) ext='%SECTION%' ;; \
84           esac; \
85 ## Extract basename of man page and run it through the program rename
86 ## transform.
87           inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
88           inst=`echo $$inst | sed -e 's/^.*\///'`; \
89           inst=`echo $$inst | sed '$(transform)'`.$$ext; \
90           echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
91           $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man%SECTION%dir)/$$inst"; \
92         done
93 endif %?TRANS_MANS%
94
95
96 ## -------------- ##
97 ## Uninstalling.  ##
98 ## -------------- ##
99
100 ## This is just completely gross.
101 .PHONY: uninstall-man
102 ?INSTALL-MAN?uninstall-am: uninstall-man
103 .PHONY uninstall-man: uninstall-man%SECTION%
104 uninstall-man%SECTION%:
105         @$(NORMAL_UNINSTALL)
106 if %?NOTRANS_MANS%
107 ## Handle MANS with notrans_ prefix
108         @list='%NOTRANS_SECT_LIST%'; \
109 ## Extract all items from notrans_man_MANS that should go in this section.
110 ## This must be done dynamically to support conditionals.
111 ?HAVE_NOTRANS?  l2='%NOTRANS_LIST%'; \
112 ?HAVE_NOTRANS?  for i in $$l2; do \
113 ?HAVE_NOTRANS?    case "$$i" in \
114 ## Have to accept files like `foo.1c'.
115 ?HAVE_NOTRANS?      *.%SECTION%*) list="$$list $$i" ;; \
116 ?HAVE_NOTRANS?    esac; \
117 ?HAVE_NOTRANS?  done; \
118         for i in $$list; do \
119 ## Change the extension if needed.
120           ext=`echo $$i | sed -e 's/^.*\\.//'`; \
121           case "$$ext" in \
122             %SECTION%*) ;; \
123             *) ext='%SECTION%' ;; \
124           esac; \
125 ## Extract basename of man page and append extension.
126           inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
127           inst=`echo $$inst | sed -e 's/^.*\///'`.$$ext; \
128           echo " rm -f '$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
129           rm -f "$(DESTDIR)$(man%SECTION%dir)/$$inst"; \
130         done
131 endif %?NOTRANS_MANS%
132 if %?TRANS_MANS%
133 ## Handle MANS without notrans_ prefix
134         @list='%TRANS_SECT_LIST%'; \
135 ## Extract all items from man_MANS that should go in this section.
136 ## This must be done dynamically to support conditionals.
137 ?HAVE_TRANS?    l2='%TRANS_LIST%'; \
138 ?HAVE_TRANS?    for i in $$l2; do \
139 ?HAVE_TRANS?      case "$$i" in \
140 ## Have to accept files like `foo.1c'.
141 ?HAVE_TRANS?        *.%SECTION%*) list="$$list $$i" ;; \
142 ?HAVE_TRANS?      esac; \
143 ?HAVE_TRANS?    done; \
144         for i in $$list; do \
145 ## Change the extension if needed.
146           ext=`echo $$i | sed -e 's/^.*\\.//'`; \
147           case "$$ext" in \
148             %SECTION%*) ;; \
149             *) ext='%SECTION%' ;; \
150           esac; \
151 ## Extract basename of man page and run it through the program rename
152 ## transform.
153           inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
154           inst=`echo $$inst | sed -e 's/^.*\///'`; \
155           inst=`echo $$inst | sed '$(transform)'`.$$ext; \
156           echo " rm -f '$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
157           rm -f "$(DESTDIR)$(man%SECTION%dir)/$$inst"; \
158         done
159 endif %?TRANS_MANS%