2021-05-18 13:31:05 +00:00
|
|
|
#!/usr/bin/env bash
|
2021-01-29 19:17:59 +00:00
|
|
|
|
2021-03-23 02:04:31 +00:00
|
|
|
echo "Cleaning.."
|
2021-05-11 18:42:12 +00:00
|
|
|
rm -f ./bin/uxnasm
|
2021-05-12 03:30:03 +00:00
|
|
|
rm -f ./bin/uxnemu
|
2021-05-26 17:02:13 +00:00
|
|
|
rm -f ./bin/uxncli
|
2021-02-09 05:59:46 +00:00
|
|
|
rm -f ./bin/boot.rom
|
2021-01-29 19:17:59 +00:00
|
|
|
|
2021-06-26 02:03:56 +00:00
|
|
|
# When clang-format is present
|
|
|
|
|
|
|
|
if command -v clang-format &> /dev/null
|
|
|
|
then
|
|
|
|
echo "Formatting.."
|
|
|
|
clang-format -i src/uxn.h
|
|
|
|
clang-format -i src/uxn.c
|
|
|
|
clang-format -i src/devices/ppu.h
|
|
|
|
clang-format -i src/devices/ppu.c
|
|
|
|
clang-format -i src/devices/apu.h
|
|
|
|
clang-format -i src/devices/apu.c
|
|
|
|
clang-format -i src/uxnasm.c
|
|
|
|
clang-format -i src/uxnemu.c
|
|
|
|
clang-format -i src/uxncli.c
|
|
|
|
fi
|
|
|
|
|
2021-03-23 02:04:31 +00:00
|
|
|
mkdir -p bin
|
2021-06-25 22:04:43 +00:00
|
|
|
CFLAGS="-std=c89 -Wall -Wno-unknown-pragmas"
|
2021-07-27 20:13:12 +00:00
|
|
|
if [ -n "${MSYSTEM}" ]; then
|
|
|
|
UXNEMU_LDFLAGS="-static $(sdl2-config --cflags --static-libs)"
|
|
|
|
else
|
|
|
|
UXNEMU_LDFLAGS="-L/usr/local/lib $(sdl2-config --cflags --libs)"
|
|
|
|
fi
|
2021-06-26 02:03:56 +00:00
|
|
|
|
2021-03-23 02:04:31 +00:00
|
|
|
if [ "${1}" = '--debug' ];
|
|
|
|
then
|
|
|
|
echo "[debug]"
|
2021-06-25 22:04:43 +00:00
|
|
|
CFLAGS="${CFLAGS} -DDEBUG -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined"
|
2021-06-25 22:30:40 +00:00
|
|
|
CORE='src/uxn.c'
|
2021-03-23 02:04:31 +00:00
|
|
|
else
|
2021-06-25 22:04:43 +00:00
|
|
|
CFLAGS="${CFLAGS} -DNDEBUG -Os -g0 -s"
|
2021-06-25 22:30:40 +00:00
|
|
|
CORE='src/uxn-fast.c'
|
2021-05-12 03:30:03 +00:00
|
|
|
fi
|
2021-06-26 02:03:56 +00:00
|
|
|
|
2021-06-27 17:56:21 +00:00
|
|
|
echo "Building.."
|
2021-06-25 22:04:43 +00:00
|
|
|
cc ${CFLAGS} src/uxnasm.c -o bin/uxnasm
|
2021-06-26 20:17:41 +00:00
|
|
|
cc ${CFLAGS} ${CORE} src/devices/ppu.c src/devices/apu.c src/uxnemu.c ${UXNEMU_LDFLAGS} -o bin/uxnemu
|
2021-06-25 22:04:43 +00:00
|
|
|
cc ${CFLAGS} ${CORE} src/uxncli.c -o bin/uxncli
|
2021-05-12 03:30:03 +00:00
|
|
|
|
|
|
|
if [ -d "$HOME/bin" ] && [ -e ./bin/uxnemu ] && [ -e ./bin/uxnasm ]
|
|
|
|
then
|
2021-06-26 02:03:56 +00:00
|
|
|
echo "Installing in $HOME/bin"
|
2021-05-12 03:30:03 +00:00
|
|
|
cp ./bin/uxnemu $HOME/bin
|
|
|
|
cp ./bin/uxnasm $HOME/bin
|
2021-05-26 17:02:13 +00:00
|
|
|
cp ./bin/uxncli $HOME/bin
|
2021-03-23 02:04:31 +00:00
|
|
|
fi
|
2021-02-09 18:06:55 +00:00
|
|
|
|
2021-03-23 02:04:31 +00:00
|
|
|
echo "Assembling.."
|
2021-08-01 18:00:07 +00:00
|
|
|
./bin/uxnasm projects/examples/devices/screen.tal bin/screen.rom
|
2021-01-29 19:17:59 +00:00
|
|
|
|
2021-03-23 02:04:31 +00:00
|
|
|
echo "Running.."
|
2021-08-01 18:00:07 +00:00
|
|
|
./bin/uxnemu bin/screen.rom
|
2021-03-22 23:51:12 +00:00
|
|
|
|
2021-05-18 13:31:05 +00:00
|
|
|
echo "Done."
|