asciidoc/%.adoc: raddb/%
@echo ADOC $^
@mkdir -p $(dir $@)
- @./scripts/asciidoc/conf2adoc -a ${top_srcdir}/asciidoc < $^ > $@
+ @./scripts/asciidoc/conf2adoc -a ${top_srcdir}/asciidoc -o $@ < $^
asciidoc/%.html: asciidoc/%.adoc
@echo HTML $^
#
#
use File::Basename;
+use File::Spec;
use Getopt::Std;
$was_raw = 0;
$raw = 0;
$blank = 0;
-getopts('a:');
+getopts('a:o:');
$script_dir = dirname(__FILE__);
$filename = "$script_dir/links.txt";
sub process_file {
my $input = shift;
- my $output = shift;
+ my $output_file = shift;
+
+ if (!defined $output_file) {
+ $output = STDOUT;
+ } else {
+ open $output, ">$output_file" or die "Failed creating $output_file: $!\n";
+ }
while (<$input>) {
#
if ($links{$key} =~ /^http/) {
$link = "`link:" . $links{$key} . "[" . $key . "]`";
+
+ } elsif ($links{$key} =~ /^$opt_a/) {
+ #
+ # Link to the *relative* path for the file.
+ # Note that we're passed "-a foo/asciidoc",
+ # and also an output file of "asciidoc/bar.adoc"
+ # So we need to strip out one level of "asciidoc/"
+ #
+ my $absdir = dirname($opt_a . "/" . $output_file);
+ $absdir =~ s,asciidoc/asciidoc,asciidoc/,;
+
+ my $relative = File::Spec->abs2rel($links{$key}, $absdir);
+
+ $link = "link:" . $relative . "[" . $key . "]";
+
} else {
$link = "<<" . $links{$key} . "," . $key . ">>";
}
$opt_a = "";
}
-process_file(STDIN, STDOUT);
+process_file(STDIN, $opt_o);