openafs/doc/xml/AdminRef/generate-xml.pl
Andrew Deason d86c4d632e doc: Fix doc/xml for objdir builds
Fix various issues so that building the documentation in doc/xml works
for objdir builds:

- set srcdir=@srcdir@ like all other Makefile's, so VPATH is set
  correctly via Makefile.config

- Pass "--path '@abs_builddir@'" to all xml/xsl processors, so they
  can find the generated version.xml (otherwise they only look in
  srcdir)

- Pass --output when building PDFs, so the generated PDF doesn't go in
  srcdir

- Specify $(srcdir) for $(BOOK).xml and generate-xml.pl

- Change generate-xml.pl to find pod2refentry in srcdir instead of '.'

Change-Id: Id09595dba6e70e3d367a26e279446844750d1fd4
Reviewed-on: https://gerrit.openafs.org/15856
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
2024-09-27 15:16:42 -04:00

49 lines
1.3 KiB
Perl
Executable File

#!/usr/bin/perl
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if $running_under_some_shell;
@sections = ('1', '3', '5', '8');
$TOP_SRCDIR = shift @ARGV;
$srcdir = sprintf "%s/../doc/xml/AdminRef", $TOP_SRCDIR;
$doc_man_pages = sprintf "%s/../doc/man-pages", $TOP_SRCDIR;
open(ENTITIES, ">entities.dtd") || die;
foreach $section (@sections) {
printf "generating section %s...\n", $section;
my @entities = ();
mkdir(sprintf "sect%d", $section);
opendir($DIR, sprintf "%s/pod%d", $doc_man_pages, $section) || die;
while ($podfile = readdir($DIR)) {
next unless $podfile =~ /\.pod$/;
($xmlfile = $podfile) =~ s/\.pod$/.xml/;
($entity = $xmlfile) =~ s/\.xml$//;
printf "%s/pod2refentry < %s > %s\n", $srcdir, $podfile, $xmlfile;
my $rc = system(sprintf "%s/pod2refentry --section=%d < %s/pod%d/%s > sect%d/%s",
$srcdir, $section, $doc_man_pages, $section, $podfile, $section, $xmlfile);
if ($rc != 0) {
die "Failed to generate sect${section}/${xmlfile}: $rc\n";
}
printf ENTITIES "<!ENTITY %s%s SYSTEM \"sect%d/%s\">\n",
$entity, $section, $section, $xmlfile;
push(@entities, $entity);
}
closedir($DIR);
open(SECT, sprintf ">sect%d.xml", $section) || die;
foreach $entity (sort(@entities)) {
printf SECT "&%s%s;\n", $entity, $section;
}
close(SECT);
}
close(ENTITIES);