Detecting C compiler in Makefile.PL

  • Thread starter Jens Thoms Toerring
  • Start date
J

Jens Thoms Toerring

Hello,

a CPAN module of mine that needs a C compiler for installation
fails in some of the tests since the C compiler isn't found. The
offending lines are

if ( system $Config{cc}, qw( -o cc_test cc_test.c ) ) {
unlink 'cc_test.c';
die "Can't run C compiler '$Config{cc}'\n";
}

where 'cc_test.c' is a simple program that gets created
automatically just for this test.

The problem is that on one of the testers machines $Config{cc}
is set to 'ccache cc' and system() obviously does not like the
space in the name of the program it's supposed to execute.

Now I probably can get around that by using a line like

if ( system split /\s+/, $Config{cc}, qw( -o cc_test cc_test.c ) ) {

or something similar but it looks ugly and I suspect that there
is a better method to invoke the correct C compiler. Does anybody
have an idea?
Thanks and regards, Jens
 
S

smallpond

Hello,

a CPAN module of mine that needs a C compiler for installation
fails in some of the tests since the C compiler isn't found. The
offending lines are

if ( system $Config{cc}, qw( -o cc_test cc_test.c ) ) {
unlink 'cc_test.c';
die "Can't run C compiler '$Config{cc}'\n";

}

where 'cc_test.c' is a simple program that gets created
automatically just for this test.

The problem is that on one of the testers machines $Config{cc}
is set to 'ccache cc' and system() obviously does not like the
space in the name of the program it's supposed to execute.

Now I probably can get around that by using a line like

if ( system split /\s+/, $Config{cc}, qw( -o cc_test cc_test.c ) ) {

or something similar but it looks ugly and I suspect that there
is a better method to invoke the correct C compiler. Does anybody
have an idea?
Thanks and regards, Jens


system fails because you are passing part as a string and
part as a list. Just pass a single string and let system
do the parsing.

if (system "$Config{cc} -o cc_test cc_test.c")

--S
 
J

Jens Thoms Toerring

system fails because you are passing part as a string and
part as a list. Just pass a single string and let system
do the parsing.
if (system "$Config{cc} -o cc_test cc_test.c")

Thank you, I will try it that way. Looks like it's the simplest
method to get it to work.
Best regards, Jens
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,209
Messages
2,571,088
Members
47,686
Latest member
scamivo

Latest Threads

Top