This centralizes the configure command line arguments used for CI builds
in a single script.  It makes it easier to test locally and keeps the
manifests dry.

Differences among the manifests are mostly kept as they were, this
can/should be cleaned up in future commit.
---
 .builds/alpine.yml    |  31 +++---------
 .builds/archlinux.yml |  31 +++---------
 .builds/build         | 111 ++++++++++++++++++++++++++++++++++++++++++
 .builds/debian.yml    |  30 +++---------
 .builds/freebsd.yml   |  30 +++---------
 .builds/openbsd.yml   |  48 +++---------------
 doc/devel-notes.txt   |   2 +
 7 files changed, 143 insertions(+), 140 deletions(-)
 create mode 100755 .builds/build

diff --git a/.builds/alpine.yml b/.builds/alpine.yml
index bdd8934c..243253d9 100644
--- a/.builds/alpine.yml
+++ b/.builds/alpine.yml
@@ -15,6 +15,8 @@ packages:
 - tcc-libs-static
 sources:
 - https://git.sr.ht/~mutt/mutt
+environment:
+  NPROC: '8'
 tasks:
 - check: |
     cd mutt
@@ -24,37 +26,16 @@ tasks:
 
 - default: |
     cd mutt
-    autoreconf -if
-    ./configure
-    make -j4 CFLAGS='-Wall -Werror'
+    ./.builds/build default
 
 - without-wc-funcs: |
     cd mutt
-    autoreconf -if
-    ./configure \
-        --without-wc-funcs
-    make -j4 CFLAGS='-Wall -Werror'
+    ./.builds/build without_wc_funcs
 
 - original: |
     cd mutt
-    autoreconf -if
-    ./configure \
-        --enable-gpgme \
-        --enable-pop \
-        --enable-imap \
-        --enable-smtp \
-        --enable-hcache \
-        --enable-sidebar \
-        --without-included-gettext \
-        --with-mailpath=/var/spool/mail \
-        --with-curses \
-        --with-ssl \
-        --with-sasl \
-        --with-idn2
-    make -j4 CFLAGS='-Wall -Werror'
+    ./.builds/build original
 
 - tcc: |
     cd mutt
-    autoreconf -if
-    CC=tcc ./configure
-    make -j4 CFLAGS='-Wall -Werror'
+    ./.builds/build tcc
diff --git a/.builds/archlinux.yml b/.builds/archlinux.yml
index dd34b98b..95419a66 100644
--- a/.builds/archlinux.yml
+++ b/.builds/archlinux.yml
@@ -15,6 +15,8 @@ packages:
 - tcc-libs-static
 sources:
 - https://git.sr.ht/~mutt/mutt
+environment:
+  NPROC: '8'
 tasks:
 - check: |
     cd mutt
@@ -24,37 +26,16 @@ tasks:
 
 - default: |
     cd mutt
-    autoreconf -if
-    ./configure
-    make -j4 CFLAGS='-Wall -Werror'
+    ./.builds/build default
 
 - without-wc-funcs: |
     cd mutt
-    autoreconf -if
-    ./configure \
-        --without-wc-funcs
-    make -j4 CFLAGS='-Wall -Werror'
+    ./.builds/build without_wc_funcs
 
 - original: |
     cd mutt
-    autoreconf -if
-    ./configure \
-        --enable-gpgme \
-        --enable-pop \
-        --enable-imap \
-        --enable-smtp \
-        --enable-hcache \
-        --enable-sidebar \
-        --without-included-gettext \
-        --with-mailpath=/var/spool/mail \
-        --with-curses \
-        --with-ssl \
-        --with-sasl \
-        --with-idn2
-    make -j4 CFLAGS='-Wall -Werror'
+    ./.builds/build original
 
 - tcc: |
     cd mutt
