Skip to content

Commit

Permalink
[ruby/openssl] Append flags from environment variables.
Browse files Browse the repository at this point in the history
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
```

ruby/openssl@b551eb86f6
  • Loading branch information
junaruga authored and rhenium committed Jun 18, 2023
1 parent 1740482 commit 0a84bd6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ext/openssl/extconf.rb
Expand Up @@ -18,6 +18,12 @@

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
Expand Down

0 comments on commit 0a84bd6

Please sign in to comment.