/config.h.in
/config.status
/install-sh
+/run
+/src/config.ml
/src/goals
/src/lexer.ml
/src/parser.conflicts
touch $@
Makefile: Makefile.in config.status
- ./config.status Makefile
+ ./config.status $@
+
+run: run.in config.status
+ ./config.status $@
$(srcdir)/configure: configure.ac aclocal.m4
cd '$(srcdir)' && autoconf
dnl Produce output files.
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
+AC_CONFIG_FILES([run], [chmod +x,-w run])
AC_CONFIG_FILES([Goalfile Makefile
- src/Goalfile src/Makefile])
+ src/Goalfile src/Makefile
+ src/config.ml])
AC_OUTPUT
--- /dev/null
+#!/usr/bin/env bash
+# Goals local run.
+# Copyright (C) 2019 Richard W.M. Jones
+# Copyright (C) 2019 Red Hat Inc.
+# @configure_input@
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+# Use ./run goals ... to run goals from a locally compiled copy.
+
+# Function to intelligently prepend a path to an environment variable.
+# See http://stackoverflow.com/a/9631350
+prepend()
+{
+ eval $1="$2\${$1:+:\$$1}"
+}
+
+# Source and build directories (absolute paths so this works from any
+# directory).
+s="$(cd @abs_srcdir@ && pwd)"
+b="$(cd @abs_builddir@ && pwd)"
+
+# Set PATH to include goals binary.
+prepend PATH "$b/src"
+
+# Set up environment variables to add default flags.
+export GOALS_DATADIR="$b"
+
+# Run the program.
+#echo "$@"
+exec "$@"
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
OBJECTS = \
+ config.cmx \
utils.cmx \
ast.cmx \
parser.cmx \
-include .depend
Makefile: Makefile.in ../config.status
- ../config.status Makefile
+ ../config.status $@
+
+config.ml: config.ml.in ../config.status
+ ../config.status $@
.PHONY: all clean depend
--- /dev/null
+(* Goals config
+ * Copyright (C) 2019 Richard W.M. Jones
+ * Copyright (C) 2019 Red Hat Inc.
+ * @configure_input@
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *)
+
+let package_name = "@PACKAGE_NAME@"
+let package_version = "@PACKAGE_VERSION@"
+let prefix = "@prefix@"
+let datadir = prefix ^ "/share"
--- /dev/null
+(* Goals config
+ * Copyright (C) 2019 Richard W.M. Jones
+ * Copyright (C) 2019 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *)
+
+val package_name : string
+val package_version : string
+val prefix : string
+val datadir : string
Options:"
+let print_version () =
+ printf "%s %s\n" Config.package_name Config.package_version;
+ exit 0
+
let main () =
+ (* Get stdlib directory. *)
+ let datadir =
+ try Sys.getenv "GOALS_DATADIR" with Not_found -> Config.datadir in
+ let stdlibdir = datadir // "stdlib" in
+ let prelude_gl = stdlibdir // "prelude.gl" in
+ if not (is_directory stdlibdir) || not (Sys.file_exists prelude_gl) then
+ failwithf "%s: cannot find the standard library directory, expected %s. If the standard library directory is in a non-standard location then set GOALS_DATADIR. If you can trying to run goals from the build directory then use ‘./run goals ...’"
+ Sys.executable_name stdlibdir;
+
(* Command line arguments. *)
let args = ref [] in
let directory = ref "." in
"filename Set name of Goalfile";
"--file", Arg.Set_string filename,
"filename Set name of Goalfile";
+ "-V", Arg.Unit print_version,
+ " Print version and exit";
+ "--version", Arg.Unit print_version,
+ " Print version and exit";
] in
let argspec = Arg.align argspec in
let anon_fun s = args := s :: !args in
let failwithf fs = ksprintf failwith fs
+let (//) = Filename.concat
+let is_directory d = try Sys.is_directory d with Sys_error _ -> false
+
(* From OCaml 4.08 sources. We can remove this when we can
* depend on min OCaml 4.08.
*)
val failwithf : ('a, unit, string, 'b) format4 -> 'a
(** Like [failwith] but supports printf-like arguments. *)
+val (//) : string -> string -> string
+(** The {!Filename.concat} function. *)
+
+val is_directory : string -> bool
+(** Return true iff parameter is a directory. *)
+
val filter_map : ('a -> 'b option) -> 'a list -> 'b list
(** [filter_map f l] applies [f] to every element of [l], filters
out the [None] elements and returns the list of the arguments of