#!/bin/sh
# SPDX-License-Identifier: GPL-3.0-only
# Build ../om.wasm from FoMni's instrument (omni.c, unchanged) and the browser shim (om_web.c).
# Needs clang and wasm-ld (LLVM 15 or newer; built with Ubuntu 24.04's clang 18):
#   apt install clang lld && sh build.sh
# The flags follow the firmware's: -O2 and -ffp-contract=off, so the arithmetic is the FM-1's.
set -e
cd "$(dirname "$0")"
clang --target=wasm32 -O2 -ffp-contract=off -std=gnu99 -ffreestanding -nostdlib -mbulk-memory \
    -DOM_HOST -Wall -Wno-unused-function \
    -Wl,--no-entry -Wl,-z,stack-size=65536 -Wl,--strip-all \
    -o ../om.wasm om_web.c omni.c
echo "om.wasm: $(wc -c < ../om.wasm) B"
