Imported Upstream version 6.0
[platform/upstream/dos2unix.git] / man / man1 / Makefile
1 # pod2man.mk -- Makefile portion to convert *.pod files to manual pages
2 #
3 #   Copyright information
4 #
5 #       Copyright (C) 2010 Jari Aalto
6 #
7 #   License
8 #
9 #       Redistribution and use in source and binary forms, with or
10 #       without modification, are permitted provided that the
11 #       following conditions are met:
12 #
13 #       1. Redistributions of source code must retain the above
14 #          copyright notice, this list of conditions and the following
15 #          disclaimer.
16 #
17 #       2. Redistributions in binary form must reproduce the above
18 #          copyright notice, this list of conditions and the following
19 #          disclaimer in the documentation and/or other materials
20 #          provided with the distribution.
21 #
22 #       THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR
23 #       IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 #       WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 #       PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OF THIS
26 #       FILE OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 #       INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 #       (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29 #       GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 #       INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31 #       WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 #       NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 #       THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
34 #       DAMAGE.
35 #
36 #       The license text is copy of the FreeBSD License available at
37 #       <http://www.gnu.org/copyleft/gpl.html> with following
38 #       modifications: wording "THIS SOFTWARE IS PROVIDED BY THE
39 #       FREEBSD PROJECT" was changed to "THIS SOFTWARE IS PROVIDED 'AS
40 #       IS'" and wording "IN NO EVENT SHALL THE FREEBSD PROJECT" was
41 #       changed to "IN NO EVENT SHALL THE AUTHOR(S)"
42 #
43 #   Description
44 #
45 #       Convert *.pod files to manual pages.
46
47 ifneq (,)
48     This makefile requires GNU Make.
49 endif
50
51 # This variable *must* be set when calling
52 PACKAGE         ?= dos2unix
53
54 # Optional variables to set
55 MANSECT         ?= 1
56 PODCENTER       ?= $$(date "+%Y-%m-%d")
57
58 # Directories
59 MANSRC          =
60 MANDEST         = $(MANSRC)
61
62 MANPOD          = $(MANSRC)$(PACKAGE).pod
63 MANPAGE         = $(MANDEST)$(PACKAGE).$(MANSECT)
64
65 POD2MAN         = pod2man
66 POD2MAN_FLAGS   =
67
68 PODFILES = $(wildcard ../*/man1/dos2unix.pod)
69 MAN_OBJECTS = dos2unix.1 $(patsubst %.pod,%.1,$(PODFILES))
70
71 all: $(MAN_OBJECTS)
72
73 %.1 : %.pod
74         # make target - create manual page from a *.pod page
75         podchecker $<
76         LC_CTYPE=C $(POD2MAN) $(POD2MAN_FLAGS) \
77                 --center="$(PODCENTER)" \
78                 --name="$(PACKAGE)" \
79                 --section="$(MANSECT)" \
80                 $< \
81         | sed 's,[Pp]erl v[0-9.]\+,$(PACKAGE),' \
82           > $@ && \
83         rm -f pod*.tmp
84 # fix for bug http://rt.perl.org/rt3//Public/Bug/Display.html?id=79410 
85 # "Pod2man creates wrong ROFF esc sequences for Latin-1 characters."
86 # Create groff (specific) escape sequences which work also on DOS/Windows.
87 # See also: https://rt.cpan.org/Public/Bug/Display.html?id=73804
88         perl -pli.bak \
89                 -e s/A\\\\\\*\'/\\\\[\'A]/g\; \
90                 -e s/a\\\\\\*\'/\\\\[\'a]/g\; \
91                 -e s/E\\\\\\*\'/\\\\[\'E]/g\; \
92                 -e s/e\\\\\\*:/\\\\[:e]/g\; \
93                 -e s/e\\\\\\*\'/\\\\[\'e]/g\; \
94                 -e s/i\\\\\\*\'/\\\\[\'i]/g\; \
95                 -e s/n\\\\\\*~/\\\\[~n]/g\; \
96                 -e s/O\\\\\\*\'/\\\\[\'O]/g\; \
97                 -e s/o\\\\\\*\'/\\\\[\'o]/g\; \
98                 -e s/u\\\\\\*\'/\\\\[\'u]/g\; \
99                 $@
100
101 # End of of Makefile part