X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Fperl%2FUCW%2FConfigure%2FC.pm;h=84c20da00680e08c4eec9aa2f45674fba0a199eb;hb=b074a6e247a4723fbd84d72445949813c8b7420b;hp=6219a164bf11eed8548f8d3ff9052dd3f1ab3ac9;hpb=9773afa84a6ba2bdaa9acab70b27ce75c9e78c4c;p=libucw.git diff --git a/ucw/perl/UCW/Configure/C.pm b/ucw/perl/UCW/Configure/C.pm index 6219a164..84c20da0 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 @@ -188,7 +188,7 @@ Set("CLANG" => "-std=gnu99 -fno-common"); # C optimizations Set("COPT" => '-O2'); if (Get("CPU_ARCH") ne "unknown" && Get("CPU_ARCH") ne "default") { - Append("COPT", '-march=$(CPU_ARCH)'); + Append("COPT", '-march=' . Get("CPU_ARCH")); } # C optimizations for highly exposed code @@ -256,11 +256,41 @@ if (IsSet("CONFIG_DARWIN")) { Append("COPT" => "-I/sw/include"); # Fill in some constants not found in the system header files Set("SOL_TCP" => 6); # missing in /usr/include/netinet/tcp.h - if (IsGiven("CONFIG_DIRECT") && IsSet("CONFIG_DIRECT")) { + if (IsGiven("CONFIG_DIRECT_IO") && IsSet("CONFIG_DIRECT_IO")) { Fail("Direct I/O is not available on darwin"); } else { - UnSet("CONFIG_DIRECT"); + UnSet("CONFIG_DIRECT_IO"); } + if (!IsSet("CONFIG_POSIX_REGEX") && !IsSet("CONFIG_PCRE")) { + Set("CONFIG_POSIX_REGEX" => 1); + Warn "BSD regex library on Darwin isn't compatible, using POSIX regex.\n"; + } +} + +### Compiling test programs ### + +sub TestCompile($$) { + my ($testname, $source) = @_; + my $dir = "conftest-$testname"; + `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 = !$?; + + `rm -rf $dir` unless Get("KEEP_CONFTEST"); + + return $result; } ### Writing C headers with configuration ###