aboutsummaryrefslogtreecommitdiffstats
path: root/bs/bs-lib.sh
diff options
context:
space:
mode:
Diffstat (limited to 'bs/bs-lib.sh')
-rw-r--r--bs/bs-lib.sh50
1 files changed, 50 insertions, 0 deletions
diff --git a/bs/bs-lib.sh b/bs/bs-lib.sh
new file mode 100644
index 000000000..8b13653f2
--- /dev/null
+++ b/bs/bs-lib.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+# common shell functions and variable setup for the bs build system,
+# expect variables to be set and exported in bs.mk
+
+test -z "$CC" && CC=cc
+test -z "$CPP" && CPP='cc -E'
+test -z "$PKGCONFIG" && PKGCONFIG=pkg-config
+
+p ()
+{
+ echo >&2 "$@"
+}
+
+run_cc ()
+{
+ $CC $CPPFLAGS $CFLAGS $LDFLAGS \
+ $cppflags $cflags $ldflags -o t.o t.c >/dev/null 2>&1
+}
+
+test_header ()
+{
+ cat > t.c <<EOF
+#include <$1.h>
+int main (void) { return 0; }
+EOF
+ run_cc
+}
+
+dep_paths ()
+{
+ name=$1
+ eval "cflags=`echo '$'`${name}_cflags"
+ eval "ldflags=`echo '$'`${name}_ldflags"
+ eval "pfx=`echo '$'`${name}_pfx"
+ if test -n "$pfx"; then
+ cflags="$cflags -I$pfx/include"
+ ldflags="$ldflags -L$pfx/lib"
+ fi
+}
+
+test_compile ()
+{
+ h=shift
+ cat > t.c <<EOF
+#include <$h.h>
+int main () { $@ return 0; }
+EOF
+ run_cc
+}
+