| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # |
| 3 | # Probe the compiler for vintage, version, etc. This is used for setting |
| 4 | # optional make knobs under the DEVELOPER knob. |
| 5 | |
| 6 | CC="$*" |
| 7 | |
| 8 | # we get something like (this is at least true for gcc and clang) |
| 9 | # |
| 10 | # FreeBSD clang version 3.4.1 (tags/RELEASE...) |
| 11 | get_version_linescip-shell shell shell-project 0.0.0 get_version_line().() { |
| 12 | LANG=C LC_ALL=C $CC -v 2>&1 | sedscip-shell system . . sed. -n '/ version /{p;q;}scip-shell filesystem . . `/ version /{p;q;}`.' |
| 13 | } |
| 14 | |
| 15 | get_familyscip-shell shell shell-project 0.0.0 get_family().() { |
| 16 | get_version_linescip-shell shell shell-project 0.0.0 get_version_line(). | sedscip-shell system . . sed. 's/^\(.*\) version [0-9].*/\1/' |
| 17 | } |
| 18 | |
| 19 | get_versionscip-shell shell shell-project 0.0.0 get_version().() { |
| 20 | # A string that begins with a digit up to the next SP |
| 21 | ver=$(get_version_linescip-shell shell shell-project 0.0.0 get_version_line(). | sedscip-shell system . . sed. 's/^.* version \([0-9][^ ]*\).*/\1/') |
| 22 | |
| 23 | # There are known -variant suffixes that do not affect the |
| 24 | # meaning of the main version number. Strip them. |
| 25 | ver=${ver%-win32} |
| 26 | ver=${ver%-posix} |
| 27 | |
| 28 | echoscip-shell system . . echo. "$ver" |
| 29 | } |
| 30 | |
| 31 | print_flagsscip-shell shell shell-project 0.0.0 print_flags().() { |
| 32 | family=$1 |
| 33 | version=$(get_versionscip-shell shell shell-project 0.0.0 get_version(). | cutscip-shell system . . cut. -f 1 -d .) |
| 34 | |
| 35 | # Print a feature flag not only for the current version, but also |
| 36 | # for any prior versions we encompass. This avoids needing to do |
| 37 | # numeric comparisons in make, which are awkward. |
| 38 | while testscip-shell system . . test. "$version" -gt 0 |
| 39 | do |
| 40 | echoscip-shell system . . echo. $family$version |
| 41 | version=$((version - 1)) |
| 42 | done |
| 43 | } |
| 44 | |
| 45 | case "$(get_familyscip-shell shell shell-project 0.0.0 get_family().)" in |
| 46 | gcc) |
| 47 | print_flagsscip-shell shell shell-project 0.0.0 print_flags(). gcc |
| 48 | ;; |
| 49 | clang | *" clang") |
| 50 | print_flagsscip-shell shell shell-project 0.0.0 print_flags(). clang |
| 51 | ;; |
| 52 | "Apple LLVM") |
| 53 | print_flagsscip-shell shell shell-project 0.0.0 print_flags(). clang |
| 54 | ;; |
| 55 | *) |
| 56 | : unknown compiler family |
| 57 | ;; |
| 58 | esac |