summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Norton2018-04-26 15:12:24 +0100
committerRobert Norton2018-04-26 15:12:24 +0100
commit0ee8e4d2dd1958d9a1aa45fbe8f67861d18e548c (patch)
tree63d51b0a53508c7a79a32e1f667a28a4250ec4bb /src
parentae12f0feb0978eb1f511482293b1d1a20fb04ee4 (diff)
Add a new SHARE_DIR argument to use when doing opam build. For non-opam builds this defaults to git root.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile13
-rw-r--r--src/ocaml_backend.ml6
-rw-r--r--src/process_file.ml8
3 files changed, 14 insertions, 13 deletions
diff --git a/src/Makefile b/src/Makefile
index d71fb20b..97b87d4b 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -67,7 +67,7 @@ endif
# set to -p on command line to enable gprof profiling
OCAML_OPTS?=
-INSTALL_DIR?=$(realpath ..)
+SHARE_DIR?=$(realpath ..)
all: sail lib doc
@@ -90,14 +90,14 @@ bytecode.ml: bytecode.lem
lem_interp/interp_ast.lem: ../language/l2.ott
ott -sort false -generate_aux_rules true -o lem_interp/interp_ast.lem -picky_multiple_parses true ../language/l2.ott
-install_directory.ml:
- echo "(* Generated file -- do not edit. *)" > install_directory.ml
- echo let d=\"$(INSTALL_DIR)\" >> install_directory.ml
+share_directory.ml:
+ echo "(* Generated file -- do not edit. *)" > share_directory.ml
+ echo let d=\"$(SHARE_DIR)\" >> share_directory.ml
-sail: ast.ml bytecode.ml install_directory.ml
+sail: ast.ml bytecode.ml share_directory.ml
ocamlbuild -use-ocamlfind sail.native sail_lib.cma sail_lib.cmxa
-isail: ast.ml bytecode.ml install_directory.ml
+isail: ast.ml bytecode.ml share_directory.ml
ocamlbuild -use-ocamlfind isail.native
sail.native: sail
@@ -148,6 +148,7 @@ clean:
-rm -f bytecode.ml
-rm -f bytecode.lem
-rm -f bytecode.ml.bak
+ -rm -f share_directory.ml
doc:
ocamlbuild -use-ocamlfind sail.docdir/index.html
diff --git a/src/ocaml_backend.ml b/src/ocaml_backend.ml
index 91ca17b6..00a6c4c3 100644
--- a/src/ocaml_backend.ml
+++ b/src/ocaml_backend.ml
@@ -686,11 +686,11 @@ let ocaml_compile spec defs =
let sail_dir =
try Sys.getenv "SAIL_DIR" with
| Not_found ->
- let share_dir = Filename.concat Install_directory.d "share/sail" in
- if Sys.is_directory share_dir then
+ let share_dir = Share_directory.d in
+ if Sys.file_exists share_dir then
share_dir
else
- failwith "Could not find sail share directory, " ^ share_dir ^ ". Make sail is installed or try setting environment variable SAIL_DIR."
+ failwith "Could not find sail share directory, " ^ share_dir ^ ". Make sure sail is installed or try setting environment variable SAIL_DIR."
in
if Sys.file_exists "_sbuild" then () else Unix.mkdir "_sbuild" 0o775;
let cwd = Unix.getcwd () in
diff --git a/src/process_file.ml b/src/process_file.ml
index dd34f49c..a576c16e 100644
--- a/src/process_file.ml
+++ b/src/process_file.ml
@@ -150,11 +150,11 @@ let rec preprocess = function
let sail_dir =
try Sys.getenv "SAIL_DIR" with
| Not_found ->
- let lib_dir = Filename.concat Install_directory.d "lib" in
- if Sys.is_directory lib_dir then
- Install_directory.d
+ let share_dir = Share_directory.d in
+ if Sys.file_exists share_dir then
+ share_dir
else
- (failwith ("Library directory " ^ lib_dir ^ " does not exist. Make sure sail is installed or try setting environment variable SAIL_DIR so that I can find $include " ^ file))
+ (failwith ("Library directory " ^ share_dir ^ " does not exist. Make sure sail is installed or try setting environment variable SAIL_DIR so that I can find $include " ^ file))
in
let file = Filename.concat sail_dir ("lib/" ^ file) in
let (Parse_ast.Defs include_defs) = parse_file file in