#!/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