summaryrefslogtreecommitdiffstats
path: root/man/local.mk
blob: 2035e8ad0e1972991a8704042815c2ce3a2ea0e4 (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
# opkhelper
# man/local.mk
#
# Copyright (C) 2012-2013 Patrick "P. J." McDermott
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

man_srcs1 = \
	man/oh-installfiles.1in \
	man/oh-strip.1in \
	man/oh-fixperms.1in \
	man/oh-autoconfigure.1in \
	man/oh-autobuild.1in \
	man/oh-autoclean.1in \
	man/oh-autotest.1in \
	man/oh-autoinstall.1in \
	man/oh-architecture.1in
man_man1 = $(man_srcs1:.1in=.1)
man_distfiles = man/local.mk $(man_srcs1)

man_script = \
	s&@@PACKAGE_NAME@@&$(package_name)&;\
	s&@@PACKAGE_VERSION@@&$(package_version)&;\
	s&@@PACKAGE_DESCRIPTION@@&$(package_description)&;

.SUFFIXES: .1in .1

.1in.1:
	@printf '  SED %s\n' '$*.1'
	@abmon='Nul Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec '; \
	date=$$(LC_TIME=POSIX ls -l '$(srcdir)/$*.1in' | sed 's/  / /g' | \
		cut -d ' ' -f 6-8); \
	md="$${date% *}"; \
	m="$$(echo $${abmon% $${md% *} *} | wc -w)"; \
	d="$${md#* }"; \
	[ $${m} -lt 10 ] && m="0$${m}"; \
	[ $${d} -lt 10 ] && d="0$${d}"; \
	y="$${date##* }"; \
	[ "$${y%:*}" != "$${y}" ] && y=$$(date '+%Y'); \
	sed "$(man_script) s&@@DATE@@&$${y}-$${m}-$${d}&;" \
		'$(srcdir)/$*.1in' >'$*.1'