e9bc502fb8
Decode hex digits from __VISUALDSPVERSION__ to compute the version number components. Note that the constant encodes decimal digits as hex digits (never larger than 9). We represent them as decimal after extraction. See documentation at: http://download.analog.com/dsp/tools/VisualDSP_45_Update_6_Release_Note_v4.pdf http://www.analog.com/static/imported-files/software_manuals/50_asm_man.rev3.1.pdf Note that __VISUALDSPVERSION__ was introduced in version 4.5.6.
213 lines
7.2 KiB
C++
213 lines
7.2 KiB
C++
/* This source file must have a .cpp extension so that all C++ compilers
|
|
recognize the extension without flags. Borland does not know .cxx for
|
|
example. */
|
|
#ifndef __cplusplus
|
|
# error "A C compiler has been selected for C++."
|
|
#endif
|
|
|
|
/* Version number components: V=Version, R=Revision, P=Patch
|
|
Version date components: YYYY=Year, MM=Month, DD=Day */
|
|
|
|
#if defined(__COMO__)
|
|
# define COMPILER_ID "Comeau"
|
|
/* __COMO_VERSION__ = VRR */
|
|
# define COMPILER_VERSION_MAJOR DEC(__COMO_VERSION__ / 100)
|
|
# define COMPILER_VERSION_MINOR DEC(__COMO_VERSION__ % 100)
|
|
|
|
#elif defined(__INTEL_COMPILER) || defined(__ICC)
|
|
# define COMPILER_ID "Intel"
|
|
/* __INTEL_COMPILER = VRP */
|
|
# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
|
|
# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
|
|
# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10)
|
|
# if defined(__INTEL_COMPILER_BUILD_DATE)
|
|
/* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
|
|
# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
|
|
# endif
|
|
|
|
#elif defined(__clang__)
|
|
# define COMPILER_ID "Clang"
|
|
# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
|
|
# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
|
|
# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
|
|
|
|
#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
|
|
# define COMPILER_ID "Embarcadero"
|
|
# define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
|
|
# define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
|
|
# define COMPILER_VERSION_PATCH HEX(__CODEGEARC_VERSION__ & 0xFFFF)
|
|
|
|
#elif defined(__BORLANDC__)
|
|
# define COMPILER_ID "Borland"
|
|
/* __BORLANDC__ = 0xVRR */
|
|
# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
|
|
# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
|
|
|
|
#elif defined(__WATCOMC__)
|
|
# define COMPILER_ID "Watcom"
|
|
/* __WATCOMC__ = VVRR */
|
|
# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
|
|
# define COMPILER_VERSION_MINOR DEC(__WATCOMC__ % 100)
|
|
|
|
#elif defined(__SUNPRO_CC)
|
|
# define COMPILER_ID "SunPro"
|
|
# if __SUNPRO_CC >= 0x5100
|
|
/* __SUNPRO_CC = 0xVRRP */
|
|
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12)
|
|
# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF)
|
|
# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
|
|
# else
|
|
/* __SUNPRO_CC = 0xVRP */
|
|
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8)
|
|
# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF)
|
|
# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
|
|
# endif
|
|
|
|
#elif defined(__HP_aCC)
|
|
# define COMPILER_ID "HP"
|
|
/* __HP_aCC = VVRRPP */
|
|
# define COMPILER_VERSION_MAJOR DEC(__HP_aCC/10000)
|
|
# define COMPILER_VERSION_MINOR DEC(__HP_aCC/100 % 100)
|
|
# define COMPILER_VERSION_PATCH DEC(__HP_aCC % 100)
|
|
|
|
#elif defined(__DECCXX)
|
|
# define COMPILER_ID "Compaq"
|
|
/* __DECCXX_VER = VVRRTPPPP */
|
|
# define COMPILER_VERSION_MAJOR DEC(__DECCXX_VER/10000000)
|
|
# define COMPILER_VERSION_MINOR DEC(__DECCXX_VER/100000 % 100)
|
|
# define COMPILER_VERSION_PATCH DEC(__DECCXX_VER % 10000)
|
|
|
|
#elif defined(__IBMCPP__)
|
|
# if defined(__COMPILER_VER__)
|
|
# define COMPILER_ID "zOS"
|
|
# else
|
|
# if __IBMCPP__ >= 800
|
|
# define COMPILER_ID "XL"
|
|
# else
|
|
# define COMPILER_ID "VisualAge"
|
|
# endif
|
|
/* __IBMCPP__ = VRP */
|
|
# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
|
|
# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
|
|
# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
|
|
# endif
|
|
|
|
#elif defined(__PGI)
|
|
# define COMPILER_ID "PGI"
|
|
# define COMPILER_VERSION_MAJOR DEC(__PGIC__)
|
|
# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
|
|
# if defined(__PGIC_PATCHLEVEL__)
|
|
# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
|
|
# endif
|
|
|
|
#elif defined(__PATHCC__)
|
|
# define COMPILER_ID "PathScale"
|
|
# define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
|
|
# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
|
|
# if defined(__PATHCC_PATCHLEVEL__)
|
|
# define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
|
|
# endif
|
|
|
|
#elif defined(_CRAYC)
|
|
# define COMPILER_ID "Cray"
|
|
# define COMPILER_VERSION_MAJOR DEC(_RELEASE)
|
|
# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
|
|
|
|
#elif defined(__TI_COMPILER_VERSION__)
|
|
# define COMPILER_ID "TI_DSP"
|
|
/* __TI_COMPILER_VERSION__ = VVVRRRPPP */
|
|
# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
|
|
# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)
|
|
# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)
|
|
|
|
#elif defined(__SCO_VERSION__)
|
|
# define COMPILER_ID "SCO"
|
|
|
|
#elif defined(__GNUC__)
|
|
# define COMPILER_ID "GNU"
|
|
# define COMPILER_VERSION_MAJOR DEC(__GNUC__)
|
|
# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
|
|
# if defined(__GNUC_PATCHLEVEL__)
|
|
# define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
|
|
# endif
|
|
|
|
#elif defined(_MSC_VER)
|
|
# define COMPILER_ID "MSVC"
|
|
/* _MSC_VER = VVRR */
|
|
# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
|
|
# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
|
|
# if defined(_MSC_FULL_VER)
|
|
# if _MSC_VER >= 1400
|
|
/* _MSC_FULL_VER = VVRRPPPPP */
|
|
# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
|
|
# else
|
|
/* _MSC_FULL_VER = VVRRPPPP */
|
|
# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
|
|
# endif
|
|
# endif
|
|
# if defined(_MSC_BUILD)
|
|
# define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
|
|
# endif
|
|
|
|
/* Analog VisualDSP++ >= 4.5.6 */
|
|
#elif defined(__VISUALDSPVERSION__)
|
|
# define COMPILER_ID "ADSP"
|
|
/* __VISUALDSPVERSION__ = 0xVVRRPP00 */
|
|
# define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24)
|
|
# define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF)
|
|
# define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF)
|
|
|
|
/* Analog VisualDSP++ < 4.5.6 */
|
|
#elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
|
|
# define COMPILER_ID "ADSP"
|
|
|
|
#elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
|
|
# define COMPILER_ID "MIPSpro"
|
|
# if defined(_SGI_COMPILER_VERSION)
|
|
/* _SGI_COMPILER_VERSION = VRP */
|
|
# define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100)
|
|
# define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10)
|
|
# define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10)
|
|
# else
|
|
/* _COMPILER_VERSION = VRP */
|
|
# define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100)
|
|
# define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10)
|
|
# define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10)
|
|
# endif
|
|
|
|
/* This compiler is either not known or is too old to define an
|
|
identification macro. Try to identify the platform and guess that
|
|
it is the native compiler. */
|
|
#elif defined(__sgi)
|
|
# define COMPILER_ID "MIPSpro"
|
|
|
|
#elif defined(__hpux) || defined(__hpua)
|
|
# define COMPILER_ID "HP"
|
|
|
|
#else /* unknown compiler */
|
|
# define COMPILER_ID ""
|
|
|
|
#endif
|
|
|
|
/* Construct the string literal in pieces to prevent the source from
|
|
getting matched. Store it in a pointer rather than an array
|
|
because some compilers will just produce instructions to fill the
|
|
array rather than assigning a pointer to a static array. */
|
|
char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
|
|
|
|
@CMAKE_CXX_COMPILER_ID_PLATFORM_CONTENT@
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
int require = 0;
|
|
require += info_compiler[argc];
|
|
require += info_platform[argc];
|
|
#ifdef COMPILER_VERSION_MAJOR
|
|
require += info_version[argc];
|
|
#endif
|
|
(void)argv;
|
|
return require;
|
|
}
|