From a22def950a0f7c27ad4f7239581bd77f9592c782 Mon Sep 17 00:00:00 2001 From: Tommy Gatti Date: Wed, 8 Nov 2023 15:00:52 +1100 Subject: [PATCH] Replaced all '=' with '$(EQUALS)' for non-assignment operations --- bin/mkmf | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/bin/mkmf b/bin/mkmf index 75f3cd58c2..7e842b787b 100755 --- a/bin/mkmf +++ b/bin/mkmf @@ -467,6 +467,32 @@ if( $suffix eq '.a' ) { print MAKEFILE "$opt_p: \$(OBJ) $opt_l\n\t\$(LD) \$(OBJ) -o $opt_p $opt_l \$(LDFLAGS)\n"; } close MAKEFILE; + +sub escapeEqualsSign { + my $val = shift; + $val =~ s/=/\$\(EQUALS\)/g; + return $val; +} + +# Make a copy of the completed Makefile, read it back in, escape all `=` signs +# and write it back out +rename($mkfile, $mkfile.'.bak'); +open(IN, '<' . $mkfile.'.bak') or die $!; +open(OUT, '>' . $mkfile) or die $!; + +print OUT "EQUALS= =\n"; + +while() { + # Only escape ASSIGN_OP lines after assignment + if (/^(\S+) = (.*)/) { + $_ = "$1 = " . escapeEqualsSign($2); + } else { + $_ = escapeEqualsSign($_); + } + print OUT $_; +} +close(IN); +close(OUT); print " $mkfile is ready.\n"; exec 'make', '-f', $mkfile if $opt_x;