1919use warnings;
2020
2121use File::Basename;
22+ use Getopt::Long;
2223
2324use FindBin;
2425use lib " $FindBin::RealBin /../catalog" ;
2526
2627use Catalog; # for RenameTempFile
2728
29+ my $output_path = ' .' ;
30+
31+ GetOptions(
32+ ' outdir:s' => \$output_path )
33+ or die " $0 : wrong arguments" ;
34+
2835
2936# Test whether first argument is element of the list in the second
3037# argument
@@ -576,7 +583,7 @@ sub elem
576583# nodetags.h
577584
578585push @output_files , ' nodetags.h' ;
579- open my $nt , ' >' , ' nodetags.h' . $tmpext or die $! ;
586+ open my $nt , ' >' , " $output_path / nodetags.h$tmpext " or die " $output_path /nodetags.h $tmpext : $! " ;
580587
581588printf $nt $header_comment , ' nodetags.h' ;
582589
@@ -620,13 +627,13 @@ sub elem
620627# copyfuncs.c, equalfuncs.c
621628
622629push @output_files , ' copyfuncs.funcs.c' ;
623- open my $cff , ' >' , ' copyfuncs.funcs.c' . $tmpext or die $! ;
630+ open my $cff , ' >' , " $output_path / copyfuncs.funcs.c$tmpext " or die $! ;
624631push @output_files , ' equalfuncs.funcs.c' ;
625- open my $eff , ' >' , ' equalfuncs.funcs.c' . $tmpext or die $! ;
632+ open my $eff , ' >' , " $output_path / equalfuncs.funcs.c$tmpext " or die $! ;
626633push @output_files , ' copyfuncs.switch.c' ;
627- open my $cfs , ' >' , ' copyfuncs.switch.c' . $tmpext or die $! ;
634+ open my $cfs , ' >' , " $output_path / copyfuncs.switch.c$tmpext " or die $! ;
628635push @output_files , ' equalfuncs.switch.c' ;
629- open my $efs , ' >' , ' equalfuncs.switch.c' . $tmpext or die $! ;
636+ open my $efs , ' >' , " $output_path / equalfuncs.switch.c$tmpext " or die $! ;
630637
631638printf $cff $header_comment , ' copyfuncs.funcs.c' ;
632639printf $eff $header_comment , ' equalfuncs.funcs.c' ;
@@ -819,13 +826,13 @@ sub elem
819826# outfuncs.c, readfuncs.c
820827
821828push @output_files , ' outfuncs.funcs.c' ;
822- open my $off , ' >' , ' outfuncs.funcs.c' . $tmpext or die $! ;
829+ open my $off , ' >' , " $output_path / outfuncs.funcs.c$tmpext " or die $! ;
823830push @output_files , ' readfuncs.funcs.c' ;
824- open my $rff , ' >' , ' readfuncs.funcs.c' . $tmpext or die $! ;
831+ open my $rff , ' >' , " $output_path / readfuncs.funcs.c$tmpext " or die $! ;
825832push @output_files , ' outfuncs.switch.c' ;
826- open my $ofs , ' >' , ' outfuncs.switch.c' . $tmpext or die $! ;
833+ open my $ofs , ' >' , " $output_path / outfuncs.switch.c$tmpext " or die $! ;
827834push @output_files , ' readfuncs.switch.c' ;
828- open my $rfs , ' >' , ' readfuncs.switch.c' . $tmpext or die $! ;
835+ open my $rfs , ' >' , " $output_path / readfuncs.switch.c$tmpext " or die $! ;
829836
830837printf $off $header_comment , ' outfuncs.funcs.c' ;
831838printf $rff $header_comment , ' readfuncs.funcs.c' ;
@@ -1130,7 +1137,7 @@ sub elem
11301137# now rename the temporary files to their final names
11311138foreach my $file (@output_files )
11321139{
1133- Catalog::RenameTempFile($ file , $tmpext );
1140+ Catalog::RenameTempFile(" $output_path / $ file" , $tmpext );
11341141}
11351142
11361143
@@ -1144,7 +1151,7 @@ END
11441151 {
11451152 foreach my $file (@output_files )
11461153 {
1147- unlink ($ file . $tmpext );
1154+ unlink (" $output_path / $ file$tmpext" );
11481155 }
11491156 }
11501157
0 commit comments