
#include "svn_version.h"
#include "libopenmpt_version.h"
#include <winver.h>

#if 0
// defined externally by build system
#define MPT_BUILD_VER_FILENAME "libopenmpt.dll"
#define MPT_BUILD_VER_FILEDESC "libopenmpt"
#undef  MPT_BUILD_VER_EXE
#define MPT_BUILD_VER_DLL 1
#define MPT_BUILD_VER_SPECIAL_PREFIX ""
#define MPT_BUILD_VER_SPECIAL_SUFFIX ""
#endif

#if defined(MPT_BUILD_VER_FILENAME) && (defined(MPT_BUILD_VER_EXE) || defined(MPT_BUILD_VER_DLL))
//#if defined(OPENMPT_VERSION_REVISION) && defined(OPENMPT_VERSION_DIRTY) && defined(OPENMPT_VERSION_MIXEDREVISIONS) && defined(OPENMPT_VERSION_IS_PACKAGE)
//#if (OPENMPT_VERSION_REVISION > 0)

#if defined(OPENMPT_VERSION_REVISION)
	#if (OPENMPT_VERSION_REVISION > 0)
		#define OPENMPT_VERSION_HAVE_REVISION
	#endif
#endif

#define VER_STRINGIZE_HELPER(x) #x
#define VER_STRINGIZE(x) VER_STRINGIZE_HELPER(x)

#if defined(OPENMPT_VERSION_DIRTY) && defined(OPENMPT_VERSION_MIXEDREVISIONS) && defined(OPENMPT_VERSION_IS_PACKAGE)
	#if (OPENMPT_VERSION_DIRTY)
		#define VER_FILEVERSION_SRC 2
	#elif (OPENMPT_VERSION_MIXEDREVISIONS)
		#define VER_FILEVERSION_SRC 1
	#elif (OPENMPT_VERSION_IS_PACKAGE)
		#define VER_FILEVERSION_SRC 0
	#else
		#define VER_FILEVERSION_SRC 0
	#endif
#else
	#define VER_FILEVERSION_SRC 0
#endif

#if defined(OPENMPT_VERSION_HAVE_REVISION)
	#define VER_FILEVERSION      OPENMPT_API_VERSION_MAJOR,OPENMPT_API_VERSION_MINOR,OPENMPT_API_VERSION_PATCH,OPENMPT_VERSION_REVISION
	#define VER_FILEVERSION1_STR OPENMPT_API_VERSION_STRING
#else
	#define VER_FILEVERSION      OPENMPT_API_VERSION_MAJOR,OPENMPT_API_VERSION_MINOR,OPENMPT_API_VERSION_PATCH,0
	#define VER_FILEVERSION1_STR OPENMPT_API_VERSION_STRING
#endif

#if defined(OPENMPT_VERSION_DIRTY) && defined(OPENMPT_VERSION_MIXEDREVISIONS) && defined(OPENMPT_VERSION_IS_PACKAGE)
	#if (OPENMPT_VERSION_DIRTY)
		#if (OPENMPT_VERSION_IS_PACKAGE)
			#if defined(OPENMPT_VERSION_HAVE_REVISION)
				#define VER_FILEVERSION2_STR "+r" VER_STRINGIZE(OPENMPT_VERSION_REVISION) "modified.pkg"
			#else
				#define VER_FILEVERSION2_STR "+modified.pkg"
			#endif					
		#else
			#if defined(OPENMPT_VERSION_HAVE_REVISION)
				#define VER_FILEVERSION2_STR "+r" VER_STRINGIZE(OPENMPT_VERSION_REVISION) ".modified"
			#else
				#define VER_FILEVERSION2_STR "+modified"
			#endif
		#endif
	#elif (OPENMPT_VERSION_MIXEDREVISIONS)
		#if (OPENMPT_VERSION_IS_PACKAGE)
			#if defined(OPENMPT_VERSION_HAVE_REVISION)
				#define VER_FILEVERSION2_STR "+r" VER_STRINGIZE(OPENMPT_VERSION_REVISION) ".modified.pkg"
			#else
				#define VER_FILEVERSION2_STR "+modified.pkg"
			#endif					
		#else
			#if defined(OPENMPT_VERSION_HAVE_REVISION)
				#define VER_FILEVERSION2_STR "+r" VER_STRINGIZE(OPENMPT_VERSION_REVISION) ".modified"
			#else
				#define VER_FILEVERSION2_STR "+modified"
			#endif					
		#endif
	#elif (OPENMPT_VERSION_IS_PACKAGE)
		#if defined(OPENMPT_VERSION_HAVE_REVISION)
			#define VER_FILEVERSION2_STR "+r" VER_STRINGIZE(OPENMPT_VERSION_REVISION) "pkg"
		#else
			#define VER_FILEVERSION2_STR "+pkg"
		#endif					
	#else
		#if defined(OPENMPT_VERSION_HAVE_REVISION)
			#define VER_FILEVERSION2_STR "+r" VER_STRINGIZE(OPENMPT_VERSION_REVISION)
		#else
			#define VER_FILEVERSION2_STR ""
		#endif					
	#endif
#else
	#if defined(OPENMPT_VERSION_HAVE_REVISION)
		#define VER_FILEVERSION2_STR "+r" VER_STRINGIZE(OPENMPT_VERSION_REVISION)
	#else
		#define VER_FILEVERSION2_STR ""
	#endif					
