]> mj.ucw.cz Git - libucw.git/commitdiff
Configure: Implemented running of test programs
authorMartin Mares <mj@ucw.cz>
Thu, 22 Jul 2010 13:31:12 +0000 (15:31 +0200)
committerMartin Mares <mj@ucw.cz>
Thu, 22 Jul 2010 13:31:12 +0000 (15:31 +0200)
ucw/perl/UCW/Configure/C.pm

index e3a7fdf859440f8b9d0187e3df3675b282f6241b..5346fb1a3a5f4a46a8deb32192ccb82841faf546 100644 (file)
@@ -1,5 +1,5 @@
 # UCW Library configuration system: OS and C compiler
-# (c) 2005--2008 Martin Mares <mj@ucw.cz>
+# (c) 2005--2010 Martin Mares <mj@ucw.cz>
 # (c) 2006 Robert Spalek <robert@ucw.cz>
 # (c) 2008 Michal Vaner <vorner@ucw.cz>
 
@@ -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($$) {