From: Martin Mares Date: Thu, 22 Jul 2010 13:31:12 +0000 (+0200) Subject: Configure: Implemented running of test programs X-Git-Tag: v5.0~155 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=404b915049ad455039f133bf9ad7cfd8708b1ebc;p=libucw.git Configure: Implemented running of test programs --- diff --git a/ucw/perl/UCW/Configure/C.pm b/ucw/perl/UCW/Configure/C.pm index e3a7fdf8..5346fb1a 100644 --- a/ucw/perl/UCW/Configure/C.pm +++ b/ucw/perl/UCW/Configure/C.pm @@ -1,5 +1,5 @@ # UCW Library configuration system: OS and C compiler -# (c) 2005--2008 Martin Mares +# (c) 2005--2010 Martin Mares # (c) 2006 Robert Spalek # (c) 2008 Michal Vaner @@ -267,6 +267,28 @@ if (IsSet("CONFIG_DARWIN")) { } } +### Compiling test programs ### + +sub TestCompile($) { + my ($source) = @_; + my $dir = 'conftest'; + `rm -rf $dir && mkdir $dir`; $? and Fail "Cannot initialize $dir"; + + open SRC, ">$dir/conftest.c"; + print SRC $source; + close SRC; + + my $cmd = join(" ", + map { defined($_) ? $_ : "" } + "cd $dir &&", + Get("CC"), Get("CLANG"), Get("COPT"), Get("CEXTRA"), Get("LIBS"), + "conftest.c", "-o", "conftest", + ">conftest.log", "2>&1" + ); + `$cmd`; + my $result = !$?; +} + ### Writing C headers with configuration ### sub ConfigHeader($$) {