Thu, 21 Sep 2023 18:22:07 +0200
add optional include file for the checklib function - fixes #305
test/make/toolchain.sh | file | annotate | diff | comparison | revisions |
--- a/test/make/toolchain.sh Thu Sep 21 18:02:30 2023 +0200 +++ b/test/make/toolchain.sh Thu Sep 21 18:22:07 2023 +0200 @@ -53,42 +53,53 @@ $1 -o "$TEMP_DIR/checkcc" $CXXFLAGS $LDFLAGS "$TEMP_DIR/test.cpp" 2> /dev/null } -check_c_lib() +create_libtest_source() { - if [ -z "$TOOLCHAIN_CC" ]; then - return 1 - fi - cat > "$TEMP_DIR/test.c" << __EOF__ + # $1: filename + # $2: optional include + cat > "$TEMP_DIR/$1" << __EOF__ /* libtest file */ int main(int argc, char **argv) { return 0; } __EOF__ + if [ -n "$2" ]; then + echo "#include <$2>" >> "$TEMP_DIR/$1" + fi +} + +check_c_lib() +{ + # $1: libname + # $2: optional include + if [ -z "$TOOLCHAIN_CC" ]; then + return 1 + fi + create_libtest_source "test.c" "$2" rm -f "$TEMP_DIR/checklib" $TOOLCHAIN_CC -o "$TEMP_DIR/checklib" $CFLAGS $LDFLAGS "-l$1" "$TEMP_DIR/test.c" 2> /dev/null } check_cpp_lib() { + # $1: libname + # $2: optional include if [ -z "$TOOLCHAIN_CXX" ]; then return 1 fi - cat > "$TEMP_DIR/test.cpp" << __EOF__ -/* libtest file */ -int main(int argc, char **argv) { - return 0; -} -__EOF__ + create_libtest_source "test.cpp" "$2" rm -f "$TEMP_DIR/checklib" $TOOLCHAIN_CXX -o "$TEMP_DIR/checklib" $CXXFLAGS $LDFLAGS "-l$1" "$TEMP_DIR/test.cpp" 2> /dev/null } check_lib() { + # $1: libname + # $2: optional include if [ -n "$TOOLCHAIN_CC" ]; then - check_c_lib "$1" + check_c_lib "$1" "$2" elif [ -n "$TOOLCHAIN_CXX" ]; then - check_cpp_lib "$1" + check_cpp_lib "$1" "$2" fi }