From 0ee8e4d2dd1958d9a1aa45fbe8f67861d18e548c Mon Sep 17 00:00:00 2001 From: Robert Norton Date: Thu, 26 Apr 2018 15:12:24 +0100 Subject: Add a new SHARE_DIR argument to use when doing opam build. For non-opam builds this defaults to git root. --- src/Makefile | 13 +++++++------ src/ocaml_backend.ml | 6 +++--- src/process_file.ml | 8 ++++---- 3 files changed, 14 insertions(+), 13 deletions(-) (limited to 'src') 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 -- cgit v1.2.3