-    autoreconf -if
-    CC=tcc ./configure
-    make -j4 CFLAGS='-Wall -Werror'
+    ./.builds/build tcc
diff --git a/.builds/build b/.builds/build
new file mode 100755
index 00000000..d97051d4
--- /dev/null
+++ b/.builds/build
@@ -0,0 +1,111 @@
+#!/bin/sh
+
+# Build and test multiple build configurations
+# USAGE: build [conf]...
+
+# Environment: CFLAGS and NPROC, see below.
+
+# If the script is called without any arguments it will automagically collect
+# all build configurations and run them all.
+
+# Every build configuration is a function. Make sure the function name is at
+# the start of the line and does only contain characters a-z and '_'. Function
+# names starting with an underscore are utility functions and will not be
+# collected.
+
+cflags="-Werror $CFLAGS"
+dft_flags="$cflags"
+nproc=${NPROC:-1}
+
+_die()
+{
+       >&2 printf "FAILED: Task: %s Step: %s\n" "$2" "$3"
+       exit "$1"
+}
+
+
+default()
+{
+       ./configure
+}
+
+openbsd()
+{
+       ./configure \
+               --enable-compressed \
+               --enable-debug \
+               --enable-external_dotlock \
+               --disable-fcntl \
+               --enable-flock \
+               --with-idn2 \
+               --enable-imap \
+               --enable-pop \
+               --enable-sidebar \
+               --enable-smtp \
+               --mandir=${PREFIX}/man \
+               --with-docdir="${PREFIX}/share/doc/mutt" \
+               --with-ssl \
+               --enable-hcache \
+               --with-qdbm
+}
+
+original()
+{
+       ./configure \
+               --enable-gpgme \
+               --enable-pop \
+               --enable-imap \
+               --enable-smtp \
+               --enable-hcache \
+               --enable-sidebar \
+               --without-included-gettext \
+               --with-mailpath=/var/spool/mail \
+               --with-curses \
+               --with-ssl \
+               --with-sasl \
+               --with-idn2
+}
+
+original_freebsd()
+{
+       ./configure \
+               --enable-gpgme \
+               --enable-pop \
+               --enable-imap \
+               --enable-smtp \
+               --enable-hcache \
+               --enable-sidebar \
+               --with-kyotocabinet=/usr/local \
+               --with-mailpath=/var/spool/mail \
+               --with-curses \
+               --with-ssl \
+               --without-sasl \
+               --with-libiconv-prefix=/usr/local \
+               --with-libintl-prefix=/usr/local
+}
+
+tcc()
+{
+       CC=tcc ./configure
+}
+
+without_wc_funcs()
+{
+       ./configure \
+               --without-wc-funcs
+}
+
+# If no arguments were passed, get all the above function names (except _die)
+# and drop the parentheses.
+# shellcheck disable=SC2046
+test "$1" || set -- $(sed -n '/^[a-z][a-z_]\{1,\}()$/s/()//p' "$0")
+
+autoreconf -fi
+
+for conf
+do
+       cflags="$dft_flags"
+       make distclean || :
+       $conf || _die "$?" "$conf" configure
+       make -j"$nproc" CFLAGS="$cflags" || _die "$?" "$conf" make
+done
diff --git a/.builds/debian.yml b/.builds/debian.yml
index b536ebbf..66aacd77 100644
--- a/.builds/debian.yml
+++ b/.builds/debian.yml
@@ -16,6 +16,8 @@ packages:
 - tcc
 sources:
 - https://git.sr.ht/~mutt/mutt
+environment:
+  NPROC: '8'
 tasks:
 - check: |
     cd mutt
@@ -25,36 +27,16 @@ tasks:
 
 - default: |
     cd mutt
-    autoreconf -if
-    ./configure
-    make -j4 CFLAGS='-Wall -Werror'
+    ./.builds/build default
 
 - without-wc-funcs: |
     cd mutt
-    autoreconf -if
-    ./configure \
-        --without-wc-funcs
-    make -j4 CFLAGS='-Wall -Werror'
+    ./.builds/build without_wc_funcs
 
 - original: |
     cd mutt
-    autoreconf -if
-    ./configure \
-        --enable-gpgme \
-        --enable-pop \
-        --enable-imap \
-        --enable-smtp \
-        --enable-hcache \
-        --enable-sidebar \
-        --without-included-gettext \
-        --with-mailpath=/var/spool/mail \
-        --with-curses \
-        --with-ssl \
-        --with-sasl
-    make -j4 CFLAGS='-Wall -Werror'
+    ./.builds/build original
 
 - tcc: |
     cd mutt
