nasm-version.c
win64-gas.c
win64-nasm.c
+YASM-VERSION-FILE
+YASM-VERSION.h
.sw*
*.s
*.asm
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
INCLUDE(YasmMacros)
+INCLUDE(VersionGen)
OPTION(ENABLE_NLS "Enable message translations" OFF)
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})
# 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
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
# 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
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
.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
+
+#include "YASM-VERSION.h"\r
#define yasm__splitpath(path, tail) yasm__splitpath_win(path, tail)\r
#define yasm__abspath(path) yasm__abspath_win(path)\r
#define yasm__combpath(from, to) yasm__combpath_win(from, to)\r
/* Define to the address where bug reports for this package should be sent. */\r
#define PACKAGE_BUGREPORT "bug-yasm@tortall.net"\r
\r
-/* Define to build version of this package. */\r
-#define PACKAGE_BUILD "HEAD"\r
-\r
-/* Define to internal version of this package. */\r
-#define PACKAGE_INTVER "1.1.99"\r
-\r
/* Define to the full name of this package. */\r
#define PACKAGE_NAME "yasm"\r
\r
/* Define to the full name and version of this package. */\r
-#define PACKAGE_STRING "yasm HEAD"\r
+/*#define PACKAGE_STRING "yasm HEAD"*/\r
\r
/* Define to the one symbol short name of this package. */\r
#define PACKAGE_TARNAME "yasm"\r
\r
/* Define to the version of this package. */\r
-#define PACKAGE_VERSION "HEAD"\r
+/*#define PACKAGE_VERSION "HEAD"*/\r
\r
/* Define if the C compiler supports function prototypes. */\r
#define PROTOTYPES 1\r
+#include "YASM-VERSION.h"\r
#define yasm__splitpath(path, tail) yasm__splitpath_win(path, tail)\r
#define yasm__abspath(path) yasm__abspath_win(path)\r
#define yasm__combpath(from, to) yasm__combpath_win(from, to)\r
/* Define to the address where bug reports for this package should be sent. */\r
#define PACKAGE_BUGREPORT "bug-yasm@tortall.net"\r
\r
-/* Define to build version of this package. */\r
-#define PACKAGE_BUILD "HEAD"\r
-\r
-/* Define to internal version of this package. */\r
-#define PACKAGE_INTVER "1.1.99"\r
-\r
/* Define to the full name of this package. */\r
#define PACKAGE_NAME "yasm"\r
\r
/* Define to the full name and version of this package. */\r
-#define PACKAGE_STRING "yasm HEAD"\r
+/*#define PACKAGE_STRING "yasm HEAD"*/\r
\r
/* Define to the one symbol short name of this package. */\r
#define PACKAGE_TARNAME "yasm"\r
\r
/* Define to the version of this package. */\r
-#define PACKAGE_VERSION "HEAD"\r
+/*#define PACKAGE_VERSION "HEAD"*/\r
\r
/* Define if the C compiler supports function prototypes. */\r
#define PROTOTYPES 1\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<Optimization>Disabled</Optimization>\r
- <AdditionalIncludeDirectories>..\..\vc10;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+ <AdditionalIncludeDirectories>..\..\vc10;../../..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
<MinimalRebuild>true</MinimalRebuild>\r
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
<PostBuildEvent>\r
<Command>run.bat "$(TargetPath)"</Command>\r
</PostBuildEvent>\r
+ <PreBuildEvent>\r
+ <Command>runpre.bat</Command>\r
+ </PreBuildEvent>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
<ClCompile>\r
--- /dev/null
+cd ..\..\..
+YASM-VERSION-GEN.bat
EndProjectSection\r
EndProject\r
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libyasm", "libyasm\libyasm.vcxproj", "{29FE7874-1256-4AD6-B889-68E399DC9608}"\r
+ ProjectSection(ProjectDependencies) = postProject\r
+ {B545983B-8EE0-4A7B-A67A-E749EEAE62A2} = {B545983B-8EE0-4A7B-A67A-E749EEAE62A2}\r
+ EndProjectSection\r
EndProject\r
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "modules", "modules\modules.vcxproj", "{D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}"\r
EndProject\r
+#include "YASM-VERSION.h"\r
#define yasm__splitpath(path, tail) yasm__splitpath_win(path, tail)\r
#define yasm__abspath(path) yasm__abspath_win(path)\r
#define yasm__combpath(from, to) yasm__combpath_win(from, to)\r
/* Define to the address where bug reports for this package should be sent. */\r
#define PACKAGE_BUGREPORT "bug-yasm@tortall.net"\r
\r
-/* Define to build version of this package. */\r
-#define PACKAGE_BUILD "HEAD"\r
-\r
-/* Define to internal version of this package. */\r
-#define PACKAGE_INTVER "1.1.99"\r
-\r
/* Define to the full name of this package. */\r
#define PACKAGE_NAME "yasm"\r
\r
/* Define to the full name and version of this package. */\r
-#define PACKAGE_STRING "yasm HEAD"\r
+/*#define PACKAGE_STRING "yasm HEAD"*/\r
\r
/* Define to the one symbol short name of this package. */\r
#define PACKAGE_TARNAME "yasm"\r
\r
/* Define to the version of this package. */\r
-#define PACKAGE_VERSION "HEAD"\r
+/*#define PACKAGE_VERSION "HEAD"*/\r
\r
/* Define if the C compiler supports function prototypes. */\r
#define PROTOTYPES 1\r
>\r
<Tool\r
Name="VCPreBuildEventTool"\r
+ CommandLine="runpre.bat"\r
/>\r
<Tool\r
Name="VCCustomBuildTool"\r
>\r
<Tool\r
Name="VCPreBuildEventTool"\r
+ CommandLine="runpre.bat"\r
/>\r
<Tool\r
Name="VCCustomBuildTool"\r
--- /dev/null
+cd ..\..\..
+YASM-VERSION-GEN.bat
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libyasm", "libyasm\libyasm.vcproj", "{29FE7874-1256-4AD6-B889-68E399DC9608}"\r
ProjectSection(ProjectDependencies) = postProject\r
{F0E8B707-00C5-4FF2-B8EF-7C39817132A0} = {F0E8B707-00C5-4FF2-B8EF-7C39817132A0}\r
+ {B545983B-8EE0-4A7B-A67A-E749EEAE62A2} = {B545983B-8EE0-4A7B-A67A-E749EEAE62A2}\r
EndProjectSection\r
EndProject\r
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "modules", "modules\modules.vcproj", "{D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6}"\r
--- /dev/null
+@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
+
--- /dev/null
+#!/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
+}
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"
--- /dev/null
+# 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)
/* 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"
# 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])
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
#
/* 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."
/* 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."
/* 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."
};
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;
}
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;