2024-01-15 15:30:21 -07:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
# Copyright (c) 2023–2024 Emma Tebibyte <emma@tebibyte.media>
|
|
|
|
|
# SPDX-License-Identifier: FSFAP
|
|
|
|
|
#
|
|
|
|
|
# Copying and distribution of this file, with or without modification, are
|
|
|
|
|
# permitted in any medium without royalty provided the copyright notice and this
|
|
|
|
|
# notice are preserved. This file is offered as-is, without any warranty.
|
|
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
CFLAGS='-Lbuild/lib -idirafter include -O3'
|
|
|
|
|
RUSTFLAGS='-Copt-level=z -Ccodegen-units=1 -Cpanic=abort -Clto=y \
|
|
|
|
|
-Cstrip=symbols -Ctarget-cpu=native \
|
|
|
|
|
--extern sysexits=build/o/libsysexits.rlib'
|
|
|
|
|
|
2024-01-16 16:47:26 -07:00
|
|
|
|
if [ "$1" = "clean" ]; then
|
|
|
|
|
rm *.mk || true
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
while test -n "$1"; do
|
|
|
|
|
case "$1" in
|
|
|
|
|
clang)
|
|
|
|
|
CFLAGS="$CFLAGS -Wall"
|
|
|
|
|
;;
|
|
|
|
|
gcc)
|
|
|
|
|
CFLAGS="$CFLAGS -s -Wl,-z,noseparate-code,-z,nosectionheader -flto"
|
|
|
|
|
;;
|
2024-01-19 20:31:34 -07:00
|
|
|
|
rustc) ;;
|
2024-01-16 16:47:26 -07:00
|
|
|
|
'rustc +nightly')
|
|
|
|
|
RUSTFLAGS="+nightly -Zlocation-detail=none $RUSTFLAGS"
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
printf 'Usage: %s [clean | compiler]\n' "$0"
|
|
|
|
|
exit 64 # sysexits.h(3) EX_USAGE
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
shift
|
|
|
|
|
done
|
2024-01-15 15:30:21 -07:00
|
|
|
|
|
|
|
|
|
printf 'CFLAGS=%s\n' "$CFLAGS" >cc.mk
|
|
|
|
|
printf 'RUSTFLAGS=%s\n' "$RUSTFLAGS" >rustc.mk
|