I don't know what capabilities there are to detect whether C compilation is available.
Neither do I, but one should be obvious: Just try to compile something. On a sane system (for some definition of sane), creating foo.c followed by invoking make foo in the directory containing foo.c should result in a binary named foo and an exit code of 0. If anything went wrong, the exit code will be non-zero and/or foo does not exist. To see if you did not accidentally invoke a cross-compiler, you would simply try to start foo. To detect if foo.c behaves as expected, make it exit with an exit code that is unlikely to happen and/or write out a text that you test for when invoking foo.
Something like this:
/tmp>cat foo.c
int main(void)
{
return 42;
}
/tmp>make foo
cc foo.c -o foo
/tmp>echo $?
0
/tmp>./foo
/tmp>echo $?
42
/tmp>
Of course, getting that to work on non-Unix systems needs a little bit more work, starting with the fact that the compiled binary will very likely be named foo.exe, not just foo, on Windows. I also completely ignored all problems of having the right libraries and headers available. And, of course, I did not write any Perl code to write foo.c and to compile it, but that's just a little bit of perlipc.
Alexander
--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
|