From 404b915049ad455039f133bf9ad7cfd8708b1ebc Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Thu, 22 Jul 2010 15:31:12 +0200 Subject: [PATCH] Configure: Implemented running of test programs --- ucw/perl/UCW/Configure/C.pm | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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($$) { -- 2.39.5