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 mandir="$datadir/man"
183 mkdir -p %DESTDIR"$bindir"
184 mkdir -p %DESTDIR"$datadir/goals/stdlib"
185 mkdir -p %DESTDIR"$mandir/man1" %DESTDIR"$mandir/man5"
186 install src/goals %DESTDIR"$bindir" -m 0755
187 install %stdlibfiles %DESTDIR"$datadir"/goals/stdlib -m 644
188 install man/*.1 %DESTDIR"$mandir"/man1/ -m 644
189 install man/*.5 %DESTDIR"$mandir"/man5/ -m 644
192 #----------------------------------------------------------------------
235 wildcard ("docs/*.pod"),
244 wildcard ("stdlib/*.gl"),
245 wildcard ("stdlib/*.sh"),
246 wildcard ("tests/*.data"),
247 wildcard ("tests/*.data[0-9]"),
248 wildcard ("tests/*.expected"),
249 wildcard ("tests/*.gl"),
250 wildcard ("tests/*.sh"),
251 wildcard ("tests/10-function-wildcard.d/*"),
254 let tarfile = "goals-%version.tar.gz"
256 goal dist = "%tarfile" : {
263 for f in %distfiles; do
264 subdir="$(dirname "$f")"
265 mkdir -p "$d/$subdir"
266 cp -a "$f" "$d/$subdir"
268 # Replace $d/install-sh with a real file
269 if [ -L "$d/install-sh" ]; then
271 cp -L "install-sh" "$d/install-sh"
278 goal distcheck = : dist {
287 print_green "PASS: distcheck"
290 #----------------------------------------------------------------------
293 # Easy way to commit and tag a release.
294 goal maintainer-commit = {
295 git commit -a -m "Version "%version"."
298 goal maintainer-tag = {
299 git tag -a v%version -m "Version "%version -f
302 # Check no files are missing from distfiles above by unpacking the
303 # distribution tarball and comparing it to git.
304 goal maintainer-check-extra-dist = : dist @{
305 tar ztf %tarfile | sort |
306 sed 's,^goals-'%version'/,,' > tarfiles
307 git ls-files | sort > gitfiles
308 comm -13 tarfiles gitfiles > comm.out
311 rm tarfiles gitfiles comm.out
312 print_green "PASS: distfiles"
315 # XXX This should also do a Fedora build.
316 goal maintainer-release = : dist,
317 maintainer-check-extra-dist,
321 maintainer-fedora-copr
323 let websitedir = "%HOME/d/websites/people.redhat.com/goals"
325 # XXX Should actually use the is-url predicate here.
326 goal maintainer-upload = : distcheck {
328 cp %tarfile %websitedir/files
329 cp README %websitedir/README
330 cp man/goals.1.txt man/Goalfile.5.txt %websitedir
332 git add files/%tarfile README goals.1.txt Goalfile.5.txt
333 git commit -m "goals "%version
338 pure function get-fedora-dist () returning string = @{
341 let fedora-dist = get-fedora-dist ()
342 # XXX Replace autoconf macro with %{version} in future.
343 let srpm = "goals-@PACKAGE_VERSION@-1%fedora-dist.src.rpm"
345 goal maintainer-srpm =
346 "%srpm" : tarfile, "goals.spec" {
348 --define "%%_sourcedir $PWD" \
349 --define "%%_srcrpmdir $PWD" \
353 goal maintainer-fedora-copr = : maintainer-upload, srpm {
354 copr build rjones/goals %srpm