aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Johnson <peter@tortall.net>2011-08-27 09:25:30 -0700
committerPeter Johnson <peter@tortall.net>2011-08-27 09:25:30 -0700
commit0ed2cc445131663b07b547cf5aefac893b619e9a (patch)
treea050603fb8a3e7edbab258779448691792d654db
parent8281be0c256a42fd2eab894c5788ace7674ed3cb (diff)
downloadyasm-0ed2cc445131663b07b547cf5aefac893b619e9a.tar.gz
Generate version number information from git history.
Due to the svn import structure, a special case is currently implemented to look for the 1.1.0 branchpoint instead of the most recent tag on the master branch. This will be removed after the first release is tagged on the master branch in git. Specific details: autogen.sh: More aggressively clean autoconf cache. This is needed to ensure the version number is actually regenerated. Don't generate PACKAGE_PATCHLEVEL or PACKAGE_BUILD variables. The genversion program now parses PACKAGE_VERSION directly. For Mkfiles builds, YASM-VERSION.h is generated and included by the custom config.h. This avoids the need to edit config.h for versioning.
-rw-r--r--.gitignore2
-rw-r--r--CMakeLists.txt9
-rw-r--r--Makefile.am8
-rw-r--r--Mkfiles/Makefile.flat7
-rw-r--r--Mkfiles/dj/config.h11
-rw-r--r--Mkfiles/vc10/config.h11
-rw-r--r--Mkfiles/vc10/genversion/genversion.vcxproj5
-rw-r--r--Mkfiles/vc10/genversion/runpre.bat2
-rw-r--r--Mkfiles/vc10/yasm.sln3
-rw-r--r--Mkfiles/vc9/config.h11
-rw-r--r--Mkfiles/vc9/genversion/genversion.vcproj2
-rw-r--r--Mkfiles/vc9/genversion/runpre.bat2
-rw-r--r--Mkfiles/vc9/yasm.sln1
-rw-r--r--YASM-VERSION-GEN.bat38
-rwxr-xr-xYASM-VERSION-GEN.sh52
-rwxr-xr-xautogen.sh3
-rw-r--r--cmake/modules/VersionGen.cmake78
-rw-r--r--config.h.cmake6
-rw-r--r--configure.ac8
-rw-r--r--frontends/tasm/tasm.c2
-rw-r--r--frontends/vsyasm/vsyasm.c2
-rw-r--r--frontends/yasm/yasm.c4
-rw-r--r--modules/preprocs/nasm/genversion.c23
23 files changed, 232 insertions, 58 deletions
diff --git a/.gitignore b/.gitignore
index 989c3f41..7ca446de 100644
--- a/.gitignore
+++ b/.gitignore
@@ -62,6 +62,8 @@ x86regtmod.c
nasm-version.c
win64-gas.c
win64-nasm.c
+YASM-VERSION-FILE
+YASM-VERSION.h
.sw*
*.s
*.asm
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9237329e..b63d14b7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,6 +10,7 @@ SET(BUILD_SHARED_LIBS ON)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
INCLUDE(YasmMacros)
+INCLUDE(VersionGen)
OPTION(ENABLE_NLS "Enable message translations" OFF)
@@ -26,12 +27,8 @@ IF(NOT CMAKE_BUILD_TYPE)
FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
-set (YASM_VERSION_MAJOR 1)
-set (YASM_VERSION_MINOR 1)
-set (YASM_VERSION_SUBMINOR 99)
-set (PACKAGE_INTVER "${YASM_VERSION_MAJOR}.${YASM_VERSION_MINOR}.${YASM_VERSION_SUBMINOR}")
-set (PACKAGE_BUILD "HEAD")
-set (PACKAGE_VERSION ${PACKAGE_BUILD})
+VERSION_GEN(PACKAGE_VERSION "${CMAKE_BINARY_DIR}/YASM-VERSION-FILE" "1.1.0")
+
set (PACKAGE_STRING "yasm ${PACKAGE_VERSION}")
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_BINARY_DIR} ${yasm_SOURCE_DIR})
diff --git a/Makefile.am b/Makefile.am
index f3ed7d41..208dc67f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -31,6 +31,7 @@ EXTRA_DIST = config/config.rpath
# libyasm-stdint.h doesn't clean up after itself?
CONFIG_CLEAN_FILES = libyasm-stdint.h
+CONFIG_CLEAN_FILES += YASM-VERSION-FILE
EXTRA_DIST += tools/Makefile.inc
EXTRA_DIST += libyasm/Makefile.inc
@@ -55,6 +56,7 @@ EXTRA_DIST += BSD.txt
EXTRA_DIST += GNU_GPL-2.0
EXTRA_DIST += GNU_LGPL-2.0
EXTRA_DIST += splint.sh
+EXTRA_DIST += YASM-VERSION-GEN.sh
EXTRA_DIST += Mkfiles/Makefile.flat
EXTRA_DIST += Mkfiles/Makefile.dj
EXTRA_DIST += Mkfiles/dj/config.h
@@ -122,6 +124,12 @@ EXTRA_DIST += Mkfiles/vc10/re2c/run.bat
# Until this gets fixed in automake
DISTCLEANFILES += libyasm/stamp-h libyasm/stamp-h[0-9]*
+dist-hook: YASM-VERSION-FILE
+ cp YASM-VERSION-FILE $(distdir)/version
+
+YASM-VERSION-FILE: $(top_srcdir)/YASM-VERSION-GEN.sh
+ $(top_srcdir)/YASM-VERSION-GEN.sh
+
distclean-local:
-rm -rf results
if HAVE_PYTHON
diff --git a/Mkfiles/Makefile.flat b/Mkfiles/Makefile.flat
index 3e190d73..011fbe51 100644
--- a/Mkfiles/Makefile.flat
+++ b/Mkfiles/Makefile.flat
@@ -197,7 +197,7 @@ win64-gas.c: modules/objfmts/coff/win64-gas.mac genmacro
modules/objfmts/coff/coff-objfmt.c: win64-nasm.c win64-gas.c
-genversion: modules/preprocs/nasm/genversion.c
+genversion: modules/preprocs/nasm/genversion.c YASM-VERSION.h
$(BUILDCC) -IMkfiles -I. -o $@ $<
version.mac: genversion
@@ -272,3 +272,8 @@ vsyasm: $(VSYASM_OBJS)
.c.o:
$(CC) -c $(CFLAGS) -o $@ $<
+$(YASM_OBJS) $(YTASM_OBJS) $(VSYASM_OBJS): YASM-VERSION.h
+
+YASM-VERSION.h: YASM-VERSION-GEN.sh
+ sh YASM-VERSION-GEN.sh
+
diff --git a/Mkfiles/dj/config.h b/Mkfiles/dj/config.h
index 46e3167e..b33554ac 100644
--- a/Mkfiles/dj/config.h
+++ b/Mkfiles/dj/config.h
@@ -1,3 +1,4 @@
+#include "YASM-VERSION.h"
#define yasm__splitpath(path, tail) yasm__splitpath_win(path, tail)
#define yasm__abspath(path) yasm__abspath_win(path)
#define yasm__combpath(from, to) yasm__combpath_win(from, to)
@@ -116,23 +117,17 @@
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "bug-yasm@tortall.net"
-/* Define to build version of this package. */
-#define PACKAGE_BUILD "HEAD"
-
-/* Define to internal version of this package. */
-#define PACKAGE_INTVER "1.1.99"
-
/* Define to the full name of this package. */
#define PACKAGE_NAME "yasm"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "yasm HEAD"
+/*#define PACKAGE_STRING "yasm HEAD"*/
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "yasm"
/* Define to the version of this package. */
-#define PACKAGE_VERSION "HEAD"
+/*#define PACKAGE_VERSION "HEAD"*/
/* Define if the C compiler supports function prototypes. */
#define PROTOTYPES 1
diff --git a/Mkfiles/vc10/config.h b/Mkfiles/vc10/config.h
index aba46abe..efb7cbe4 100644
--- a/Mkfiles/vc10/config.h
+++ b/Mkfiles/vc10/config.h
@@ -1,3 +1,4 @@
+#include "YASM-VERSION.h"
#define yasm__splitpath(path, tail) yasm__splitpath_win(path, tail)
#define yasm__abspath(path) yasm__abspath_win(path)
#define yasm__combpath(from, to) yasm__combpath_win(from, to)
@@ -114,23 +115,17 @@
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "bug-yasm@tortall.net"
-/* Define to build version of this package. */
-#define PACKAGE_BUILD "HEAD"
-
-/* Define to internal version of this package. */
-#define PACKAGE_INTVER "1.1.99"
-
/* Define to the full name of this package. */
#define PACKAGE_NAME "yasm"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "yasm HEAD"
+/*#define PACKAGE_STRING "yasm HEAD"*/
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "yasm"
/* Define to the version of this package. */
-#define PACKAGE_VERSION "HEAD"
+/*#define PACKAGE_VERSION "HEAD"*/
/* Define if the C compiler supports function prototypes. */
#define PROTOTYPES 1
diff --git a/Mkfiles/vc10/genversion/genversion.vcxproj b/Mkfiles/vc10/genversion/genversion.vcxproj
index cce7c7fd..1bfd9e7a 100644
--- a/Mkfiles/vc10/genversion/genversion.vcxproj
+++ b/Mkfiles/vc10/genversion/genversion.vcxproj
@@ -48,7 +48,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>..\..\vc10;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>..\..\vc10;../../..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -73,6 +73,9 @@
<PostBuildEvent>
<Command>run.bat "$(TargetPath)"</Command>
</PostBuildEvent>
+ <PreBuildEvent>
+ <Command>runpre.bat</Command>
+ </PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
diff --git a/Mkfiles/vc10/genversion/runpre.bat b/Mkfiles/vc10/genversion/runpre.bat
new file mode 100644
index 00000000..fdd15708
--- /dev/null
+++ b/Mkfiles/vc10/genversion/runpre.bat
@@ -0,0 +1,2 @@
+cd ..\..\..
+YASM-VERSION-GEN.bat
diff --git a/Mkfiles/vc10/yasm.sln b/Mkfiles/vc10/yasm.sln
index 342bf07b..306c7b10 100644
--- a/Mkfiles/vc10/yasm.sln
+++ b/Mkfiles/vc10/yasm.sln
@@ -7,6 +7,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libyasm", "libyasm\libyasm.vcxproj", "{29FE7874-1256-4AD6-B889-68E399DC9608}"
+ ProjectSection(ProjectDependencies) = postProject
+ {B545983B-8EE0-4A7B-A67A-E749EEAE62A2} = {B545983B-8EE0-4A7B-A67A-E749EEAE62A2}
+ EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "modules", "modules\modules.vcxproj", "{D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}"
EndProject
diff --git a/Mkfiles/vc9/config.h b/Mkfiles/vc9/config.h
index aba46abe..efb7cbe4 100644
--- a/Mkfiles/vc9/config.h
+++ b/Mkfiles/vc9/config.h
@@ -1,3 +1,4 @@
+#include "YASM-VERSION.h"
#define yasm__splitpath(path, tail) yasm__splitpath_win(path, tail)
#define yasm__abspath(path) yasm__abspath_win(path)
#define yasm__combpath(from, to) yasm__combpath_win(from, to)
@@ -114,23 +115,17 @@
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "bug-yasm@tortall.net"
-/* Define to build version of this package. */
-#define PACKAGE_BUILD "HEAD"
-
-/* Define to internal version of this package. */
-#define PACKAGE_INTVER "1.1.99"
-
/* Define to the full name of this package. */
#define PACKAGE_NAME "yasm"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "yasm HEAD"
+/*#define PACKAGE_STRING "yasm HEAD"*/
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "yasm"
/* Define to the version of this package. */
-#define PACKAGE_VERSION "HEAD"
+/*#define PACKAGE_VERSION "HEAD"*/
/* Define if the C compiler supports function prototypes. */
#define PROTOTYPES 1
diff --git a/Mkfiles/vc9/genversion/genversion.vcproj b/Mkfiles/vc9/genversion/genversion.vcproj
index 84c92a2d..f5a01f97 100644
--- a/Mkfiles/vc9/genversion/genversion.vcproj
+++ b/Mkfiles/vc9/genversion/genversion.vcproj
@@ -26,6 +26,7 @@
>
<Tool
Name="VCPreBuildEventTool"
+ CommandLine="runpre.bat"
/>
<Tool
Name="VCCustomBuildTool"
@@ -106,6 +107,7 @@
>
<Tool
Name="VCPreBuildEventTool"
+ CommandLine="runpre.bat"
/>
<Tool
Name="VCCustomBuildTool"
diff --git a/Mkfiles/vc9/genversion/runpre.bat b/Mkfiles/vc9/genversion/runpre.bat
new file mode 100644
index 00000000..fdd15708
--- /dev/null
+++ b/Mkfiles/vc9/genversion/runpre.bat
@@ -0,0 +1,2 @@
+cd ..\..\..
+YASM-VERSION-GEN.bat
diff --git a/Mkfiles/vc9/yasm.sln b/Mkfiles/vc9/yasm.sln
index 833e3beb..e74fc823 100644
--- a/Mkfiles/vc9/yasm.sln
+++ b/Mkfiles/vc9/yasm.sln
@@ -9,6 +9,7 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libyasm", "libyasm\libyasm.vcproj", "{29FE7874-1256-4AD6-B889-68E399DC9608}"
ProjectSection(ProjectDependencies) = postProject
{F0E8B707-00C5-4FF2-B8EF-7C39817132A0} = {F0E8B707-00C5-4FF2-B8EF-7C39817132A0}
+ {B545983B-8EE0-4A7B-A67A-E749EEAE62A2} = {B545983B-8EE0-4A7B-A67A-E749EEAE62A2}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "modules", "modules\modules.vcproj", "{D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}"
diff --git a/YASM-VERSION-GEN.bat b/YASM-VERSION-GEN.bat
new file mode 100644
index 00000000..92bb97e6
--- /dev/null
+++ b/YASM-VERSION-GEN.bat
@@ -0,0 +1,38 @@
+@echo off
+if exist version goto haveversion
+
+set errorlevel=0
+set _my_=
+for /f "usebackq tokens=1*" %%f in (`reg query HKCU\Software\TortoiseGit /v MSysGit`) do (set _my_=%%f %%g)
+if %errorlevel% neq 0 goto notfound
+if "%_my_%" == "" goto notfound
+
+rem Using the shell script version (calling Git) ...
+set _gitbin_=%_my_:*REG_SZ=%
+for /f "tokens=* delims= " %%a in ("%_gitbin_%") do set _gitbin_=%%a
+set OLDPATH=%PATH%
+set PATH=%_gitbin_%;%PATH%
+"%_gitbin_%\sh" YASM-VERSION-GEN.sh "%_gitbin_%"
+set PATH=%OLDPATH%
+exit /b
+
+:notfound
+rem Could not find Git ...
+set _ver_=
+for /f "usebackq tokens=2 delims==" %%a in (`%SystemRoot%\system32\find "DEF_VER=" ^<YASM-VERSION-GEN.sh`) do (set _ver_=%%a)
+set _ver_=%_ver_:~1%
+goto output
+
+:haveversion
+set /p _ver_=<version
+goto output
+
+:output
+set /p _oldver_=<YASM-VERSION-FILE
+set _oldver_=%_oldver_:~,-1%
+if "%_ver_%" == "%_oldver_%" exit /b
+echo %_ver_%
+echo %_ver_% > YASM-VERSION-FILE
+echo #define PACKAGE_STRING "yasm %_ver_%" > YASM-VERSION.h
+echo #define PACKAGE_VERSION "%_ver_%" >> YASM-VERSION.h
+
diff --git a/YASM-VERSION-GEN.sh b/YASM-VERSION-GEN.sh
new file mode 100755
index 00000000..00c0136f
--- /dev/null
+++ b/YASM-VERSION-GEN.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+YVF=YASM-VERSION-FILE
+DEF_VER=v1.1.0
+
+LF='
+'
+
+# First see if there is a version file (included in release tarballs),
+# then try git-describe, then default.
+if test -f version
+then
+ VN=$(cat version) || VN="$DEF_VER"
+elif test -d .git -o -f .git &&
+ VN=$(git describe --match "v[0-9]*" --abbrev=4 HEAD 2>/dev/null) &&
+ case "$VN" in
+ *$LF*) (exit 1) ;;
+ v0.1.0*)
+ # Special handling until we get a more recent tag on the
+ # master branch
+ MERGE_BASE=$(git merge-base $DEF_VER HEAD 2>/dev/null)
+ VN1=$(git rev-list $MERGE_BASE..HEAD | wc -l 2>/dev/null)
+ VN2=$(git rev-list --max-count=1 --abbrev-commit --abbrev=4 HEAD 2>/dev/null)
+ VN=$(echo "v$DEF_VER-$VN1-g$VN2" | sed -e 's/ //g')
+ git update-index -q --refresh
+ test -z "$(git diff-index --name-only HEAD --)" ||
+ VN="$VN-dirty" ;;
+ v[0-9]*)
+ git update-index -q --refresh
+ test -z "$(git diff-index --name-only HEAD --)" ||
+ VN="$VN-dirty" ;;
+ esac
+then
+ VN=$(echo "$VN" | sed -e 's/-/./g');
+else
+ VN="$DEF_VER"
+fi
+
+VN=$(expr "$VN" : v*'\(.*\)')
+
+if test -r $YVF
+then
+ VC=$(cat $YVF)
+else
+ VC=unset
+fi
+test "$VN" = "$VC" || {
+ echo >&2 "$VN"
+ echo "$VN" >$YVF
+ echo "#define PACKAGE_STRING \"yasm $VN\"" > YASM-VERSION.h
+ echo "#define PACKAGE_VERSION \"$VN\"" >> YASM-VERSION.h
+}
diff --git a/autogen.sh b/autogen.sh
index b91fc286..12da6aa4 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -73,7 +73,8 @@ if test ! -d "config"; then
mkdir config
fi
-rm -f stamp-h.in
+rm -rf autom4te.cache
+rm -f configure config.h config.status config.log stamp-h.in
#echo " gettextize -f --no-changelog"
#echo "N" | gettextize -f --no-changelog || exit 1
echo " aclocal $ACLOCAL_FLAGS"
diff --git a/cmake/modules/VersionGen.cmake b/cmake/modules/VersionGen.cmake
new file mode 100644
index 00000000..340455b3
--- /dev/null
+++ b/cmake/modules/VersionGen.cmake
@@ -0,0 +1,78 @@
+# Redistribution and use is allowed according to the terms of the BSD license.
+#
+# Copyright (c) 2011 Peter Johnson
+
+macro (VERSION_GEN _version _version_file _default_version)
+ set (_vn "v${_default_version}")
+
+ # First see if there is a version file (included in release tarballs),
+ # then try git-describe, then default.
+ if (EXISTS "${CMAKE_SOURCE_DIR}/version")
+ file (STRINGS "${CMAKE_SOURCE_DIR}/version" _version_strs LIMIT_COUNT 1)
+ list (GET _version_strs 0 _version_strs0)
+ if (NOT (${_version_strs0} STREQUAL ""))
+ set (_vn "v${_version_strs0}")
+ endif (${_version_strs0})
+ elseif (EXISTS "${CMAKE_SOURCE_DIR}/.git")
+ execute_process (COMMAND git describe --match "v[0-9]*" --abbrev=4 HEAD
+ RESULT_VARIABLE _git_result
+ OUTPUT_VARIABLE _git_vn
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ if (_git_result EQUAL 0)
+ # Special handling until we get a more recent tag on the master
+ # branch
+ if (_git_vn MATCHES "^v0[.]1[.]0")
+ execute_process (COMMAND git merge-base v${_default_version} HEAD
+ OUTPUT_VARIABLE _merge_base
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ #message (STATUS "Merge base: ${_merge_base}")
+
+ execute_process (COMMAND git rev-list ${_merge_base}..HEAD
+ OUTPUT_VARIABLE _rev_list
+ ERROR_QUIET)
+ string (REGEX MATCHALL "[^\n]*\n" _rev_list_lines "${_rev_list}")
+ #message (STATUS "Rev list: ${_rev_list_lines}")
+ list (LENGTH _rev_list_lines _vn1)
+
+ execute_process (COMMAND git rev-list --max-count=1 --abbrev-commit --abbrev=4 HEAD
+ OUTPUT_VARIABLE _vn2
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ set (_git_vn "v${_default_version}-${_vn1}-g${_vn2}")
+ endif (_git_vn MATCHES "^v0[.]1[.]0")
+
+ # Append -dirty if there are local changes
+ execute_process (COMMAND git update-index -q --refresh)
+ execute_process (COMMAND git diff-index --name-only HEAD --
+ OUTPUT_VARIABLE _git_vn_dirty)
+ if (_git_vn_dirty)
+ set (_git_vn "${_git_vn}-dirty")
+ endif (_git_vn_dirty)
+
+ # Substitute . for - in the result
+ string (REPLACE "-" "." _vn "${_git_vn}")
+ endif (_git_result EQUAL 0)
+ endif (EXISTS "${CMAKE_SOURCE_DIR}/version")
+
+ # Strip leading "v" from version
+ #message (STATUS "_vn: ${_vn}")
+ string (REGEX REPLACE "^v*(.+)" "\\1" _vn "${_vn}")
+
+ # Update version file if required
+ if (EXISTS ${_version_file})
+ file (STRINGS ${_version_file} _version_strs LIMIT_COUNT 1)
+ list (GET _version_strs 0 _vc)
+ else (EXISTS ${_version_file})
+ set (_vc "unset")
+ endif (EXISTS ${_version_file})
+ if (NOT ("${_vn}" STREQUAL "${_vc}"))
+ file (WRITE ${_version_file} "${_vn}")
+ endif (NOT ("${_vn}" STREQUAL "${_vc}"))
+
+ # Set output version variable
+ set (${_version} ${_vn})
+endmacro (VERSION_GEN)
diff --git a/config.h.cmake b/config.h.cmake
index d282b931..50ed93ab 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -29,12 +29,6 @@
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "bug-yasm@tortall.net"
-/* Define to internal version of this package. */
-#define PACKAGE_INTVER "@PACKAGE_INTVER@"
-
-/* Define to build version of this package. */
-#define PACKAGE_BUILD "@PACKAGE_BUILD@"
-
/* Define to the full name of this package. */
#define PACKAGE_NAME "yasm"
diff --git a/configure.ac b/configure.ac
index 4dc92f41..c0507a6b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,9 @@
# autoconf setup
#
AC_PREREQ(2.53)
-AC_INIT([yasm], [HEAD], [bug-yasm@tortall.net])
+AC_INIT([yasm],
+ m4_esyscmd([./YASM-VERSION-GEN.sh && tr -d '\n' <YASM-VERSION-FILE]),
+ [bug-yasm@tortall.net])
#AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_HEADER([config.h])
@@ -12,10 +14,6 @@ AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE([1.9.6 foreign])
AM_MAINTAINER_MODE
-AC_DEFINE(PACKAGE_INTVER, ["1.1.99"],
- [Define to internal version of this package.])
-AC_DEFINE(PACKAGE_BUILD, ["HEAD"], [Define to build version of this package.])
-
#
# autoconf command-line options
#
diff --git a/frontends/tasm/tasm.c b/frontends/tasm/tasm.c
index 6efac28f..b0b89de7 100644
--- a/frontends/tasm/tasm.c
+++ b/frontends/tasm/tasm.c
@@ -223,7 +223,7 @@ static opt_option options[] =
/* version message */
/*@observer@*/ static const char *version_msg[] = {
- PACKAGE_NAME " " PACKAGE_INTVER "." PACKAGE_BUILD,
+ PACKAGE_STRING,
"Compiled on " __DATE__ ".",
"Copyright (c) 2001-2010 Peter Johnson and other Yasm developers.",
"Run yasm --license for licensing overview and summary."
diff --git a/frontends/vsyasm/vsyasm.c b/frontends/vsyasm/vsyasm.c
index 115e34e6..4ab46369 100644
--- a/frontends/vsyasm/vsyasm.c
+++ b/frontends/vsyasm/vsyasm.c
@@ -215,7 +215,7 @@ static opt_option options[] =
/* version message */
/*@observer@*/ static const char *version_msg[] = {
- PACKAGE_NAME " " PACKAGE_INTVER "." PACKAGE_BUILD,
+ PACKAGE_STRING,
"Compiled on " __DATE__ ".",
"Copyright (c) 2001-2010 Peter Johnson and other Yasm developers.",
"Run yasm --license for licensing overview and summary."
diff --git a/frontends/yasm/yasm.c b/frontends/yasm/yasm.c
index 4c61e77e..ddd044bb 100644
--- a/frontends/yasm/yasm.c
+++ b/frontends/yasm/yasm.c
@@ -212,9 +212,9 @@ static opt_option options[] =
/* version message */
/*@observer@*/ static const char *version_msg[] = {
- PACKAGE_NAME " " PACKAGE_INTVER "." PACKAGE_BUILD,
+ PACKAGE_STRING,
"Compiled on " __DATE__ ".",
- "Copyright (c) 2001-2010 Peter Johnson and other Yasm developers.",
+ "Copyright (c) 2001-2011 Peter Johnson and other Yasm developers.",
"Run yasm --license for licensing overview and summary."
};
diff --git a/modules/preprocs/nasm/genversion.c b/modules/preprocs/nasm/genversion.c
index a0b884b9..164b4d6b 100644
--- a/modules/preprocs/nasm/genversion.c
+++ b/modules/preprocs/nasm/genversion.c
@@ -36,14 +36,19 @@ int
main(int argc, char *argv[])
{
FILE *out;
- int major, minor, subminor;
+ int major, minor, subminor, patchlevel, matched;
if (argc != 2) {
fprintf(stderr, "Usage: %s <outfile>\n", argv[0]);
return EXIT_FAILURE;
}
- if (sscanf(PACKAGE_INTVER, "%d.%d.%d", &major, &minor, &subminor) != 3) {
+ matched = sscanf(PACKAGE_VERSION, "%d.%d.%d.%d", &major, &minor, &subminor,
+ &patchlevel);
+
+ if (matched == 3)
+ patchlevel = 0;
+ else if (matched != 4) {
fprintf(stderr, "Version tokenizing error\n");
return EXIT_FAILURE;
}
@@ -61,17 +66,15 @@ main(int argc, char *argv[])
fprintf(out, "%%define __YASM_MAJOR__ %d\n", major);
fprintf(out, "%%define __YASM_MINOR__ %d\n", minor);
fprintf(out, "%%define __YASM_SUBMINOR__ %d\n", subminor);
- if (!isdigit(PACKAGE_BUILD[0]))
- fprintf(out, "%%define __YASM_BUILD__ 0\n");
- else
- fprintf(out, "%%define __YASM_BUILD__ %d\n", atoi(PACKAGE_BUILD));
+ fprintf(out, "%%define __YASM_BUILD__ %d\n", patchlevel);
+ fprintf(out, "%%define __YASM_PATCHLEVEL__ %d\n", patchlevel);
/* Version id (hex number) */
- fprintf(out, "%%define __YASM_VERSION_ID__ 0%02x%02x%02x00h\n", major,
- minor, subminor);
+ fprintf(out, "%%define __YASM_VERSION_ID__ 0%02x%02x%02x%02xh\n", major,
+ minor, subminor, patchlevel);
- /* Version string - version sans build */
- fprintf(out, "%%define __YASM_VER__ \"%s\"\n", PACKAGE_INTVER);
+ /* Version string */
+ fprintf(out, "%%define __YASM_VER__ \"%s\"\n", PACKAGE_VERSION);
fclose(out);
return EXIT_SUCCESS;