stdlib/fedora: Use grep -F when matching %fedora-rebuild-name
[goals.git] / Goalfile.in
index e8d6018..7dca26f 100644 (file)
@@ -1,6 +1,7 @@
 # Goalfile
-# Copyright (C) 2019 Richard W.M. Jones
-# Copyright (C) 2019 Red Hat Inc.
+# @configure_input@
+# Copyright (C) 2019-2020 Richard W.M. Jones
+# Copyright (C) 2019-2020 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
@@ -18,6 +19,8 @@
 
 include "ocaml.gl"
 
+let version = "@PACKAGE_VERSION@"
+
 let subdirs = [ "m4", "src", "stdlib", "docs", "man", "tests" ]
 
 goal all = : "Goalfile", tool, documentation;
@@ -89,7 +92,7 @@ goal tool = : ocaml_link ("src/goals", objects) ;
 
 # Parser.
 "src/parser.mli", "src/parser.ml" : "src/parser.mly" {
-    %MENHIR --explain %<
+    %MENHIR --explain --code-ancient %<
     # Hack required to break circular dependencies.
     echo 'val lexer_read : (Lexing.lexbuf -> token) option ref' >> src/parser.mli
     echo 'val eval_substitute : (Ast.env -> Ast.loc -> Ast.substs -> string) option ref' >> src/parser.mli
@@ -132,7 +135,7 @@ goal pod2man (page, section) =
     %POD2MAN \
         -u \
         -c "goals" \
-        --release "@PACKAGE_NAME@-@PACKAGE_VERSION@" \
+        --release goals-%version \
         --section %section %< > %@-t
     mv %@-t %@
 }
@@ -176,10 +179,14 @@ goal install = {
     # exec_prefix die die die
     bindir="@prefix@/bin"
     datadir="@prefix@/share"
-    mkdir -p %DESTDIR/"$bindir"
-    mkdir -p %DESTDIR/"$datadir/goals"
-    install src/goals %DESTDIR/"$bindir" -m 0755
-    install %stdlibfiles %DESTDIR/"$datadir"/goals -m 644
+    mandir="$datadir/man"
+    mkdir -p %DESTDIR"$bindir"
+    mkdir -p %DESTDIR"$datadir/goals/stdlib"
+    mkdir -p %DESTDIR"$mandir/man1" %DESTDIR"$mandir/man5"
+    install src/goals %DESTDIR"$bindir" -m 0755
+    install %stdlibfiles %DESTDIR"$datadir"/goals/stdlib -m 644
+    install man/*.1 %DESTDIR"$mandir"/man1/ -m 644
+    install man/*.5 %DESTDIR"$mandir"/man5/ -m 644
 }
 
 #----------------------------------------------------------------------
@@ -215,16 +222,21 @@ let distfiles = [
     ".gitignore",
     "COPYING",
     "Goalfile.in",
+    "Makefile.am",
     "Makefile.in",
     "README",
     "TODO",
+    "aclocal.m4",
     "autogen.sh",
+    "compile",
     "config.h.in",
     "configure",
     "configure.ac",
     wildcard ("docs/*.pod"),
+    "goals.spec.in",
     "install-sh",
     "m4/ocaml.m4",
+    "missing",
     "run.in",
     "src/.depend",
     sources,
@@ -239,10 +251,10 @@ let distfiles = [
     wildcard ("tests/10-function-wildcard.d/*"),
 ]
 
-let tarfile = "@PACKAGE_NAME@-@PACKAGE_VERSION@.tar.gz"
+let tarfile = "goals-%version.tar.gz"
 
 goal dist = "%tarfile" : {
-    d="@PACKAGE_NAME@-@PACKAGE_VERSION@"
+    d=goals-%version
     o=%tarfile
     rm -rf "$d"
     rm -f "$o" "$o-t"
@@ -253,13 +265,18 @@ goal dist = "%tarfile" : {
         mkdir -p "$d/$subdir"
         cp -a "$f" "$d/$subdir"
     done
+    # Replace $d/install-sh with a real file
+    if [ -L "$d/install-sh" ]; then
+        rm "$d/install-sh"
+        cp -L "install-sh" "$d/install-sh"
+    fi
     tar zcf "$o-t" "$d"
     mv "$o-t" "$o"
     rm -rf "$d"
 }
 
 goal distcheck = : dist {
-    d="@PACKAGE_NAME@-@PACKAGE_VERSION@"
+    d=goals-%version
     tar zxf %tarfile
     pushd "$d"
     ./configure
@@ -273,11 +290,20 @@ goal distcheck = : dist {
 #----------------------------------------------------------------------
 # Maintainer rules.
 
+# Easy way to commit and tag a release.
+goal maintainer-commit = {
+    git commit -a -m "Version "%version"."
+}
+
+goal maintainer-tag = {
+    git tag -a v%version -m "Version "%version -f
+}
+
 # Check no files are missing from distfiles above by unpacking the
 # distribution tarball and comparing it to git.
 goal maintainer-check-extra-dist = : dist @{
     tar ztf %tarfile | sort |
-        sed 's,^@PACKAGE_NAME@-@PACKAGE_VERSION@/,,' > tarfiles
+        sed 's,^goals-'%version'/,,' > tarfiles
     git ls-files | sort > gitfiles
     comm -13 tarfiles gitfiles > comm.out
     cat comm.out
@@ -290,19 +316,40 @@ goal maintainer-check-extra-dist = : dist @{
 goal maintainer-release = : dist,
                             maintainer-check-extra-dist,
                             distcheck,
-                            maintainer-upload
+                            maintainer-upload,
+                            maintainer-srpm,
+                            maintainer-fedora-copr
 
 let websitedir = "%HOME/d/websites/people.redhat.com/goals"
 
-# XXX Should actually use the *url tactic here.
-goal maintainer-upload = {
+# XXX Should actually use the is-url predicate here.
+goal maintainer-upload = : distcheck {
     [ -d %websitedir ]
     cp %tarfile %websitedir/files
     cp README %websitedir/README
     cp man/goals.1.txt man/Goalfile.5.txt %websitedir
     cd %websitedir
     git add files/%tarfile README goals.1.txt Goalfile.5.txt
-    git commit -m "@PACKAGE_NAME@ @PACKAGE_VERSION@"
+    git commit -m "goals "%version
     cd ..
     ./.rsync
 }
+
+pure function get-fedora-dist () returning string = @{
+    rpm --eval '%%dist'
+}
+let fedora-dist = get-fedora-dist ()
+# XXX Replace autoconf macro with %{version} in future.
+let srpm = "goals-@PACKAGE_VERSION@-1%fedora-dist.src.rpm"
+
+goal maintainer-srpm =
+"%srpm" : tarfile, "goals.spec" {
+    rpmbuild -bs \
+        --define "%%_sourcedir $PWD" \
+        --define "%%_srcrpmdir $PWD" \
+        goals.spec
+}
+
+goal maintainer-fedora-copr = : maintainer-upload, srpm {
+    copr build rjones/goals %srpm
+}
\ No newline at end of file