Commits

Sebastian Freundt  committed e4a507c Merge

Merge branch 'bld/dist' into next

* bld/dist:
chore, populate version.mk VERSION string in test suite also
chore, move auxiliary build stuff into build-aux
chore major, use rudi's tinav version number system
chore, add EXTRA_CFLAGS to AM_CFLAGS
chore, up sxe-compiler.m4 pkg to the latest revision

  • Participants
  • Parent commits fd80a07, 7b8fb75

Comments (0)

Files changed (13)

+# This GNUmakefile is used only if you run GNU Make.
+
+# If the user runs GNU make but has not yet run ./configure,
+# give them a diagnostic.
+_gl-Makefile := $(wildcard [M]akefile)
+ifneq ($(_gl-Makefile),)
+
+include Makefile
+
+# update the included makefile snippet which sets VERSION variables
+version.mk: FORCE
+	$(top_srcdir)/build-aux/git-version-gen $(top_srcdir) $@
+
+else
+
+.DEFAULT_GOAL := abort-due-to-no-makefile
+$(MAKECMDGOALS): abort-due-to-no-makefile
+
+abort-due-to-no-makefile:
+	@echo There seems to be no Makefile in this directory.   1>&2
+	@echo "You must run ./configure before running 'make'." 1>&2
+	exit 1
+
+endif
+
+.PHONY: FORCE
+include $(top_builddir)/version.mk
+
 LANG = C
 LC_ALL = C
 
 
 SUBDIRS = lib src info test contrib
 
-EXTRA_DIST = git-version-gen $(doc_DATA)
+EXTRA_DIST = build-aux/git-version-gen
+DISTCLEANFILES = version.mk
 
 doc_DATA = README.md
+EXTRA_DIST += $(doc_DATA)
 
 pkgconfigdir = @libdir@/pkgconfig
 pkgconfig_DATA =
 pkgconfig_DATA += libdut.pc
+
+dist-hook:
+	echo $(VERSION) > $(distdir)/version \
+	&& touch -r $(top_builddir)/version.mk $(distdir)/version

File build-aux/git-version-gen

+#!/bin/sh
+
+GVF="none"
+DEF_VER="v0.2.4.GIT"
+TOUCH_GVF="no"
+
+LF='
+'
+curdir="`pwd`" || exit 1
+
+# usage: git-version-gen [srcdir [builddir/version.mk]]
+srcdir="."
+if test "x${1}" != "x"
+then
+	srcdir="${1}"
+fi
+if test "x${2}" != "x"
+then
+	GVF="${2}"
+fi
+
+# First see if there is a version file (included in release tarballs),
+# then try git-describe, then default.
+cd "${srcdir}" || exit 1
+if test -f version
+then
+	VN="`cat version`" || VN="${DEF_VER}"
+	TOUCH_GVF="yes"
+elif test -d .git -o -f .git &&
+	VN="`git describe --match "v[0-9]*" --abbrev=5 HEAD 2>/dev/null`" &&
+	case "${VN}" in
+	*"${LF}"*) (exit 1) ;;
+	v[0-9]*)
+		git update-index -q --refresh
+		test -z "`git diff-index --name-only HEAD --`" ||
+		VN="${VN}-dirty" ;;
+	esac
+then
+	# convert "v0.4.0-32-gf350f" to "v0.4.0.git32.f350f"
+	VN="`echo "${VN}" | sed -e 's/-\([0-9]*\)-g/.git\1./g' -e 's/-/./g'`";
+else
+	VN="${DEF_VER}"
+fi
+cd "${curdir}" || exit 1
+
+VN="`expr "${VN}" : v*'\(.*\)'`"
+
+if test -r "${GVF}"
+then
+	VC="`sed -n -e 's/^VERSION = //p' <"${GVF}"`"
+	# don't safe version file's timestamp if we overwrite an exising GVF file
+	TOUCH_GVF="no"
+else
+	VC="unset"
+fi
+
+case "${GVF}" in
+none)
+	echo "${VN}"
+	;;
+*)
+	test "${VN}" = "${VC}" || {
+		echo "update ${GVF} to ${VN}" >&2
+		( echo "VERSION = ${VN}"
+		  echo 'PACKAGE_VERSION = $(VERSION)'
+		  echo 'PACKAGE_STRING = $(PACKAGE) $(VERSION)' ) >"${GVF}"
+		if test "${TOUCH_GVF}" = "yes"; then
+			touch -r "${srcdir}/version" "${GVF}"
+		fi
+	}
+	;;
+esac
+

File configure.ac

 dnl -------------------------------------------------------------------------
 
 AC_PREREQ([2.63])
