Skip to content

Commit

Permalink
Merge pull request #11 from ACCESS-NRI/mkmf-escape-fix
Browse files Browse the repository at this point in the history
Mkmf escape fix
  • Loading branch information
CodeGat committed Nov 8, 2023
2 parents 0f27404 + 5f70241 commit baaf7ed
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions bin/mkmf
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,22 @@ if( $suffix eq '.a' ) {
print MAKEFILE "$opt_p: \$(OBJ) $opt_l\n\t\$(LD) \$(OBJ) -o $opt_p $opt_l \$(LDFLAGS)\n";
}
close MAKEFILE;

# Make a copy of the completed Makefile, read it back in, escape all relevant `=` signs
# and write it back out
rename($mkfile, $mkfile.'.bak');
open(IN, '<' . $mkfile.'.bak') or die $!;
open(OUT, '>' . $mkfile) or die $!;

print OUT "EQUALS = =";

while(<IN>) {
# Only escape '=' that aren't assignments (aka anything that spaces either side)
$_ =~ s/(?<! )=(?! )/\$\(EQUALS\)/g;
print OUT "$_";
}
close(IN);
close(OUT);
print " $mkfile is ready.\n";

exec 'make', '-f', $mkfile if $opt_x;

0 comments on commit baaf7ed

Please sign in to comment.