transport-helper: drop read/write errno checks
[git.git] / detect-compiler
blob70b754481c877cab3d7f87cf08b7403846925860
1 #!/bin/sh
3 # Probe the compiler for vintage, version, etc. This is used for setting
4 # optional make knobs under the DEVELOPER knob.
6 CC="$*"
8 # we get something like (this is at least true for gcc and clang)
10 # FreeBSD clang version 3.4.1 (tags/RELEASE...)
11 get_version_line() {
12 $CC -v 2>&1 | grep ' version '
15 get_family() {
16 get_version_line | sed 's/^\(.*\) version [0-9][^ ]* .*/\1/'
19 get_version() {
20 get_version_line | sed 's/^.* version \([0-9][^ ]*\) .*/\1/'
23 print_flags() {
24 family=$1
25 version=$(get_version | cut -f 1 -d .)
27 # Print a feature flag not only for the current version, but also
28 # for any prior versions we encompass. This avoids needing to do
29 # numeric comparisons in make, which are awkward.
30 while test "$version" -gt 0
32 echo $family$version
33 version=$((version - 1))
34 done
37 case "$(get_family)" in
38 gcc)
39 print_flags gcc
41 clang)
42 print_flags clang
44 "FreeBSD clang")
45 print_flags clang
47 "Apple LLVM")
48 print_flags clang
51 : unknown compiler family
53 esac