-m4_define([GIT_VERSION_GEN], [dnl
-pushdef([version], [m4_esyscmd([./git-version-gen])])[]dnl
-ifelse([]version[], [], [0.2.4], []version[])[]dnl
-popdef([version])[]dnl
-])
-AC_INIT([dateutils], [GIT_VERSION_GEN], [https://github.com/hroptatyr/dateutils])
-AC_CONFIG_AUX_DIR([.])
+## t.i.n.a.v = this is not a version, never use it!
+AC_INIT([dateutils], [t.i.n.a.v], [https://github.com/hroptatyr/dateutils])
+AC_CONFIG_AUX_DIR([build-aux])
 AC_CONFIG_HEADER([src/config.h])
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_SRCDIR([src/])
 AM_INIT_AUTOMAKE([foreign dist-xz color-tests parallel-tests])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
+GIT_VERSION_MAGIC
+AC_CONFIG_LINKS([GNUmakefile:GNUmakefile])
+
 ## the build chain
 AC_PROG_CC([icc gcc tcc cc])
 SXE_CHECK_CC([gnu11 c11 gnu1x c1x gnu99 c99])
+AC_CHECK_TOOLS([AR], [xiar ar], [false])
 AC_C_BIGENDIAN
 SXE_CHECK_CFLAGS
 

File git-version-gen

-#!/bin/sh
-# Print a version string.
-
-# Copyright (C) 2007-2010 Free Software Foundation, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# This script is derived from GIT-VERSION-GEN from GIT: http://git.or.cz/.
-# It may be run two ways:
-# - from a git repository in which the "git describe" command below
-#   produces useful output (thus requiring at least one signed tag)
-# - from a non-git-repo directory containing a .tarball-version file, which
-#   presumes this script is invoked like "./git-version-gen .tarball-version".
-
-# In order to use intra-version strings in your project, you will need two
-# separate generated version string files:
-#
-# .tarball-version - present only in a distribution tarball, and not in
-#   a checked-out repository.  Created with contents that were learned at
-#   the last time autoconf was run, and used by git-version-gen.  Must not
-#   be present in either $(srcdir) or $(builddir) for git-version-gen to
-#   give accurate answers during normal development with a checked out tree,
-#   but must be present in a tarball when there is no version control system.
-#   Therefore, it cannot be used in any dependencies.  GNUmakefile has
-#   hooks to force a reconfigure at distribution time to get the value
-#   correct, without penalizing normal development with extra reconfigures.
-#
-# .version - present in a checked-out repository and in a distribution
-#   tarball.  Usable in dependencies, particularly for files that don't
-#   want to depend on config.h but do want to track version changes.
-#   Delete this file prior to any autoconf run where you want to rebuild
-#   files to pick up a version string change; and leave it stale to
-#   minimize rebuild time after unrelated changes to configure sources.
-#
-# It is probably wise to add these two files to .gitignore, so that you
-# don't accidentally commit either generated file.
-#
-# Use the following line in your configure.ac, so that $(VERSION) will
-# automatically be up-to-date each time configure is run (and note that
-# since configure.ac no longer includes a version string, Makefile rules
-# should not depend on configure.ac for version updates).
-#
-# AC_INIT([GNU project],
-#         m4_esyscmd([build-aux/git-version-gen .tarball-version]),
-#         [bug-project@example])
-#
-# Then use the following lines in your Makefile.am, so that .version
-# will be present for dependencies, and so that .tarball-version will
-# exist in distribution tarballs.
-#
-# BUILT_SOURCES = $(top_srcdir)/.version
-# $(top_srcdir)/.version:
-#	echo $(VERSION) > $@-t && mv $@-t $@
-# dist-hook:
-#	echo $(VERSION) > $(distdir)/.tarball-version
-
-## keep track of the basedir and our own name
-BASEDIR=`dirname "${0}"`
-BASESCR=`basename "${0}"`
-
-if test "${#}" -gt 2; then
-	echo "Usage: ${BASESCR} VERSION-FILE [TAG-NORMALIZATION-SED-SCRIPT]" >&2
-	exit 1
-fi
-
-tarball_version_file="${1}"
-tag_sed_script="${2:-s/x/x/}"
-
-## quick replacement of echo -n
-echo_n()
-{
-	echo "${@}" | tr -d '\r\n'
-}
-
-## or resort to echo -n if that works
-if test -z `echo -n`; then
-	echo_n()
-	{
-		echo -n "${@}"
-	}
-fi
-
-## Avoid meddling by environment variable of the same name.
-v=
-
-## First see if there is a tarball-only version file.
-## then try "git describe", then default.
-if test -f "${tarball_version_file}"; then
-	v=`head -n 1 -- "${tarball_version_file}"` || exit 1
-	case "${v}" in
-	[0-9a-f]*)
-		;;
-	*)
-		## reset v
-		v=
-		;;
-	esac
-	if test -z "${v}"; then
-		echo "${BASESCR}: WARNING: " \
-			"${tarball_version_file} seems to be damaged" >&2
-	fi
-fi
-
-if test -d "${BASEDIR}/.git"; then
-	## save the ${v} we've got so far
-	old_v="${v}"
-else
-	## otherwise, just go on with the thing we've got so far
-	echo_n "${v}"
-	exit 0
-fi
-
-describe()
-{
-	REV="${1}"
-	git describe --abbrev=8 --match='v[0-9]*' "${REV}" 2>/dev/null || \
-		git describe --abbrev=8 "${REV}" 2>/dev/null
-}
-
-v=`describe HEAD | sed "${tag_sed_script}"`
-if test -n "${v}" && case "${v}" in
-	v[0-9]*)
-		;;
-	*)
-		(exit 1)
-		;;
-	esac; then
-	## Is this a new git that lists number of commits since the last
-	## tag or the previous older version that did not?
-	##   Newer: v6.10-77-g0f8faeb
-	##   Older: v6.10-g0f8faeb
-	case "${v}" in
-	*-*-*)
-		: git describe is okay three part flavor
-		;;
-	*-*)
-		: git describe is older two part flavor
-		## Recreate the number of commits and rewrite such that the
-		## result is the same as if we were using the newer version
-		## of git describe.
-		vtag=`echo "${v}" | sed 's/-.*//'`
-		numcommits=`git rev-list "${vtag}"..HEAD | wc -l`
-		v=`echo "${v}" | sed "s/\(.*\)-\(.*\)/\1-${numcommits}-\2/"`
-		;;
-	esac
-else
-	v=`git show-ref --head --hash=8 HEAD 2>/dev/null | head -n 1`
-fi
-
-v=`echo "${v}" | sed 's/^v//'`
-
-# Don't declare a version "dirty" merely because a time stamp has changed.
-git update-index --refresh > /dev/null 2>&1
-
-dirty=`git diff-index --name-only HEAD -- 2>/dev/null` || dirty=
-if test -n "${dirty}"; then
-	case "${v}" in
-	*-dirty)
-		;;
-	*)
-		v="${v}-dirty"
-		;;
-	esac
-fi
-
-# Omit the trailing newline, so that m4_esyscmd can use the result directly.
-new_v=`echo_n "${v}"`
-if test "${new_v}" = "${old_v}"; then
-	## print the old version
-	echo_n "${old_v}"
-elif test -z "${tarball_version_file}"; then
-	echo_n "${new_v}"
-else
-	echo "${new_v}" | tee -- "${tarball_version_file}" | tr -d '\r\n'
-fi
-
-## git-version-gen ends here

