include "ocaml.gl"
+let subdirs = [ "m4", "src", "stdlib", "docs", "man", "tests" ]
+
+goal all = : "Goalfile", tool, documentation;
+
+"Goalfile": "Goalfile.in", "config.status" {
+ ./config.status %@
+}
+"src/config.ml" : "src/config.ml.in", "config.status" {
+ ./config.status %@
+}
+
+goal clean = {
+ for d in %subdirs; do
+ pushd $d
+ rm -f *~
+ rm -f *.cmi *.cmo *.cmx *.o
+ popd
+ done
+ rm -f src/parser.ml src/parser.mli src/lexer.ml src/parser.conflicts
+ rm -f man/*.1 man/*.5
+
+ # We don't delete src/goals because it is required to do builds.
+ # If you want to really delete it, use the maintainer-clean rule.
+}
+
+goal maintainer-clean = : clean {
+ rm -f src/goals
+}
+
+#----------------------------------------------------------------------
+# Build the goals tool itself.
+
let MENHIR = "@MENHIR@"
let OCAMLDEP = "@OCAMLDEP@"
let OCAMLFIND = "@OCAMLFIND@"
#let OCAMLPACKAGES = "@OCAMLPACKAGES@"
let objects = [
+ # These must be in dependency order.
"src/config.cmx",
"src/utils.cmx",
"src/cmdline.cmx",
"src/ast.cmx",
- "src/eval.cmx",
- "src/run.cmx",
"src/parser.cmx",
"src/lexer.cmx",
"src/parse.cmx",
+ "src/eval.cmx",
+ "src/run.cmx",
"src/main.cmx"
]
-goal all = : ocaml_link ("src/goals", objects)
-
-goal clean = {
- for d in `find -type d`; do
- pushd $d
- rm -f *~
- rm -f *.cmi *.cmo *.cmx *.o
- done
- rm -f src/parser.ml src/parser.mli src/lexer.ml src/parser.conflicts
-
- # We don't delete src/goals because it is required to do builds.
- # If you want to really delete it, use the maintainer-clean rule.
-}
-
-goal maintainer-clean = : clean {
- rm -f src/goals
-}
+goal tool = : ocaml_link ("src/goals", objects) ;
+# Parser.
"src/parser.mli", "src/parser.ml" : "src/parser.mly" {
%MENHIR --explain %<
+ # Hack required to break circular dependencies.
+ echo 'val lexer_read : (Lexing.lexbuf -> token) option ref' >> src/parser.mli
+ echo 'val eval_substitute : (Ast.env -> Ast.loc -> Ast.substs -> string) option ref' >> src/parser.mli
}
"src/lexer.ml" : "src/lexer.mll" {
%OCAMLLEX %<
}
-# XXX Depends on *.ml *.mli, but we don't have a function for this yet.
# XXX Goalfile itself depends on this and we should probably have a
# way to reevaluate it.
# XXX Atomic output.
-# XXX GNU sed: https://unix.stackexchange.com/a/13704
-"src/.depend" : {
+goal depend =
+"src/.depend" : wildcard ("src/*.ml"), wildcard ("src/*.mli") {
rm -f %@ %@-t
# Like many existing tools, ocamldep produces make-compatible
# output which doesn't work directly in goals.
- %OCAMLDEP src/*.ml src/*.mli |
- sed ':x; /\\$/ { N; s/\\\n//; tx }' |
- sed 's,[./[:alnum:]]\+,"&",g' > %@-t
+ %OCAMLDEP -all -one-line -I src %< |
+ sed 's|[./[:alnum:]]\+|"&"|g' |
+ sed 's|" "|", "|g' |
+ sed 's|.*|& ;|' > %@-t
mv %@-t %@
}
--include "src/.depend"
+-include "src/.depend";
-# XXX The Goalfile itself needs rules to rebuild it.
-#Makefile: Makefile.in ../config.status
-# ../config.status $@
-#config.ml: config.ml.in ../config.status
-# ../config.status $@
+#----------------------------------------------------------------------
+# Documentation.
+
+let POD2MAN = "@POD2MAN@"
+
+goal documentation = : pod2man ("goals", "1"),
+ pod2man ("Goalfile", "5"),
+ pod2man ("goals-reference", "5")
+
+goal pod2man (page, section) =
+"man/%page.%section" : "docs/%page.pod" {
+ rm -f %@ %@-t
+ %POD2MAN \
+ -u \
+ -c "goals" \
+ --release "@PACKAGE_NAME@-@PACKAGE_VERSION@" \
+ --section %section %< > %@-t
+ mv %@-t %@
+}
\ No newline at end of file