Blame view

scripts/gcc-version.sh 588 Bytes
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
  #!/bin/sh
b24413180   Greg Kroah-Hartman   License cleanup: ...
2
  # SPDX-License-Identifier: GPL-2.0
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3
  #
fa7295ab6   Masahiro Yamada   kbuild: clean up ...
4
  # gcc-version gcc-command
0ab2a272e   Segher Boessenkool   kbuild: New 'cc-f...
5
  #
fa7295ab6   Masahiro Yamada   kbuild: clean up ...
6
7
  # Print the gcc version of `gcc-command' in a 5 or 6-digit form
  # such as `29503' for gcc-2.95.3, `30301' for gcc-3.3.1, etc.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
8
9
  
  compiler="$*"
de47062a1   Jesper Juhl   kbuild: improve s...
10
  if [ ${#compiler} -eq 0 ]; then
fa7295ab6   Masahiro Yamada   kbuild: clean up ...
11
12
13
14
  	echo "Error: No compiler specified." >&2
  	printf "Usage:
  \t$0 <gcc-command>
  " >&2
de47062a1   Jesper Juhl   kbuild: improve s...
15
16
  	exit 1
  fi
b1e0d8b70   Jean Delvare   kbuild: Fix gcc -...
17
18
  MAJOR=$(echo __GNUC__ | $compiler -E -x c - | tail -n 1)
  MINOR=$(echo __GNUC_MINOR__ | $compiler -E -x c - | tail -n 1)
fa7295ab6   Masahiro Yamada   kbuild: clean up ...
19
20
21
  PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -x c - | tail -n 1)
  printf "%d%02d%02d\
  " $MAJOR $MINOR $PATCHLEVEL