Code

Moved generation of fb_features.h from configure to src/Makefile.
authorSebastian Harl <sh@tokkee.org>
Sun, 2 May 2010 20:48:39 +0000 (22:48 +0200)
committerSebastian Harl <sh@tokkee.org>
Sun, 2 May 2010 21:27:24 +0000 (23:27 +0200)
This ensures that we'll have up-to-date version information on each build. For
this purpose, version-gen.sh now creates a file ``version'' including the
current version.

.gitignore
configure.ac
src/Makefile.am
version-gen.sh

index 69fab010a69c0c8374063e8ab39a764d6073d917..2c5f4c4543f3cb49ac529df4678dc364180e6230 100644 (file)
@@ -11,6 +11,7 @@ depcomp
 install-sh
 missing
 stamp-h1
+version
 
 # ltdl stuff
 libtool
index 97e3ca081a2175d617258bd4178e4ac59e8bd574..e1c988f7603ce830c7f0a801b0bbee58ab48da69 100644 (file)
@@ -190,22 +190,9 @@ build_date="`date --utc '+%F %T'` (UTC)"
 AC_DEFINE_UNQUOTED([BUILD_DATE], ["$build_date"],
                [Define to the date the package has been built on.])
 
-dnl Version information provided by fb_features.h.
-FB_VERSION_MAJOR=`echo $PACKAGE_VERSION | cut -d'.' -f1`
-FB_VERSION_MINOR=`echo $PACKAGE_VERSION | cut -d'.' -f2`
-FB_VERSION_PATCH=`echo $PACKAGE_VERSION | cut -d'.' -f3`
-FB_VERSION_EXTRA=`echo $PACKAGE_VERSION | cut -d'.' -f4-`
-FB_VERSION_STRING="$FB_VERSION_MAJOR.$FB_VERSION_MINOR.$FB_VERSION_PATCH"
-
-AC_SUBST(FB_VERSION_MAJOR)
-AC_SUBST(FB_VERSION_MINOR)
-AC_SUBST(FB_VERSION_PATCH)
-AC_SUBST(FB_VERSION_EXTRA)
-AC_SUBST(FB_VERSION_STRING)
-
 AC_CHECK_HEADERS(libgen.h)
 
-AC_CONFIG_FILES([Makefile src/Makefile src/fb_features.h])
+AC_CONFIG_FILES([Makefile src/Makefile])
 AC_OUTPUT
 
 cat <<EOF;
index 1c22316b43280d1e00ffc8cd1c4b78095b2ee3af..5c8a5ceb0563f203be31192e81f3fa1ceaca5a70 100644 (file)
@@ -13,3 +13,18 @@ bin_PROGRAMS = fb
 fb_SOURCES = fb.c foobar.h
 fb_LDADD = libfoobar.la
 
+../version: FORCE
+       @# As a side-effect, this updates ../version.
+       @echo Building $(PACKAGE_NAME) version $$( cd .. && ./version-gen.sh )
+
+fb_features.h: fb_features.h.in ../version
+       source ../version; sed \
+           -e "s/@FB_VERSION_MAJOR@/$$VERSION_MAJOR/g" \
+           -e "s/@FB_VERSION_MINOR@/$$VERSION_MINOR/g" \
+           -e "s/@FB_VERSION_PATCH@/$$VERSION_PATCH/g" \
+           -e "s/@FB_VERSION_EXTRA@/$$VERSION_EXTRA/g" \
+           -e "s/@FB_VERSION_STRING@/$$VERSION_STRING/g" \
+           fb_features.h.in > fb_features.h
+
+.PHONY: FORCE
+
index ca8414d47b4afe0c7e707b729423f8b3b6f39418..57300717c1ca9597259683368b458f8e3be92d2d 100755 (executable)
@@ -17,3 +17,23 @@ fi
 VERSION="$( echo "$VERSION" | sed -e 's/-/./g' )"
 echo -n "$VERSION"
 
+OLD_VERSION=""
+if test -e version; then
+       OLD_VERSION=$( sed -ne 's/^VERSION="\(.*\)"/\1/p' version )
+fi
+
+if test "$OLD_VERSION" != "$VERSION"; then
+       VERSION_MAJOR=$( echo $VERSION | cut -d'.' -f1 )
+       VERSION_MINOR=$( echo $VERSION | cut -d'.' -f2 )
+       VERSION_PATCH=$( echo $VERSION | cut -d'.' -f3 )
+       VERSION_EXTRA="\"$( echo $VERSION | cut -d'.' -f4- )\""
+       (
+        echo "VERSION=\"$VERSION\""
+        echo "VERSION_MAJOR=$VERSION_MAJOR"
+        echo "VERSION_MINOR=$VERSION_MINOR"
+        echo "VERSION_PATCH=$VERSION_PATCH"
+        echo "VERSION_EXTRA=\"$VERSION_EXTRA\""
+        echo "VERSION_STRING=\"$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH\""
+       ) > version
+fi
+