OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / freeswan / utils / manlink
1 #! /bin/sh
2 # make symlinks to alternate names for manpages
3
4 PATH=/bin:/usr/bin ; export PATH
5 usage="$0 mandir manpage ..."
6
7 if test ! -e $1
8 then
9         echo "$0: directory \`$1' does not exist, aborting" >&2
10         exit 1
11 fi
12 cd $1 || {
13         echo "$0: cannot cd \`$1', aborting" >&2
14         exit 1
15 }
16 shift
17
18 for m
19 do
20         if test ! -f $m
21         then
22                 echo "$0: cannot find \`$m'" >&2
23                 exit 1
24         fi
25         suf=$(expr $m : '.*\([.][^.][^.]*\)$')
26
27         # a .\"+ line rules
28         them=$(awk '/^\.\\"\+[  ]/ { for (i = 2; i <= NF; i++) print $i }' $m)
29
30         # otherwise, try to intuit the list of names from the NAME section
31         if test " $them" = " "
32         then
33                 them=$( awk '/^\.SH[ \t]+NAME/,/^\.SH[ \t]+[^N]/' $m |
34                         egrep -v '^\.' | tr '   ,' '  ' |
35                         sed -n '/  *\\*-  *.*/s///p' | tr -s ' ' '\012' |
36                         egrep -v '^ipsec$' )
37         fi
38
39         # do it
40         for f in $them
41         do
42                 case $f in
43                 ipsec*) ff="$f"         ;;      # ipsec.8, ipsec.conf.5, etc.
44                 *)      ff="ipsec_$f"   ;;
45                 esac
46                 case $ff in
47                 *.[1-8])                        ;;
48                 *)              ff="$ff$suf"    ;;
49                 esac
50                 if test " $ff" != " $m"
51                 then
52                         ln -f -s $m $ff
53                 fi
54         done
55 done