#!/usr/bin/perl # # Hacked version of installman that just prints out dependencies for # Makefile.bsd-wrapper. When upgrading to a new version of perl, # look at the runpod2man() calls in installman and duplicate here. # use Getopt::Long; use File::Find; require Cwd; umask 022; $usage = "Usage: gen_openbsd_mandep --man1ext=cat1 --man3ext=cat3p Defaults are: man1ext = cat1 man3ext = cat3p "; GetOptions( qw( man1ext=s man3ext=s help) ) || die $usage; die $usage if $opt_help; # These are written funny to avoid -w typo warnings. $man1ext = defined($opt_man1ext) ? $opt_man1ext : 'cat1'; $man3ext = defined($opt_man3ext) ? $opt_man3ext : 'cat3p'; print "# Dependecies generated by the ``gen_openbsd_mandep'' script\n"; # Convert the main pod pages. runpod2man('pod', $man1ext); # Convert the pods for library modules. runpod2man('lib', $man3ext); # Convert the pods embedded in the installed scripts runpod2man('utils', $man1ext, 'c2ph'); runpod2man('utils', $man1ext, 'h2ph'); runpod2man('utils', $man1ext, 'h2xs'); runpod2man('utils', $man1ext, 'perldoc'); runpod2man('utils', $man1ext, 'perlbug'); runpod2man('utils', $man1ext, 'pl2pm'); runpod2man('utils', $man1ext, 'splain'); runpod2man('x2p', $man1ext, 's2p'); runpod2man('x2p', $man1ext, 'a2p.pod'); runpod2man('pod', $man1ext, 'pod2man'); runpod2man('pod', $man1ext, 'pod2html'); runpod2man('lib/ExtUtils', $man1ext, 'xsubpp'); # Man links print " MLINKS= c2ph.1 pstruct.1 "; # Print MANALL decl $manall_lines[0] =~ s/^/MANALL=/; foreach (@manall_lines) { print $_; } print "$manall_line\n" if defined($manall_line); sub runpod2man { # $script is script name if we are installing a manpage embedded # in a script, undef otherwise my($poddir, $manext, $script) = @_; my($downdir); # can't just use .. when installing xsubpp manpage $downdir = $poddir; $downdir =~ s:[^/]+:..:g; my($builddir) = Cwd::getcwd(); chdir $poddir || die "Unable to cd to $poddir directory!\n$!\n"; # Use 1, not cat1 as section $manext =~ /^(cat)?(.*)$/; $pod2man = "\${POD2MAN} --section=$2 --official"; # Make a list of all the .pm and .pod files in the directory. if ($script) { @modpods = ($script); } else { @modpods = (); find(\&lsmodpods, '.'); } foreach $mod (@modpods) { $manpage = $mod; my $tmp; # Skip .pm files that have corresponding .pod files, and Functions.pm. next if (($tmp = $mod) =~ s/\.pm$/.pod/ && -f $tmp); next if ($mod eq 'Pod/Functions.pm'); #### Used only by pod itself # Convert name from File/Basename.pm to File::Basename.3 format, # if necessary. $manpage =~ s#\.p(m|od)$##; if ($^O eq 'os2' || $^O eq 'amigaos' || $^O eq 'uwin') { $manpage =~ s#/#.#g; } else { $manpage =~ s#/#::#g; } $manpage .= ".${manext}"; # Print out the dependency print "$manpage: $poddir/$mod\n\t$pod2man", ' ${.ALLSRC} | ${NROFF} -man > ${.TARGET}', "\n"; # Store for MANALL decl later on if (length($manall_line) + length($manpage) > 69) { push(@manall_lines, "$manall_line \\\n"); undef($manall_line); } if (defined($manall_line)) { $manall_line .= " $manpage"; } else { $manall_line = "\t$manpage"; } } chdir "$builddir" || die "Unable to cd back to $builddir directory!\n$!\n"; } sub lsmodpods { my $dir = $File::Find::dir; my $name = $File::Find::name; if (-f $_) { $name =~ s#^\./##; push(@modpods, $name) if ($name =~ /\.p(m|od)$/); } } exit 0;