stdlib: Implement wildcard function.
[goals.git] / Goalfile.in
index 2fcf7dd..4a80a3f 100644 (file)
@@ -41,13 +41,16 @@ let objects = [
     "src/main.cmx"
 ]
 
+let subdirs = [ "m4", "src", "stdlib", "tests" ]
+
 goal all = : ocaml_link ("src/goals", objects)
 
 goal clean = {
-    for d in `find -type d`; do
+    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
 
@@ -61,25 +64,27 @@ goal maintainer-clean = : clean {
 
 "src/parser.mli", "src/parser.ml" : "src/parser.mly" {
     %MENHIR --explain %<
+    # Hack required to get includes working.
+    echo 'val lexer_read : (Lexing.lexbuf -> token) 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' |
-        sed 's,.*,& ;,' > %@-t
+    %OCAMLDEP -all -one-line %< |
+        sed 's|[./[:alnum:]]\+|"&"|g' |
+        sed 's|" "|", "|g' |
+        sed 's|.*|& ;|' > %@-t
     mv %@-t %@
 }