Skip to content

Commit

Permalink
Merge pull request #332 from alerque/autoconf-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque authored Dec 29, 2023
2 parents 71b036f + e966e55 commit 243ab00
Show file tree
Hide file tree
Showing 15 changed files with 275 additions and 209 deletions.
14 changes: 13 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@ root = true
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true

[{Makefile*,*.mk,*.mk.in}]
indent_style = tab
indent_size = 4

[*.m4]
indent_style = space
indent_size = 8

[*.md]
trim_trailing_whitespace = false

[{vcsh.in,completions/vcsh.*}]
indent_style = tab
trim_trailing_whitespace = true
173 changes: 85 additions & 88 deletions LICENSE → LICENSE.md

Large diffs are not rendered by default.

50 changes: 14 additions & 36 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,66 +8,47 @@ ACLOCAL_AMFLAGS = -I build-aux
docdir = $(datarootdir)/doc/$(TRANSFORMED_PACKAGE_NAME)
licensedir = $(datarootdir)/licenses/$(TRANSFORMED_PACKAGE_NAME)

bin_SCRIPTS = vcsh
dist_doc_DATA = changelog doc/INSTALL.md doc/README.md doc/error_codes.md
samplehooksdir = $(docdir)/sample_hooks
dist_samplehooks_DATA = doc/sample_hooks/post-init-add-origin doc/sample_hooks/post-init-setup-mr doc/sample_hooks/post-merge-unclobber doc/sample_hooks/pre-merge-unclobber
dist_license_DATA = LICENSE CONTRIBUTORS
dist_license_DATA = LICENSE.md CONTRIBUTORS
if ENABLE_MAN_PAGE
dist_man_MANS = doc/vcsh.1
endif
bin_SCRIPTS = vcsh

EXTRA_DIST = completions/vcsh.bash completions/vcsh.zsh build-aux/git-version-gen build-aux/ax_prog_perl_modules.m4
EXTRA_DIST = completions/vcsh.bash completions/vcsh.zsh build-aux/ax_prog_perl_modules.m4
EXTRA_DIST += t/000-tear-env.t t/001-setup-env.t t/100-init.t t/300-add.t t/950-delete.t t/999-tear-env.t

BUILT_SOURCES = .version
CLEANFILES = $(BUILT_SOURCES) .version-prev $(dist_man_MANS) $(bin_SCRIPTS)

if ENABLE_BASH_COMPLETION
bashcompletiondir = $(BASH_COMPLETION_DIR)
nodist_bashcompletion_DATA = completions/$(TRANSFORMED_PACKAGE_NAME)
CLEANFILES += $(nodist_bashcompletion_DATA)
endif
BUILT_SOURCES =
CLEANFILES = $(dist_man_MANS) $(bin_SCRIPTS)

if ENABLE_ZSH_COMPLETION
zshcompletiondir = $(ZSH_COMPLETION_DIR)
nodist_zshcompletion_DATA = completions/_$(TRANSFORMED_PACKAGE_NAME)
CLEANFILES += $(nodist_zshcompletion_DATA)
endif
include $(top_srcdir)/build-aux/git_version.mk
include $(top_srcdir)/build-aux/shell_completion_dirs.mk

if !IS_SDIST
doc/vcsh.1: doc/vcsh.1.ronn
$(RONN) < $< > $@
endif

completions/$(TRANSFORMED_PACKAGE_NAME): completions/vcsh.bash
$(COMPLETIONS_OUT_DIR)/$(TRANSFORMED_PACKAGE_NAME): completions/vcsh.bash
mkdir -p $(dir $@)
install $< $@

completions/_$(TRANSFORMED_PACKAGE_NAME): completions/vcsh.zsh
$(COMPLETIONS_OUT_DIR)/_$(TRANSFORMED_PACKAGE_NAME): completions/vcsh.zsh
mkdir -p $(dir $@)
install $< $@

.version: $(shell $(AWK) '{print ".git/" $$2}' .git/HEAD 2>/dev/null ||:)
[ -e "$@" ] && mv "$@" "$@-prev" || $(if $<,touch,cp "$(srcdir)/.tarball-version") "$@-prev"
$(if $<,./build-aux/git-version-gen "$(srcdir)/.tarball-version",printf "$(VERSION)") > "$@"
$(CMP) -s "$@" "$@-prev" || autoreconf configure.ac --force

_CHECKDEPS = check-version

if ENABLE_TESTS
_CHECKDEPS += prove
_CHECKDEPS = prove
endif

check-local: $(_CHECKDEPS)

installcheck-local:
./$(TRANSFORMED_PACKAGE_NAME) version
check-version: check-dep-versions

