+ if (IsGiven("CONFIG_DIRECT_IO") && IsSet("CONFIG_DIRECT_IO")) {
+ Fail("Direct I/O is not available on darwin");
+ } else {
+ 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;