aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitattributes1
-rw-r--r--.gitignore1
-rw-r--r--Makefile.am33
-rw-r--r--Makefile.unix12
-rw-r--r--celt/celt.c6
-rw-r--r--celt/celt.h4
-rw-r--r--configure.ac65
-rwxr-xr-xupdate_version65
8 files changed, 132 insertions, 55 deletions
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 00000000..69b2827d
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+update_version export-ignore
diff --git a/.gitignore b/.gitignore
index 673ac436..fddf6ddf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -51,6 +51,7 @@ celt/tests/test_unit_types
*.vcxproj.user
opus.sdf
opus.suo
+package_version
version.h
celt/Debug
celt/Release
diff --git a/Makefile.am b/Makefile.am
index cca953b5..e22abfa5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -150,4 +150,37 @@ uninstall-local:
( cd doc && $(MAKE) $(AM_MAKEFLAGS) uninstall )
+# We check this every time make is run, with configure.ac being touched to
+# trigger an update of the build system files if update_version changes the
+# current PACKAGE_VERSION (or if package_version was modified manually by a
+# user with either AUTO_UPDATE=no or no update_version script present - the
+# latter being the normal case for tarball releases).
+#
+# We can't just add the package_version file to CONFIGURE_DEPENDENCIES since
+# simply running autoconf will not actually regenerate configure for us when
+# the content of that file changes (due to autoconf dependency checking not
+# knowing about that without us creating yet another file for it to include).
+#
+# The MAKECMDGOALS check is a gnu-make'ism, but will degrade 'gracefully' for
+# makes that don't support it. The only loss of functionality is not forcing
+# an update of package_version for `make dist` if AUTO_UPDATE=no, but that is
+# unlikely to be a real problem for any real user.
+$(top_srcdir)/configure.ac: force
+ @case "$(MAKECMDGOALS)" in \
+ dist-hook) exit 0 ;; \
+ dist-* | dist | distcheck | distclean) _arg=release ;; \
+ esac; \
+ if ! $(top_srcdir)/update_version $$_arg 2> /dev/null; then \
+ . $(top_srcdir)/package_version || exit 1; \
+ [ "$(PACKAGE_VERSION)" != "$$PACKAGE_VERSION" ] || exit 0; \
+ fi; \
+ touch $@
+
+force:
+
+# Create a minimal package_version file when make dist is run.
+dist-hook:
+ echo 'PACKAGE_VERSION="$(PACKAGE_VERSION)"' > $(top_distdir)/package_version
+
+
.PHONY: opus check-opus install-opus docs install-docs
diff --git a/Makefile.unix b/Makefile.unix
index bd980c60..619dea7e 100644
--- a/Makefile.unix
+++ b/Makefile.unix
@@ -20,8 +20,8 @@ CFLAGS := -Drestrict= $(CFLAGS)
###################### END OF OPTIONS ######################
-include version.mk
-CFLAGS += -DOPUS_VERSION='$(OPUS_VERSION)'
+-include package_version
+
include silk_sources.mk
include celt_sources.mk
include opus_sources.mk
@@ -124,5 +124,13 @@ opus_demo$(EXESUFFIX): $(OPUSDEMO_OBJS) $(TARGET)
opus_compare$(EXESUFFIX): $(OPUSCOMPARE_OBJS)
$(LINK.o.cmdline)
+celt/celt.o: CFLAGS += -DPACKAGE_VERSION='$(PACKAGE_VERSION)'
+celt/celt.o: package_version
+
+package_version: force
+ @./update_version || true
+
+force:
+
clean:
rm -f opus_demo$(EXESUFFIX) opus_compare$(EXESUFFIX) $(TARGET) $(OBJS) $(OPUSDEMO_OBJS)
diff --git a/celt/celt.c b/celt/celt.c
index aaab9662..dfa5c68b 100644
--- a/celt/celt.c
+++ b/celt/celt.c
@@ -50,6 +50,10 @@
#include "celt_lpc.h"
#include "vq.h"
+#ifndef PACKAGE_VERSION
+#define PACKAGE_VERSION "unknown"
+#endif
+
int resampling_factor(opus_int32 rate)
{
@@ -193,7 +197,7 @@ const char *opus_strerror(int error)
const char *opus_get_version_string(void)
{
- return "libopus " OPUS_VERSION
+ return "libopus " PACKAGE_VERSION
#ifdef FIXED_POINT
"-fixed"
#endif
diff --git a/celt/celt.h b/celt/celt.h
index 614698f0..0404d918 100644
--- a/celt/celt.h
+++ b/celt/celt.h
@@ -131,10 +131,6 @@ int celt_decode_with_ec(OpusCustomDecoder * OPUS_RESTRICT st, const unsigned cha
#define celt_decoder_ctl opus_custom_decoder_ctl
-#ifndef OPUS_VERSION
-#define OPUS_VERSION "unknown"
-#endif
-
#ifdef CUSTOM_MODES
#define OPUS_CUSTOM_NOSTATIC
#else
diff --git a/configure.ac b/configure.ac
index 3f32d838..03c36c47 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,55 +1,23 @@
dnl Process this file with autoconf to produce a configure script. -*-m4-*-
-AC_INIT(src/opus_encoder.c)
+dnl The package_version file will be automatically synced to the git revision
+dnl by the update_version script when configured in the repository, but will
+dnl remain constant in tarball releases unless it is manually edited.
+m4_define([CURRENT_VERSION],
+ m4_esyscmd_s([ if test -e package_version || ./update_version; then
+ . ./package_version
+ printf "$PACKAGE_VERSION"
+ else
+ printf "unknown"
+ fi ]))
-AC_CONFIG_HEADERS([config.h])
+AC_INIT([opus],[CURRENT_VERSION],[opus@xiph.org])
+
+AC_CONFIG_SRCDIR(src/opus_encoder.c)
dnl enable silent rules on automake 1.11 and later
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
-# Read our default version string from version.mk.
-# Please update this file for releases.
-AC_MSG_CHECKING([version.mk])
-MK_VERSION=$(awk 'BEGIN { FS = "=" }
- /OPUS_VERSION/ { ver = $2}
- END {
- gsub(/"/, "", ver);
- gsub(/^ /, "", ver);
- gsub(/ $/, "", ver);
- print ver;
- }' $srcdir/version.mk)
-if test -z "$MK_VERSION"; then
- AC_MSG_RESULT([no])
-else
- AC_MSG_RESULT([$MK_VERSION])
- OPUS_VERSION="$MK_VERSION"
-fi
-
-# Override with the git version, if available.
-AC_MSG_CHECKING([git revision])
-GIT_VERSION=$(git describe --tags --match 'v*' 2>/dev/null | sed 's/^v//')
-if test -z "$GIT_VERSION"; then
- AC_MSG_RESULT([no])
-else
- AC_MSG_RESULT([$GIT_VERSION])
- OPUS_VERSION="$GIT_VERSION"
-fi
-
-# Use 'unknown' if all else fails.
-if test -z "$OPUS_VERSION"; then
- OPUS_VERSION="unknown"
-fi
-
-# For automake.
-PACKAGE=opus
-VERSION=$OPUS_VERSION
-
-# For autoconf
-AC_SUBST(OPUS_VERSION)
-
-# For config.h.
-AC_DEFINE_UNQUOTED([OPUS_VERSION], ["$OPUS_VERSION"],
- [Opus library version string])
# For libtool.
dnl Please update these for releases.
@@ -61,7 +29,7 @@ AC_SUBST(OPUS_LT_CURRENT)
AC_SUBST(OPUS_LT_REVISION)
AC_SUBST(OPUS_LT_AGE)
-AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
+AM_INIT_AUTOMAKE([no-define])
AM_MAINTAINER_MODE([enable])
AC_CANONICAL_HOST
@@ -294,13 +262,14 @@ AC_SUBST([PC_LIBM])
AC_CONFIG_FILES([Makefile opus.pc opus-uninstalled.pc
doc/Makefile doc/Doxyfile])
+AC_CONFIG_HEADERS([config.h])
AC_OUTPUT
AC_MSG_RESULT([
------------------------------------------------------------------------
- $PACKAGE $VERSION: Automatic configuration OK.
-
+ $PACKAGE_NAME $PACKAGE_VERSION: Automatic configuration OK.
+
Compiler support:
C99 var arrays: ................ ${has_var_arrays}
diff --git a/update_version b/update_version
new file mode 100755
index 00000000..a9999918
--- /dev/null
+++ b/update_version
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+# Creates and updates the package_version information used by configure.ac
+# (or other makefiles). When run inside a git repository it will use the
+# version information that can be queried from it unless AUTO_UPDATE is set
+# to 'no'. If no version is currently known it will be set to 'unknown'.
+#
+# If called with the argument 'release', the PACKAGE_VERSION will be updated
+# even if AUTO_UPDATE=no, but the value of AUTO_UPDATE shall be preserved.
+# This is used to force a version update whenever `make dist` is run.
+#
+# The exit status is 1 if package_version is not modified, else 0 is returned.
+#
+# This script should NOT be included in distributed tarballs, because if a
+# parent directory contains a git repository we do not want to accidentally
+# retrieve the version information from it instead. Tarballs should ship
+# with only the package_version file.
+#
+# Ron <ron@debian.org>, 2012.
+
+SRCDIR=$(dirname $0)
+
+if [ -e "$SRCDIR/package_version" ]; then
+ . "$SRCDIR/package_version"
+fi
+
+if [ "$AUTO_UPDATE" = no ]; then
+ [ "$1" = release ] || exit 1
+else
+ AUTO_UPDATE=yes
+fi
+
+# We run `git status` before describe here to ensure that we don't get a false
+# -dirty from files that have been touched but are not actually altered in the
+# working dir.
+GIT_VERSION=$(cd "$SRCDIR" && git status > /dev/null 2>&1 \
+ && git describe --tags --match 'v*' --dirty 2> /dev/null)
+GIT_VERSION=${GIT_VERSION#v}
+
+if [ -n "$GIT_VERSION" ]; then
+
+ [ "$GIT_VERSION" != "$PACKAGE_VERSION" ] || exit 1
+ PACKAGE_VERSION="$GIT_VERSION"
+
+elif [ -z "$PACKAGE_VERSION" ]; then
+ # No current package_version and no git ...
+ # We really shouldn't ever get here, because this script should only be
+ # included in the git repository, and should usually be export-ignored.
+ PACKAGE_VERSION="unknown"
+else
+ exit 1
+fi
+
+cat > "$SRCDIR/package_version" <<-EOF
+ # Automatically generated by update_version.
+ # This file may be sourced into a shell script or makefile.
+
+ # Set this to 'no' if you do not wish the version information
+ # to be checked and updated for every build. Most people will
+ # never want to change this, it is an option for developers
+ # making frequent changes that they know will not be released.
+ AUTO_UPDATE=$AUTO_UPDATE
+
+ PACKAGE_VERSION="$PACKAGE_VERSION"
+EOF