.PHONY: check-version
check-version: vcsh | .version
$(GREP) -Fx '$(VERSION)' $|
./$< version | $(GREP) -Ff $|
.PHONY: check-dep-versions
check-dep-version: $(PACKAGE_NAME) | .version
./$< version | $(GREP) -Ff <($(GIT) version)

.PHONY: prove
Expand All @@ -85,7 +66,7 @@ lint-editor-config:
ec

.PHONY: lint-shellheck
lint-shellcheck: vcsh
lint-shellcheck: $(PACKAGE_NAME)
shellcheck $<

CONTRIBUTORS:
Expand All @@ -97,6 +78,3 @@ CONTRIBUTORS:

changelog-HEAD: changelog
sed -nEe '2d;s/^\t//p;/^$$/q;' $< > $@

dist-hook:
printf "$(VERSION)" > "$(distdir)/.tarball-version"
9 changes: 9 additions & 0 deletions build-aux/ax_git_version.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
AC_DEFUN([AX_GIT_VERSION], [
AC_PROG_AWK
AC_PROG_GREP
AX_PROGVAR([cmp])
AX_TRANSFORM_PACKAGE_NAME
])
53 changes: 26 additions & 27 deletions build-aux/ax_prog_perl_modules.m4
Original file line number Diff line number Diff line change
Expand Up @@ -38,40 +38,39 @@ AU_ALIAS([AC_PROG_PERL_MODULES], [AX_PROG_PERL_MODULES])
AC_DEFUN([AX_PROG_PERL_MODULES],[dnl
m4_define([ax_perl_modules])
m4_foreach([ax_perl_module], m4_split(m4_normalize([$1])),
[
m4_append([ax_perl_modules],
[']m4_bpatsubst(ax_perl_module,=,[ ])[' ])
])
m4_foreach([ax_perl_module], m4_split(m4_normalize([$1])), [
m4_append([ax_perl_modules],
[']m4_bpatsubst(ax_perl_module,=,[ ])[' ])
])
# Make sure we have perl
if test -z "$PERL"; then
AC_CHECK_PROG(PERL,perl,perl)
AC_CHECK_PROG(PERL,perl,perl)
fi
if test "x$PERL" != x; then
ax_perl_modules_failed=0
for ax_perl_module in ax_perl_modules; do
AC_MSG_CHECKING(for perl module $ax_perl_module)
ax_perl_modules_failed=0
for ax_perl_module in ax_perl_modules; do
AC_MSG_CHECKING(for perl module $ax_perl_module)
# Would be nice to log result here, but can't rely on autoconf internals
$PERL -e "use $ax_perl_module; exit" > /dev/null 2>&1
if test $? -ne 0; then
AC_MSG_RESULT(no);
ax_perl_modules_failed=1
else
AC_MSG_RESULT(ok);
fi
done
# Would be nice to log result here, but can't rely on autoconf internals
$PERL -e "use $ax_perl_module; exit" > /dev/null 2>&1
if test $? -ne 0; then
AC_MSG_RESULT(no);
ax_perl_modules_failed=1
else
AC_MSG_RESULT(ok);
fi
done
# Run optional shell commands
if test "$ax_perl_modules_failed" = 0; then
:
$2
else
:
$3
fi
# Run optional shell commands
if test "$ax_perl_modules_failed" = 0; then
:
$2
else
:
$3
fi
else
AC_MSG_WARN(could not find perl)
AC_MSG_WARN(could not find perl)
fi])dnl
6 changes: 3 additions & 3 deletions build-aux/ax_progvar.m4
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AC_DEFUN([AX_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])
])
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])
])

33 changes: 33 additions & 0 deletions build-aux/ax_shell_completion_dirs.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
AC_DEFUN_ONCE([AX_SHELL_COMPLETION_DIRS], [
AX_TRANSFORM_PACKAGE_NAME
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@:>@]),
[],
[with_bash_completion_dir=yes])
AM_CONDITIONAL([ENABLE_BASH_COMPLETION],
[test "x$with_bash_completion_dir" != "xno"])
AM_COND_IF([ENABLE_BASH_COMPLETION],
[PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0],
[BASH_COMPLETION_DIR="$(pkg-config --define-variable=datadir=$datadir --variable=completionsdir bash-completion)"],
[BASH_COMPLETION_DIR="$datadir/bash-completion/completions"])],
[BASH_COMPLETION_DIR="$with_bash_completion_dir"])
AC_SUBST([BASH_COMPLETION_DIR])
AC_ARG_WITH([zsh-completion-dir],
AS_HELP_STRING([--with-zsh-completion-dir[=PATH]],
[Install the zsh auto-completion script in this directory. @<:@default=yes@:>@]),
[],
[with_zsh_completion_dir=yes])
AM_CONDITIONAL([ENABLE_ZSH_COMPLETION],
[test "x$with_zsh_completion_dir" != "xno"])
AM_COND_IF([ENABLE_ZSH_COMPLETION],
[ZSH_COMPLETION_DIR="$datadir/zsh/site-functions"],
[ZSH_COMPLETION_DIR="$with_zsh_completion_dir"])
AC_SUBST([ZSH_COMPLETION_DIR])
])
5 changes: 0 additions & 5 deletions build-aux/ax_subst_transformed_package_name.m4

