summaryrefslogtreecommitdiff
path: root/japanese/xjman/scripts/configure
blob: eb66aa645232cf91ece73e4f12d9870fa9bb4625 (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
exec /usr/bin/perl -Sx "$0" ${1+"$@"}
#! perl

$WRKSRC = $ENV{'WRKSRC'};
@MANSECS = split(/\s+/, $ENV{'MANSECS'});

for $sec (@MANSECS) {
    print "===> Creating Makefile in man${sec}\n";

    chdir "$WRKSRC/man$sec";
    @manpages = ();
    @mlinks = ();

    for $manpage (<*.${sec}x>) {
	open(F, $manpage) || die "cannot open $manpage: $!\n";
	$_ = <F>;
	chop;
	close(F);
	if (/^\.so /) {
	    ($real = $') =~ s!^man./!!;
	    push(@mlinks, "$real\t$manpage");
	}
	else {
	    push(@manpages, $manpage);
	}
    }

    open(MAKEFILE, '>Makefile');

    if (@manpages) {
	print MAKEFILE join("\t\\\n\t", "MAN${sec} =", sort @manpages);
	print MAKEFILE "\n\n";
    }
    if (@mlinks) {
	print MAKEFILE join("\t\\\n\t", "MLINKS =", sort @mlinks);
	print MAKEFILE "\n\n";
    }

    print MAKEFILE <<EOF;
pages-list:
	@\${ECHO} \${MAN${sec}} \${MLINKS}

.include <bsd.prog.mk>
EOF

    close(MAKEFILE);
}