extern crate pkg_config;
extern crate gcc;

fn main() {
    let target = std::env::var("TARGET").unwrap();

    if !pkg_config::find_library("liblmdb").is_ok() {
        let mut config = gcc::Config::new();
        config.file("mdb/libraries/liblmdb/mdb.c")
              .file("mdb/libraries/liblmdb/midl.c");

        if target.contains("dragonfly") {
            config.flag("-DMDB_DSYNC=O_SYNC");
            config.flag("-DMDB_FDATASYNC=fsync");
        }

        config.compile("liblmdb.a");
    }
}

extern crate pkg_config;
extern crate gcc;

fn main() {
    if !pkg_config::find_library("liblmdb").is_ok() {
        gcc::compile_library("liblmdb.a",
                             &["mdb/libraries/liblmdb/mdb.c",
                               "mdb/libraries/liblmdb/midl.c"]);
    }
}

--- 
+++ 
@@ -2,9 +2,18 @@
 extern crate gcc;
 
 fn main() {
+    let target = std::env::var("TARGET").unwrap();
+
     if !pkg_config::find_library("liblmdb").is_ok() {
-        gcc::compile_library("liblmdb.a",
-                             &["mdb/libraries/liblmdb/mdb.c",
-                               "mdb/libraries/liblmdb/midl.c"]);
+        let mut config = gcc::Config::new();
+        config.file("mdb/libraries/liblmdb/mdb.c")
+              .file("mdb/libraries/liblmdb/midl.c");
+
+        if target.contains("dragonfly") {
+            config.flag("-DMDB_DSYNC=O_SYNC");
+            config.flag("-DMDB_FDATASYNC=fsync");
+        }
+
+        config.compile("liblmdb.a");
     }
 }
Set MDB_DSYNC and MDB_FDATASYNC on dragonflybsd.