summaryrefslogtreecommitdiff
path: root/src/compiler.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-10-26 08:41:17 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-10-26 08:41:17 -0400
commit5badaf182a69fc7d67f9ae2e5a0a8e5bf7edea36 (patch)
tree063e92eebe8bb8761687451b45c15d9101af60b3 /src/compiler.sml
parent978e1439b5b985f1483f7eb1edfc954e3f2bf1c2 (diff)
Avoid using libpq when unneeded
Diffstat (limited to 'src/compiler.sml')
-rw-r--r--src/compiler.sml13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/compiler.sml b/src/compiler.sml
index df4ee48d..5d48287b 100644
--- a/src/compiler.sml
+++ b/src/compiler.sml
@@ -506,13 +506,13 @@ val sqlify = {
val toSqlify = transform sqlify "sqlify" o toMono_opt2
-fun compileC {cname, oname, ename} =
+fun compileC {cname, oname, ename, libs} =
let
val urweb_o = clibFile "urweb.o"
val driver_o = clibFile "driver.o"
val compile = "gcc -Wstrict-prototypes -Werror -O3 -I include -c " ^ cname ^ " -o " ^ oname
- val link = "gcc -Werror -O3 -lm -pthread -lpq " ^ urweb_o ^ " " ^ oname ^ " " ^ driver_o ^ " -o " ^ ename
+ val link = "gcc -Werror -O3 -lm -pthread " ^ libs ^ " " ^ urweb_o ^ " " ^ oname ^ " " ^ driver_o ^ " -o " ^ ename
in
if not (OS.Process.isSuccess (OS.Process.system compile)) then
print "C compilation failed\n"
@@ -553,6 +553,13 @@ fun compile job =
let
val outf = TextIO.openOut cname
val s = TextIOPP.openOut {dst = outf, wid = 80}
+
+ val hasDb = List.exists (fn (Cjr.DDatabase _, _) => true | _ => false) (#1 file)
+ val libs =
+ if hasDb then
+ "-lpq"
+ else
+ ""
in
Print.fprint s (CjrPrint.p_file CjrEnv.empty file);
TextIO.output1 (outf, #"\n");
@@ -569,7 +576,7 @@ fun compile job =
TextIO.closeOut outf
end;
- compileC {cname = cname, oname = oname, ename = ename};
+ compileC {cname = cname, oname = oname, ename = ename, libs = libs};
cleanup ()
end