File lib/Makefile.am

 ### Makefile.am
+include $(top_builddir)/version.mk
 
+AM_CFLAGS = $(EXTRA_CFLAGS)
 AM_CPPFLAGS = -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
 AM_LDFLAGS =
 
 libdut_a_CPPFLAGS += -DDECLF=extern
 libdut_a_CPPFLAGS += -I$(builddir)
 libdut_a_SOURCES =
+libdut_a_SOURCES += version.c version.h version.c.in
 libdut_a_SOURCES += date-core.h
 libdut_a_SOURCES += time-core.h
 libdut_a_SOURCES += dt-core.h dt-core.c
 EXTRA_libdut_a_SOURCES += daisy.c
 EXTRA_libdut_a_SOURCES += fmt-special.gperf fmt-special.c
 EXTRA_libdut_a_SOURCES += leapseconds
+BUILT_SOURCES += version.c
 BUILT_SOURCES += fmt-special.c
 BUILT_SOURCES += leapseconds.def
 
 	$(MAKE) $(AM_MAKEFLAGS) ltrcc$(EXEEXT)
 	$(AM_V_LTRCC)$(builddir)/ltrcc$(EXEEXT) -C $< > $@ || rm -f $@
 
+version.c: version.c.in $(top_builddir)/version.mk
+	sed -e 's,[@]VERSION[@],$(VERSION),g' <$(srcdir)/$@.in >$@
+
 ## gperf rule
 %.c: %.gperf
 	$(AM_V_GEN) $(GPERF) -L ANSI-C $< --output-file $@
 #include "dt-core.h"
 #include "nifty.h"
 
+#include "version.c"
+
 
 #define PROLOGUE	(-1UL)
 #define EPILOGUE	(0UL)
 static void
 pr_version(FILE *where)
 {
-	fputs("ltrcc " PACKAGE_VERSION "\n", where);
+	fputs("ltrcc " VERSION "\n", where);
 	return;
 }
 

File lib/version.c.in

+#include "version.h"
+
+#define VERSION "@VERSION@"
+
+const char dateutils_version_string[] = VERSION;

File lib/version.h

+#ifndef VERSION_H
+#define VERSION_H
+
+extern const char dateutils_version_string[];
+
+#endif /* VERSION_H */

File m4/git_version_magic.m4

+
+AC_DEFUN([GIT_VERSION_MAGIC], [dnl
+## initially generate version.mk here because only GNU make can do this
+## at make time
+AC_MSG_CHECKING([git-version-gen])
+if  "${srcdir}/build-aux/git-version-gen" "${srcdir}" version.mk 2>/dev/null \
+    && git_version="`head -n 1 version.mk`" ;then
+  AC_MSG_RESULT([${git_version}])
+else
+  AC_MSG_FAILURE([failed])
+fi
+
+dnl remove version info from config header
+AH_BOTTOM([
+#/**/undef/**/ VERSION
+#/**/undef/**/ PACKAGE_VERSION
+#/**/undef/**/ PACKAGE_STRING
+])
+])

File m4/sxe-compiler.m4

 dnl
 dnl This file is part of SXEmacs.
 
