1717
1818use strict;
1919use warnings;
20+ use Getopt::Long;
2021
2122use File::Basename;
2223
2526
2627use Catalog; # for RenameTempFile
2728
29+ my $output_path = ' .' ;
30+
31+ GetOptions(
32+ ' output:s' => \$output_path );
33+
2834
2935# Test whether first argument is element of the list in the second
3036# argument
@@ -453,7 +459,7 @@ sub elem
453459# nodetags.h
454460
455461push @output_files , ' nodetags.h' ;
456- open my $nt , ' >' , ' nodetags.h' . $tmpext or die $! ;
462+ open my $nt , ' >' , " $output_path / nodetags.h" . $tmpext or die " $output_path /nodetags.h: $! " ;
457463
458464printf $nt $header_comment , ' nodetags.h' ;
459465
@@ -480,13 +486,13 @@ sub elem
480486# copyfuncs.c, equalfuncs.c
481487
482488push @output_files , ' copyfuncs.funcs.c' ;
483- open my $cff , ' >' , ' copyfuncs.funcs.c' . $tmpext or die $! ;
489+ open my $cff , ' >' , " $output_path / copyfuncs.funcs.c" . $tmpext or die $! ;
484490push @output_files , ' equalfuncs.funcs.c' ;
485- open my $eff , ' >' , ' equalfuncs.funcs.c' . $tmpext or die $! ;
491+ open my $eff , ' >' , " $output_path / equalfuncs.funcs.c" . $tmpext or die $! ;
486492push @output_files , ' copyfuncs.switch.c' ;
487- open my $cfs , ' >' , ' copyfuncs.switch.c' . $tmpext or die $! ;
493+ open my $cfs , ' >' , " $output_path / copyfuncs.switch.c" . $tmpext or die $! ;
488494push @output_files , ' equalfuncs.switch.c' ;
489- open my $efs , ' >' , ' equalfuncs.switch.c' . $tmpext or die $! ;
495+ open my $efs , ' >' , " $output_path / equalfuncs.switch.c" . $tmpext or die $! ;
490496
491497printf $cff $header_comment , ' copyfuncs.funcs.c' ;
492498printf $eff $header_comment , ' equalfuncs.funcs.c' ;
@@ -672,13 +678,13 @@ sub elem
672678# outfuncs.c, readfuncs.c
673679
674680push @output_files , ' outfuncs.funcs.c' ;
675- open my $off , ' >' , ' outfuncs.funcs.c' . $tmpext or die $! ;
681+ open my $off , ' >' , " $output_path / outfuncs.funcs.c" . $tmpext or die $! ;
676682push @output_files , ' readfuncs.funcs.c' ;
677- open my $rff , ' >' , ' readfuncs.funcs.c' . $tmpext or die $! ;
683+ open my $rff , ' >' , " $output_path / readfuncs.funcs.c" . $tmpext or die $! ;
678684push @output_files , ' outfuncs.switch.c' ;
679- open my $ofs , ' >' , ' outfuncs.switch.c' . $tmpext or die $! ;
685+ open my $ofs , ' >' , " $output_path / outfuncs.switch.c" . $tmpext or die $! ;
680686push @output_files , ' readfuncs.switch.c' ;
681- open my $rfs , ' >' , ' readfuncs.switch.c' . $tmpext or die $! ;
687+ open my $rfs , ' >' , " $output_path / readfuncs.switch.c" . $tmpext or die $! ;
682688
683689printf $off $header_comment , ' outfuncs.funcs.c' ;
684690printf $rff $header_comment , ' readfuncs.funcs.c' ;
@@ -976,7 +982,7 @@ sub elem
976982# now rename the temporary files to their final names
977983foreach my $file (@output_files )
978984{
979- Catalog::RenameTempFile($ file , $tmpext );
985+ Catalog::RenameTempFile(" $output_path / $ file" , $tmpext );
980986}
981987
982988
0 commit comments