Skip to content

Commit

Permalink
refactor(build): Adapt custom macro for upstreaming to autoconf-archive
Browse files Browse the repository at this point in the history
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.

autoconf-archive/autoconf-archive#324
  • Loading branch information
alerque committed Dec 11, 2024
1 parent 14b3671 commit 95cccf2
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 51 deletions.
49 changes: 49 additions & 0 deletions build-aux/ax_require_prog.m4
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
#
# 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])
])
4 changes: 2 additions & 2 deletions build-aux/que_dist_checksums.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion build-aux/que_docker_boilerplate.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion build-aux/que_git_version.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 0 additions & 11 deletions build-aux/que_progvar.m4

This file was deleted.

14 changes: 7 additions & 7 deletions build-aux/que_rust_boilerplate.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions build-aux/que_subst_man_date.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
54 changes: 27 additions & 27 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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], [
Expand All @@ -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])
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 95cccf2

Please sign in to comment.