ax_compiler_version.m4 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_compiler_version.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_COMPILER_VERSION
  8. #
  9. # DESCRIPTION
  10. #
  11. # This macro retrieves the compiler version and returns it in the cache
  12. # variable $ax_cv_c_compiler_version for C and $ax_cv_cxx_compiler_version
  13. # for C++.
  14. #
  15. # Version is returned as epoch:major.minor.patchversion
  16. #
  17. # Epoch is used in order to have an increasing version number in case of
  18. # marketing change.
  19. #
  20. # Epoch use: * borland compiler use chronologically 0turboc for turboc
  21. # era,
  22. #
  23. # 1borlanc BORLANDC++ before 5, 2cppbuilder for cppbuilder era,
  24. # 3borlancpp for return of BORLANDC++ (after version 5.5),
  25. # 4cppbuilder for cppbuilder with year version,
  26. # and 5xe for XE era.
  27. #
  28. # An empty string is returned otherwise.
  29. #
  30. # LICENSE
  31. #
  32. # Copyright (c) 2014 Bastien ROUCARIES <roucaries.bastien+autoconf@gmail.com>
  33. #
  34. # Copying and distribution of this file, with or without modification, are
  35. # permitted in any medium without royalty provided the copyright notice
  36. # and this notice are preserved. This file is offered as-is, without any
  37. # warranty.
  38. #serial 12
  39. # for intel
  40. AC_DEFUN([_AX_COMPILER_VERSION_INTEL],
  41. [ dnl
  42. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
  43. [__INTEL_COMPILER/100],,
  44. AC_MSG_FAILURE([[[$0]] unknown intel compiler version]))
  45. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
  46. [(__INTEL_COMPILER%100)/10],,
  47. AC_MSG_FAILURE([[[$0]] unknown intel compiler version]))
  48. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
  49. [(__INTEL_COMPILER%10)],,
  50. AC_MSG_FAILURE([[[$0]] unknown intel compiler version]))
  51. ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
  52. ])
  53. # for IBM
  54. AC_DEFUN([_AX_COMPILER_VERSION_IBM],
  55. [ dnl
  56. dnl check between z/OS C/C++ and XL C/C++
  57. AC_COMPILE_IFELSE([
  58. AC_LANG_PROGRAM([],
  59. [
  60. #if defined(__COMPILER_VER__)
  61. choke me;
  62. #endif
  63. ])],
  64. [
  65. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
  66. [__xlC__/100],,
  67. AC_MSG_FAILURE([[[$0]] unknown IBM compiler major version]))
  68. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
  69. [__xlC__%100],,
  70. AC_MSG_FAILURE([[[$0]] unknown IBM compiler minor version]))
  71. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
  72. [__xlC_ver__/0x100],,
  73. AC_MSG_FAILURE([[[$0]] unknown IBM compiler patch version]))
  74. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_build,
  75. [__xlC_ver__%0x100],,
  76. AC_MSG_FAILURE([[[$0]] unknown IBM compiler build version]))
  77. ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_build"
  78. ],
  79. [
  80. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
  81. [__xlC__%1000],,
  82. AC_MSG_FAILURE([[[$0]] unknown IBM compiler patch version]))
  83. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
  84. [(__xlC__/10000)%10],,
  85. AC_MSG_FAILURE([[[$0]] unknown IBM compiler minor version]))
  86. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
  87. [(__xlC__/100000)%10],,
  88. AC_MSG_FAILURE([[[$0]] unknown IBM compiler major version]))
  89. ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
  90. ])
  91. ])
  92. # for pathscale
  93. AC_DEFUN([_AX_COMPILER_VERSION_PATHSCALE],[
  94. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
  95. __PATHCC__,,
  96. AC_MSG_FAILURE([[[$0]] unknown pathscale major]))
  97. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
  98. __PATHCC_MINOR__,,
  99. AC_MSG_FAILURE([[[$0]] unknown pathscale minor]))
  100. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
  101. [__PATHCC_PATCHLEVEL__],,
  102. AC_MSG_FAILURE([[[$0]] unknown pathscale patch level]))
  103. ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
  104. ])
  105. # for clang
  106. AC_DEFUN([_AX_COMPILER_VERSION_CLANG],[
  107. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
  108. __clang_major__,,
  109. AC_MSG_FAILURE([[[$0]] unknown clang major]))
  110. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
  111. __clang_minor__,,
  112. AC_MSG_FAILURE([[[$0]] unknown clang minor]))
  113. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
  114. [__clang_patchlevel__],,0)
  115. ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
  116. ])
  117. # for crayc
  118. AC_DEFUN([_AX_COMPILER_VERSION_CRAY],[
  119. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
  120. _RELEASE,,
  121. AC_MSG_FAILURE([[[$0]] unknown crayc release]))
  122. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
  123. _RELEASE_MINOR,,
  124. AC_MSG_FAILURE([[[$0]] unknown crayc minor]))
  125. ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor"
  126. ])
  127. # for fujitsu
  128. AC_DEFUN([_AX_COMPILER_VERSION_FUJITSU],[
  129. AC_COMPUTE_INT(ax_cv_[]_AC_LANG_ABBREV[]_compiler_version,
  130. __FCC_VERSION,,
  131. AC_MSG_FAILURE([[[$0]]unknown fujitsu release]))
  132. ])
  133. # for GNU
  134. AC_DEFUN([_AX_COMPILER_VERSION_GNU],[
  135. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
  136. __GNUC__,,
  137. AC_MSG_FAILURE([[[$0]] unknown gcc major]))
  138. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
  139. __GNUC_MINOR__,,
  140. AC_MSG_FAILURE([[[$0]] unknown gcc minor]))
  141. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
  142. [__GNUC_PATCHLEVEL__],,
  143. AC_MSG_FAILURE([[[$0]] unknown gcc patch level]))
  144. ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
  145. ])
  146. # For sun
  147. AC_DEFUN([_AX_COMPILER_VERSION_SUN],[
  148. m4_define([_AX_COMPILER_VERSION_SUN_NUMBER],
  149. [
  150. #if defined(__SUNPRO_CC)
  151. __SUNPRO_CC
  152. #else
  153. __SUNPRO_C
  154. #endif
  155. ])
  156. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_until59,
  157. !!(_AX_COMPILER_VERSION_SUN_NUMBER < 0x1000),,
  158. AC_MSG_FAILURE([[[$0]] unknown sun release version]))
  159. AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_until59" = X1],
  160. [dnl
  161. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
  162. _AX_COMPILER_VERSION_SUN_NUMBER % 0x10,,
  163. AC_MSG_FAILURE([[[$0]] unknown sun patch version]))
  164. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
  165. (_AX_COMPILER_VERSION_SUN_NUMBER / 0x10) % 0x10,,
  166. AC_MSG_FAILURE([[[$0]] unknown sun minor version]))
  167. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
  168. (_AX_COMPILER_VERSION_SUN_NUMBER / 0x100),,
  169. AC_MSG_FAILURE([[[$0]] unknown sun major version]))
  170. ],
  171. [dnl
  172. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
  173. _AX_COMPILER_VERSION_SUN_NUMBER % 0x10,,
  174. AC_MSG_FAILURE([[[$0]] unknown sun patch version]))
  175. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
  176. (_AX_COMPILER_VERSION_SUN_NUMBER / 0x100) % 0x100,,
  177. AC_MSG_FAILURE([[[$0]] unknown sun minor version]))
  178. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
  179. (_AX_COMPILER_VERSION_SUN_NUMBER / 0x1000),,
  180. AC_MSG_FAILURE([[[$0]] unknown sun major version]))
  181. ])
  182. ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
  183. ])
  184. AC_DEFUN([_AX_COMPILER_VERSION_HP],[
  185. m4_define([_AX_COMPILER_VERSION_HP_NUMBER],
  186. [
  187. #if defined(__HP_cc)
  188. __HP_cc
  189. #else
  190. __HP_aCC
  191. #endif
  192. ])
  193. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_untilA0121,
  194. !!(_AX_COMPILER_VERSION_HP_NUMBER <= 1),,
  195. AC_MSG_FAILURE([[[$0]] unknown hp release version]))
  196. AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_untilA0121" = X1],
  197. [dnl By default output last version with this behavior.
  198. dnl it is so old
  199. ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="01.21.00"
  200. ],
  201. [dnl
  202. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
  203. (_AX_COMPILER_VERSION_HP_NUMBER % 100),,
  204. AC_MSG_FAILURE([[[$0]] unknown hp release version]))
  205. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
  206. ((_AX_COMPILER_VERSION_HP_NUMBER / 100)%100),,
  207. AC_MSG_FAILURE([[[$0]] unknown hp minor version]))
  208. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
  209. ((_AX_COMPILER_VERSION_HP_NUMBER / 10000)%100),,
  210. AC_MSG_FAILURE([[[$0]] unknown hp major version]))
  211. ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
  212. ])
  213. ])
  214. AC_DEFUN([_AX_COMPILER_VERSION_DEC],[dnl
  215. m4_define([_AX_COMPILER_VERSION_DEC_NUMBER],
  216. [
  217. #if defined(__DECC_VER)
  218. __DECC_VER
  219. #else
  220. __DECCXX_VER
  221. #endif
  222. ])
  223. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
  224. (_AX_COMPILER_VERSION_DEC_NUMBER % 10000),,
  225. AC_MSG_FAILURE([[[$0]] unknown dec release version]))
  226. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
  227. ((_AX_COMPILER_VERSION_DEC_NUMBER / 100000UL)%100),,
  228. AC_MSG_FAILURE([[[$0]] unknown dec minor version]))
  229. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
  230. ((_AX_COMPILER_VERSION_DEC_NUMBER / 10000000UL)%100),,
  231. AC_MSG_FAILURE([[[$0]] unknown dec major version]))
  232. ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
  233. ])
  234. # borland
  235. AC_DEFUN([_AX_COMPILER_VERSION_BORLAND],[dnl
  236. m4_define([_AX_COMPILER_VERSION_TURBOC_NUMBER],
  237. [
  238. #if defined(__TURBOC__)
  239. __TURBOC__
  240. #else
  241. choke me
  242. #endif
  243. ])
  244. m4_define([_AX_COMPILER_VERSION_BORLANDC_NUMBER],
  245. [
  246. #if defined(__BORLANDC__)
  247. __BORLANDC__
  248. #else
  249. __CODEGEARC__
  250. #endif
  251. ])
  252. AC_COMPILE_IFELSE(
  253. [AC_LANG_PROGRAM(,
  254. _AX_COMPILER_VERSION_TURBOC_NUMBER)],
  255. [dnl TURBOC
  256. AC_COMPUTE_INT(
  257. _ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw,
  258. _AX_COMPILER_VERSION_TURBOC_NUMBER,,
  259. AC_MSG_FAILURE([[[$0]] unknown turboc version]))
  260. AS_IF(
  261. [test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw -lt 661 || test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw -gt 1023],
  262. [dnl compute normal version
  263. AC_COMPUTE_INT(
  264. _ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
  265. _AX_COMPILER_VERSION_TURBOC_NUMBER % 0x100,,
  266. AC_MSG_FAILURE([[[$0]] unknown turboc minor version]))
  267. AC_COMPUTE_INT(
  268. _ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
  269. (_AX_COMPILER_VERSION_TURBOC_NUMBER/0x100)%0x100,,
  270. AC_MSG_FAILURE([[[$0]] unknown turboc major version]))
  271. ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor"],
  272. [dnl special version
  273. AS_CASE([$_ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw],
  274. [661],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:1.00"],
  275. [662],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:1.01"],
  276. [663],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:2.00"],
  277. [
  278. AC_MSG_WARN([[[$0]] unknown turboc version between 0x295 and 0x400 please report bug])
  279. ax_cv_[]_AC_LANG_ABBREV[]_compiler_version=""
  280. ])
  281. ])
  282. ],
  283. # borlandc
  284. [
  285. AC_COMPUTE_INT(
  286. _ax_[]_AC_LANG_ABBREV[]_compiler_version_borlandc_raw,
  287. _AX_COMPILER_VERSION_BORLANDC_NUMBER,,
  288. AC_MSG_FAILURE([[[$0]] unknown borlandc version]))
  289. AS_CASE([$_ax_[]_AC_LANG_ABBREV[]_compiler_version_borlandc_raw],
  290. dnl BORLANDC++ before 5.5
  291. [512] ,[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:2.00"],
  292. [1024],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:3.00"],
  293. [1024],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:3.00"],
  294. [1040],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:3.1"],
  295. [1106],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:4.0"],
  296. [1280],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:5.0"],
  297. [1312],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:5.02"],
  298. dnl C++ Builder era
  299. [1328],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="2cppbuilder:3.0"],
  300. [1344],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="2cppbuilder:4.0"],
  301. dnl BORLANDC++ after 5.5
  302. [1360],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="3borlancpp:5.5"],
  303. [1361],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="3borlancpp:5.51"],
  304. [1378],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="3borlancpp:5.6.4"],
  305. dnl C++ Builder with year number
  306. [1392],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2006"],
  307. [1424],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2007"],
  308. [1555],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2009"],
  309. [1569],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2010"],
  310. dnl XE version
  311. [1584],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe"],
  312. [1600],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe:2"],
  313. [1616],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe:3"],
  314. [1632],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe:4"],
  315. [
  316. AC_MSG_WARN([[[$0]] Unknown borlandc compiler version $_ax_[]_AC_LANG_ABBREV[]_compiler_version_borlandc_raw please report bug])
  317. ])
  318. ])
  319. ])
  320. # COMO
  321. AC_DEFUN([_AX_COMPILER_VERSION_COMEAU],
  322. [ dnl
  323. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
  324. [__COMO_VERSION__%100],,
  325. AC_MSG_FAILURE([[[$0]] unknown comeau compiler minor version]))
  326. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
  327. [(__COMO_VERSION__/100)%10],,
  328. AC_MSG_FAILURE([[[$0]] unknown comeau compiler major version]))
  329. ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor"
  330. ])
  331. # KAI
  332. AC_DEFUN([_AX_COMPILER_VERSION_KAI],[
  333. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
  334. [__KCC_VERSION%100],,
  335. AC_MSG_FAILURE([[[$0]] unknown kay compiler patch version]))
  336. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
  337. [(__KCC_VERSION/100)%10],,
  338. AC_MSG_FAILURE([[[$0]] unknown kay compiler minor version]))
  339. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
  340. [(__KCC_VERSION/1000)%10],,
  341. AC_MSG_FAILURE([[[$0]] unknown kay compiler major version]))
  342. ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
  343. ])
  344. dnl LCC
  345. dnl LCC does not output version...
  346. # SGI
  347. AC_DEFUN([_AX_COMPILER_VERSION_SGI],[
  348. m4_define([_AX_COMPILER_VERSION_SGI_NUMBER],
  349. [
  350. #if defined(_COMPILER_VERSION)
  351. _COMPILER_VERSION
  352. #else
  353. _SGI_COMPILER_VERSION
  354. #endif
  355. ])
  356. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
  357. [_AX_COMPILER_VERSION_SGI_NUMBER%10],,
  358. AC_MSG_FAILURE([[[$0]] unknown SGI compiler patch version]))
  359. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
  360. [(_AX_COMPILER_VERSION_SGI_NUMBER/10)%10],,
  361. AC_MSG_FAILURE([[[$0]] unknown SGI compiler minor version]))
  362. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
  363. [(_AX_COMPILER_VERSION_SGI_NUMBER/100)%10],,
  364. AC_MSG_FAILURE([[[$0]] unknown SGI compiler major version]))
  365. ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
  366. ])
  367. # microsoft
  368. AC_DEFUN([_AX_COMPILER_VERSION_MICROSOFT],[
  369. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
  370. _MSC_VER%100,,
  371. AC_MSG_FAILURE([[[$0]] unknown microsoft compiler minor version]))
  372. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
  373. (_MSC_VER/100)%100,,
  374. AC_MSG_FAILURE([[[$0]] unknown microsoft compiler major version]))
  375. dnl could be overridden
  376. _ax_[]_AC_LANG_ABBREV[]_compiler_version_patch=0
  377. _ax_[]_AC_LANG_ABBREV[]_compiler_version_build=0
  378. # special case for version 6
  379. AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major" = "X12"],
  380. [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
  381. _MSC_FULL_VER%1000,,
  382. _ax_[]_AC_LANG_ABBREV[]_compiler_version_patch=0)])
  383. # for version 7
  384. AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major" = "X13"],
  385. [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
  386. _MSC_FULL_VER%1000,,
  387. AC_MSG_FAILURE([[[$0]] unknown microsoft compiler patch version]))
  388. ])
  389. # for version > 8
  390. AS_IF([test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_major -ge 14],
  391. [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
  392. _MSC_FULL_VER%10000,,
  393. AC_MSG_FAILURE([[[$0]] unknown microsoft compiler patch version]))
  394. ])
  395. AS_IF([test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_major -ge 15],
  396. [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_build,
  397. _MSC_BUILD,,
  398. AC_MSG_FAILURE([[[$0]] unknown microsoft compiler build version]))
  399. ])
  400. ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_build"
  401. ])
  402. # for metrowerks
  403. AC_DEFUN([_AX_COMPILER_VERSION_METROWERKS],[dnl
  404. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
  405. __MWERKS__%0x100,,
  406. AC_MSG_FAILURE([[[$0]] unknown metrowerks compiler patch version]))
  407. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
  408. (__MWERKS__/0x100)%0x10,,
  409. AC_MSG_FAILURE([[[$0]] unknown metrowerks compiler minor version]))
  410. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
  411. (__MWERKS__/0x1000)%0x10,,
  412. AC_MSG_FAILURE([[[$0]] unknown metrowerks compiler major version]))
  413. ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
  414. ])
  415. # for watcom
  416. AC_DEFUN([_AX_COMPILER_VERSION_WATCOM],[dnl
  417. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
  418. __WATCOMC__%100,,
  419. AC_MSG_FAILURE([[[$0]] unknown watcom compiler minor version]))
  420. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
  421. (__WATCOMC__/100)%100,,
  422. AC_MSG_FAILURE([[[$0]] unknown watcom compiler major version]))
  423. ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor"
  424. ])
  425. # for PGI
  426. AC_DEFUN([_AX_COMPILER_VERSION_PORTLAND],[
  427. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
  428. __PGIC__,,
  429. AC_MSG_FAILURE([[[$0]] unknown pgi major]))
  430. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
  431. __PGIC_MINOR__,,
  432. AC_MSG_FAILURE([[[$0]] unknown pgi minor]))
  433. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
  434. [__PGIC_PATCHLEVEL__],,
  435. AC_MSG_FAILURE([[[$0]] unknown pgi patch level]))
  436. ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
  437. ])
  438. # tcc
  439. AC_DEFUN([_AX_COMPILER_VERSION_TCC],[
  440. ax_cv_[]_AC_LANG_ABBREV[]_compiler_version=[`tcc -v | $SED 's/^[ ]*tcc[ ]\+version[ ]\+\([0-9.]\+\).*/\1/g'`]
  441. ])
  442. # for GNU
  443. AC_DEFUN([_AX_COMPILER_VERSION_SDCC],[
  444. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major,
  445. /* avoid parse error with comments */
  446. #if(defined(__SDCC_VERSION_MAJOR))
  447. __SDCC_VERSION_MAJOR
  448. #else
  449. SDCC/100
  450. #endif
  451. ,,
  452. AC_MSG_FAILURE([[[$0]] unknown sdcc major]))
  453. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor,
  454. /* avoid parse error with comments */
  455. #if(defined(__SDCC_VERSION_MINOR))
  456. __SDCC_VERSION_MINOR
  457. #else
  458. (SDCC%100)/10
  459. #endif
  460. ,,
  461. AC_MSG_FAILURE([[[$0]] unknown sdcc minor]))
  462. AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch,
  463. [
  464. /* avoid parse error with comments */
  465. #if(defined(__SDCC_VERSION_PATCH))
  466. __SDCC_VERSION_PATCH
  467. #elsif(defined(_SDCC_VERSION_PATCHLEVEL))
  468. __SDCC_VERSION_PATCHLEVEL
  469. #else
  470. SDCC%10
  471. #endif
  472. ],,
  473. AC_MSG_FAILURE([[[$0]] unknown sdcc patch level]))
  474. ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch"
  475. ])
  476. # main entry point
  477. AC_DEFUN([AX_COMPILER_VERSION],[dnl
  478. AC_REQUIRE([AX_COMPILER_VENDOR])
  479. AC_REQUIRE([AC_PROG_SED])
  480. AC_CACHE_CHECK([for _AC_LANG compiler version],
  481. ax_cv_[]_AC_LANG_ABBREV[]_compiler_version,
  482. [ dnl
  483. AS_CASE([$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor],
  484. [intel],[_AX_COMPILER_VERSION_INTEL],
  485. [ibm],[_AX_COMPILER_VERSION_IBM],
  486. [pathscale],[_AX_COMPILER_VERSION_PATHSCALE],
  487. [clang],[_AX_COMPILER_VERSION_CLANG],
  488. [cray],[_AX_COMPILER_VERSION_CRAY],
  489. [fujitsu],[_AX_COMPILER_VERSION_FUJITSU],
  490. [gnu],[_AX_COMPILER_VERSION_GNU],
  491. [sun],[_AX_COMPILER_VERSION_SUN],
  492. [hp],[_AX_COMPILER_VERSION_HP],
  493. [dec],[_AX_COMPILER_VERSION_DEC],
  494. [borland],[_AX_COMPILER_VERSION_BORLAND],
  495. [comeau],[_AX_COMPILER_VERSION_COMEAU],
  496. [kai],[_AX_COMPILER_VERSION_KAI],
  497. [sgi],[_AX_COMPILER_VERSION_SGI],
  498. [microsoft],[_AX_COMPILER_VERSION_MICROSOFT],
  499. [metrowerks],[_AX_COMPILER_VERSION_METROWERKS],
  500. [watcom],[_AX_COMPILER_VERSION_WATCOM],
  501. [portland],[_AX_COMPILER_VERSION_PORTLAND],
  502. [tcc],[_AX_COMPILER_VERSION_TCC],
  503. [sdcc],[_AX_COMPILER_VERSION_SDCC],
  504. [ax_cv_[]_AC_LANG_ABBREV[]_compiler_version=""])
  505. ])
  506. ])