Last active
July 13, 2018 18:34
-
-
Save sunhay/2ca7304a4360b70d93d41333d6024cb4 to your computer and use it in GitHub Desktop.
Checking c compiler (from musl configure)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo () { printf "%s\n" "$*" ; } | |
fail () { echo "$*" ; exit 1 ; } | |
fnmatch () { eval "case \"\$2\" in $1) return 0 ;; *) return 1 ;; esac" ; } | |
cmdexists () { type "$1" >/dev/null 2>&1 ; } | |
trycc () { test -z "$CC" && cmdexists "$1" && CC=$1 ; } | |
printf "checking for C compiler... " | |
trycc ${CROSS_COMPILE}gcc | |
trycc ${CROSS_COMPILE}c99 | |
trycc ${CROSS_COMPILE}cc | |
printf "%s\n" "$CC" | |
test -n "$CC" || { echo "$0: cannot find a C compiler" ; exit 1 ; } | |
printf "checking for C compiler family... " | |
cc_ver="$(LC_ALL=C $CC -v 2>&1)" | |
cc_family=unknown | |
if fnmatch '*gcc\ version*' "$cc_ver" ; then | |
cc_family=gcc | |
elif fnmatch '*clang\ version*' "$cc_ver" ; then | |
cc_family=clang | |
fi | |
echo "$cc_family" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment