From 14b3671b40e1cc64f7217381431f2b81b448bec8 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 8 Dec 2024 23:24:47 +0300 Subject: [PATCH 1/2] refactor(build): Wrap tooling checks so duplicates don't need to be rerun --- build-aux/que_docker_boilerplate.m4 | 2 +- build-aux/que_font.m4 | 2 +- build-aux/que_git_version.m4 | 4 ++-- build-aux/que_rust_boilerplate.m4 | 4 ++-- build-aux/que_transform_package_name.m4 | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build-aux/que_docker_boilerplate.m4 b/build-aux/que_docker_boilerplate.m4 index 066bf3e13..e3e282b2e 100644 --- a/build-aux/que_docker_boilerplate.m4 +++ b/build-aux/que_docker_boilerplate.m4 @@ -3,7 +3,7 @@ AC_DEFUN_ONCE([QUE_DOCKER_BOILERPLATE], [ QUE_TRANSFORM_PACKAGE_NAME AC_MSG_NOTICE([checking for tools used by automake to build Docker projects]) - AC_PROG_INSTALL + AC_REQUIRE([AC_PROG_INSTALL]) AM_COND_IF([DEVELOPER_MODE], [ QUE_PROGVAR([docker]) ]) diff --git a/build-aux/que_font.m4 b/build-aux/que_font.m4 index 9599b3940..fd524d98f 100644 --- a/build-aux/que_font.m4 +++ b/build-aux/que_font.m4 @@ -1,5 +1,5 @@ AC_DEFUN([QUE_FONT], [ - AC_PROG_GREP + AC_REQUIRE([AC_PROG_GREP]) if test -z "$FCMATCH"; then AC_PATH_PROG(FCMATCH, fc-match) if test -z "$FCMATCH"; then diff --git a/build-aux/que_git_version.m4 b/build-aux/que_git_version.m4 index f91ca11b2..792067773 100644 --- a/build-aux/que_git_version.m4 +++ b/build-aux/que_git_version.m4 @@ -9,8 +9,8 @@ AC_DEFUN_ONCE([QUE_GIT_VERSION], [ AM_CONDITIONAL([SOURCE_IS_ARCHIVE], [test ! -d .git -a ! -f .tarball-version]) - AC_PROG_AWK - AC_PROG_GREP + AC_REQUIRE([AC_PROG_AWK]) + AC_REQUIRE([AC_PROG_GREP]) QUE_TRANSFORM_PACKAGE_NAME diff --git a/build-aux/que_rust_boilerplate.m4 b/build-aux/que_rust_boilerplate.m4 index 050afbf4e..1bfdb60f3 100644 --- a/build-aux/que_rust_boilerplate.m4 +++ b/build-aux/que_rust_boilerplate.m4 @@ -10,8 +10,8 @@ AC_DEFUN_ONCE([QUE_RUST_BOILERPLATE], [ AM_CONDITIONAL([DEBUG_RELEASE], [test "x$debug_release" = "xyes"]) AC_MSG_NOTICE([checking for tools used by automake to build Rust projects]) - AC_PROG_INSTALL - AC_PROG_SED + AC_REQUIRE([AC_PROG_INSTALL]) + AC_REQUIRE([AC_PROG_SED]) QUE_PROGVAR([cargo]) QUE_PROGVAR([jq]) QUE_PROGVAR([rustc]) diff --git a/build-aux/que_transform_package_name.m4 b/build-aux/que_transform_package_name.m4 index ee1e89726..477245b42 100644 --- a/build-aux/que_transform_package_name.m4 +++ b/build-aux/que_transform_package_name.m4 @@ -5,7 +5,7 @@ AC_DEFUN_ONCE([QUE_TRANSFORM_PACKAGE_NAME], [ - AC_PROG_SED + AC_REQUIRE([AC_PROG_SED]) TRANSFORMED_PACKAGE_NAME="$(printf "$PACKAGE_NAME" | $SED -e "$(printf "$program_transform_name" | $SED -e 's/\$\$/\$/')")" AC_SUBST([TRANSFORMED_PACKAGE_NAME]) From 95cccf2860d56b1398496df9f0e3274df64d7d51 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 8 Dec 2024 16:57:33 +0300 Subject: [PATCH 2/2] refactor(build): Adapt custom macro for upstreaming to autoconf-archive Since I seem to use this on every project I touch now, I went ahead and spruced it up in a way that should make it acceptable as a contribution to autoconf-archive. As of tihs writing it has been PR'ed but not morged, so consider the exact script with this serial still fungable. https://github.com/autoconf-archive/autoconf-archive/pull/324 --- build-aux/ax_require_prog.m4 | 49 ++++++++++++++++++++++++++ build-aux/que_dist_checksums.m4 | 4 +-- build-aux/que_docker_boilerplate.m4 | 2 +- build-aux/que_git_version.m4 | 2 +- build-aux/que_progvar.m4 | 11 ------ build-aux/que_rust_boilerplate.m4 | 14 ++++---- build-aux/que_subst_man_date.m4 | 4 +-- configure.ac | 54 ++++++++++++++--------------- 8 files changed, 89 insertions(+), 51 deletions(-) create mode 100644 build-aux/ax_require_prog.m4 delete mode 100644 build-aux/que_progvar.m4 diff --git a/build-aux/ax_require_prog.m4 b/build-aux/ax_require_prog.m4 new file mode 100644 index 000000000..219ecafc1 --- /dev/null +++ b/build-aux/ax_require_prog.m4 @@ -0,0 +1,49 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_require_prog.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_REQUIRE_PROG([EXECUTABLE], [VARIABLE]) +# +# DESCRIPTION +# +# Locates an installed binary program that is a prerequisite to continue. +# Uses AX_WITH_PROG under the hood, but follows up the check with an error +# if no executable could be located. +# +# Example usage: +# +# AX_REQUIRE_PROG(git-warp-time) +# +# Note: If the second argument is not provided, a default value of +# VARIABLE is automatically derived from the executable name by upper +# casing it and substituting any dashes or periods with underscores. In +# the example above the resulting precious variable would be +# GIT_WARP_TIME. +# +# LICENSE +# +# Copyright (c) 2021 Caleb Maclennan +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 1 + +AC_DEFUN([AX_REQUIRE_PROG], [ + AC_PREREQ([2.61]) + + pushdef([EXECUTABLE],$1) + pushdef([VARIABLE],m4_default($2,m4_toupper(m4_translit($1,-.,__)))) + + AX_WITH_PROG(VARIABLE,EXECUTABLE) + AS_IF([test "x$with_$1" != xno && test -z "$VARIABLE"], [ + AC_MSG_ERROR([EXECUTABLE is required]) + ]) + + popdef([VARIABLE]) + popdef([EXECUTABLE]) +]) diff --git a/build-aux/que_dist_checksums.m4 b/build-aux/que_dist_checksums.m4 index 7ace93afd..b6c281900 100644 --- a/build-aux/que_dist_checksums.m4 +++ b/build-aux/que_dist_checksums.m4 @@ -9,8 +9,8 @@ EXTRA_DIST += build-aux/que_dist_checksums.am AM_COND_IF([DEVELOPER_MODE], [ - QUE_PROGVAR([sha256sum]) - QUE_PROGVAR([tee]) + AX_REQUIRE_PROG([sha256sum]) + AX_REQUIRE_PROG([tee]) AX_ADD_AM_MACRO([dnl $(cat build-aux/que_dist_checksums.am) diff --git a/build-aux/que_docker_boilerplate.m4 b/build-aux/que_docker_boilerplate.m4 index e3e282b2e..f21741907 100644 --- a/build-aux/que_docker_boilerplate.m4 +++ b/build-aux/que_docker_boilerplate.m4 @@ -5,7 +5,7 @@ AC_DEFUN_ONCE([QUE_DOCKER_BOILERPLATE], [ AC_MSG_NOTICE([checking for tools used by automake to build Docker projects]) AC_REQUIRE([AC_PROG_INSTALL]) AM_COND_IF([DEVELOPER_MODE], [ - QUE_PROGVAR([docker]) + AX_REQUIRE_PROG([docker]) ]) AC_REQUIRE([AX_AM_MACROS]) diff --git a/build-aux/que_git_version.m4 b/build-aux/que_git_version.m4 index 792067773..36285e8e6 100644 --- a/build-aux/que_git_version.m4 +++ b/build-aux/que_git_version.m4 @@ -14,7 +14,7 @@ AC_DEFUN_ONCE([QUE_GIT_VERSION], [ QUE_TRANSFORM_PACKAGE_NAME - AM_COND_IF([SOURCE_IS_DIST], [], [QUE_PROGVAR([cmp])]) + AM_COND_IF([SOURCE_IS_DIST], [], [AX_REQUIRE_PROG([cmp])]) AC_REQUIRE([AX_AM_MACROS]) AX_ADD_AM_MACRO([dnl diff --git a/build-aux/que_progvar.m4 b/build-aux/que_progvar.m4 deleted file mode 100644 index 043a93758..000000000 --- a/build-aux/que_progvar.m4 +++ /dev/null @@ -1,11 +0,0 @@ -AC_DEFUN([QUE_PROGVAR], [ - pushdef([VARIABLE],m4_toupper($1)) - pushdef([EXECUTABLE],m4_default($2,$1)) - AX_WITH_PROG(VARIABLE,EXECUTABLE) - AS_IF([test "x$with_$1" != xno && test -z "$VARIABLE"], [ - AC_MSG_ERROR([EXECUTABLE is required]) - ]) - popdef([EXECUTABLE]) - popdef([VARIABLE]) -]) - diff --git a/build-aux/que_rust_boilerplate.m4 b/build-aux/que_rust_boilerplate.m4 index 1bfdb60f3..b9f63f802 100644 --- a/build-aux/que_rust_boilerplate.m4 +++ b/build-aux/que_rust_boilerplate.m4 @@ -12,14 +12,14 @@ AC_DEFUN_ONCE([QUE_RUST_BOILERPLATE], [ AC_MSG_NOTICE([checking for tools used by automake to build Rust projects]) AC_REQUIRE([AC_PROG_INSTALL]) AC_REQUIRE([AC_PROG_SED]) - QUE_PROGVAR([cargo]) - QUE_PROGVAR([jq]) - QUE_PROGVAR([rustc]) - QUE_PROGVAR([cmp]) - QUE_PROGVAR([xargs]) + AX_REQUIRE_PROG([cargo]) + AX_REQUIRE_PROG([jq]) + AX_REQUIRE_PROG([rustc]) + AX_REQUIRE_PROG([cmp]) + AX_REQUIRE_PROG([xargs]) AM_COND_IF([DEVELOPER_MODE], [ - QUE_PROGVAR([git]) - QUE_PROGVAR([rustfmt]) + AX_REQUIRE_PROG([git]) + AX_REQUIRE_PROG([rustfmt]) ]) AC_ARG_VAR(CARGO_TARGET_TRIPLE, "Target triple for Rust compilations") diff --git a/build-aux/que_subst_man_date.m4 b/build-aux/que_subst_man_date.m4 index b016b2356..0866adb74 100644 --- a/build-aux/que_subst_man_date.m4 +++ b/build-aux/que_subst_man_date.m4 @@ -3,10 +3,10 @@ AC_DEFUN([QUE_SUBST_MAN_DATE], [ ax_src_file="m4_default($2,*.1.in)" AS_IF([test ! -e .gitignore], [ - QUE_PROGVAR([date]) + AX_REQUIRE_PROG([date]) AX_BUILD_DATE_EPOCH(MAN_DATE, "$ax_date_fmt") ], [ - QUE_PROGVAR([git]) + AX_REQUIRE_PROG([git]) MAN_DATE=$($GIT log -1 --format="%cd" --date=format:"$ax_date_fmt" -- $ax_src_file) ]) AC_SUBST([MAN_DATE]) diff --git a/configure.ac b/configure.ac index bd55b7a09..72473ee63 100644 --- a/configure.ac +++ b/configure.ac @@ -21,15 +21,15 @@ AC_PROG_CC AC_PROG_GREP AC_PROG_OBJC AC_PROG_SED -QUE_PROGVAR([cmp]) -QUE_PROGVAR([diff]) -QUE_PROGVAR([find]) -QUE_PROGVAR([head]) -QUE_PROGVAR([jq]) -QUE_PROGVAR([luarocks]) -QUE_PROGVAR([pdfinfo]) -QUE_PROGVAR([sort]) -QUE_PROGVAR([xargs]) +AX_REQUIRE_PROG([cmp]) +AX_REQUIRE_PROG([diff]) +AX_REQUIRE_PROG([find]) +AX_REQUIRE_PROG([head]) +AX_REQUIRE_PROG([jq]) +AX_REQUIRE_PROG([luarocks]) +AX_REQUIRE_PROG([pdfinfo]) +AX_REQUIRE_PROG([sort]) +AX_REQUIRE_PROG([xargs]) # Disable ranlib to avoid it being run on our rusile.so module, already LTO # optimized but libtool wants to relink it... @@ -119,8 +119,8 @@ AM_CONDITIONAL([FONT_DOWNLOAD_TOOLS], [test -z ${DEVELOPER_MODE_TRUE} || (test - AC_SUBST([FONT_DOWNLOAD_TOOLS]) AM_COND_IF([MANUAL], [ - QUE_PROGVAR([dot]) - QUE_PROGVAR([gs]) + AX_REQUIRE_PROG([dot]) + AX_REQUIRE_PROG([gs]) ]) AC_MSG_CHECKING([for OS X]) @@ -189,8 +189,8 @@ AM_CONDITIONAL([ICU], [test "x$with_icu" = "xyes"]) # Required for downloading fonts for the manual and for tests # Since the source tarball includes a prebuilt manual we only need this for Git source builds AM_COND_IF([FONT_DOWNLOAD_TOOLS], [ - QUE_PROGVAR([bsdtar]) - QUE_PROGVAR([curl]) + AX_REQUIRE_PROG([bsdtar]) + AX_REQUIRE_PROG([curl]) ]) AM_COND_IF([DEVELOPER_MODE], [ @@ -199,19 +199,19 @@ AM_COND_IF([DEVELOPER_MODE], [ ]) AM_COND_IF([DEVELOPER_TOOLS], [ - QUE_PROGVAR([busted]) - QUE_PROGVAR([cargosetversion], [cargo-set-version]) - QUE_PROGVAR([curl]) - QUE_PROGVAR([ldoc]) - QUE_PROGVAR([luacheck]) - QUE_PROGVAR([nix]) - QUE_PROGVAR([npm]) - QUE_PROGVAR([perl]) - QUE_PROGVAR([stylua]) - QUE_PROGVAR([taplo]) - QUE_PROGVAR([tr]) - QUE_PROGVAR([typos]) - QUE_PROGVAR([xsltproc]) + AX_REQUIRE_PROG([busted]) + AX_REQUIRE_PROG([cargo-set-version]) + AX_REQUIRE_PROG([curl]) + AX_REQUIRE_PROG([ldoc]) + AX_REQUIRE_PROG([luacheck]) + AX_REQUIRE_PROG([nix]) + AX_REQUIRE_PROG([npm]) + AX_REQUIRE_PROG([perl]) + AX_REQUIRE_PROG([stylua]) + AX_REQUIRE_PROG([taplo]) + AX_REQUIRE_PROG([tr]) + AX_REQUIRE_PROG([typos]) + AX_REQUIRE_PROG([xsltproc]) ]) AX_PROG_LUA([5.1], [], [], [], [prefer]) @@ -242,7 +242,7 @@ AM_COND_IF([SYSTEM_LUAROCKS], [ AX_LUA_MODULE(penlight, pl) AX_LUA_MODULE(vstruct) ], [ - QUE_PROGVAR([git]) # required for luarocks to install zlib rock + AX_REQUIRE_PROG([git]) # required for luarocks to install zlib rock ]) QUE_FONT(Gentium Plus)