add check_lib() utility to toolchain.sh

Sat, 02 Sep 2023 18:19:43 +0200

author
Mike Becker <universe@uap-core.de>
date
Sat, 02 Sep 2023 18:19:43 +0200
changeset 31
4c6060dad560
parent 30
d4c38bb71fa0
child 32
c3132f7f19da

add check_lib() utility to toolchain.sh

fixes #280

test/make/toolchain.sh file | annotate | diff | comparison | revisions
--- a/test/make/toolchain.sh	Sat Sep 02 14:25:05 2023 +0200
+++ b/test/make/toolchain.sh	Sat Sep 02 18:19:43 2023 +0200
@@ -63,6 +63,26 @@
 	return 0
 }
 
+check_lib()
+{
+	if [ -z "$TOOLCHAIN_LD" ]; then
+		return 1
+	fi
+	cat > $TEMP_DIR/test.c << __EOF__
+/* libtest file */
+int main(int argc, char **argv) {
+	return 0;
+}
+__EOF__
+	rm -f $TEMP_DIR/checklib
+	$TOOLCHAIN_LD -o $TEMP_DIR/checklib $CFLAGS $LDFLAGS "-l$1" $TEMP_DIR/test.c 2> /dev/null
+
+	if [ $? -ne 0 ]; then
+		return 1
+	fi
+	return 0
+}
+
 printf "detect C compiler... "
 
 for COMP in $C_COMPILERS

mercurial