summaryrefslogtreecommitdiff
path: root/enc/make_encmake.rb
diff options
context:
space:
mode:
authorYuta Saito <kateinoigakukun@gmail.com>2024-03-03 15:02:00 +0000
committerYuta Saito <kateinoigakukun@gmail.com>2024-03-04 00:57:57 +0900
commit0d9a681eff867b569a31ab4f85a43ce53712a9cd (patch)
treeddf6462b8e6601a848b429298c4ef1831ac25913 /enc/make_encmake.rb
parent072761bb3f794d8176c1f1815d10f1c0ca8eccda (diff)
enc: Expand substitution variables in Makefile.in by default
This change makes `make_encmake.rb` expand all substitution variables when replacing them in `enc/Makefile.in` to avoid propagating all possibly referenced variables to the generated Makefile. The old behavior, which don't expand make variables when generating Makefile, was useful to temporarily override inherited variables like `cflags` in `CFLAGS` at make-time. However, it's not a common use case and it requires to propagate all possibly referenced variables properly considering key name duplication between `enc/Makefile.in` and `RbConfig::CONFIG`.
Diffstat (limited to 'enc/make_encmake.rb')
-rwxr-xr-xenc/make_encmake.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/enc/make_encmake.rb b/enc/make_encmake.rb
index a0bf4be969..09e19f6551 100755
--- a/enc/make_encmake.rb
+++ b/enc/make_encmake.rb
@@ -129,7 +129,12 @@ else
dep = ""
end
mkin = File.read(File.join($srcdir, "Makefile.in"))
-mkin.gsub!(/@(#{CONFIG.keys.join('|')})@/) {CONFIG[$1]}
+# Variables that should not be expanded in Makefile.in to allow
+# overriding inherited variables at make-time.
+not_expand_vars = %w(CFLAGS)
+mkin.gsub!(/@(#{RbConfig::CONFIG.keys.join('|')})@/) do
+ not_expand_vars.include?($1) ? CONFIG[$1] : RbConfig::CONFIG[$1]
+end
File.open(ARGV[0], 'wb') {|f|
f.puts mkin, dep
}