Permalink
Browse files

build: add profiling build option to add -pg/-p to ocaml and c builds

  • Loading branch information...
1 parent 90451e2 commit 3035408a0c7920c5a1e6519a843ee307d77ef98b @avsm committed Apr 10, 2011
Showing with 8 additions and 2 deletions.
  1. +3 −2 lib/Makefile
  2. +5 −0 lib/myocamlbuild.ml
View
5 lib/Makefile
@@ -1,16 +1,17 @@
.PHONY: all unix clean
JOBS ?= -j 4
+OFLAGS ?= -classic-display
all: unix-direct unix-socket
unix-direct:
@mkdir -p _build
- @env MIRAGEOS=unix MIRAGEFLOW=direct ocamlbuild $(JOBS) unix.otarget
+ @env MIRAGEOS=unix MIRAGEFLOW=direct ocamlbuild $(OFLAGS) $(JOBS) unix.otarget
unix-socket:
@mkdir -p _build
- @env MIRAGEOS=unix MIRAGEFLOW=socket ocamlbuild $(JOBS) unix.otarget
+ @env MIRAGEOS=unix MIRAGEFLOW=socket ocamlbuild $(OFLAGS) $(JOBS) unix.otarget
xen-direct:
@mkdir -p _build
View
5 lib/myocamlbuild.ml
@@ -8,6 +8,7 @@ let ps = Printf.sprintf
let ep = Printf.eprintf
let debug = false
+let profiling = false
(* This decides the global OS backend. It could be moved into explicit
dependencies in the future, but for now is set as an environment
@@ -230,6 +231,8 @@ let _ = dispatch begin function
(* do not compile and pack with the standard lib *)
flag ["ocaml"; "compile"; "mirage" ] & S [A"-nostdlib"];
flag ["ocaml"; "pack"; "mirage"] & S [A"-nostdlib"];
+ if profiling then
+ flag ["ocaml"; "compile"; "native" ] & S [A"-p"];
(* use pa_`lib` syntax extension if the _tags file specifies it *)
let p4_build = "../../../syntax/_build" in
@@ -264,6 +267,8 @@ let _ = dispatch begin function
(* base cflags for C code *)
flag ["c"; "compile"] & S CC.cc_cflags;
flag ["asm"; "compile"] & S [A "-D__ASSEMBLY__"];
+ if profiling then
+ flag ["c"; "compile"] & S [A"-pg"];
(* xen code needs special cflags *)
flag ["c"; "compile"; "include_xen"] & S CC.xen_incs;

0 comments on commit 3035408

Please sign in to comment.