xref: /netbsd-src/share/man/man8/MAKEDEV2manpage.sh (revision ab8cc620097efc5003c47a489e0e785d9446973f)
1d9b6f493Sdillo#!/bin/sh
2d9b6f493Sdillo#
3*ab8cc620Sdbj#       $NetBSD: MAKEDEV2manpage.sh,v 1.5 2005/12/28 03:54:07 dbj Exp $
4d9b6f493Sdillo#
5d9b6f493Sdillo# Copyright (c) 2002
67dc9239dSgrant#       Dieter Baron <dillo@NetBSD.org>.  All rights reserved.
7d9b6f493Sdillo#
8d9b6f493Sdillo# Redistribution and use in source and binary forms, with or without
9d9b6f493Sdillo# modification, are permitted provided that the following conditions
10d9b6f493Sdillo# are met:
11d9b6f493Sdillo# 1. Redistributions of source code must retain the above copyright
12d9b6f493Sdillo#    notice, this list of conditions and the following disclaimer.
13d9b6f493Sdillo# 2. Redistributions in binary form must reproduce the above copyright
14d9b6f493Sdillo#    notice, this list of conditions and the following disclaimer in the
15d9b6f493Sdillo#    documentation and/or other materials provided with the distribution.
16d9b6f493Sdillo# 3. Neither the name of the University nor the names of its contributors
17d9b6f493Sdillo#    may be used to endorse or promote products derived from this software
18d9b6f493Sdillo#    without specific prior written permission.
19d9b6f493Sdillo#
20d9b6f493Sdillo# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21d9b6f493Sdillo# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22d9b6f493Sdillo# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23d9b6f493Sdillo# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24d9b6f493Sdillo# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25d9b6f493Sdillo# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26d9b6f493Sdillo# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27d9b6f493Sdillo# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28d9b6f493Sdillo# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29d9b6f493Sdillo# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30d9b6f493Sdillo# SUCH DAMAGE.
31d9b6f493Sdillo#
32d9b6f493Sdillo#
33d9b6f493Sdillo###########################################################################
34d9b6f493Sdillo#
35d9b6f493Sdillo# Convert src/etc/etc.${ARCH}/MAKEDEV and
36d9b6f493Sdillo# src/share/man/man8/MAKEDEV.8.template to
37d9b6f493Sdillo# src/share/man/man8/man8.${ARCH}/MAKEDEV.8, replacing
38d9b6f493Sdillo#  - @@@SPECIAL@@@ with all targets in the first section (all, std, ...)
39d9b6f493Sdillo#  - @@@DEVICES@@@ with the remaining targets
40d9b6f493Sdillo#  - @@@DATE@@@ with the date from the previous version, if found
41d9b6f493Sdillo#  - @@@ARCH@@@ with the architecture name
42d9b6f493Sdillo# using src/share/man/man8/MAKEDEV2manpage.awk
43d9b6f493Sdillo#
44d9b6f493Sdillo
45d9b6f493SdilloAWK=${AWK:-awk}
46d9b6f493SdilloDIFF=${DIFF:-diff}
47d9b6f493Sdillo
487381215eSjdolecekmanpage="MAKEDEV.8";
49d9b6f493Sdillotmpfile="${manpage}.$$";
50d9b6f493Sdillo
517381215eSjdolecek${AWK} -f MAKEDEV2manpage.awk MAKEDEV.8.template \
52d9b6f493Sdillo	> ${tmpfile} || { rm ${tmpfile}; exit 1; }
53d9b6f493Sdilloif ${DIFF} -I'^\.Dd ' -I'^\.\\" $NetBSD' -q ${manpage} ${tmpfile} \
54d9b6f493Sdillo	>/dev/null
55d9b6f493Sdillothen
56d9b6f493Sdillo	result='unchanged';
57d9b6f493Sdillo	rm ${tmpfile};
58d9b6f493Sdilloelse
59d9b6f493Sdillo	result='updated';
607381215eSjdolecek	if [ `wc -l < ${tmpfile}` -ne `wc -l < ${manpage}` ]; then
61*ab8cc620Sdbj		LC_ALL=C LC_CTYPE=C date=`date +"%B %e, %Y"`
62d9b6f493Sdillo	else
63d9b6f493Sdillo		date=`sed -n 's/^\.Dd //p' ${manpage}`
64d9b6f493Sdillo	fi
65d9b6f493Sdillo	sed "s/@@@DATE@@@/$date/" ${tmpfile} > ${tmpfile}.2
66d9b6f493Sdillo	rm ${tmpfile}
67d9b6f493Sdillo	mv ${tmpfile}.2 ${manpage}
68d9b6f493Sdillofi
697381215eSjdolecekecho "$manpage: ${result}"
70