summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Norton2018-04-26 11:14:11 +0100
committerRobert Norton2018-04-26 11:49:57 +0100
commit1bd54ce4c7d85b150f2200abeed0dff67087837c (patch)
tree9b2a1d727e98317deb2226c5bdb9f0a5fe4f1eb7
parente18d8f85058f50043e600c4a0c32937a24777438 (diff)
Opam packaging: add install and uninstall targets and code to find various files in installed location.
-rw-r--r--Makefile15
-rw-r--r--src/Makefile10
-rw-r--r--src/ocaml_backend.ml7
-rw-r--r--src/process_file.ml7
4 files changed, 35 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index fe7206f7..a343e257 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,7 @@
.PHONY: all sail language clean archs isabelle-lib apply_header
+INSTALL_DIR ?= .
+
all: sail
sail:
@@ -10,6 +12,19 @@ isail:
$(MAKE) -C src isail
ln -f -s src/isail.native sail
+install:
+ mkdir -p $(INSTALL_DIR)/bin
+ cp src/isail.native $(INSTALL_DIR)/bin/sail
+ mkdir -p $(INSTALL_DIR)/share/sail
+ cp -r lib $(INSTALL_DIR)/share/sail
+ mkdir -p $(INSTALL_DIR)/share/sail/src
+ cp src/elf_loader.ml $(INSTALL_DIR)/share/sail/src
+ cp src/sail_lib.ml $(INSTALL_DIR)/share/sail/src
+
+uninstall:
+ rm -f $(INSTALL_DIR)/bin/sail
+ rm -rf $(INSTALL_DIR)/share/sail
+
language:
$(MAKE) -C language
diff --git a/src/Makefile b/src/Makefile
index cb1a8eb8..d71fb20b 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -67,6 +67,8 @@ endif
# set to -p on command line to enable gprof profiling
OCAML_OPTS?=
+INSTALL_DIR?=$(realpath ..)
+
all: sail lib doc
full: sail lib power doc test
@@ -88,10 +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
-sail: ast.ml bytecode.ml
+install_directory.ml:
+ echo "(* Generated file -- do not edit. *)" > install_directory.ml
+ echo let d=\"$(INSTALL_DIR)\" >> install_directory.ml
+
+sail: ast.ml bytecode.ml install_directory.ml
ocamlbuild -use-ocamlfind sail.native sail_lib.cma sail_lib.cmxa
-isail: ast.ml bytecode.ml
+isail: ast.ml bytecode.ml install_directory.ml
ocamlbuild -use-ocamlfind isail.native
sail.native: sail
diff --git a/src/ocaml_backend.ml b/src/ocaml_backend.ml
index 34039080..91ca17b6 100644
--- a/src/ocaml_backend.ml
+++ b/src/ocaml_backend.ml
@@ -685,7 +685,12 @@ let system_checked str =
let ocaml_compile spec defs =
let sail_dir =
try Sys.getenv "SAIL_DIR" with
- | Not_found -> failwith "Environment variable SAIL_DIR needs to be set"
+ | Not_found ->
+ let share_dir = Filename.concat Install_directory.d "share/sail" in
+ if Sys.is_directory 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."
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 88220841..dd34f49c 100644
--- a/src/process_file.ml
+++ b/src/process_file.ml
@@ -149,7 +149,12 @@ let rec preprocess = function
let file = String.sub file 1 (len - 2) in
let sail_dir =
try Sys.getenv "SAIL_DIR" with
- | Not_found -> (failwith ("Environment variable SAIL_DIR unset. Cannot $include " ^ file))
+ | Not_found ->
+ let lib_dir = Filename.concat Install_directory.d "lib" in
+ if Sys.is_directory lib_dir then
+ Install_directory.d
+ 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))
in
let file = Filename.concat sail_dir ("lib/" ^ file) in
let (Parse_ast.Defs include_defs) = parse_file file in