src/main/resources/make/toolchain.sh

Fri, 19 Jan 2024 21:23:56 +0100

author
Mike Becker <universe@uap-core.de>
date
Fri, 19 Jan 2024 21:23:56 +0100
changeset 102
bc7837852b7c
parent 101
7f40964bf1e9
child 105
4b3e655339cb
permissions
-rw-r--r--

add OpenBSD and NetBSD platform detection

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

mercurial