+##### http://autoconf-archive.cryp.to/ax_check_compiler_flags.html
+## renamed the prefix to SXE_
+AC_DEFUN([SXE_CHECK_COMPILER_FLAG], [dnl
+dnl SXE_CHECK_COMPILER_FLAG([flag], [action-if-accepted], [action-if-not-accepted])
+	AC_MSG_CHECKING([whether _AC_LANG compiler accepts $1])
+
+	## store werror status, then turn -Werror on
+	save_ac_[]_AC_LANG_ABBREV[]_werror_flag="${ac_[]_AC_LANG_ABBREV[]_werror_flag}"
+	AC_LANG_WERROR
+
+	AC_CACHE_VAL(AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_flag_$1), [dnl
+		sxe_save_FLAGS="${[]_AC_LANG_PREFIX[]FLAGS}"
+		_AC_LANG_PREFIX[]FLAGS="$1"
+		AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
+			eval AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_flag_$1)="yes",
+			eval AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_flag_$1)="no")
+		_AC_LANG_PREFIX[]FLAGS="${sxe_save_FLAGS}"
+	])
+	eval sxe_check_flag=$AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_flag_$1)
+	ac_[]_AC_LANG_ABBREV[]_werror_flag="${save_ac_[]_AC_LANG_ABBREV[]_werror_flag}"
+
+	AC_MSG_RESULT([${sxe_check_flag}])
+	if test "${sxe_check_flag}" = "yes"; then
+		:
+		$2
+	else
+		:
+		$3
+	fi
+])dnl SXE_CHECK_COMPILER_FLAG
+
+AC_DEFUN([SXE_CHECK_PREPROC_FLAG], [dnl
+dnl SXE_CHECK_CPP_FLAG([flag], [action-if-found], [action-if-not-found])
+	AC_MSG_CHECKING([whether _AC_LANG preprocessor accepts $1])
+
+	## store werror status, then turn -Werror on
+	save_ac_[]_AC_LANG_ABBREV[]_werror_flag="${ac_[]_AC_LANG_ABBREV[]_werror_flag}"
+	AC_LANG_WERROR
+
+	AC_CACHE_VAL(AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]pp_flag_$1), [dnl
+		sxe_save_FLAGS="${[]_AC_LANG_PREFIX[]PPFLAGS}"
+		_AC_LANG_PREFIX[]PPFLAGS="$1"
+		AC_PREPROC_IFELSE([AC_LANG_PROGRAM()],
+			eval AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]pp_flag_$1)="yes",
+			eval AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]pp_flag_$1)="no")
+		_AC_LANG_PREFIX[]PPFLAGS=$sxe_save_FLAGS
+	])
+	eval sxe_check_flag=$AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]pp_flag_$1)
+	ac_[]_AC_LANG_ABBREV[]_werror_flag="${save_ac_[]_AC_LANG_ABBREV[]_werror_flag}"
+
+	AC_MSG_RESULT([${sxe_check_flag}])
+	if test "${sxe_check_flag}" = "yes"; then
+		:
+		$2
+	else
+		:
+		$3
+	fi
+])dnl SXE_CHECK_PREPROC_FLAG
+
+
 AC_DEFUN([SXE_DEBUGFLAGS], [dnl
 	## distinguish between different compilers, no?
-	SXE_CHECK_COMPILER_FLAGS([-g])
-	SXE_CHECK_COMPILER_FLAGS([-g3])
+	SXE_CHECK_COMPILER_FLAG([-g])
+	SXE_CHECK_COMPILER_FLAG([-g3])
 
 	AC_PATH_PROG([DBX], [dbx])
 	if test -n "$ac_cv_path_DBX"; then
-		SXE_CHECK_COMPILER_FLAGS([-gstabs])
-		SXE_CHECK_COMPILER_FLAGS([-gstabs3])
-		SXE_CHECK_COMPILER_FLAGS([-gxcoff])
-		SXE_CHECK_COMPILER_FLAGS([-gxcoff3])
+		SXE_CHECK_COMPILER_FLAG([-gstabs])
+		SXE_CHECK_COMPILER_FLAG([-gstabs3])
+		SXE_CHECK_COMPILER_FLAG([-gxcoff])
+		SXE_CHECK_COMPILER_FLAG([-gxcoff3])
 	fi
 
 	AC_PATH_PROG([GDB], [gdb])
 	if test -n "$ac_cv_path_GDB"; then
-		SXE_CHECK_COMPILER_FLAGS([-ggdb])
-		SXE_CHECK_COMPILER_FLAGS([-ggdb3])
+		SXE_CHECK_COMPILER_FLAG([-ggdb])
+		SXE_CHECK_COMPILER_FLAG([-ggdb3])
 	fi
 
 	AC_PATH_PROG([SDB], [sdb])
 	if test -n "$ac_cv_path_SDB"; then
-		SXE_CHECK_COMPILER_FLAGS([-gcoff])
-		SXE_CHECK_COMPILER_FLAGS([-gcoff3])
+		SXE_CHECK_COMPILER_FLAG([-gcoff])
+		SXE_CHECK_COMPILER_FLAG([-gcoff3])
 	fi
 
 	## final evaluation
 	debugflags=""
 	## gdb
-	if test "$sxe_cv_c_flags__ggdb3" = "yes"; then
+	if test "$sxe_cv_c_flag__ggdb3" = "yes"; then
 		debugflags="$debugflags -ggdb3"
-	elif test "$sxe_cv_c_flags__ggdb" = "yes"; then
+	elif test "$sxe_cv_c_flag__ggdb" = "yes"; then
 		debugflags="$debugflags -ggdb"
 	fi
 	## stabs
-	if test "$sxe_cv_c_flags__gstabs3" = "yes"; then
+	if test "$sxe_cv_c_flag__gstabs3" = "yes"; then
 		debugflags="$debugflags -gstabs3"
-	elif test "$sxe_cv_c_flags__gstabs" = "yes"; then
+	elif test "$sxe_cv_c_flag__gstabs" = "yes"; then
 		debugflags="$debugflags -gstabs"
 	fi
 	## coff
-	if test "$sxe_cv_c_flags__gcoff3" = "yes"; then
+	if test "$sxe_cv_c_flag__gcoff3" = "yes"; then
 		debugflags="$debugflags -gcoff3"
-	elif test "$sxe_cv_c_flags__gcoff" = "yes"; then
+	elif test "$sxe_cv_c_flag__gcoff" = "yes"; then
 		debugflags="$debugflags -gcoff"
 	fi
 	## xcoff
-	if test "$sxe_cv_c_flags__gxcoff3" = "yes"; then
+	if test "$sxe_cv_c_flag__gxcoff3" = "yes"; then
 		debugflags="$debugflags -gxcoff3"
-	elif test "$sxe_cv_c_flags__gxcoff" = "yes"; then
+	elif test "$sxe_cv_c_flag__gxcoff" = "yes"; then
 		debugflags="$debugflags -gxcoff"
 	fi
 
 	if test -z "debugflags" -a \
-		"$sxe_cv_c_flags__g" = "yes"; then
+		"$sxe_cv_c_flag__g" = "yes"; then
 		debugflags="$debugflags -g"
 	fi
 
-	SXE_CHECK_COMPILER_FLAGS([-ftime-report])
-	SXE_CHECK_COMPILER_FLAGS([-fmem-report])
-	SXE_CHECK_COMPILER_FLAGS([-fvar-tracking])
-	SXE_CHECK_COMPILER_FLAGS([-save-temps])
+	SXE_CHECK_COMPILER_FLAG([-ftime-report])
+	SXE_CHECK_COMPILER_FLAG([-fmem-report])
+	SXE_CHECK_COMPILER_FLAG([-fvar-tracking])
+	SXE_CHECK_COMPILER_FLAG([-save-temps])
 
-	#if test "$sxe_cv_c_flags__ggdb3" = "yes" -a \
-	#	"$sxe_cv_c_flags__fvar_tracking" = "yes"; then
+	#if test "$sxe_cv_c_flag__ggdb3" = "yes" -a \
+	#	"$sxe_cv_c_flag__fvar_tracking" = "yes"; then
 	#	debugflags="$debugflags -fvar-tracking"
 	#fi
 
 	## by everyone who doesn't specifically override them.
 
 	## by default we want the -Wall level
-	SXE_CHECK_COMPILER_FLAGS([-Wall], [warnflags="-Wall"])
+	SXE_CHECK_COMPILER_FLAG([-Wall], [warnflags="-Wall"])
 
-	SXE_CHECK_COMPILER_FLAGS([-qinfo], [
+	SXE_CHECK_COMPILER_FLAG([-qinfo], [
 		warnflags="${warnflags} -qinfo"])
 
-	SXE_CHECK_COMPILER_FLAGS([-Wextra], [
+	SXE_CHECK_COMPILER_FLAG([-Wextra], [
 		warnflags="${warnflags} -Wextra"])
 
 	## Yuck, bad compares have been worth at
 	## Warnings about char subscripts are pretty
 	## pointless, though,
 	## and we use them in various places.
-	SXE_CHECK_COMPILER_FLAGS([-Wsign-compare], [
+	SXE_CHECK_COMPILER_FLAG([-Wsign-compare], [
 		warnflags="$warnflags -Wsign-compare"])
-	SXE_CHECK_COMPILER_FLAGS([-Wno-char-subscripts], [
+	SXE_CHECK_COMPILER_FLAG([-Wno-char-subscripts], [
 		warnflags="$warnflags -Wno-char-subscripts"])
-	SXE_CHECK_COMPILER_FLAGS([-Wundef], [
+	SXE_CHECK_COMPILER_FLAG([-Wundef], [
 		warnflags="$warnflags -Wundef"])
 
 	## too much at the moment, we rarely define protos
 	#warnflags="$warnflags -Wmissing-prototypes -Wstrict-prototypes"
-	SXE_CHECK_COMPILER_FLAGS([-Wpacked], [
+	SXE_CHECK_COMPILER_FLAG([-Wpacked], [
 		warnflags="$warnflags -Wpacked"])
 
 	## glibc is intentionally not `-Wpointer-arith'-clean.
 	## Ulrich Drepper has rejected patches to fix
 	## the glibc header files.
 	## we dont care
-	SXE_CHECK_COMPILER_FLAGS([-Wpointer-arith], [
+	SXE_CHECK_COMPILER_FLAG([-Wpointer-arith], [
 		warnflags="$warnflags -Wpointer-arith"])
 
-	SXE_CHECK_COMPILER_FLAGS([-Wshadow], [
+	SXE_CHECK_COMPILER_FLAG([-Wshadow], [
 		warnflags="$warnflags -Wshadow"])
 
 	## our code lacks declarations almost all the time
-	SXE_CHECK_COMPILER_FLAGS([-Wmissing-declarations], [
+	SXE_CHECK_COMPILER_FLAG([-Wmissing-declarations], [
 		warnflags="$warnflags -Wmissing-declarations"])
-	SXE_CHECK_COMPILER_FLAGS([-Wmissing-prototypes], [
+	SXE_CHECK_COMPILER_FLAG([-Wmissing-prototypes], [
 		warnflags="$warnflags -Wmissing-prototypes"])
 
 	## gcc can't practically inline anything, so exclude this
 		;;
 	dnl (
 	*)
-		SXE_CHECK_COMPILER_FLAGS([-Winline], [
+		SXE_CHECK_COMPILER_FLAG([-Winline], [
 			warnflags="$warnflags -Winline"])
 		;;
 	esac
 
-	SXE_CHECK_COMPILER_FLAGS([-Wbad-function-cast], [
+	SXE_CHECK_COMPILER_FLAG([-Wbad-function-cast], [
 		warnflags="$warnflags -Wbad-function-cast"])
-	SXE_CHECK_COMPILER_FLAGS([-Wcast-qual], [
+	SXE_CHECK_COMPILER_FLAG([-Wcast-qual], [
 		warnflags="$warnflags -Wcast-qual"])
-	SXE_CHECK_COMPILER_FLAGS([-Wcast-align], [
+	SXE_CHECK_COMPILER_FLAG([-Wcast-align], [
 		warnflags="$warnflags -Wcast-align"])
 
 	## warn about incomplete switches
 	## for gcc, see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50422
 	## we used to have -Wswitch-default and -Wswitch-enum but that
 	## set gcc off quite badly in the nested switch case
-	SXE_CHECK_COMPILER_FLAGS([-Wswitch], [
+	SXE_CHECK_COMPILER_FLAG([-Wswitch], [
 		warnflags="$warnflags -Wswitch"])
 
-	SXE_CHECK_COMPILER_FLAGS([-Wunused-function], [
+	SXE_CHECK_COMPILER_FLAG([-Wunused-function], [
 		warnflags="$warnflags -Wunused-function"])
-	SXE_CHECK_COMPILER_FLAGS([-Wunused-variable], [
+	SXE_CHECK_COMPILER_FLAG([-Wunused-variable], [
 		warnflags="$warnflags -Wunused-variable"])
-	SXE_CHECK_COMPILER_FLAGS([-Wunused-parameter], [
+	SXE_CHECK_COMPILER_FLAG([-Wunused-parameter], [
 		warnflags="$warnflags -Wunused-parameter"])
-	SXE_CHECK_COMPILER_FLAGS([-Wunused-value], [
+	SXE_CHECK_COMPILER_FLAG([-Wunused-value], [
 		warnflags="$warnflags -Wunused-value"])
-	SXE_CHECK_COMPILER_FLAGS([-Wunused], [
+	SXE_CHECK_COMPILER_FLAG([-Wunused], [
 		warnflags="$warnflags -Wunused"])
-	SXE_CHECK_COMPILER_FLAGS([-Wmaybe-uninitialized], [
+	SXE_CHECK_COMPILER_FLAG([-Wmaybe-uninitialized], [
 		warnflags="${warnflags} -Wmaybe-uninitialized"])
 
-	SXE_CHECK_COMPILER_FLAGS([-Wnopragma], [
+	SXE_CHECK_COMPILER_FLAG([-Wnopragma], [
 		warnflags="$warnflags -Wnopragma"])
 
-	SXE_CHECK_COMPILER_FLAGS([-fdiagnostics-show-option], [
+	SXE_CHECK_COMPILER_FLAG([-fdiagnostics-show-option], [
 		warnflags="${warnflags} -fdiagnostics-show-option"])
 
-	SXE_CHECK_COMPILER_FLAGS([-Wunknown-pragmas], [
+	SXE_CHECK_COMPILER_FLAG([-Wunknown-pragmas], [
 		warnflags="$warnflags -Wunknown-pragmas"])
-	SXE_CHECK_COMPILER_FLAGS([-Wuninitialized], [
+	SXE_CHECK_COMPILER_FLAG([-Wuninitialized], [
 		warnflags="$warnflags -Wuninitialized"])
-	SXE_CHECK_COMPILER_FLAGS([-Wreorder], [
+	SXE_CHECK_COMPILER_FLAG([-Wreorder], [
 		warnflags="$warnflags -Wreorder"])
-	SXE_CHECK_COMPILER_FLAGS([-Wdeprecated], [
+	SXE_CHECK_COMPILER_FLAG([-Wdeprecated], [
 		warnflags="$warnflags -Wdeprecated"])
 
-	SXE_CHECK_COMPILER_FLAGS([-Wparentheses], [
+	SXE_CHECK_COMPILER_FLAG([-Wparentheses], [
 		warnflags="${warnflags} -Wparentheses"])
 
 	## icc specific
-	SXE_CHECK_COMPILER_FLAGS([-Wcheck], [
+	SXE_CHECK_COMPILER_FLAG([-Wcheck], [
 		warnflags="$warnflags -Wcheck"])
 
-	dnl SXE_CHECK_COMPILER_FLAGS([-Wp64], [
+	dnl SXE_CHECK_COMPILER_FLAG([-Wp64], [
 	dnl 	warnflags="$warnflags -Wp64"])
 
-	SXE_CHECK_COMPILER_FLAGS([-Wstrict-aliasing], [
+	SXE_CHECK_COMPILER_FLAG([-Wstrict-aliasing], [
 		warnflags="$warnflags -Wstrict-aliasing"])
 
-	SXE_CHECK_COMPILER_FLAGS([-w3], [
+	SXE_CHECK_COMPILER_FLAG([-w3], [
 		warnflags="$warnflags -w3"])
 
-	SXE_CHECK_COMPILER_FLAGS([-diag-disable 10237], [dnl
+	SXE_CHECK_COMPILER_FLAG([-diag-disable 10237], [dnl
 		warnflags="${warnflags} -diag-disable 10237"], [
-		SXE_CHECK_COMPILER_FLAGS([-wd 10237], [dnl
+		SXE_CHECK_COMPILER_FLAG([-wd 10237], [dnl
 			warnflags="${warnflags} -wd 10237"])])
 
-	dnl SXE_CHECK_COMPILER_FLAGS([-diag-disable 2259], [dnl
-	dnl 	warnflags="${warnflags} -diag-disable 2259"], [
-	dnl 	SXE_CHECK_COMPILER_FLAGS([-wd 2259], [dnl
-	dnl 		warnflags="${warnflags} -wd 2259"])])
+	SXE_CHECK_COMPILER_FLAG([-debug inline-debug-info], [
+		warnflags="${warnflags} -debug inline-debug-info"])
 
+	SXE_CHECK_COMPILER_FLAG([-diag-enable remark,vec,par], [
+		warnflags="${warnflags} -diag-enable remark,vec,par"])
 
 	AC_MSG_CHECKING([for preferred warning flags])
 	AC_MSG_RESULT([${warnflags}])
 
 AC_DEFUN([SXE_OPTIFLAGS], [dnl
 	optiflags="-O3"
+
+	SXE_CHECK_COMPILER_FLAG([-ipo256], [
+		special_optiflags="${special_optiflags} -ipo256"])
+
+	SXE_CHECK_COMPILER_FLAG([-ipo-jobs256], [
+		special_optiflags="${special_optiflags} -ipo-jobs256"])
 ])dnl SXE_OPTIFLAGS
 
 AC_DEFUN([SXE_FEATFLAGS], [dnl
 	## however I've got one report about a working PIE build
 	## we'll just check for -nopie here, if it works, we turn it on
 	## (and hence PIE off) and hope bug 16 remains fixed
-	SXE_CHECK_COMPILER_FLAGS([-nopie],
+	SXE_CHECK_COMPILER_FLAG([-nopie],
 		[featflags="$featflags -nopie"])
 
 	## it's utterly helpful to get the sse2 unit up
-	SXE_CHECK_COMPILER_FLAGS([-msse2], [dnl
+	SXE_CHECK_COMPILER_FLAG([-msse2], [dnl
 		## sse2 is the cure
 		featflags="$featflags -msse2"], [dnl
 		## oh bugger
 	## check if some stuff can be staticalised
 	## actually requires SXE_WARNFLAGS so warnings would be disabled
 	## that affect the outcome of the following tests
-	SXE_CHECK_COMPILER_FLAGS([-static-intel], [
+	SXE_CHECK_COMPILER_FLAG([-static-intel], [
 		featflags="${featflags} -static-intel"
 		XCCLDFLAGS="${XCCLDFLAGS} \${XCCFLAG} -static-intel"], [:],
 		[${SXE_CFLAGS}])
-	SXE_CHECK_COMPILER_FLAGS([-static-libgcc], [
+	SXE_CHECK_COMPILER_FLAG([-static-libgcc], [
 		featflags="${featflags} -static-libgcc"
 		XCCLDFLAGS="${XCCLDFLAGS} \${XCCFLAG} -static-libgcc"], [:],
 		[${SXE_CFLAGS}])
 	AC_SUBST([XCCFLAG])
 ])dnl SXE_FEATFLAGS
 
-
-##### http://autoconf-archive.cryp.to/ax_check_compiler_flags.html
-## renamed the prefix to SXE_
-AC_DEFUN([SXE_CHECK_COMPILER_FLAGS], [dnl
-dnl SXE_CHECK_COMPILER_FLAGS([flag], [do-if-works], [do-if-not-works])
-	AC_MSG_CHECKING([whether _AC_LANG compiler accepts $1])
-
-	dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
-	AC_LANG_WERROR([on])
-	AS_LITERAL_IF([$1], [
-		AC_CACHE_VAL(AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_flags_$1), [
-			sxe_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
-			_AC_LANG_PREFIX[]FLAGS="$1"
-			AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
-				AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_flags_$1)="yes",
-				AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_flags_$1)="no")
-			_AC_LANG_PREFIX[]FLAGS=$sxe_save_FLAGS])], [
-		sxe_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
-		_AC_LANG_PREFIX[]FLAGS="$1"
-		AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
-			eval AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_flags_$1)="yes",
-			eval AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_flags_$1)="no")
-		_AC_LANG_PREFIX[]FLAGS=$sxe_save_FLAGS])
-	eval sxe_check_compiler_flags=$AS_TR_SH(sxe_cv_[]_AC_LANG_ABBREV[]_flags_$1)
-	AC_LANG_WERROR([off])
-
-	AC_MSG_RESULT([$sxe_check_compiler_flags])
-	if test "$sxe_check_compiler_flags" = "yes"; then
-		m4_default([$2], :)
-	else
-		m4_default([$3], :)
-	fi
-])dnl SXE_CHECK_COMPILER_FLAGS
-
 AC_DEFUN([SXE_CHECK_COMPILER_XFLAG], [dnl
 	if test "${XFLAG}" = ""; then
-		SXE_CHECK_COMPILER_FLAGS([-XCClinker -foo], [XFLAG="-XCClinker"])
+		SXE_CHECK_COMPILER_FLAG([-XCClinker -foo], [XFLAG="-XCClinker"])
 	fi
 	if test "${XFLAG}" = ""; then
-		SXE_CHECK_COMPILER_FLAGS([-Xlinker -foo], [XFLAG="-Xlinker"])
+		SXE_CHECK_COMPILER_FLAG([-Xlinker -foo], [XFLAG="-Xlinker"])
 	fi
 
 	AC_SUBST([XFLAG])
 	SXE_FEATFLAGS
 	SXE_CFLAGS="$SXE_CFLAGS $featflags"
 
-	## unset the werror flag again
-	AC_LANG_WERROR([off])
+	save_ac_c_werror_flag="${ac_c_werror_flag}"
 
 	CFLAGS="${SXE_CFLAGS} ${ac_cv_env_CFLAGS_value}"
 	AC_MSG_CHECKING([for preferred CFLAGS])
 	AC_MSG_RESULT([${CFLAGS}])
 
+	EXTRA_CFLAGS="${special_optiflags}"
+	AC_SUBST([EXTRA_CFLAGS])
+	AC_MSG_CHECKING([for EXTRA_CFLAGS])
+	AC_MSG_RESULT([${EXTRA_CFLAGS}])
+
 	AC_MSG_NOTICE([
 If you wish to ADD your own flags you want to stop here and rerun the
 configure script like so:
   make CFLAGS=<your-own-flags> [target]
 respectively
 		])
+
+	ac_c_werror_flag="${save_ac_c_werror_flag}"
 ])dnl SXE_CHECK_CFLAGS
 
 AC_DEFUN([SXE_CHECK_CC], [dnl
 		dnl (
 	*)
 		for i in []stds[]; do
-			SXE_CHECK_COMPILER_FLAGS([-std="${i}"], [
+			SXE_CHECK_COMPILER_FLAG([-std="${i}"], [
 				std="-std=${i}"
 				save_CC="${CC}"
 				CC="${CC} ${std}"
 	save_CFLAGS="${CFLAGS}"
 	CFLAGS="-Werror"
 
-	SXE_CHECK_COMPILER_FLAGS([-Wmissing-field-initializers], [
+	SXE_CHECK_COMPILER_FLAG([-Wmissing-field-initializers], [
 		CFLAGS="${CFLAGS} -Wmissing-field-initializers"])
 
 	AC_MSG_CHECKING([dnl
 	AC_LANG_POP()
 ])dnl SXE_CHECK_SLOPPY_STRUCTS_INIT
 
-
 dnl sxe-compiler.m4 ends here

File src/Makefile.am

 ### Makefile.am
+include $(top_builddir)/version.mk
 
+AM_CFLAGS = $(EXTRA_CFLAGS)
 AM_CPPFLAGS = -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
 AM_LDFLAGS =
 
 dseq_SOURCES = dseq.c dseq-clo.ggo
 dseq_CPPFLAGS = $(AM_CPPFLAGS) $(DT_INCLUDES)
 dseq_LDFLAGS = $(AM_LDFLAGS)
+dseq_LDADD = $(top_builddir)/lib/libdut.a
 BUILT_SOURCES += dseq-clo.c dseq-clo.h
 
 if HAVE_STRPTIME
 strptime_SOURCES += prchunk.c prchunk.h
 strptime_CPPFLAGS = $(AM_CPPFLAGS) $(DT_INCLUDES)
 strptime_LDFLAGS = $(AM_LDFLAGS)
+strptime_LDADD = $(top_builddir)/lib/libdut.a
 endif
 BUILT_SOURCES += strptime-clo.c strptime-clo.h
 
 dconv_SOURCES += prchunk.c prchunk.h
 dconv_CPPFLAGS = $(AM_CPPFLAGS) $(DT_INCLUDES)
 dconv_LDFLAGS = $(AM_LDFLAGS)
+dconv_LDADD = $(top_builddir)/lib/libdut.a
 BUILT_SOURCES += dconv-clo.c dconv-clo.h
 
 bin_PROGRAMS += dtest
 dtest_SOURCES = dtest.c dtest-clo.ggo
 dtest_CPPFLAGS = $(AM_CPPFLAGS) $(DT_INCLUDES)
 dtest_LDFLAGS = $(AM_LDFLAGS)
+dtest_LDADD = $(top_builddir)/lib/libdut.a
 BUILT_SOURCES += dtest-clo.c dtest-clo.h
 
 bin_PROGRAMS += dadd
 dadd_SOURCES += prchunk.c prchunk.h
 dadd_CPPFLAGS = $(AM_CPPFLAGS) $(DT_INCLUDES)
 dadd_LDFLAGS = $(AM_LDFLAGS)
+dadd_LDADD = $(top_builddir)/lib/libdut.a
 BUILT_SOURCES += dadd-clo.c dadd-clo.h
 
 bin_PROGRAMS += ddiff
 ddiff_SOURCES += prchunk.c prchunk.h
 ddiff_CPPFLAGS = $(AM_CPPFLAGS) $(DT_INCLUDES)
 ddiff_LDFLAGS = $(AM_LDFLAGS)
+ddiff_LDADD = $(top_builddir)/lib/libdut.a
 BUILT_SOURCES += ddiff-clo.c ddiff-clo.h
 
 bin_PROGRAMS += dgrep
 dgrep_SOURCES += prchunk.c prchunk.h
 dgrep_CPPFLAGS = $(AM_CPPFLAGS) $(DT_INCLUDES)
 dgrep_LDFLAGS = $(AM_LDFLAGS)
+dgrep_LDADD = $(top_builddir)/lib/libdut.a
 BUILT_SOURCES += dgrep-clo.c dgrep-clo.h
 
 bin_PROGRAMS += dround
 dround_SOURCES += prchunk.c prchunk.h
 dround_CPPFLAGS = $(AM_CPPFLAGS) $(DT_INCLUDES)
 dround_LDFLAGS = $(AM_LDFLAGS)
+dround_LDADD = $(top_builddir)/lib/libdut.a
 BUILT_SOURCES += dround-clo.c dround-clo.h
 
 if BUILD_DEXPR
 dexpr_SOURCES += dexpr-parser.y
 dexpr_CPPFLAGS = $(AM_CPPFLAGS) $(DT_INCLUDES) -DSTANDALONE
 dexpr_LDFLAGS = $(AM_LDFLAGS)
+dexpr_LDADD = $(top_builddir)/lib/libdut.a
 endif  ## BUILD_DEXPR
 BUILT_SOURCES += dexpr-scanner.c dexpr-parser.c dexpr-parser.h
 
 %.c %.h: %.ggo $(GGO_HELPERS)
 	$(AM_V_GEN)$(M4) -I $(srcdir) common.ggo.in $< | gengetopt -l -F $*
 ## patch the multiple arg thingie dingie
-	@sed -f $(srcdir)/__gengetopt-mularg.sed -- $*.c > $*.c.sed && \
-		mv $*.c.sed $*.c
+	@sed -f $(srcdir)/__gengetopt-mularg.sed -- $*.c > $*.c.sed \
+	&& mv $*.c.sed $*.c
+	@sed -e 's,config.h,version.h,g' \
+	     -e 's,\(.*\)_PARSER_VERSION VERSION,\1_PARSER_VERSION $(PACKAGE)_version_string,g' $*.h > $*.h-t \
+	&& mv $*.h-t $*.h
 
 ## gperf rule
 %.c: %.gperf

File test/Makefile.am

 # Help the Developers and yourself. Just use the C locale and settings
 # for the compilation. They can still be overriden by make LANG=<whatever>
 # but that is general a not very good idea
+include $(top_builddir)/version.mk
+
 LANG = C
 LC_ALL = C
 
 ## ggo rule
 %.c %.h: %.ggo
 	$(AM_V_GEN) gengetopt -F $* -i $<
+	@sed -e 's,config.h,version.h,g' \
+	     -e 's,_PARSER_VERSION VERSION,_PARSER_VERSION "$(VERSION)",g' \
+	     $*.h > $*.h-t \
+	&& mv $*.h-t $*.h
 
 clean-local:
 	-rm -rf *.tmpd