diff --git a/build-aux/ax_require_prog.m4 b/build-aux/ax_require_prog.m4 new file mode 100644 index 00000000..219ecafc --- /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/ax_with_prog.m4 b/build-aux/ax_with_prog.m4 new file mode 100644 index 00000000..b3a881c0 --- /dev/null +++ b/build-aux/ax_with_prog.m4 @@ -0,0 +1,70 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_with_prog.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_WITH_PROG([VARIABLE],[program],[VALUE-IF-NOT-FOUND],[PATH]) +# +# DESCRIPTION +# +# Locates an installed program binary, placing the result in the precious +# variable VARIABLE. Accepts a present VARIABLE, then --with-program, and +# failing that searches for program in the given path (which defaults to +# the system path). If program is found, VARIABLE is set to the full path +# of the binary; if it is not found VARIABLE is set to VALUE-IF-NOT-FOUND +# if provided, unchanged otherwise. +# +# A typical example could be the following one: +# +# AX_WITH_PROG(PERL,perl) +# +# NOTE: This macro is based upon the original AX_WITH_PYTHON macro from +# Dustin J. Mitchell . +# +# LICENSE +# +# Copyright (c) 2008 Francesco Salvestrini +# Copyright (c) 2008 Dustin J. Mitchell +# +# 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 17 + +AC_DEFUN([AX_WITH_PROG],[ + AC_PREREQ([2.61]) + + pushdef([VARIABLE],$1) + pushdef([EXECUTABLE],$2) + pushdef([VALUE_IF_NOT_FOUND],$3) + pushdef([PATH_PROG],$4) + + AC_ARG_VAR(VARIABLE,Absolute path to EXECUTABLE executable) + + AS_IF(test -z "$VARIABLE",[ + AC_MSG_CHECKING(whether EXECUTABLE executable path has been provided) + AC_ARG_WITH(EXECUTABLE,AS_HELP_STRING([--with-EXECUTABLE=[[[PATH]]]],absolute path to EXECUTABLE executable), [ + AS_IF([test "$withval" != yes && test "$withval" != no],[ + VARIABLE="$withval" + AC_MSG_RESULT($VARIABLE) + ],[ + VARIABLE="" + AC_MSG_RESULT([no]) + AS_IF([test "$withval" != no], [ + AC_PATH_PROG([]VARIABLE[],[]EXECUTABLE[],[]VALUE_IF_NOT_FOUND[],[]PATH_PROG[]) + ]) + ]) + ],[ + AC_MSG_RESULT([no]) + AC_PATH_PROG([]VARIABLE[],[]EXECUTABLE[],[]VALUE_IF_NOT_FOUND[],[]PATH_PROG[]) + ]) + ]) + + popdef([PATH_PROG]) + popdef([VALUE_IF_NOT_FOUND]) + popdef([EXECUTABLE]) + popdef([VARIABLE]) +]) diff --git a/build-aux/que_dist_checksums.m4 b/build-aux/que_dist_checksums.m4 index 6848cdcc..b6c28190 100644 --- a/build-aux/que_dist_checksums.m4 +++ b/build-aux/que_dist_checksums.m4 @@ -1,13 +1,17 @@ AC_DEFUN_ONCE([QUE_DIST_CHECKSUMS], [ - AM_COND_IF([DEVELOPER_MODE], [ + QUE_TRANSFORM_PACKAGE_NAME + + AC_REQUIRE([AX_AM_MACROS]) + AX_ADD_AM_MACRO([dnl +EXTRA_DIST += build-aux/que_dist_checksums.am +])dnl - QUE_PROGVAR([sha256sum]) - QUE_PROGVAR([tee]) + AM_COND_IF([DEVELOPER_MODE], [ - QUE_TRANSFORM_PACKAGE_NAME + AX_REQUIRE_PROG([sha256sum]) + AX_REQUIRE_PROG([tee]) - AC_REQUIRE([AX_AM_MACROS]) AX_ADD_AM_MACRO([dnl $(cat build-aux/que_dist_checksums.am) ])dnl diff --git a/build-aux/que_git_version.m4 b/build-aux/que_git_version.m4 index 56e7f18b..36285e8e 100644 --- a/build-aux/que_git_version.m4 +++ b/build-aux/que_git_version.m4 @@ -9,15 +9,17 @@ 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 - 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 +EXTRA_DIST += build-aux/que_git_version.am + $(cat build-aux/que_git_version.am) ])dnl diff --git a/build-aux/que_progvar.m4 b/build-aux/que_progvar.m4 deleted file mode 100644 index 20d1288b..00000000 --- a/build-aux/que_progvar.m4 +++ /dev/null @@ -1,5 +0,0 @@ -AC_DEFUN([QUE_PROGVAR], [ - test -n "$m4_toupper($1)" || { AC_PATH_PROG(m4_toupper($1), m4_default($2,$1)) } - test -n "$m4_toupper($1)" || AC_MSG_ERROR([m4_default($2,$1) is required]) -]) - diff --git a/build-aux/que_shell_completion_dirs.m4 b/build-aux/que_shell_completion_dirs.m4 index 6ceed855..ad3260ac 100644 --- a/build-aux/que_shell_completion_dirs.m4 +++ b/build-aux/que_shell_completion_dirs.m4 @@ -2,8 +2,6 @@ AC_DEFUN_ONCE([QUE_SHELL_COMPLETION_DIRS], [ QUE_TRANSFORM_PACKAGE_NAME - AC_PROG_SED - AC_ARG_WITH([bash-completion-dir], AS_HELP_STRING([--with-bash-completion-dir[=PATH]], [Install the bash auto-completion script in this directory. @<:@default=yes@:>@]), @@ -34,6 +32,8 @@ AC_DEFUN_ONCE([QUE_SHELL_COMPLETION_DIRS], [ AC_REQUIRE([AX_AM_MACROS]) AX_ADD_AM_MACRO([dnl +EXTRA_DIST += build-aux/que_shell_completion_dirs.am + $(cat build-aux/que_shell_completion_dirs.am) ])dnl diff --git a/build-aux/que_transform_package_name.m4 b/build-aux/que_transform_package_name.m4 index ee1e8972..477245b4 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]) diff --git a/configure.ac b/configure.ac index 928033aa..f85b57cf 100644 --- a/configure.ac +++ b/configure.ac @@ -37,9 +37,9 @@ QUE_DIST_CHECKSUMS AC_PROG_GREP AC_PROG_SED -QUE_PROGVAR([comm]) -QUE_PROGVAR([git]) -QUE_PROGVAR([wc]) +AX_REQUIRE_PROG([comm]) +AX_REQUIRE_PROG([git]) +AX_REQUIRE_PROG([wc]) AC_ARG_WITH([deployment], AS_HELP_STRING([--with-deployment], @@ -58,7 +58,7 @@ AM_CONDITIONAL([ENABLE_MAN_PAGE], AM_COND_IF([SOURCE_IS_GIT], [AM_COND_IF([ENABLE_MAN_PAGE], - [QUE_PROGVAR([ronn])]) + [AX_REQUIRE_PROG([ronn])]) ]) AM_COND_IF([SOURCE_IS_GIT], @@ -73,7 +73,7 @@ AM_CONDITIONAL([ENABLE_TESTS], [test x"$enable_tests" != x"no"]) AM_COND_IF([ENABLE_TESTS], [ - QUE_PROGVAR([prove]) + AX_REQUIRE_PROG([prove]) AX_PROG_PERL_MODULES(Shell::Command, [], AC_MSG_ERROR(Perl module required for testing not found)) AX_PROG_PERL_MODULES(Test::Most, [],