stbey has asked for the wisdom of the Perl Monks concerning the following question:
Dear Perl Monks,
what would be the best way to detect whether a working C compiler is available at build time of a module (i.e., in Makefile.PL)?
I would like to install a (faster) XS version of a module if that is the case, and a (slower) pure-Perl implementation if not.
Remember that C compilers are not always available on all systems. Sometimes they cost heavy extra money, or sometimes you have to work with what's there on a customer's or provider's server (where frequently installing a C compiler is not an option due to company policies).
Thank you!
UPDATE:
In the meantime, I've adopted a mixed approach, using an "Inline"-like search of the PATH (as fallback) and the "have_compiler" method (which actually compiles and links a test file) when "ExtUtils::CBuilder" is available.
Look here: http://cpansearch.perl.org/src/STBEY/Date-Calc-6.1/Makefile.PL
After that, I dropped this approach altogether and went for the usual "wrapper" approach - "Date::Calc" is now (v6.2) a wrapper which tries to load "Date::Calc::XS", and failing that, loads "Date::Calc::PP".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to best detect availability of C compiler in Makefile.PL?
by bingos (Vicar) on Oct 13, 2009 at 11:23 UTC | |
|
Re: How to best detect availability of C compiler in Makefile.PL?
by cdarke (Prior) on Oct 13, 2009 at 10:22 UTC | |
by DrHyde (Prior) on Oct 14, 2009 at 09:43 UTC | |
by syphilis (Archbishop) on Oct 14, 2009 at 10:24 UTC | |
by DrHyde (Prior) on Oct 15, 2009 at 10:04 UTC |