-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AC_INIT: Use version number from CMakeLists.txt
Generate the version number used in the Autotools builds via a script instead of manual editing. This script mimics what the avrdude top-level CMakeLists.txt does for composing AVRDUDE_FULL_VERSION. Consequently, maintainers do not need to edit the version numbers in the "src/configure.ac" file's "AC_INIT(...)" line any more. However, unlike the cmake based builds, this does not print the commit hash in the "avrdude --help" message or in the "avrdude.conf" file's "avrdude_conf_version = " line -- YET. These are the six build types supported and what avrdude versions cmake and the autoconf builds actually produce: cmake autoconf git clone release 7.2 7.2 git clone non-release 7.2-DATE+HASH 7.2-DATE git archive release 7.2 7.2 git archive non-release 7.2 7.2 dist tarball release N/A 7.2 dist tarball non-release N/A 7.2-DATE
- Loading branch information
Showing
6 changed files
with
178 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ ylwrap | |
tags | ||
cscope.out | ||
/src/avrdude-[1-9].*.tar.* | ||
/src/GNUmakefile | ||
|
||
*.o | ||
*.lo | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Helps update the version number automatically if using GNU make. | ||
include Makefile | ||
|
||
AUTORECONF ?= autoreconf | ||
AUTORECONF_OPTS ?= -vis | ||
|
||
script_version := $(shell $(top_srcdir)/build-helpers/package-version $(top_srcdir) version-stamp) | ||
ifneq ($(PACKAGE_VERSION),$(script_version)) | ||
$(info autoconf and script versions do not match: $(PACKAGE_VERSION) vs $(script_version)) | ||
$(info Removing autom4te.cache and related files and re-running autoreconf) | ||
dummy1 := $(shell rm -rf $(top_srcdir)/autom4te.cache) | ||
dummy2 := $(shell $(AUTORECONF) $(AUTORECONF_OPTS) $(top_srcdir)) | ||
endif | ||
|
||
# vim: syntax=make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/bin/sh | ||
# Syntax: | ||
# $0 <path-to-top_srcdir> <version-stamp-file> | ||
# | ||
# <path-to-top_srcdir> may be relative | ||
# <version-stamp-file> is relative to the dist top_srcdir | ||
# | ||
# Test this script by running | ||
# rm -rf autom4te.cache/ && autoreconf -vis . && sed -n "/^# Generated by GNU/p" configure | ||
# | ||
# If we run into an error, we cannot abort the "autoreconf" run by | ||
# exiting with a non-0 error code. (We do exit non-0 in that case | ||
# anyway for help when testing this script.) | ||
# The only thing we can do to report an error is to write to stderr | ||
# which appears as "autoreconf" output, and to write a version number | ||
# to stdout which indicates an error. The "configure" script can | ||
# then check whether $PACKAGE_VERSION indicates such an error. | ||
|
||
# Parse the command line arguments | ||
prog="$(basename "$0")" | ||
top_srcdir="${1-.}" | ||
test -d "$top_srcdir" || { \ | ||
echo "$prog: Error: Could not change to top_srcdir '$1'" >&2; \ | ||
echo "version_error_1" | ${TR-tr} -d '\012' | ||
exit 2; \ | ||
} | ||
version_stamp="${2-version-stamp}" | ||
|
||
# echo "$prog: Error: Some error happend." >&2 | ||
# echo "version_error_2" | ${TR-tr} -d '\012' | ||
# exit 2 | ||
|
||
# Is this a dist source tree? | ||
# If so, use the version number from the version_stamp file. | ||
if test -f "$top_srcdir/$version_stamp"; then | ||
cat "$top_srcdir/$version_stamp" | ${TR-tr} -d '\012' | ||
exit | ||
fi | ||
|
||
# Is this part of a git checkout or an expanded github snapshot tarball? | ||
test -f "$top_srcdir/../CMakeLists.txt" || { \ | ||
echo "$prog: Error: top-level avrdude CMakeLists.txt file not found" >&2; \ | ||
echo "version_error_3" | ${TR-tr} -d '\012' | ||
exit 2; \ | ||
} | ||
|
||
if PROJECT_VERSION="$(${SED-sed} -n 's/project(avrdude[[:space:]]\{1,\}VERSION[[:space:]]\{1,\}\([0-9\.]\{1,\}\)[[:space:]]\{1,\}.*/\1/p' "$top_srcdir/../CMakeLists.txt")"; then | ||
: | ||
else | ||
echo "$prog: Error parsing top-level avrdude 'CMakeLists.txt'." >&2 | ||
echo "version_error_4" | ${TR-tr} -d '\012' | ||
exit 2 | ||
fi | ||
|
||
test -n "$PROJECT_VERSION" || { \ | ||
echo "$prog: Error: Could not find project(...) in top-level avrdude 'CMakeLists.txt'" >&2; \ | ||
echo "version_error_5" | ${TR-tr} -d '\012' | ||
exit 2; \ | ||
} | ||
|
||
# If GIT_DIR is set, use it. If not, try "$top_srcdir/../.git". | ||
test -n "$GIT_DIR" || { \ | ||
GIT_DIR="$top_srcdir/../.git"; \ | ||
export GIT_DIR; \ | ||
} | ||
|
||
# Working with a git source tree | ||
if test -d "$GIT_DIR"; then | ||
GIT_COMMIT_HASH="$(${GIT-git} log -1 --format=%h)" || { \ | ||
echo "$prog: Error: Cannot run 'git log' for commit hash" >&2; \ | ||
echo "version_error_71" | ${TR-tr} -d '\012'; \ | ||
exit 2; \ | ||
} | ||
GIT_COMMIT_DATE="$(${GIT-git} log -1 --format=%ad --date=format:%Y%m%d)" || { \ | ||
echo "$prog: Error: Cannot run 'git log' for commit date" >&2; \ | ||
echo "version_error_72" | ${TR-tr} -d '\012'; \ | ||
exit 2; \ | ||
} | ||
GIT_TAG_HASH="$(${GIT-git} log -1 --tags --format=%h)" || { \ | ||
echo "$prog: Error: Cannot run 'git log' for tag hash" >&2; \ | ||
echo "version_error_73" | ${TR-tr} -d '\012'; \ | ||
exit 2; \ | ||
} | ||
if test "x$GIT_COMMIT_HASH" = "x$GIT_TAG_HASH"; then | ||
echo "${PROJECT_VERSION}" | ${TR-tr} -d '\012' | ||
exit | ||
else | ||
echo "${PROJECT_VERSION}-${GIT_COMMIT_DATE}" | ${TR-tr} -d '\012' | ||
exit | ||
fi | ||
else | ||
# Building a github release tarball or github snapshot tarball. | ||
# | ||
# Presume this is a release version, because who would build a | ||
# non-release version from a snapshot tarball? | ||
echo "${PROJECT_VERSION}" | ${TR-tr} -d '\012' | ||
exit | ||
fi | ||
|
||
# If everything else has failed, call this version "devel" | ||
echo "devel" | ${TR-tr} -d '\012' | ||
exit 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
BUILD_SCRIPT_DIR = build-helpers | ||
|
||
# Check that package version matches git version before creating dist tarballs | ||
dist-hook: cur-version-check cur-version-stamp | ||
distcheck-hook: cur-version-check | ||
|
||
# Note: We cannot run autoreconf from here, because we would need some way to | ||
# restart the whole dist process from the start and there is none. | ||
EXTRA_DIST += $(top_srcdir)/$(BUILD_SCRIPT_DIR)/package-version | ||
cur-version-check: | ||
@cur_ver=`$(top_srcdir)/$(BUILD_SCRIPT_DIR)/package-version $(top_srcdir) version-stamp`; \ | ||
if test "x$${cur_ver}" = "x$(PACKAGE_VERSION)"; then :; else \ | ||
echo "ERROR: Recorded PACKAGE_VERSION and current version do not match:"; \ | ||
echo " current version: $${cur_ver}"; \ | ||
echo " recorded PACKAGE_VERSION: $(PACKAGE_VERSION)"; \ | ||
rm -rf "$(top_srcdir)/autom4te.cache"; \ | ||
echo "Update PACKAGE_VERSION by running autoreconf(1)."; \ | ||
exit 1; \ | ||
fi | ||
|
||
# Version stamp files can only exist in tarball source trees. | ||
# | ||
# So there is no need to generate them anywhere else or to clean them | ||
# up anywhere. | ||
cur-version-stamp: | ||
echo "$(PACKAGE_VERSION)" > "$(distdir)/version-stamp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters