test/make/toolchain.sh

Sun, 12 Jan 2025 16:28:08 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 12 Jan 2025 16:28:08 +0100
changeset 135
9afe68b15c66
parent 132
e0478362c2cf
permissions
-rw-r--r--

improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508

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)
135
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
29 printf("toolchain:msc\n");
105
4b3e655339cb improve toolchain detection
Mike Becker <universe@uap-core.de>
parents: 101
diff changeset
30 #elif defined(__clang__)
135
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
31 printf("toolchain: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__)
135
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
33 printf("toolchain:gcc gnuc\n");
0
38775db5fdf5 add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 #elif defined(__sun)
135
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
35 printf("toolchain:suncc\n");
0
38775db5fdf5 add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 #else
135
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
37 printf("toolchain:unknown\n");
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
38 #endif
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
39 printf("wsize:%d\n", (int)sizeof(void*)*8);
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
40 #ifdef __STDC_VERSION__
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
41 printf("stdcversion:%d\n", __STDC_VERSION__);
0
38775db5fdf5 add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 #endif
101
7f40964bf1e9 prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
43 return 0;
0
38775db5fdf5 add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 }
38775db5fdf5 add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 __EOF__
101
7f40964bf1e9 prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
46 rm -f "$TEMP_DIR/checkcc"
7f40964bf1e9 prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
47 $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
48 }
82cd9f1d94cb add c++ compiler detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 7
diff changeset
49
82cd9f1d94cb add c++ compiler detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 7
diff changeset
50 check_cpp_compiler()
82cd9f1d94cb add c++ compiler detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 7
diff changeset
51 {
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
52 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
53 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
54 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
55 fi
101
7f40964bf1e9 prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
56 cat > "$TEMP_DIR/test.cpp" << __EOF__
8
82cd9f1d94cb add c++ compiler detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 7
diff changeset
57 /* test file */
82cd9f1d94cb add c++ compiler detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 7
diff changeset
58 #include <iostream>
82cd9f1d94cb add c++ compiler detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 7
diff changeset
59 int main(int argc, char **argv) {
105
4b3e655339cb improve toolchain detection
Mike Becker <universe@uap-core.de>
parents: 101
diff changeset
60 #if defined(_MSC_VER)
135
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
61 std::cout << "toolchain:msc" << std::endl;
105
4b3e655339cb improve toolchain detection
Mike Becker <universe@uap-core.de>
parents: 101
diff changeset
62 #elif defined(__clang__)
135
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
63 std::cout << "toolchain: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
64 #elif defined(__GNUC__)
135
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
65 std::cout << "toolchain:gcc gnuc" << std::endl;
8
82cd9f1d94cb add c++ compiler detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 7
diff changeset
66 #elif defined(__sun)
135
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
67 std::cout << "toolchain:suncc" << std::endl;
8
82cd9f1d94cb add c++ compiler detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 7
diff changeset
68 #else
135
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
69 std::cout << "toolchain:unknown" << std::endl;
8
82cd9f1d94cb add c++ compiler detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 7
diff changeset
70 #endif
135
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
71 std:cout << "wsize:" << sizeof(void*)*8 << std::endl;
101
7f40964bf1e9 prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
72 return 0;
8
82cd9f1d94cb add c++ compiler detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 7
diff changeset
73 }
82cd9f1d94cb add c++ compiler detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 7
diff changeset
74 __EOF__
101
7f40964bf1e9 prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
75 rm -f "$TEMP_DIR/checkcc"
7f40964bf1e9 prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
76 $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
77 }
38775db5fdf5 add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78
70
d79fc765fd4a add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents: 69
diff changeset
79 create_libtest_source()
31
4c6060dad560 add check_lib() utility to toolchain.sh
Mike Becker <universe@uap-core.de>
parents: 15
diff changeset
80 {
70
d79fc765fd4a add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents: 69
diff changeset
81 # $1: filename
d79fc765fd4a add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents: 69
diff changeset
82 # $2: optional include
101
7f40964bf1e9 prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
83 cat > "$TEMP_DIR/$1" << __EOF__
31
4c6060dad560 add check_lib() utility to toolchain.sh
Mike Becker <universe@uap-core.de>
parents: 15
diff changeset
84 /* libtest file */
4c6060dad560 add check_lib() utility to toolchain.sh
Mike Becker <universe@uap-core.de>
parents: 15
diff changeset
85 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
86 return 0;
31
4c6060dad560 add check_lib() utility to toolchain.sh
Mike Becker <universe@uap-core.de>
parents: 15
diff changeset
87 }
4c6060dad560 add check_lib() utility to toolchain.sh
Mike Becker <universe@uap-core.de>
parents: 15
diff changeset
88 __EOF__
70
d79fc765fd4a add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents: 69
diff changeset
89 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
90 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
91 fi
d79fc765fd4a add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents: 69
diff changeset
92 }
d79fc765fd4a add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents: 69
diff changeset
93
d79fc765fd4a add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents: 69
diff changeset
94 check_c_lib()
d79fc765fd4a add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents: 69
diff changeset
95 {
d79fc765fd4a add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents: 69
diff changeset
96 # $1: libname
d79fc765fd4a add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents: 69
diff changeset
97 # $2: optional include
d79fc765fd4a add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents: 69
diff changeset
98 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
99 return 1
d79fc765fd4a add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents: 69
diff changeset
100 fi
d79fc765fd4a add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents: 69
diff changeset
101 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
102 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
103 $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
104 }
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
105
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
106 check_cpp_lib()
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
107 {
70
d79fc765fd4a add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents: 69
diff changeset
108 # $1: libname
d79fc765fd4a add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents: 69
diff changeset
109 # $2: optional include
66
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
110 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
111 return 1
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
112 fi
101
7f40964bf1e9 prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
113 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
114 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
115 $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
116 }
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
117
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
118 check_lib()
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
119 {
70
d79fc765fd4a add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents: 69
diff changeset
120 # $1: libname
d79fc765fd4a add optional include file for the checklib function - fixes #305
Mike Becker <universe@uap-core.de>
parents: 69
diff changeset
121 # $2: optional include
101
7f40964bf1e9 prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
122 if [ -n "$TOOLCHAIN_CC" ]; then
7f40964bf1e9 prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
123 check_c_lib "$1" "$2"
7f40964bf1e9 prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
124 elif [ -n "$TOOLCHAIN_CXX" ]; then
7f40964bf1e9 prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
125 check_cpp_lib "$1" "$2"
7f40964bf1e9 prioritize clang on bsd that is not openbsd
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
126 fi
31
4c6060dad560 add check_lib() utility to toolchain.sh
Mike Becker <universe@uap-core.de>
parents: 15
diff changeset
127 }
4c6060dad560 add check_lib() utility to toolchain.sh
Mike Becker <universe@uap-core.de>
parents: 15
diff changeset
128
66
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
129 detect_c_compiler()
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
130 {
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
131 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
132 return 0
52
afcb57893858 major evolution of configure template - fixes #283
Mike Becker <universe@uap-core.de>
parents: 51
diff changeset
133 fi
66
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
134 printf "detect C compiler... "
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
135 if [ -n "$CC" ]; then
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
136 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
137 TOOLCHAIN_CC=$CC
135
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
138 "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out"
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
139 TOOLCHAIN=`grep '^toolchain:' "$TEMP_DIR/checkcc_out" | tail -c +11`
105
4b3e655339cb improve toolchain detection
Mike Becker <universe@uap-core.de>
parents: 101
diff changeset
140 TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -`
135
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
141 TOOLCHAIN_WSIZE=`grep '^wsize:' "$TEMP_DIR/checkcc_out" | tail -c +7`
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
142 TOOLCHAIN_CSTD=`grep '^stdcversion:' "$TEMP_DIR/checkcc_out" | tail -c +13`
66
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
143 echo "$CC"
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
144 return 0
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
145 else
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
146 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
147 return 1
52
afcb57893858 major evolution of configure template - fixes #283
Mike Becker <universe@uap-core.de>
parents: 51
diff changeset
148 fi
66
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
149 else
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
150 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
151 do
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
152 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
153 TOOLCHAIN_CC=$COMP
135
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
154 "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out"
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
155 TOOLCHAIN=`grep '^toolchain:' "$TEMP_DIR/checkcc_out" | tail -c +11`
105
4b3e655339cb improve toolchain detection
Mike Becker <universe@uap-core.de>
parents: 101
diff changeset
156 TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -`
135
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
157 TOOLCHAIN_WSIZE=`grep '^wsize:' "$TEMP_DIR/checkcc_out" | tail -c +7`
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
158 TOOLCHAIN_CSTD=`grep '^stdcversion:' "$TEMP_DIR/checkcc_out" | tail -c +13`
66
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
159 echo "$COMP"
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 done
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
163 echo "not found"
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
164 return 1
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
165 fi
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
166 }
0
38775db5fdf5 add existing source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
167
66
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
168 detect_cpp_compiler()
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
169 {
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
170 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
171 return 0
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
172 fi
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
173 printf "detect C++ compiler... "
52
afcb57893858 major evolution of configure template - fixes #283
Mike Becker <universe@uap-core.de>
parents: 51
diff changeset
174
66
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
175 if [ -n "$CXX" ]; then
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
176 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
177 TOOLCHAIN_CXX=$CXX
135
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
178 "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out"
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
179 TOOLCHAIN=`grep '^toolchain:' "$TEMP_DIR/checkcc_out" | tail -c +11`
105
4b3e655339cb improve toolchain detection
Mike Becker <universe@uap-core.de>
parents: 101
diff changeset
180 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
181 echo "$CXX"
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
182 return 0
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
183 else
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
184 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
185 return 1
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
186 fi
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
187 else
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
188 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
189 do
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
190 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
191 TOOLCHAIN_CXX=$COMP
135
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
192 "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out"
9afe68b15c66 improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 132
diff changeset
193 TOOLCHAIN=`grep '^toolchain:' "$TEMP_DIR/checkcc_out" | tail -c +11`
105
4b3e655339cb improve toolchain detection
Mike Becker <universe@uap-core.de>
parents: 101
diff changeset
194 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
195 echo "$COMP"
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
196 return 0
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
197 fi
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
198 done
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
199 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
200 return 1
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
201 fi
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
202 }
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
203
66
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
204 write_toolchain_defaults()
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
205 {
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
206 echo "# toolchain" >> "$1"
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
207 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
208 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
209 fi
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
210 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
211 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
212 fi
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
213 echo >> "$1"
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
214 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
215 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
216 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
217 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
218 else
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
219 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
220 fi
dc758dcd4645 add basic support for the lang element - fixes #284
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
221 }

mercurial