Sun, 12 Jan 2025 12:40:20 +0100
add command check to check_c_compiler/check_cpp_compiler, because some shells print an error if it doesn't exist
0
38775db5fdf5
add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | #!/bin/sh |
38775db5fdf5
add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | # |
38775db5fdf5
add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | # toolchain detection |
38775db5fdf5
add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | # |
38775db5fdf5
add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | |
101
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
6 | if isplatform "bsd" && notisplatform "openbsd"; then |
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
7 | C_COMPILERS="clang gcc cc" |
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
8 | CPP_COMPILERS="clang++ g++ CC" |
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
9 | else |
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
10 | C_COMPILERS="gcc clang suncc cc" |
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
11 | CPP_COMPILERS="g++ clang++ sunCC CC" |
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
12 | fi |
105
4b3e655339cb
improve toolchain detection
Mike Becker <universe@uap-core.de>
parents:
101
diff
changeset
|
13 | unset TOOLCHAIN |
0
38775db5fdf5
add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | unset TOOLCHAIN_NAME |
52
afcb57893858
major evolution of configure template - fixes #283
Mike Becker <universe@uap-core.de>
parents:
51
diff
changeset
|
15 | unset TOOLCHAIN_CC |
afcb57893858
major evolution of configure template - fixes #283
Mike Becker <universe@uap-core.de>
parents:
51
diff
changeset
|
16 | unset TOOLCHAIN_CXX |
0
38775db5fdf5
add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | |
8
82cd9f1d94cb
add c++ compiler detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
18 | check_c_compiler() |
0
38775db5fdf5
add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | { |
132
e0478362c2cf
add command check to check_c_compiler/check_cpp_compiler, because some shells print an error if it doesn't exist
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
20 | command -v $1 2>&1 >/dev/null |
e0478362c2cf
add command check to check_c_compiler/check_cpp_compiler, because some shells print an error if it doesn't exist
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
21 | if [ $? -ne 0 ]; then |
e0478362c2cf
add command check to check_c_compiler/check_cpp_compiler, because some shells print an error if it doesn't exist
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
22 | return 1 |
e0478362c2cf
add command check to check_c_compiler/check_cpp_compiler, because some shells print an error if it doesn't exist
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
23 | fi |
101
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
24 | cat > "$TEMP_DIR/test.c" << __EOF__ |
0
38775db5fdf5
add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
25 | /* test file */ |
38775db5fdf5
add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | #include <stdio.h> |
38775db5fdf5
add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | int main(int argc, char **argv) { |
105
4b3e655339cb
improve toolchain detection
Mike Becker <universe@uap-core.de>
parents:
101
diff
changeset
|
28 | #if defined(_MSC_VER) |
4b3e655339cb
improve toolchain detection
Mike Becker <universe@uap-core.de>
parents:
101
diff
changeset
|
29 | printf("msc\n"); |
4b3e655339cb
improve toolchain detection
Mike Becker <universe@uap-core.de>
parents:
101
diff
changeset
|
30 | #elif defined(__clang__) |
4b3e655339cb
improve toolchain detection
Mike Becker <universe@uap-core.de>
parents:
101
diff
changeset
|
31 | printf("clang gnuc\n"); |
15
971ac4f0f1df
fix toolchain detection in case gcc is not available
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
13
diff
changeset
|
32 | #elif defined(__GNUC__) |
105
4b3e655339cb
improve toolchain detection
Mike Becker <universe@uap-core.de>
parents:
101
diff
changeset
|
33 | printf("gcc gnuc\n"); |
0
38775db5fdf5
add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
34 | #elif defined(__sun) |
101
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
35 | printf("suncc\n"); |
0
38775db5fdf5
add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
36 | #else |
101
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
37 | printf("unknown\n"); |
0
38775db5fdf5
add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
38 | #endif |
101
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
39 | return 0; |
0
38775db5fdf5
add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
40 | } |
38775db5fdf5
add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
41 | __EOF__ |
101
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
42 | rm -f "$TEMP_DIR/checkcc" |
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
43 | $1 -o "$TEMP_DIR/checkcc" $CFLAGS $LDFLAGS "$TEMP_DIR/test.c" 2> /dev/null |
8
82cd9f1d94cb
add c++ compiler detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
44 | } |
82cd9f1d94cb
add c++ compiler detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
45 | |
82cd9f1d94cb
add c++ compiler detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
46 | check_cpp_compiler() |
82cd9f1d94cb
add c++ compiler detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
47 | { |
132
e0478362c2cf
add command check to check_c_compiler/check_cpp_compiler, because some shells print an error if it doesn't exist
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
48 | command -v $1 2>&1 >/dev/null |
e0478362c2cf
add command check to check_c_compiler/check_cpp_compiler, because some shells print an error if it doesn't exist
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
49 | if [ $? -ne 0 ]; then |
e0478362c2cf
add command check to check_c_compiler/check_cpp_compiler, because some shells print an error if it doesn't exist
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
50 | return 1 |
e0478362c2cf
add command check to check_c_compiler/check_cpp_compiler, because some shells print an error if it doesn't exist
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
105
diff
changeset
|
51 | fi |
101
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
52 | cat > "$TEMP_DIR/test.cpp" << __EOF__ |
8
82cd9f1d94cb
add c++ compiler detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
53 | /* test file */ |
82cd9f1d94cb
add c++ compiler detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
54 | #include <iostream> |
82cd9f1d94cb
add c++ compiler detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
55 | int main(int argc, char **argv) { |
105
4b3e655339cb
improve toolchain detection
Mike Becker <universe@uap-core.de>
parents:
101
diff
changeset
|
56 | #if defined(_MSC_VER) |
4b3e655339cb
improve toolchain detection
Mike Becker <universe@uap-core.de>
parents:
101
diff
changeset
|
57 | std::cout << "msc" << std::endl; |
4b3e655339cb
improve toolchain detection
Mike Becker <universe@uap-core.de>
parents:
101
diff
changeset
|
58 | #elif defined(__clang__) |
4b3e655339cb
improve toolchain detection
Mike Becker <universe@uap-core.de>
parents:
101
diff
changeset
|
59 | std::cout << "clang gnuc" << std::endl; |
15
971ac4f0f1df
fix toolchain detection in case gcc is not available
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
13
diff
changeset
|
60 | #elif defined(__GNUC__) |
105
4b3e655339cb
improve toolchain detection
Mike Becker <universe@uap-core.de>
parents:
101
diff
changeset
|
61 | std::cout << "gcc gnuc" << std::endl; |
8
82cd9f1d94cb
add c++ compiler detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
62 | #elif defined(__sun) |
101
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
63 | std::cout << "suncc" << std::endl; |
8
82cd9f1d94cb
add c++ compiler detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
64 | #else |
101
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
65 | std::cout << "cc" << std::endl; |
8
82cd9f1d94cb
add c++ compiler detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
66 | #endif |
101
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
67 | return 0; |
8
82cd9f1d94cb
add c++ compiler detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
68 | } |
82cd9f1d94cb
add c++ compiler detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
69 | __EOF__ |
101
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
70 | rm -f "$TEMP_DIR/checkcc" |
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
71 | $1 -o "$TEMP_DIR/checkcc" $CXXFLAGS $LDFLAGS "$TEMP_DIR/test.cpp" 2> /dev/null |
0
38775db5fdf5
add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
72 | } |
38775db5fdf5
add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
73 | |
70
d79fc765fd4a
add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
74 | create_libtest_source() |
31
4c6060dad560
add check_lib() utility to toolchain.sh
Mike Becker <universe@uap-core.de>
parents:
15
diff
changeset
|
75 | { |
70
d79fc765fd4a
add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
76 | # $1: filename |
d79fc765fd4a
add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
77 | # $2: optional include |
101
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
78 | cat > "$TEMP_DIR/$1" << __EOF__ |
31
4c6060dad560
add check_lib() utility to toolchain.sh
Mike Becker <universe@uap-core.de>
parents:
15
diff
changeset
|
79 | /* libtest file */ |
4c6060dad560
add check_lib() utility to toolchain.sh
Mike Becker <universe@uap-core.de>
parents:
15
diff
changeset
|
80 | int main(int argc, char **argv) { |
101
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
81 | return 0; |
31
4c6060dad560
add check_lib() utility to toolchain.sh
Mike Becker <universe@uap-core.de>
parents:
15
diff
changeset
|
82 | } |
4c6060dad560
add check_lib() utility to toolchain.sh
Mike Becker <universe@uap-core.de>
parents:
15
diff
changeset
|
83 | __EOF__ |
70
d79fc765fd4a
add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
84 | if [ -n "$2" ]; then |
d79fc765fd4a
add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
85 | echo "#include <$2>" >> "$TEMP_DIR/$1" |
d79fc765fd4a
add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
86 | fi |
d79fc765fd4a
add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
87 | } |
d79fc765fd4a
add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
88 | |
d79fc765fd4a
add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
89 | check_c_lib() |
d79fc765fd4a
add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
90 | { |
d79fc765fd4a
add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
91 | # $1: libname |
d79fc765fd4a
add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
92 | # $2: optional include |
d79fc765fd4a
add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
93 | if [ -z "$TOOLCHAIN_CC" ]; then |
d79fc765fd4a
add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
94 | return 1 |
d79fc765fd4a
add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
95 | fi |
d79fc765fd4a
add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
96 | create_libtest_source "test.c" "$2" |
66
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
97 | rm -f "$TEMP_DIR/checklib" |
101
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
98 | $TOOLCHAIN_CC -o "$TEMP_DIR/checklib" $CFLAGS $LDFLAGS "-l$1" "$TEMP_DIR/test.c" 2> /dev/null |
66
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
99 | } |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
100 | |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
101 | check_cpp_lib() |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
102 | { |
70
d79fc765fd4a
add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
103 | # $1: libname |
d79fc765fd4a
add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
104 | # $2: optional include |
66
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
105 | if [ -z "$TOOLCHAIN_CXX" ]; then |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
106 | return 1 |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
107 | fi |
101
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
108 | create_libtest_source "test.cpp" "$2" |
66
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
109 | rm -f "$TEMP_DIR/checklib" |
101
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
110 | $TOOLCHAIN_CXX -o "$TEMP_DIR/checklib" $CXXFLAGS $LDFLAGS "-l$1" "$TEMP_DIR/test.cpp" 2> /dev/null |
66
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
111 | } |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
112 | |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
113 | check_lib() |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
114 | { |
70
d79fc765fd4a
add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
115 | # $1: libname |
d79fc765fd4a
add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
116 | # $2: optional include |
101
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
117 | if [ -n "$TOOLCHAIN_CC" ]; then |
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
118 | check_c_lib "$1" "$2" |
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
119 | elif [ -n "$TOOLCHAIN_CXX" ]; then |
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
120 | check_cpp_lib "$1" "$2" |
7f40964bf1e9
prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents:
70
diff
changeset
|
121 | fi |
31
4c6060dad560
add check_lib() utility to toolchain.sh
Mike Becker <universe@uap-core.de>
parents:
15
diff
changeset
|
122 | } |
4c6060dad560
add check_lib() utility to toolchain.sh
Mike Becker <universe@uap-core.de>
parents:
15
diff
changeset
|
123 | |
66
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
124 | detect_c_compiler() |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
125 | { |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
126 | if [ -n "$TOOLCHAIN_CC" ]; then |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
127 | return 0 |
52
afcb57893858
major evolution of configure template - fixes #283
Mike Becker <universe@uap-core.de>
parents:
51
diff
changeset
|
128 | fi |
66
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
129 | printf "detect C compiler... " |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
130 | if [ -n "$CC" ]; then |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
131 | if check_c_compiler "$CC"; then |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
132 | TOOLCHAIN_CC=$CC |
105
4b3e655339cb
improve toolchain detection
Mike Becker <universe@uap-core.de>
parents:
101
diff
changeset
|
133 | TOOLCHAIN=`"$TEMP_DIR/checkcc"` |
4b3e655339cb
improve toolchain detection
Mike Becker <universe@uap-core.de>
parents:
101
diff
changeset
|
134 | TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` |
66
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
135 | echo "$CC" |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
136 | return 0 |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
137 | else |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
138 | echo "$CC is not a working C compiler" |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
139 | return 1 |
52
afcb57893858
major evolution of configure template - fixes #283
Mike Becker <universe@uap-core.de>
parents:
51
diff
changeset
|
140 | fi |
66
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
141 | else |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
142 | for COMP in $C_COMPILERS |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
143 | do |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
144 | if check_c_compiler "$COMP"; then |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
145 | TOOLCHAIN_CC=$COMP |
105
4b3e655339cb
improve toolchain detection
Mike Becker <universe@uap-core.de>
parents:
101
diff
changeset
|
146 | TOOLCHAIN=`"$TEMP_DIR/checkcc"` |
4b3e655339cb
improve toolchain detection
Mike Becker <universe@uap-core.de>
parents:
101
diff
changeset
|
147 | TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` |
66
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
148 | echo "$COMP" |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
149 | return 0 |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
150 | fi |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
151 | done |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
152 | echo "not found" |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
153 | return 1 |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
154 | fi |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
155 | } |
0
38775db5fdf5
add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
156 | |
66
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
157 | detect_cpp_compiler() |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
158 | { |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
159 | if [ -n "$TOOLCHAIN_CXX" ]; then |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
160 | return 0 |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
161 | fi |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
162 | printf "detect C++ compiler... " |
52
afcb57893858
major evolution of configure template - fixes #283
Mike Becker <universe@uap-core.de>
parents:
51
diff
changeset
|
163 | |
66
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
164 | if [ -n "$CXX" ]; then |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
165 | if check_cpp_compiler "$CXX"; then |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
166 | TOOLCHAIN_CXX=$CXX |
105
4b3e655339cb
improve toolchain detection
Mike Becker <universe@uap-core.de>
parents:
101
diff
changeset
|
167 | TOOLCHAIN=`"$TEMP_DIR/checkcc"` |
4b3e655339cb
improve toolchain detection
Mike Becker <universe@uap-core.de>
parents:
101
diff
changeset
|
168 | TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` |
66
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
169 | echo "$CXX" |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
170 | return 0 |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
171 | else |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
172 | echo "$CXX is not a working C++ compiler" |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
173 | return 1 |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
174 | fi |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
175 | else |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
176 | for COMP in $CPP_COMPILERS |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
177 | do |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
178 | if check_cpp_compiler "$COMP"; then |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
179 | TOOLCHAIN_CXX=$COMP |
105
4b3e655339cb
improve toolchain detection
Mike Becker <universe@uap-core.de>
parents:
101
diff
changeset
|
180 | TOOLCHAIN=`"$TEMP_DIR/checkcc"` |
4b3e655339cb
improve toolchain detection
Mike Becker <universe@uap-core.de>
parents:
101
diff
changeset
|
181 | TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` |
66
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
182 | echo "$COMP" |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
183 | return 0 |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
184 | fi |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
185 | done |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
186 | echo "${TOOLCHAIN_CXX:-"not found"}" |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
187 | return 1 |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
188 | fi |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
189 | } |
38
02b000e40e5e
fix missing initialization of CFLAGS and LDFLAGS when toolchain is unknown - fixes #288
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
190 | |
66
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
191 | write_toolchain_defaults() |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
192 | { |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
193 | echo "# toolchain" >> "$1" |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
194 | if [ -n "$TOOLCHAIN_CC" ]; then |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
195 | echo "CC = ${TOOLCHAIN_CC}" >> "$1" |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
196 | fi |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
197 | if [ -n "$TOOLCHAIN_CXX" ]; then |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
198 | echo "CXX = ${TOOLCHAIN_CXX}" >> "$1" |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
199 | fi |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
200 | echo >> "$1" |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
201 | if [ -f "make/${TOOLCHAIN_NAME}.mk" ]; then |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
202 | cat "make/${TOOLCHAIN_NAME}.mk" >> "$1" |
69
96d8badffe58
use cc.mk as default if someone does not want to create a separate mk file for every toolchain
Mike Becker <universe@uap-core.de>
parents:
66
diff
changeset
|
203 | elif [ -f "make/cc.mk" ]; then |
96d8badffe58
use cc.mk as default if someone does not want to create a separate mk file for every toolchain
Mike Becker <universe@uap-core.de>
parents:
66
diff
changeset
|
204 | cat "make/cc.mk" >> "$1" |
66
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
205 | else |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
206 | echo "!!! WARNING !!! Default toolchain flags not found. Configuration might be incomplete." |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
207 | fi |
dc758dcd4645
add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents:
54
diff
changeset
|
208 | } |