THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Git Source Code Mirror - This is a publish-only repository and all pull requests are ignored. Please follow Documentation/SubmittingPatches procedure for any of your improvements.
git
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1016B

  1. #!/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. CC="$*"
  6. # we get something like (this is at least true for gcc and clang)
  7. #
  8. # FreeBSD clang version 3.4.1 (tags/RELEASE...)
  9. get_version_line() {
  10. $CC -v 2>&1 | grep ' version '
  11. }
  12. get_family() {
  13. get_version_line | sed 's/^\(.*\) version [0-9][^ ]* .*/\1/'
  14. }
  15. get_version() {
  16. get_version_line | sed 's/^.* version \([0-9][^ ]*\) .*/\1/'
  17. }
  18. print_flags() {
  19. family=$1
  20. version=$(get_version | cut -f 1 -d .)
  21. # Print a feature flag not only for the current version, but also
  22. # for any prior versions we encompass. This avoids needing to do
  23. # numeric comparisons in make, which are awkward.
  24. while test "$version" -gt 0
  25. do
  26. echo $family$version
  27. version=$((version - 1))
  28. done
  29. }
  30. case "$(get_family)" in
  31. gcc)
  32. print_flags gcc
  33. ;;
  34. clang)
  35. print_flags clang
  36. ;;
  37. "FreeBSD clang")
  38. print_flags clang
  39. ;;
  40. "Apple LLVM")
  41. print_flags clang
  42. ;;
  43. *)
  44. : unknown compiler family
  45. ;;
  46. esac