build: Implement install rule.
authorRichard W.M. Jones <rjones@redhat.com>
Sun, 12 Jan 2020 22:46:24 +0000 (22:46 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Sun, 12 Jan 2020 22:46:24 +0000 (22:46 +0000)
Goalfile.in
src/cmdline.ml

index 0fd2b5b..6601c58 100644 (file)
@@ -153,3 +153,22 @@ goal test (name) = @{
         exit 1
     fi
 }
+
+#----------------------------------------------------------------------
+# Install.
+
+# DESTDIR can be overridden on the command line to install into
+# a subdirectory.
+let DESTDIR = ""
+
+let stdlibfiles = [wildcard ("stdlib/*.gl"), wildcard ("stdlib/*.sh")]
+
+goal install = {
+    # exec_prefix die die die
+    bindir="@prefix@/bin"
+    datadir="@prefix@/share"
+    mkdir -p %DESTDIR/"$bindir"
+    mkdir -p %DESTDIR/"$datadir/goals"
+    install src/goals %DESTDIR/"$bindir" -m 0755
+    install %stdlibfiles %DESTDIR/"$datadir"/goals -m 644
+}
index ff71c9c..927dfdf 100644 (file)
@@ -41,7 +41,8 @@ let print_version () =
 
 (* Get stdlib directory. *)
 let datadir =
-  try Sys.getenv "GOALS_DATADIR" with Not_found -> Config.datadir
+  try Sys.getenv "GOALS_DATADIR"
+  with Not_found -> Config.datadir // "goals"
 let stdlibdir = datadir // "stdlib"
 let prelude_gl_file = stdlibdir // "prelude.gl"
 let prelude_sh_file = stdlibdir // "prelude.sh"