+# Tell whether "gcc" is a symlink to Clang (this is the case on macOS).
+gcc_is_clang_in_disguise() {
+ case `cc_id`/`basename "${CC:?}"` in
+ clang-*/gcc)
+ return 0
+ ;;
+ esac
+ return 1
+}
+
+os_id() {
+ # OS does not change between builds or in the middle of a build, so it is
+ # fine to cache uname output.
+ : "${os_id_sysname:=`uname -s`}"
+ printf '%s-' "$os_id_sysname"
+ : "${os_id_release:=`uname -r`}"
+ case "$os_id_sysname" in
+ AIX)
+ : "${os_id_version:=`uname -v`}"
+ echo "${os_id_version}.${os_id_release}"
+ ;;
+ Darwin|NetBSD|OpenBSD|SunOS)
+ echo "$os_id_release"
+ ;;
+ FreeBSD|Linux)
+ # Meaningful version is usually the substring before the first dash.
+ echo "$os_id_release" | sed 's/^\([0-9\.]*\).*$/\1/'
+ ;;
+ Haiku)
+ # Meaningful version is the substring before the plus sign.
+ # "hrev56578" stands for "R1/beta4".
+ # "hrev55181" stands for "R1/beta3".
+ # "hrev54154" stands for "R1/beta2".
+ : "${os_id_version:=`uname -v`}"
+ echo "$os_id_version" | sed 's/^\(hrev.*\)+.*$/\1/'
+ ;;
+ *)
+ echo 'UNKNOWN'
+ ;;
+ esac
+}
+