-    autoreconf -if
-    CC=tcc ./configure
-    make -j4 CFLAGS='-Wall -Werror'
+    ./.builds/build tcc
diff --git a/.builds/freebsd.yml b/.builds/freebsd.yml
index 0e17d23b..d8e4398a 100644
--- a/.builds/freebsd.yml
+++ b/.builds/freebsd.yml
@@ -17,6 +17,8 @@ packages:
 - urlview
 sources:
 - https://git.sr.ht/~mutt/mutt
+environment:
+  NPROC: '8'
 tasks:
 - check: |
     cd mutt
@@ -26,32 +28,12 @@ tasks:
 
 - default: |
     cd mutt
-    autoreconf -if
-    ./configure
-    make -j4 CFLAGS='-Wall -Werror'
+    ./.builds/build default
 
 - without-wc-funcs: |
     cd mutt
-    autoreconf -if
-    ./configure \
-        --without-wc-funcs
-    make -j4 CFLAGS='-Wall -Werror'
+    ./.builds/build without_wc_funcs
 
-- original: |
+- original_freebsd: |
     cd mutt
-    autoreconf -if
-    ./configure \
-        --enable-gpgme \
-        --enable-pop \
-        --enable-imap \
-        --enable-smtp \
-        --enable-hcache \
-        --enable-sidebar \
-        --with-kyotocabinet=/usr/local \
-        --with-mailpath=/var/spool/mail \
-        --with-curses \
-        --with-ssl \
-        --without-sasl \
-        --with-libiconv-prefix=/usr/local \
-        --with-libintl-prefix=/usr/local
-      make -j4 CFLAGS='-Wall -Werror'
+    ./.builds/build original_freebsd
diff --git a/.builds/openbsd.yml b/.builds/openbsd.yml
index bdfee93c..9816354c 100644
--- a/.builds/openbsd.yml
+++ b/.builds/openbsd.yml
@@ -20,6 +20,7 @@ environment:
   AUTOCONF_VERSION: 2.72
   AUTOMAKE_VERSION: 1.18
   LDFLAGS: -L/usr/local/lib
+  NPROC: '8'
 tasks:
 - check: |
     cd mutt
@@ -29,53 +30,16 @@ tasks:
 
 - default: |
     cd mutt
-    autoreconf -if
-    ./configure
-    make -j4 CFLAGS='-Wall -Werror'
+    ./.builds/build default
 
 - without-wc-funcs: |
     cd mutt
-    autoreconf -if
-    ./configure \
-        --without-wc-funcs
-    make -j4 CFLAGS='-Wall -Werror'
+    ./.builds/build without_wc_funcs
 
-- original: |
+- original_freebsd: |
     cd mutt
-    autoreconf -if
-    ./configure \
-        --enable-gpgme \
-        --enable-pop \
-        --enable-imap \
-        --enable-smtp \
-        --enable-hcache \
-        --enable-sidebar \
-        --with-kyotocabinet=/usr/local \
-        --with-mailpath=/var/spool/mail \
-        --with-curses \
-        --with-ssl \
-        --without-sasl \
-        --with-libiconv-prefix=/usr/local \
-        --with-libintl-prefix=/usr/local
-      make -j4 CFLAGS='-Wall -Werror'
+    ./.builds/build original_freebsd
 
 - openbsd: |
     cd mutt
-    autoreconf -if
-    ./configure \
-      --enable-compressed \
-      --enable-debug \
-      --enable-external_dotlock \
-      --disable-fcntl \
-      --enable-flock \
-      --with-idn2 \
-      --enable-imap \
-      --enable-pop \
-      --enable-sidebar \
-      --enable-smtp \
-      --mandir=${PREFIX}/man \
-      --with-docdir="${PREFIX}/share/doc/mutt" \
-      --with-ssl \
-      --enable-hcache \
-      --with-qdbm
-      make -j4 CFLAGS='-Wall -Werror'
+    ./.builds/build openbsd
diff --git a/doc/devel-notes.txt b/doc/devel-notes.txt
index 30edbed5..91db9380 100644
--- a/doc/devel-notes.txt
+++ b/doc/devel-notes.txt
@@ -159,6 +159,8 @@ in the top-level source directory reports no 
errors/warnings.
 Documentation changes should be validated by running 'make validate'
 in the doc subdirectory.
 
+You can test the most important build configurations by running
+.builds/build (which is also run by the CI system in use).
 
 String comparisons
 ------------------
-- 
2.51.0

Reply via email to