Skip to content

Commit

Permalink
Use more GNU/Autotools idiomatic names and methods
Browse files Browse the repository at this point in the history
We're extending GNU/Autotools with our own macros. This is allowed and
even expected, but there are certainly more and less idiomatic ways to
do so. This normalizes all our extended bits to be as idiomatic as
possible to make auditing easier.

* Filename prefixes are more representative of their source:
  especially we are not hijacking the ax_ prefix which usually
  references something from autotools-archive that could be compared
  with a known source. All files starting with ax_ could be removed from
  the repository and the project still built provided autotools-archive
  was available on the host system. We're still vendoring them because
  it is not as broadly available as autotools, but these bits don't need
  to be audited as part of this project.

  I used que_ as a prefix to make them easy to find and because I've
  authored them and share identical extensions across a number of other
  projects. The configure macros and makefile extensions have matching
  prefixes so they sort together.

* The AMINCLUDE system is leveraged instead of hand rolling includes.
  This is actually probably slightly *harder* to grok, but again the
  macros used are standardized in autoconf-archive.) I think the more
  idiomatic usage has the payoff of not sounding any more alarms than we
  need to.

  It also has the advantage of a single place to enable/disable
  a component of the build instead of needing to comment out both the
  configure macro(s) and makefile include(s) separately.
  • Loading branch information
alerque committed Apr 4, 2024
1 parent 61aac7d commit f73cb86
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ completions/vcsh
config.log
config.status
configure
aminclude.am
/vcsh
vcsh-*
5 changes: 2 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ EXTRA_DIST += t/000-tear-env.t t/001-setup-env.t t/100-init.t t/300-add.t t/950-
BUILT_SOURCES =
CLEANFILES = $(dist_man_MANS) $(bin_SCRIPTS)

include $(top_srcdir)/build-aux/git_version.mk
include $(top_srcdir)/build-aux/dist_checksums.mk
include $(top_srcdir)/build-aux/shell_completion_dirs.mk
@INC_AMINCLUDE@
DISTCLEANFILES = @AMINCLUDE@

if !IS_SDIST
doc/vcsh.1: doc/vcsh.1.ronn
Expand Down
6 changes: 0 additions & 6 deletions build-aux/ax_dist_checksums.m4

This file was deleted.

9 changes: 0 additions & 9 deletions build-aux/ax_git_version.m4

This file was deleted.

13 changes: 13 additions & 0 deletions build-aux/que_dist_checksums.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
AC_DEFUN([QUE_DIST_CHECKSUMS], [
QUE_PROGVAR([sha256sum])
QUE_PROGVAR([tee])
QUE_TRANSFORM_PACKAGE_NAME
AC_REQUIRE([AX_AM_MACROS])
AX_ADD_AM_MACRO([dnl
$(cat build-aux/que_dist_checksums.mk)
])dnl
])
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ distclean-local:

# Append checksum operation to function that runs after compressing dist archives
am__post_remove_distdir = $(am__remove_distdir); $(checksum_dist)

# vim: ft=automake
14 changes: 14 additions & 0 deletions build-aux/que_git_version.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
AC_DEFUN([QUE_GIT_VERSION], [
AC_PROG_AWK
AC_PROG_GREP
QUE_PROGVAR([cmp])
QUE_TRANSFORM_PACKAGE_NAME
AC_REQUIRE([AX_AM_MACROS])
AX_ADD_AM_MACRO([dnl
$(cat build-aux/que_git_version.mk)
])dnl
])
1 change: 0 additions & 1 deletion build-aux/git_version.mk → build-aux/que_git_version.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.SECONDEXPANSION:

# EXTRA_@PACKAGE_VAR@_SOURCES += .version
EXTRA_DIST += build-aux/git-version-gen
BUILT_SOURCES += .version
CLEANFILES += .version .version-prev
Expand Down
2 changes: 1 addition & 1 deletion build-aux/ax_progvar.m4 → build-aux/que_progvar.m4
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AC_DEFUN([AX_PROGVAR], [
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])
])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
AC_DEFUN_ONCE([AX_SHELL_COMPLETION_DIRS], [
AC_DEFUN_ONCE([QUE_SHELL_COMPLETION_DIRS], [
AX_TRANSFORM_PACKAGE_NAME
QUE_TRANSFORM_PACKAGE_NAME
AC_ARG_WITH([bash-completion-dir],
AS_HELP_STRING([--with-bash-completion-dir[=PATH]],
Expand Down Expand Up @@ -30,4 +30,9 @@ AC_DEFUN_ONCE([AX_SHELL_COMPLETION_DIRS], [
[ZSH_COMPLETION_DIR="$with_zsh_completion_dir"])
AC_SUBST([ZSH_COMPLETION_DIR])
AC_REQUIRE([AX_AM_MACROS])
AX_ADD_AM_MACRO([dnl
$(cat build-aux/que_shell_completion_dirs.mk)
])dnl
])
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This isn't convenient to use if we're just renaming the top level package, so
# we go ahead and *do* the transformation and save for use as a substitution.

AC_DEFUN_ONCE([AX_TRANSFORM_PACKAGE_NAME], [
AC_DEFUN_ONCE([QUE_TRANSFORM_PACKAGE_NAME], [
AC_PROG_SED
Expand Down
19 changes: 10 additions & 9 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,20 @@ AC_ARG_WITH([standalone],
],
[])

QUE_TRANSFORM_PACKAGE_NAME

# These macros must be run after processing our standalone setup because
# they all expect the program name transformation setup to be complete.
AX_GIT_VERSION
AX_DIST_CHECKSUMS
AX_SHELL_COMPLETION_DIRS
AX_TRANSFORM_PACKAGE_NAME
QUE_GIT_VERSION
QUE_DIST_CHECKSUMS
QUE_SHELL_COMPLETION_DIRS

AC_PROG_GREP
AC_PROG_SED

AX_PROGVAR([comm])
AX_PROGVAR([git])
AX_PROGVAR([wc])
QUE_PROGVAR([comm])
QUE_PROGVAR([git])
QUE_PROGVAR([wc])

AC_ARG_WITH([deployment],
AS_HELP_STRING([--with-deployment],
Expand All @@ -60,7 +61,7 @@ AM_CONDITIONAL([ENABLE_MAN_PAGE],
AM_COND_IF([IS_SDIST],
[],
[AM_COND_IF([ENABLE_MAN_PAGE],
[AX_PROGVAR([ronn])])
[QUE_PROGVAR([ronn])])
])

AM_COND_IF([IS_SDIST],
Expand All @@ -75,7 +76,7 @@ AM_CONDITIONAL([ENABLE_TESTS],
[test x"$enable_tests" != x"no"])

AM_COND_IF([ENABLE_TESTS], [
AX_PROGVAR([prove])
QUE_PROGVAR([prove])
AX_PROG_PERL_MODULES(Shell::Command, [],
AC_MSG_ERROR(Perl module required for testing not found))
AX_PROG_PERL_MODULES(Test::Most, [],
Expand Down

0 comments on commit f73cb86

Please sign in to comment.