summaryrefslogtreecommitdiff
path: root/lib/build.sh
diff options
context:
space:
mode:
Diffstat (limited to 'lib/build.sh')
-rwxr-xr-xlib/build.sh52
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/build.sh b/lib/build.sh
new file mode 100755
index 0000000..f506120
--- /dev/null
+++ b/lib/build.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+fail() {
+ echo "$0: $*" >&2
+ exit 1
+}
+
+CC=cc
+CFLAGS="-std=c99 -Wall -Wextra -Wpedantic -D_POSIX_C_SOURCE=200809L"
+LDFLAGS="-fPIC"
+SOURCES="test.c"
+output="build"
+
+for arg ; do
+ case "$arg" in
+ --runtime=*)
+ runtime="${arg#*=}"
+ ;;
+ --output=*)
+ output="${arg#*=}"
+ ;;
+ *)
+ echo "usage"
+ ;;
+ esac
+done
+
+if [ -z "$runtime" ]; then
+ echo "Guessing runtime ..."
+
+ case "$(uname -s)" in
+ Linux)
+ case "$(uname -m)" in
+ x86_64)
+ runtime="linux-x64"
+ ;;
+ esac
+ ;;
+ esac
+fi
+
+case "$runtime" in
+ linux-x64)
+ sofile="libdjup.so"
+ ;;
+ *)
+ fail "Unsupported runtime $runtime"
+esac
+
+echo Building for runtime "$runtime ..."
+mkdir -p "$output/runtimes/$runtime/native" && $CC $CFLAGS $SOURCES -shared $LDFLAGS -o "$output/runtimes/$runtime/native/$sofile"
+echo Done