File: ax_compiler_version.m4

package info (click to toggle)
povray 1%3A3.7.0.10-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 147,232 kB
  • sloc: cpp: 845,011; ansic: 122,118; sh: 34,204; pascal: 6,420; asm: 3,355; ada: 1,681; makefile: 1,389; cs: 879; awk: 590; perl: 245; xml: 95
file content (61 lines) | stat: -rw-r--r-- 2,009 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# SYNOPSIS
#
#   AX_COMPILER_VERSION
#
# DESCRIPTION
#
#   Try to determine the version of the current compiler.
#   Result is output in $ax_compiler_version
#
#
# LAST MODIFICATION
#
#   2009-01-16
#
# COPYLEFT
#
#   Copyright (c) 2009 Nicolas Calimet
#
#   Copying and distribution of this file, with or without
#   modification, are permitted in any medium without royalty provided
#   the copyright notice and this notice are preserved.

AC_DEFUN([AX_COMPILER_VERSION],
[
  AC_REQUIRE([AC_PROG_EGREP])
  ax_compiler_version=

  # get current compiler; don't use $ac_compiler
  eval ax_compiler=`set X $ac_compile; echo $[2]`
  AC_MSG_CHECKING([for $ax_compiler version])

  filter1="$EGREP [[0-9]]"
  filter2="tr A-Z a-z | $EGREP version | sed 's,\(.*version[[[:space:]]]*\)\(.*\),\2,'"
  filter3="head -n 1 | sed 's,.*[[[:space:]]],,'"

  # check for various version options and remove leading/trailing blanks
  for ax_compiler_version_option_filter in -dumpversion:filter1 -v:filter2 -V:filter2 --version:filter3
  do
    if test x"$ax_compiler_version" = x""; then
      ax_compiler_version_option=`echo $ax_compiler_version_option_filter | cut -d: -f1`
      ax_compiler_version_filter=`echo $ax_compiler_version_option_filter | cut -d: -f2`
      eval ax_compiler_version_filter=\$$ax_compiler_version_filter
      ax_compiler_version_try="$ax_compiler $ax_compiler_version_option < /dev/null > conftest.out 2>&1"
      echo try option $ax_compiler_version_option with filter \"$ax_compiler_version_filter\" >&AS_MESSAGE_LOG_FD
      echo $ax_compiler_version_try >&AS_MESSAGE_LOG_FD
      eval $ax_compiler_version_try
      cat conftest.out >&AS_MESSAGE_LOG_FD
      ax_compiler_version=`eval cat conftest.out \| $ax_compiler_version_filter`
      ax_compiler_version=`echo $ax_compiler_version`
    fi
  done

  # print compiler version string
  if test x"$ax_compiler_version" = x""; then
    AC_MSG_RESULT([unkown])
  else
    AC_MSG_RESULT([$ax_compiler_version])
  fi

  rm -f conftest.out
])