3 # Copyright (C) 2019-2020 Richard W.M. Jones
4 # Copyright (C) 2019-2020 Red Hat Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with this program; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 let version = "@PACKAGE_VERSION@"
24 let subdirs = [ "m4", "src", "stdlib", "docs", "man", "tests" ]
26 goal all = : "Goalfile", tool, documentation;
28 "Goalfile": "Goalfile.in", "config.status" {
31 "src/config.ml" : "src/config.ml.in", "config.status" {
35 goal clean = : wrap ("clean-subdir", subdirs), clean-subdir ("."), clean-other
37 goal clean-subdir (dir) = {
40 rm -f *.cmi *.cmo *.cmx *.o
44 rm -f src/parser.ml src/parser.mli src/lexer.ml src/parser.conflicts
48 # We don't delete src/goals because it is required to do builds.
49 # If you want to really delete it, use the maintainer-clean rule.
52 goal maintainer-clean = : clean {
56 #----------------------------------------------------------------------
57 # Build the goals tool itself.
60 let OCAMLLIB = "@OCAMLLIB@"
61 let MENHIR = "@MENHIR@"
62 let OCAMLDEP = "@OCAMLDEP@"
63 let OCAMLFIND = "@OCAMLFIND@"
64 let OCAMLLEX = "@OCAMLLEX@"
65 let CFLAGS = join (split ("@CFLAGS@"), ["-I%OCAMLLIB", "-I."])
66 let OCAMLFLAGS = split ("@OCAMLFLAGS@")
67 let OCAMLPACKAGES = join (split ("@OCAMLPACKAGES@"), ["-I", "src"])
70 # These must be in dependency order.
86 goal tool = : ocaml_link ("src/goals", objects) ;
89 "src/utils-c.o" : "src/utils-c.c" {
90 %CC %CFLAGS -c %< -o %@
94 "src/parser.mli", "src/parser.ml" : "src/parser.mly" {
96 # Hack required to break circular dependencies.
97 echo 'val lexer_read : (Lexing.lexbuf -> token) option ref' >> src/parser.mli
98 echo 'val eval_substitute : (Ast.env -> Ast.loc -> Ast.substs -> string) option ref' >> src/parser.mli
101 "src/lexer.ml" : "src/lexer.mll" {
105 # XXX Goalfile itself depends on this and we should probably have a
106 # way to reevaluate it.
109 "src/.depend" : wildcard ("src/*.ml"), wildcard ("src/*.mli") {
111 # Like many existing tools, ocamldep produces make-compatible
112 # output which doesn't work directly in goals.
113 %OCAMLDEP -all -one-line -I src %< |
114 sed 's|[./[:alnum:]]\+|"&"|g' |
116 sed 's|.*|& ;|' > %@-t
120 -include "src/.depend";
122 #----------------------------------------------------------------------
125 let POD2MAN = "@POD2MAN@"
126 let POD2TEXT = "@POD2TEXT@"
128 goal documentation = : pod2man ("goals", "1"), pod2man ("Goalfile", "5"),
129 pod2text ("goals", "1"), pod2text ("Goalfile", "5")
131 goal pod2man (page, section) =
132 "man/%page.%section" : "docs/%page.pod" {
138 --release goals-%version \
139 --section %section %< > %@-t
143 goal pod2text (page, section) =
144 "man/%page.%section.txt" : "docs/%page.pod" {
147 %POD2TEXT -u %< > %@-t
151 #----------------------------------------------------------------------
154 let tests = wrap ("test", wildcard ("tests/*.sh"))
156 goal check () = : tests
158 goal test (name) = @{
161 if ../run ./$t > $t.log 2>&1; then
162 print_green "PASS:" $t
169 #----------------------------------------------------------------------
172 # DESTDIR can be overridden on the command line to install into
176 let stdlibfiles = [wildcard ("stdlib/*.gl"), wildcard ("stdlib/*.sh")]
179 # exec_prefix die die die
180 bindir="@prefix@/bin"
181 datadir="@prefix@/share"
182 mkdir -p %DESTDIR"$bindir"
183 mkdir -p %DESTDIR"$datadir/goals"
184 install src/goals %DESTDIR"$bindir" -m 0755
185 install %stdlibfiles %DESTDIR"$datadir"/goals -m 644
188 #----------------------------------------------------------------------
228 wildcard ("docs/*.pod"),
236 wildcard ("stdlib/*.gl"),
237 wildcard ("stdlib/*.sh"),
238 wildcard ("tests/*.data"),
239 wildcard ("tests/*.data[0-9]"),
240 wildcard ("tests/*.expected"),
241 wildcard ("tests/*.gl"),
242 wildcard ("tests/*.sh"),
243 wildcard ("tests/10-function-wildcard.d/*"),
246 let tarfile = "goals-%version.tar.gz"
248 goal dist = "%tarfile" : {
255 for f in %distfiles; do
256 subdir="$(dirname "$f")"
257 mkdir -p "$d/$subdir"
258 cp -a "$f" "$d/$subdir"
265 goal distcheck = : dist {
274 print_green "PASS: distcheck"
277 #----------------------------------------------------------------------
280 # Check no files are missing from distfiles above by unpacking the
281 # distribution tarball and comparing it to git.
282 goal maintainer-check-extra-dist = : dist @{
283 tar ztf %tarfile | sort |
284 sed 's,^goals-'%version'/,,' > tarfiles
285 git ls-files | sort > gitfiles
286 comm -13 tarfiles gitfiles > comm.out
289 rm tarfiles gitfiles comm.out
290 print_green "PASS: distfiles"
293 # XXX This should also do a Fedora build.
294 goal maintainer-release = : dist,
295 maintainer-check-extra-dist,
299 maintainer-fedora-copr
301 let websitedir = "%HOME/d/websites/people.redhat.com/goals"
303 # XXX Should actually use the *url tactic here.
304 goal maintainer-upload = : distcheck {
306 cp %tarfile %websitedir/files
307 cp README %websitedir/README
308 cp man/goals.1.txt man/Goalfile.5.txt %websitedir
310 git add files/%tarfile README goals.1.txt Goalfile.5.txt
311 git commit -m "goals "%version
316 pure function get-fedora-dist () returning string = @{
319 let fedora-dist = get-fedora-dist ()
320 # XXX Replace autoconf macro with %{version} in future.
321 let srpm = "goals-@PACKAGE_VERSION@-1%fedora-dist.src.rpm"
323 goal maintainer-srpm =
324 "%srpm" : tarfile, "goals.spec" {
326 --define "%%_sourcedir $PWD" \
327 --define "%%_srcrpmdir $PWD" \
331 goal maintainer-fedora-copr = : maintainer-upload, srpm {
332 copr build rjones/goals %srpm