diff options
| author | Joel Stålnacke <joel@saker.fi> | 2024-10-06 11:25:49 +0300 |
|---|---|---|
| committer | Joel Stålnacke <joel@saker.fi> | 2024-10-06 11:25:49 +0300 |
| commit | 11e09f477480531487cd12b5c107ac1d8352a7a5 (patch) | |
| tree | 19ce8424608fa9dd617208d8ed60da7a2a2b4287 /lib/build.sh | |
Initial commit
Diffstat (limited to 'lib/build.sh')
| -rwxr-xr-x | lib/build.sh | 52 |
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 |
