]>
git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/scripts/detect_cc.sh
10 err
"Detect compiler and linker versions, generate mk/cc.mk"
12 err
"Usage: ./detect_cc.sh [OPTION]..."
14 err
"Defaults for the options are specified in brackets."
17 err
" -h, --help Display this help and exit"
18 err
" --cc=path C compiler to use"
19 err
" --cxx=path C++ compiler to use"
20 err
" --ld=path Linker to use"
21 err
" --lto=[y|n] Attempt to configure for LTO"
22 err
" --cross-prefix=prefix Use the given prefix for the cross compiler toolchain"
32 if [[ -n "${i#*=}" ]]; then
37 if [[ -n "${i#*=}" ]]; then
42 if [[ -n "${i#*=}" ]]; then
47 if [[ -n "${i#*=}" ]]; then
52 if [[ -n "${i#*=}" ]]; then
53 CROSS_PREFIX
="${i#*=}"
60 err
"Unrecognized option $i"
76 if [ "$OS" = "Linux" ]; then
79 if [ "$OS" = "FreeBSD" ]; then
84 CC_TYPE
=$
($CC -v 2>&1 |
grep -o -E '\w+ version' |
head -1 |
awk '{ print $1 }')
85 CXX_TYPE
=$
($CXX -v 2>&1 |
grep -o -E '\w+ version' |
head -1 |
awk '{ print $1 }')
86 if [ "$CC_TYPE" != "$CXX_TYPE" ]; then
87 err
"C compiler is $CC_TYPE but C++ compiler is $CXX_TYPE"
88 err
"This may result in errors"
91 LD_TYPE
=$
($LD --version 2>&1 |
head -n1 |
awk '{print $1, $2}')
103 err
"Unsupported linker: $LD"
109 if [ "$LTO" = "y" ]; then
110 if [ "$CC_TYPE" = "clang" ]; then
111 if [ "$LD_TYPE" != "gold" ]; then
112 err
"Using LTO with clang requires the gold linker."
121 if [ -n "$CROSS_PREFIX" ]; then
122 expected_prefix
=$
($CC -dumpmachine)
124 if [ ! "$expected_prefix" = "$CROSS_PREFIX" ]; then
125 err
"Cross prefix specified ($CROSS_PREFIX) does not match prefix of $CC ($expected_prefix)."
127 # Try to fix this automatically. Maybe the user set CROSS_PREFIX but not CC.
129 if hash $CC 2> /dev
/null
; then
130 expected_prefix
=$
($CC -dumpmachine)
132 if [ "$expected_prefix" = "$CROSS_PREFIX" ]; then
133 err
"Automatically changed CC to $CC"
135 err
"Set CC to the appropriate compiler."
139 err
"Set CC to the appropriate compiler."
145 expected_prefix
=$
($CXX -dumpmachine)
147 if [ ! "$expected_prefix" = "$CROSS_PREFIX" ]; then
148 err
"Cross prefix specified ($CROSS_PREFIX) does not match prefix of $CXX ($expected_prefix)."
150 # Try to fix this automatically. Maybe the user set CROSS_PREFIX but not CXX.
151 CXX
=$CROSS_PREFIX-$CXX
152 if hash $CXX 2> /dev
/null
; then
153 expected_prefix
=$
($CXX -dumpmachine)
155 if [ "$expected_prefix" = "$CROSS_PREFIX" ]; then
156 err
"Automatically changed CXX to $CXX"
158 err
"Set CXX to the appropriate compiler."
162 err
"Set CXX to the appropriate compiler."
168 function set_default
() {
170 echo "ifeq (\$(origin $1),default)"
177 set_default CXX
"$CXX"
181 echo "CC_TYPE=$CC_TYPE"
182 echo "LD_TYPE=$LD_TYPE"
184 if [ -n "$CROSS_PREFIX" ]; then
185 echo "CROSS_PREFIX=$CROSS_PREFIX"