Sun, 20 Apr 2025 15:41:16 +0200
add support for 2d textures in sprite shader - fixes #386
| 0 | 1 | #!/bin/sh |
| 2 | # | |
| 3 | # toolchain detection | |
| 4 | # | |
| 5 | ||
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
6 | if isplatform "bsd" && notisplatform "openbsd"; then |
|
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
7 | C_COMPILERS="clang gcc cc" |
|
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
8 | CPP_COMPILERS="clang++ g++ CC" |
|
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
9 | else |
|
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
10 | C_COMPILERS="gcc clang suncc cc" |
|
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
11 | CPP_COMPILERS="g++ clang++ sunCC CC" |
|
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
12 | fi |
|
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
13 | unset TOOLCHAIN |
| 0 | 14 | unset TOOLCHAIN_NAME |
| 15 | unset TOOLCHAIN_CC | |
| 16 | unset TOOLCHAIN_CXX | |
| 17 | ||
| 18 | check_c_compiler() | |
| 19 | { | |
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
20 | cat > "$TEMP_DIR/test.c" << __EOF__ |
| 0 | 21 | /* test file */ |
| 22 | #include <stdio.h> | |
| 23 | int main(int argc, char **argv) { | |
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
24 | #if defined(_MSC_VER) |
|
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
25 | printf("msc\n"); |
|
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
26 | #elif defined(__clang__) |
|
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
27 | printf("clang gnuc\n"); |
| 0 | 28 | #elif defined(__GNUC__) |
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
29 | printf("gcc gnuc\n"); |
| 0 | 30 | #elif defined(__sun) |
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
31 | printf("suncc\n"); |
| 0 | 32 | #else |
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
33 | printf("unknown\n"); |
| 0 | 34 | #endif |
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
35 | return 0; |
| 0 | 36 | } |
| 37 | __EOF__ | |
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
38 | rm -f "$TEMP_DIR/checkcc" |
|
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
39 | $1 -o "$TEMP_DIR/checkcc" $CFLAGS $LDFLAGS "$TEMP_DIR/test.c" 2> /dev/null |
| 0 | 40 | } |
| 41 | ||
| 42 | check_cpp_compiler() | |
| 43 | { | |
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
44 | cat > "$TEMP_DIR/test.cpp" << __EOF__ |
| 0 | 45 | /* test file */ |
| 46 | #include <iostream> | |
| 47 | int main(int argc, char **argv) { | |
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
48 | #if defined(_MSC_VER) |
|
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
49 | std::cout << "msc" << std::endl; |
|
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
50 | #elif defined(__clang__) |
|
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
51 | std::cout << "clang gnuc" << std::endl; |
| 0 | 52 | #elif defined(__GNUC__) |
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
53 | std::cout << "gcc gnuc" << std::endl; |
| 0 | 54 | #elif defined(__sun) |
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
55 | std::cout << "suncc" << std::endl; |
| 0 | 56 | #else |
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
57 | std::cout << "cc" << std::endl; |
| 0 | 58 | #endif |
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
59 | return 0; |
| 0 | 60 | } |
| 61 | __EOF__ | |
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
62 | rm -f "$TEMP_DIR/checkcc" |
|
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
63 | $1 -o "$TEMP_DIR/checkcc" $CXXFLAGS $LDFLAGS "$TEMP_DIR/test.cpp" 2> /dev/null |
| 0 | 64 | } |
| 65 | ||
| 66 | create_libtest_source() | |
| 67 | { | |
| 68 | # $1: filename | |
| 69 | # $2: optional include | |
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
70 | cat > "$TEMP_DIR/$1" << __EOF__ |
| 0 | 71 | /* libtest file */ |
| 72 | int main(int argc, char **argv) { | |
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
73 | return 0; |
| 0 | 74 | } |
| 75 | __EOF__ | |
| 76 | if [ -n "$2" ]; then | |
| 77 | echo "#include <$2>" >> "$TEMP_DIR/$1" | |
| 78 | fi | |
| 79 | } | |
| 80 | ||
| 81 | check_c_lib() | |
| 82 | { | |
| 83 | # $1: libname | |
| 84 | # $2: optional include | |
| 85 | if [ -z "$TOOLCHAIN_CC" ]; then | |
| 86 | return 1 | |
| 87 | fi | |
| 88 | create_libtest_source "test.c" "$2" | |
| 89 | rm -f "$TEMP_DIR/checklib" | |
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
90 | $TOOLCHAIN_CC -o "$TEMP_DIR/checklib" $CFLAGS $LDFLAGS "-l$1" "$TEMP_DIR/test.c" 2> /dev/null |
| 0 | 91 | } |
| 92 | ||
| 93 | check_cpp_lib() | |
| 94 | { | |
| 95 | # $1: libname | |
| 96 | # $2: optional include | |
| 97 | if [ -z "$TOOLCHAIN_CXX" ]; then | |
| 98 | return 1 | |
| 99 | fi | |
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
100 | create_libtest_source "test.cpp" "$2" |
| 0 | 101 | rm -f "$TEMP_DIR/checklib" |
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
102 | $TOOLCHAIN_CXX -o "$TEMP_DIR/checklib" $CXXFLAGS $LDFLAGS "-l$1" "$TEMP_DIR/test.cpp" 2> /dev/null |
| 0 | 103 | } |
| 104 | ||
| 105 | check_lib() | |
| 106 | { | |
| 107 | # $1: libname | |
| 108 | # $2: optional include | |
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
109 | if [ -n "$TOOLCHAIN_CC" ]; then |
|
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
110 | check_c_lib "$1" "$2" |
|
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
111 | elif [ -n "$TOOLCHAIN_CXX" ]; then |
|
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
112 | check_cpp_lib "$1" "$2" |
|
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
113 | fi |
| 0 | 114 | } |
| 115 | ||
| 116 | detect_c_compiler() | |
| 117 | { | |
| 118 | if [ -n "$TOOLCHAIN_CC" ]; then | |
| 119 | return 0 | |
| 120 | fi | |
| 121 | printf "detect C compiler... " | |
| 122 | if [ -n "$CC" ]; then | |
| 123 | if check_c_compiler "$CC"; then | |
| 124 | TOOLCHAIN_CC=$CC | |
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
125 | TOOLCHAIN=`"$TEMP_DIR/checkcc"` |
|
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
126 | TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` |
| 0 | 127 | echo "$CC" |
| 128 | return 0 | |
| 129 | else | |
| 130 | echo "$CC is not a working C compiler" | |
| 131 | return 1 | |
| 132 | fi | |
| 133 | else | |
| 134 | for COMP in $C_COMPILERS | |
| 135 | do | |
| 136 | if check_c_compiler "$COMP"; then | |
| 137 | TOOLCHAIN_CC=$COMP | |
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
138 | TOOLCHAIN=`"$TEMP_DIR/checkcc"` |
|
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
139 | TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` |
| 0 | 140 | echo "$COMP" |
| 141 | return 0 | |
| 142 | fi | |
| 143 | done | |
| 144 | echo "not found" | |
| 145 | return 1 | |
| 146 | fi | |
| 147 | } | |
| 148 | ||
| 149 | detect_cpp_compiler() | |
| 150 | { | |
| 151 | if [ -n "$TOOLCHAIN_CXX" ]; then | |
| 152 | return 0 | |
| 153 | fi | |
| 154 | printf "detect C++ compiler... " | |
| 155 | ||
| 156 | if [ -n "$CXX" ]; then | |
| 157 | if check_cpp_compiler "$CXX"; then | |
| 158 | TOOLCHAIN_CXX=$CXX | |
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
159 | TOOLCHAIN=`"$TEMP_DIR/checkcc"` |
|
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
160 | TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` |
| 0 | 161 | echo "$CXX" |
| 162 | return 0 | |
| 163 | else | |
| 164 | echo "$CXX is not a working C++ compiler" | |
| 165 | return 1 | |
| 166 | fi | |
| 167 | else | |
| 168 | for COMP in $CPP_COMPILERS | |
| 169 | do | |
| 170 | if check_cpp_compiler "$COMP"; then | |
| 171 | TOOLCHAIN_CXX=$COMP | |
|
76
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
172 | TOOLCHAIN=`"$TEMP_DIR/checkcc"` |
|
eb16be99b0ad
update to newest versions of uwproj and ucx
Mike Becker <universe@uap-core.de>
parents:
0
diff
changeset
|
173 | TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` |
| 0 | 174 | echo "$COMP" |
| 175 | return 0 | |
| 176 | fi | |
| 177 | done | |
| 178 | echo "${TOOLCHAIN_CXX:-"not found"}" | |
| 179 | return 1 | |
| 180 | fi | |
| 181 | } | |
| 182 | ||
| 183 | write_toolchain_defaults() | |
| 184 | { | |
| 185 | echo "# toolchain" >> "$1" | |
| 186 | if [ -n "$TOOLCHAIN_CC" ]; then | |
| 187 | echo "CC = ${TOOLCHAIN_CC}" >> "$1" | |
| 188 | fi | |
| 189 | if [ -n "$TOOLCHAIN_CXX" ]; then | |
| 190 | echo "CXX = ${TOOLCHAIN_CXX}" >> "$1" | |
| 191 | fi | |
| 192 | echo >> "$1" | |
| 193 | if [ -f "make/${TOOLCHAIN_NAME}.mk" ]; then | |
| 194 | cat "make/${TOOLCHAIN_NAME}.mk" >> "$1" | |
| 195 | elif [ -f "make/cc.mk" ]; then | |
| 196 | cat "make/cc.mk" >> "$1" | |
| 197 | else | |
| 198 | echo "!!! WARNING !!! Default toolchain flags not found. Configuration might be incomplete." | |
| 199 | fi | |
| 200 | } |