Nokogiri allows for this by specifying the libraries in the install command:
gem install nokogiri -- --with-xml2-lib=/home/joe/builds/lib
--with-xml2-include=/home/joe/builds/include/libxml2
--with-xslt-lib=/home/joe/builds/lib
--with-xslt-include=/home/joe/builds/include
I did a little digging through Nokogiri’s source to try to find out how they allow for those options to get passed down from the command to the actual build/installation.
I noticed the use of Rake::ExtensionTask as well as mini_portile, however their use seems to be limited to cross compiling on Windows systems in their code.
Is there some bit of code I can throw in my gem to allow users to specify the library they want to link against at install time? How did nokogiri allow for this?
This is using the
dir_configmethod of themkmflibrary.The
gem installcommand uses any arguments after--as arguments to the build command, so they get passes to yourextconf.rb.Note you still need to use
have_libraryorfind_libraryin order to actually link to the library.