aboutsummaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authorJun Aruga <jaruga@redhat.com>2023-05-31 00:10:41 +0200
committerJun Aruga <jaruga@redhat.com>2023-05-31 08:32:38 +0200
commitb551eb86f6466801d27e841e6e7384648532ddf6 (patch)
treebe97db406c0b9e0384181008c013358e2d38085d /ext
parent22e601a08cd59264a8faa7aecb27f6cf03dfabfd (diff)
downloadruby-openssl-b551eb86f6466801d27e841e6e7384648532ddf6.tar.gz
Append flags from environment variables.
According to the `mkmf.rb#init_mkmf`, there are command line options below. * `--with-cflags` to set the `cflags` * `--with-ldflags` to set the `ldflags` For example the following command compiles with the specified flags. Note that `MAKEFLAGS` is to print the compiler command lines. ``` $ MAKEFLAGS="V=1" \ bundle exec rake compile -- \ --with-cflags="-Wundef -Werror" \ --with-ldflags="-fstack-protector" ``` However, I couldn't find command line options to append the flags. And this commit is to append the `cflags` and `ldflags` by the environment variables. ``` $ MAKEFLAGS="V=1" \ RUBY_OPENSSL_EXTCFLAGS="-Wundef -Werror" \ RUBY_OPENSSL_EXTLDFLAGS="-fstack-protector" \ bundle exec rake compile ```
Diffstat (limited to 'ext')
-rw-r--r--ext/openssl/extconf.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/ext/openssl/extconf.rb b/ext/openssl/extconf.rb
index ef21bd5f..737d9318 100644
--- a/ext/openssl/extconf.rb
+++ b/ext/openssl/extconf.rb
@@ -18,6 +18,12 @@ dir_config("kerberos")
Logging::message "=== OpenSSL for Ruby configurator ===\n"
+# Append flags from environment variables.
+extcflags = ENV["RUBY_OPENSSL_EXTCFLAGS"]
+append_cflags(extcflags.split) if extcflags
+extldflags = ENV["RUBY_OPENSSL_EXTLDFLAGS"]
+append_ldflags(extldflags.split) if extldflags
+
##
# Adds -DOSSL_DEBUG for compilation and some more targets when GCC is used
# To turn it on, use: --with-debug or --enable-debug