Append flags from environment variables. #629
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
According to the
mkmf.rb#init_mkmf
, there are command line options below.--with-cflags
to set thecflags
--with-ldflags
to set theldflags
For example the following command compiles with the specified flags. Note that
MAKEFLAGS
is to print the compiler command lines.However, I couldn't find command line options to append the flags. And this
commit is to append the
cflags
andldflags
by the environment variables.Details
The implementation was inspired by Nokogiri project.
https://github.com/sparklemotion/nokogiri/blob/30e965809c4c55b191c5c9f3a2cc5a289fce4681/ext/nokogiri/extconf.rb#L648-L651
However, I wanted to avoid the
CFLAGS
was loaded unintentionally. Because I seeCFLAGS
andLDFLAGS
are already set in the build environment in Fedora project. Those are used to set the flags, not to append. So, I used the prefixRUBY_OPENSSL_
. I also wanted to clarify that the value is used not to set but to append to the existing cflags coming from therbconfig.rb
. It seems theEXTLDFLAGS
exists in the purpose of appendng the flags in thetemplate/Makefile.in
in ruby/ruby. So, I chose theRUBY_OPENSSL_EXTCFLAGS
andRUBY_OPENSSL_EXTLDFLAGS
.You can also add your preferred debug flags like this.