Prefer generated manpages over distributed ones.
[automake/plouj.git] / lib / am / mans.am
blob42812543c750f4c5cd225d31c48a29c3392edb8b
1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 1998, 2001, 2003, 2004, 2006, 2008 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 3, 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 <http://www.gnu.org/licenses/>.
17 man%SECTION%dir = $(mandir)/man%SECTION%
19 ## ------------ ##
20 ## Installing.  ##
21 ## ------------ ##
23 ## MANS primary are always installed in mandir, hence install-data
24 ## is hard coded.
26 .PHONY: install-man
27 ?INSTALL-MAN?install-data-am: install-man
28 ?INSTALL-MAN?am__installdirs += "$(DESTDIR)$(man%SECTION%dir)"
29 .PHONY install-man: install-man%SECTION%
30 install-man%SECTION%: $(man%SECTION%_MANS) $(man_MANS)
31         @$(NORMAL_INSTALL)
32         test -z "$(man%SECTION%dir)" || $(MKDIR_P) "$(DESTDIR)$(man%SECTION%dir)"
33         @list='$(man%SECTION%_MANS) $(dist_man%SECTION%_MANS) $(nodist_man%SECTION%_MANS)'; \
34 ## Extract all items from man_MANS that should go in this section.
35 ## This must be done dynamically to support conditionals.
36         l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
37         for i in $$l2; do \
38           case "$$i" in \
39 ## Have to accept files like `foo.1c'.
40             *.%SECTION%*) list="$$list $$i" ;; \
41           esac; \
42         done; \
43         for i in $$list; do \
44 ## Find the file.
45           if test -f $$i; then file=$$i; \
46           else file=$(srcdir)/$$i; fi; \
47 ## Change the extension if needed.
48           ext=`echo $$i | sed -e 's/^.*\\.//'`; \
49           case "$$ext" in \
50             %SECTION%*) ;; \
51             *) ext='%SECTION%' ;; \
52           esac; \
53 ## Extract basename of man page and run it through the program rename
54 ## transform.
55           inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
56           inst=`echo $$inst | sed -e 's/^.*\///'`; \
57           inst=`echo $$inst | sed '$(transform)'`.$$ext; \
58           echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
59           $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man%SECTION%dir)/$$inst"; \
60         done
63 ## -------------- ##
64 ## Uninstalling.  ##
65 ## -------------- ##
67 ## This is just completely gross.
68 .PHONY: uninstall-man
69 ?INSTALL-MAN?uninstall-am: uninstall-man
70 .PHONY uninstall-man: uninstall-man%SECTION%
71 uninstall-man%SECTION%:
72         @$(NORMAL_UNINSTALL)
73         @list='$(man%SECTION%_MANS) $(dist_man%SECTION%_MANS) $(nodist_man%SECTION%_MANS)'; \
74 ## Extract all items from man_MANS that should go in this section.
75 ## This must be done dynamically to support conditionals.
76         l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
77         for i in $$l2; do \
78           case "$$i" in \
79 ## Have to accept files like `foo.1c'.
80             *.%SECTION%*) list="$$list $$i" ;; \
81           esac; \
82         done; \
83         for i in $$list; do \
84 ## Change the extension if needed.
85           ext=`echo $$i | sed -e 's/^.*\\.//'`; \
86           case "$$ext" in \
87             %SECTION%*) ;; \
88             *) ext='%SECTION%' ;; \
89           esac; \
90 ## Extract basename of man page and run it through the program rename
91 ## transform.
92           inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
93           inst=`echo $$inst | sed -e 's/^.*\///'`; \
94           inst=`echo $$inst | sed '$(transform)'`.$$ext; \
95           echo " rm -f '$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
96           rm -f "$(DESTDIR)$(man%SECTION%dir)/$$inst"; \
97         done