This file was deleted.

18 changes: 18 additions & 0 deletions build-aux/ax_transform_package_name.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# The autotools supplied AC_ARG_PROGRAM enables renaming operations, but it
# supplies them as a sed operation that can be applied to multiple binaries.
# 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_PROG_SED
TRANSFORMED_PACKAGE_NAME="$(printf "$PACKAGE_NAME" | $SED -e "$(printf "$program_transform_name" | $SED -e 's/\$\$/\$/')")"
AC_SUBST([TRANSFORMED_PACKAGE_NAME])
PACKAGE_VAR="$(printf "$PACKAGE_NAME" | $SED -e "s/-/_/g")"
AC_SUBST([PACKAGE_VAR])
AC_ARG_PROGRAM
])
4 changes: 2 additions & 2 deletions build-aux/git-version-gen
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ then
# directory, and "git describe" output looks sensible, use that to
# derive a version string.
elif test "`git log -1 --pretty=format:x . 2>/dev/null`" = x \
&& v=`git describe --tags --abbrev=7 --match="$prefix*" HEAD 2>/dev/null \
&& v=`git describe --tags --abbrev=7 --match="$prefix*\.*\.*" HEAD 2>/dev/null \
|| git describe --tags --abbrev=7 HEAD 2>/dev/null \
|| git log -1 --pretty=format:'v0-HEAD-%h' 2>/dev/null` \
&& v=`printf '%s\n' "$v" | sed "$tag_sed_script"` \
Expand Down Expand Up @@ -182,7 +182,7 @@ then
;;
esac

v=`echo "$v" | sed 's/-\([0-9]\)/.r\1/'`;
v=`echo "$v" | sed 's/-\([0-9]\)/.r\1/'`;
v_from_git=1
else
v=UNKNOWN
Expand Down
37 changes: 37 additions & 0 deletions build-aux/git_version.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.SECONDEXPANSION:

# EXTRA_@PACKAGE_VAR@_SOURCES += .version
EXTRA_DIST += build-aux/git-version-gen
BUILT_SOURCES += .version
CLEANFILES += .version .version-prev

_BRANCH_REF != $(AWK) '{print ".git/" $$2}' .git/HEAD 2>/dev/null ||:
.version: $(_BRANCH_REF)
@if [ -e "$(srcdir)/.tarball-version" ]; then \
printf "$(VERSION)" > $@; \
else \
touch "$@-prev"; \
if [ -e "$@" ]; then \
cp "$@" "$@-prev"; \
fi; \
./build-aux/git-version-gen "$(srcdir)/.tarball-version" > $@; \
$(CMP) -s "$@" "$@-prev" || autoreconf configure.ac --force; \
fi

check-version: check-git-version

.PHONY: check-git-version
check-git-version: $(PACKAGE_NAME)$(EXEEXT) | .version
$(GREP) -Fx '$(VERSION)' $|
./$< --version | $(GREP) -Ff $|

installcheck-local-version:
./$(TRANSFORMED_PACKAGE_NAME)$(EXEEXT) --version

dist-hook: dist-tarball-version

.PHONY: dist-tarball-version
dist-tarball-version:
printf "$(VERSION)" > "$(distdir)/.tarball-version"

# vim: ft=automake
21 changes: 21 additions & 0 deletions build-aux/shell_completion_dirs.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
COMPLETIONS_OUT_DIR = completions

if ENABLE_BASH_COMPLETION
bashcompletiondir = $(BASH_COMPLETION_DIR)
nodist_bashcompletion_DATA = $(COMPLETIONS_OUT_DIR)/$(TRANSFORMED_PACKAGE_NAME)
CLEANFILES += $(nodist_bashcompletion_DATA)
endif

# if ENABLE_FISH_COMPLETION
# fishcompletiondir = $(FISH_COMPLETION_DIR)
# nodist_fishcompletion_DATA = $(COMPLETIONS_OUT_DIR)/$(TRANSFORMED_PACKAGE_NAME).fish
# CLEANFILES += $(nodist_fishcompletion_DATA)
# endif

if ENABLE_ZSH_COMPLETION
zshcompletiondir = $(ZSH_COMPLETION_DIR)
nodist_zshcompletion_DATA = $(COMPLETIONS_OUT_DIR)/_$(TRANSFORMED_PACKAGE_NAME)
CLEANFILES += $(nodist_zshcompletion_DATA)
endif

# vim: ft=automake
Loading

0 comments on commit 243ab00

Please sign in to comment.