.depend
Goalfile
Makefile
-config.log
/aclocal.m4
/autom4te.cache/
/configure
/config.h
/config.h.in
+/config.log
/config.status
/install-sh
/run
-# Goalfile parser
+# Goalfile
# Copyright (C) 2019 Richard W.M. Jones
# Copyright (C) 2019 Red Hat Inc.
#
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+include "ocaml.gl"
+
+let MENHIR = "@MENHIR@"
+let OCAMLDEP = "@OCAMLDEP@"
+let OCAMLFIND = "@OCAMLFIND@"
+let OCAMLLEX = "@OCAMLLEX@"
+# XXX
+let OCAMLFLAGS = [ "-g", "-safe-string", "-warn-error", "CDEFLMPSUVYZX+52-3" ]
+let OCAMLPACKAGES = [ "-package", "str,unix", "-I", "src" ]
+#let OCAMLFLAGS = "@OCAMLFLAGS@"
+#let OCAMLPACKAGES = "@OCAMLPACKAGES@"
+
+let objects = [
+ "src/config.cmx",
+ "src/utils.cmx",
+ "src/cmdline.cmx",
+ "src/ast.cmx",
+ "src/eval.cmx",
+ "src/parser.cmx",
+ "src/lexer.cmx",
+ "src/parse.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
+}
+
+"src/parser.mli", "src/parser.ml" : "src/parser.mly" {
+ %MENHIR --explain %<
+}
+
+"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" : {
+ 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
+ mv %@-t %@
+}
+
+-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 $@
-# Goalfile parser
+# Goals
# Copyright (C) 2019 Richard W.M. Jones
# Copyright (C) 2019 Red Hat Inc.
#
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-SUBDIRS = src tests
+# Pass through normal targets to Goalfile.in
-all clean depend install:
- $(MAKE) -C src $@
+# XXX Why can't this parse "all" instead of "all ()"?
+all clean install: src/goals
+ ./run src/goals -d "$@ ()"
+# If src/goals doesn't exist then brute-force build it. Once we have
+# src/goals we can rebuild it and other parts of the project using
+# goals itself (see Goalfile.in).
+
+MENHIR = @MENHIR@
+OCAMLFIND = @OCAMLFIND@
+OCAMLLEX = @OCAMLLEX@
+OCAMLFLAGS = @OCAMLFLAGS@
+OCAMLPACKAGES = @OCAMLPACKAGES@
+
+src/goals:
+ $(MENHIR) --explain src/parser.mly
+# Hack required to get includes working.
+ echo 'val lexer_read : (Lexing.lexbuf -> token) option ref' \
+ >> src/parser.mli
+ $(OCAMLLEX) src/lexer.mll
+ $(OCAMLFIND) opt $(OCAMLFLAGS) $(OCAMLPACKAGES) -I src \
+ src/config.mli src/utils.mli src/cmdline.mli src/ast.mli \
+ src/eval.mli src/parser.mli src/lexer.mli src/parse.mli \
+ src/config.ml src/utils.ml src/cmdline.ml src/ast.ml \
+ src/eval.ml src/parser.ml src/lexer.ml src/parse.ml \
+ src/main.ml \
+ -linkpkg -o $@
+
+# These rules are required by autoconf.
config.h: stamp-h
stamp-h: config.h.in config.status
./config.status config.h
AC_MSG_ERROR([OCaml menhir parser generator is required])
])
+dnl Substitute OCaml flags and packages.
+AC_SUBST([OCAMLFLAGS], ["-g -safe-string -warn-error CDEFLMPSUVYZX+52-3"])
+AC_SUBST([OCAMLPACKAGES], ["-package str,unix"])
+
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/config.ml])
AC_OUTPUT
+++ /dev/null
-# Goalfile parser
-# 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.
-
-let objects = ["ast.cmx", "parser.cmx", "lexer.cmx", "main.cmx"]
-
-goal all = : file("goals")
-
-goal clean = {
- rm -f *~
- rm -f *.cmi *.cmo *.cmx *.o
- rm -f parser.ml parser.mli lexer.ml parser.conflicts
- rm -f goals
-}
-
-file("goals"): objects {
- @OCAMLFIND@ opt %^ -o %@
-}
-
-let OCAMLFLAGS = "-g -safe-string -warn-error CDEFLMPSUVYZX+52-3"
-
-goal compile_cmi (name) = "%name.cmi": "%name.mli" {
- @OCAMLFIND@ c %OCAMLFLAGS -c %< -o %@
-}
-goal compile_cmo (name) = "%name.cmo": "%name.ml" {
- @OCAMLFIND@ c %OCAMLFLAGS -c %< -o %@
-}
-goal compile_cmx (name) = "%name.cmx": "%name.ml" {
- @OCAMLFIND@ opt %OCAMLFLAGS -c %< -o %@
-}
-
-"parser.ml", "parser.mli": "parser.mly" {
- @MENHIR@ --explain %<
-}
-
-"lexer.ml": "lexer.mll", "lexer.cmi", "parser.ml" {
- @OCAMLLEX@ %<
-}
-
-# depend: .depend
-
-# .depend: parser.mly lexer.mll *.mli
-# rm -f $@ $@-t
-# @MENHIR@ --depend parser.mly > $@-t
-# ocamldep lexer.mll *.mli >> $@-t
-# mv $@-t $@
-
-# -include .depend
-
-# .PHONY: all clean depend
+++ /dev/null
-# Goalfile parser
-# 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.
-
-OBJECTS = \
- config.cmx \
- utils.cmx \
- cmdline.cmx \
- ast.cmx \
- eval.cmx \
- parser.cmx \
- lexer.cmx \
- parse.cmx \
- main.cmx
-
-all: goals
-
-clean:
- rm -f *~
- rm -f *.cmi *.cmo *.cmx *.o
- rm -f parser.ml parser.mli lexer.ml parser.conflicts stamp-parser
- rm -f goals
-
-OCAMLPACKAGES = -package str,unix
-OCAMLFLAGS = -g -safe-string -warn-error CDEFLMPSUVYZX+52-3
-
-goals: $(OBJECTS)
- @OCAMLFIND@ opt $(OCAMLFLAGS) $(OCAMLPACKAGES) -linkpkg $^ -o $@
-
-%.cmi: %.mli
- @OCAMLFIND@ c $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@
-%.cmo: %.ml
- @OCAMLFIND@ c $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@
-%.cmx: %.ml
- @OCAMLFIND@ opt $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@
-
-parser.ml parser.mli: stamp-parser
-stamp-parser: parser.mly
- @MENHIR@ --explain $<
-# Hack required to get includes working.
- echo 'val lexer_read : (Lexing.lexbuf -> token) option ref' >> parser.mli
- touch $@
-
-lexer.ml: lexer.mll lexer.cmi parser.ml
- @OCAMLLEX@ $<
-
-depend: .depend
-
-.depend: parser.mly lexer.mll *.mli
- rm -f $@ $@-t
- @MENHIR@ --depend parser.mly > $@-t
- ocamldep lexer.mll *.ml *.mli >> $@-t
- mv $@-t $@
-
--include .depend
-
-Makefile: Makefile.in ../config.status
- ../config.status $@
-
-config.ml: config.ml.in ../config.status
- ../config.status $@
-
-.PHONY: all clean depend
-
-# Doesn't build all *.cmi files before *.cmo/cmx files:
-#.NOTPARALLEL: