2 # Copyright (C) 2019 Richard W.M. Jones
3 # Copyright (C) 2019 Red Hat Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 let subdirs = [ "m4", "src", "stdlib", "docs", "man", "tests" ]
23 goal all = : "Goalfile", tool, documentation;
25 "Goalfile": "Goalfile.in", "config.status" {
28 "src/config.ml" : "src/config.ml.in", "config.status" {
32 goal clean = : wrap ("clean-subdir", subdirs), clean-subdir ("."), clean-other
34 goal clean-subdir (dir) = {
37 rm -f *.cmi *.cmo *.cmx *.o
41 rm -f src/parser.ml src/parser.mli src/lexer.ml src/parser.conflicts
45 # We don't delete src/goals because it is required to do builds.
46 # If you want to really delete it, use the maintainer-clean rule.
49 goal maintainer-clean = : clean {
53 #----------------------------------------------------------------------
54 # Build the goals tool itself.
57 let OCAMLLIB = "@OCAMLLIB@"
58 let MENHIR = "@MENHIR@"
59 let OCAMLDEP = "@OCAMLDEP@"
60 let OCAMLFIND = "@OCAMLFIND@"
61 let OCAMLLEX = "@OCAMLLEX@"
62 let CFLAGS = join (split ("@CFLAGS@"), ["-I%OCAMLLIB", "-I."])
63 let OCAMLFLAGS = split ("@OCAMLFLAGS@")
64 let OCAMLPACKAGES = join (split ("@OCAMLPACKAGES@"), ["-I", "src"])
67 # These must be in dependency order.
83 goal tool = : ocaml_link ("src/goals", objects) ;
86 "src/utils-c.o" : "src/utils-c.c" {
87 %CC %CFLAGS -c %< -o %@
91 "src/parser.mli", "src/parser.ml" : "src/parser.mly" {
93 # Hack required to break circular dependencies.
94 echo 'val lexer_read : (Lexing.lexbuf -> token) option ref' >> src/parser.mli
95 echo 'val eval_substitute : (Ast.env -> Ast.loc -> Ast.substs -> string) option ref' >> src/parser.mli
98 "src/lexer.ml" : "src/lexer.mll" {
102 # XXX Goalfile itself depends on this and we should probably have a
103 # way to reevaluate it.
106 "src/.depend" : wildcard ("src/*.ml"), wildcard ("src/*.mli") {
108 # Like many existing tools, ocamldep produces make-compatible
109 # output which doesn't work directly in goals.
110 %OCAMLDEP -all -one-line -I src %< |
111 sed 's|[./[:alnum:]]\+|"&"|g' |
113 sed 's|.*|& ;|' > %@-t
117 -include "src/.depend";
119 #----------------------------------------------------------------------
122 let POD2MAN = "@POD2MAN@"
123 let POD2TEXT = "@POD2TEXT@"
125 goal documentation = : pod2man ("goals", "1"), pod2man ("Goalfile", "5"),
126 pod2text ("goals", "1"), pod2text ("Goalfile", "5")
128 goal pod2man (page, section) =
129 "man/%page.%section" : "docs/%page.pod" {
135 --release "@PACKAGE_NAME@-@PACKAGE_VERSION@" \
136 --section %section %< > %@-t
140 goal pod2text (page, section) =
141 "man/%page.%section.txt" : "docs/%page.pod" {
144 %POD2TEXT -u %< > %@-t
148 #----------------------------------------------------------------------
151 let tests = wrap ("test", wildcard ("tests/*.sh"))
153 goal check () = : tests
155 goal test (name) = @{
158 if ../run ./$t > $t.log 2>&1; then
159 print_green "PASS:" $t
166 #----------------------------------------------------------------------
169 # DESTDIR can be overridden on the command line to install into
173 let stdlibfiles = [wildcard ("stdlib/*.gl"), wildcard ("stdlib/*.sh")]
176 # exec_prefix die die die
177 bindir="@prefix@/bin"
178 datadir="@prefix@/share"
179 mkdir -p %DESTDIR/"$bindir"
180 mkdir -p %DESTDIR/"$datadir/goals"
181 install src/goals %DESTDIR/"$bindir" -m 0755
182 install %stdlibfiles %DESTDIR/"$datadir"/goals -m 644
185 #----------------------------------------------------------------------
225 wildcard ("docs/*.pod"),
232 wildcard ("stdlib/*.gl"),
233 wildcard ("stdlib/*.sh"),
234 wildcard ("tests/*.data"),
235 wildcard ("tests/*.data[0-9]"),
236 wildcard ("tests/*.expected"),
237 wildcard ("tests/*.gl"),
238 wildcard ("tests/*.sh"),
239 wildcard ("tests/10-function-wildcard.d/*"),
242 let tarfile = "@PACKAGE_NAME@-@PACKAGE_VERSION@.tar.gz"
245 d="@PACKAGE_NAME@-@PACKAGE_VERSION@"
251 for f in %distfiles; do
252 subdir="$(dirname "$f")"
253 mkdir -p "$d/$subdir"
254 cp -a "$f" "$d/$subdir"
261 goal distcheck = : dist {
262 d="@PACKAGE_NAME@-@PACKAGE_VERSION@"
270 print_green "PASS: distcheck"
273 #----------------------------------------------------------------------
276 # Check no files are missing from distfiles above by unpacking the
277 # distribution tarball and comparing it to git.
278 goal maintainer-check-extra-dist = : dist @{
279 tar ztf %tarfile | sort |
280 sed 's,^@PACKAGE_NAME@-@PACKAGE_VERSION@/,,' > tarfiles
281 git ls-files | sort > gitfiles
282 comm -13 tarfiles gitfiles > comm.out
285 rm tarfiles gitfiles comm.out
286 print_green "PASS: distfiles"
289 # XXX This should also do a Fedora build.
290 goal maintainer-release = : dist,
291 maintainer-check-extra-dist,
295 let websitedir = "%HOME/d/websites/people.redhat.com/goals"
297 # XXX Should actually use the *url tactic here.
298 goal maintainer-upload = {
300 cp %tarfile %websitedir/files
301 cp README %websitedir/README
302 cp man/goals.1.txt man/Goalfile.5.txt %websitedir
304 git add files/%tarfile README goals.1.txt Goalfile.5.txt
305 git commit -m "@PACKAGE_NAME@ @PACKAGE_VERSION@"