src/main/resources/make/toolchain.sh

Mon, 23 Sep 2024 22:52:48 +0200

author
Mike Becker <universe@uap-core.de>
date
Mon, 23 Sep 2024 22:52:48 +0200
changeset 115
36e4aedd5663
parent 105
4b3e655339cb
permissions
-rw-r--r--

fix hardcoded default for prefix in help text

fixes #428

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

mercurial