#endif

#define VER_FILEVERSION_STR VER_FILEVERSION1_STR VER_FILEVERSION2_STR

#ifdef _DEBUG
	#define VER_DEBUG VS_FF_DEBUG
#else
	#define VER_DEBUG 0
#endif

#if defined(OPENMPT_VERSION_DIRTY) && defined(OPENMPT_VERSION_MIXEDREVISIONS)
	#if ((OPENMPT_VERSION_DIRTY) || (OPENMPT_VERSION_MIXEDREVISIONS))
		#define VER_PATCHED VS_FF_PATCHED
	#else
		#define VER_PATCHED 0
	#endif
#else
	#define VER_PATCHED 0
#endif

#if (OPENMPT_API_VERSION_IS_PREREL)
	#define VER_PRERELEASE VS_FF_PRERELEASE
#else
	#define VER_PRERELEASE 0
#endif

#if defined(OPENMPT_VERSION_REVISION) && defined(OPENMPT_VERSION_DIRTY) && defined(OPENMPT_VERSION_MIXEDREVISIONS) && defined(OPENMPT_VERSION_IS_PACKAGE)
	#if (OPENMPT_VERSION_REVISION > 0)
		#define VER_PRIVATEBUILD     0
		#define VER_PRIVATEBUILD_STR ""
	#else
		#define VER_PRIVATEBUILD     VS_FF_PRIVATEBUILD
		#define VER_PRIVATEBUILD_STR "unknwon"
	#endif
#else
	#define VER_PRIVATEBUILD     VS_FF_PRIVATEBUILD
	#define VER_PRIVATEBUILD_STR "unknwon"
#endif

#if defined(MPT_BUILD_TARGET_XP) || defined(MPT_BUILD_VER_SPECIAL_PREFIX) || defined(MPT_BUILD_VER_SPECIAL_SUFFIX)
	#ifndef MPT_BUILD_VER_SPECIAL_PREFIX
	#define MPT_BUILD_VER_SPECIAL_PREFIX ""
	#endif
	#ifndef MPT_BUILD_VER_SPECIAL_SUFFIX
	#define MPT_BUILD_VER_SPECIAL_SUFFIX ""
	#endif
	#define VER_SPECIALBUILD VS_FF_SPECIALBUILD
	#if defined(MPT_BUILD_TARGET_XP)
		#define VER_SPECIALBUILD_STR MPT_BUILD_VER_SPECIAL_PREFIX "+winxp" MPT_BUILD_VER_SPECIAL_SUFFIX
	#else
		#define VER_SPECIALBUILD_STR MPT_BUILD_VER_SPECIAL_PREFIX MPT_BUILD_VER_SPECIAL_SUFFIX
	#endif
#elif defined(MPT_BUILD_VER_SPECIAL_PREFIX) || defined(MPT_BUILD_VER_SPECIAL_SUFFIX)
	#define VER_SPECIALBUILD     1
	#define VER_SPECIALBUILD_STR MPT_BUILD_VER_SPECIAL_PREFIX MPT_BUILD_VER_SPECIAL_SUFFIX
#else
	#define VER_SPECIALBUILD     0
	#define VER_SPECIALBUILD_STR ""
#endif

#define VER_FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#define VER_FILEFLAGS     (VER_DEBUG|VER_PATCHED|VER_PRERELEASE|VER_PRIVATEBUILD|VER_SPECIALBUILD)

#if defined(MPT_BUILD_VER_EXE)
	#define VER_FILETYPE VFT_APP
#elif defined(MPT_BUILD_VER_DLL)
	#define VER_FILETYPE VFT_DLL
#else
	#define VER_FILETYPE VFT_UNKNOWN
#endif

#define VER_FILENAME_STR MPT_BUILD_VER_FILENAME

#if defined(MPT_BUILD_VER_FILEDESC)
	#define VER_FILEDESC_STR MPT_BUILD_VER_FILEDESC
#else
	#define VER_FILEDESC_STR MPT_BUILD_VER_FILENAME
#endif

VS_VERSION_INFO VERSIONINFO
 FILEVERSION      VER_FILEVERSION
 PRODUCTVERSION   VER_FILEVERSION
 FILEFLAGSMASK    VER_FILEFLAGSMASK
 FILEFLAGS        VER_FILEFLAGS
 FILEOS           VOS_NT_WINDOWS32
 FILETYPE         VER_FILETYPE
 FILESUBTYPE      0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904b0"
        BEGIN
            VALUE "CompanyName",      "openmpt.org"
            VALUE "FileDescription",  VER_FILEDESC_STR
            VALUE "FileVersion",      VER_FILEVERSION_STR
            VALUE "InternalName",     VER_FILENAME_STR
            VALUE "LegalCopyright",   "Copyright © 2004-2024 OpenMPT contributors, Copyright © 1997-2003 Olivier Lapicque"
            VALUE "OriginalFilename", VER_FILENAME_STR
            VALUE "ProductName",      "libopenmpt"
            VALUE "ProductVersion",   VER_FILEVERSION_STR
#if VER_PRIVATEBUILD
            VALUE "PrivateBuild",     VER_PRIVATEBUILD_STR
#endif
#if VER_SPECIALBUILD
            VALUE "SpecialBuild",     VER_SPECIALBUILD_STR
#endif
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1200
    END
END

//#endif
//#endif
#endif

