2021-05-18 09:31:05 -04:00
|
|
|
#!/usr/bin/env bash
|
2021-01-29 14:17:59 -05:00
|
|
|
|
2021-03-22 22:04:31 -04:00
|
|
|
echo "Formatting.."
|
|
|
|
clang-format -i src/uxn.h
|
|
|
|
clang-format -i src/uxn.c
|
2021-05-11 14:42:12 -04:00
|
|
|
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/devices/mpu.h
|
|
|
|
clang-format -i src/devices/mpu.c
|
2021-05-26 13:02:13 -04:00
|
|
|
clang-format -i src/uxnasm.c
|
|
|
|
clang-format -i src/uxnemu.c
|
|
|
|
clang-format -i src/uxncli.c
|
2021-01-29 14:17:59 -05:00
|
|
|
|
2021-03-22 22:04:31 -04:00
|
|
|
echo "Cleaning.."
|
2021-05-11 14:42:12 -04:00
|
|
|
rm -f ./bin/uxnasm
|
2021-05-11 23:30:03 -04:00
|
|
|
rm -f ./bin/uxnemu
|
2021-05-26 13:02:13 -04:00
|
|
|
rm -f ./bin/uxncli
|
2021-02-09 00:59:46 -05:00
|
|
|
rm -f ./bin/boot.rom
|
2021-01-29 14:17:59 -05:00
|
|
|
|
2021-03-22 22:04:31 -04:00
|
|
|
mkdir -p bin
|
2021-06-25 18:04:43 -04:00
|
|
|
CFLAGS="-std=c89 -Wall -Wno-unknown-pragmas"
|
|
|
|
UXNEMU_LDFLAGS="-L/usr/local/lib $(sdl2-config --cflags --libs)"
|
2021-06-25 18:20:36 -04:00
|
|
|
if cc ${CFLAGS} -c src/devices/mpu.c -o bin/mpu.o 2>/dev/null; then
|
|
|
|
rm -f bin/mpu.o
|
|
|
|
echo "Building with portmidi.."
|
|
|
|
UXNEMU_LDFLAGS="${UXNEMU_LDFLAGS} -lportmidi"
|
|
|
|
else
|
|
|
|
echo "Building without portmidi.."
|
|
|
|
CFLAGS="${CFLAGS} -DNO_PORTMIDI"
|
|
|
|
fi
|
2021-03-22 22:04:31 -04:00
|
|
|
if [ "${1}" = '--debug' ];
|
|
|
|
then
|
|
|
|
echo "[debug]"
|
2021-06-25 18:04:43 -04: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 18:30:40 -04:00
|
|
|
CORE='src/uxn.c'
|
2021-03-22 22:04:31 -04:00
|
|
|
else
|
2021-06-25 18:04:43 -04:00
|
|
|
CFLAGS="${CFLAGS} -DNDEBUG -Os -g0 -s"
|
2021-06-25 18:30:40 -04:00
|
|
|
CORE='src/uxn-fast.c'
|
2021-05-11 23:30:03 -04:00
|
|
|
fi
|
2021-06-25 18:04:43 -04:00
|
|
|
cc ${CFLAGS} src/uxnasm.c -o bin/uxnasm
|
|
|
|
cc ${CFLAGS} ${CORE} src/devices/ppu.c src/devices/apu.c src/devices/mpu.c src/uxnemu.c ${UXNEMU_LDFLAGS} -o bin/uxnemu
|
|
|
|
cc ${CFLAGS} ${CORE} src/uxncli.c -o bin/uxncli
|
2021-05-11 23:30:03 -04:00
|
|
|
|
|
|
|
echo "Installing.."
|
|
|
|
if [ -d "$HOME/bin" ] && [ -e ./bin/uxnemu ] && [ -e ./bin/uxnasm ]
|
|
|
|
then
|
|
|
|
cp ./bin/uxnemu $HOME/bin
|
|
|
|
cp ./bin/uxnasm $HOME/bin
|
2021-05-26 13:02:13 -04:00
|
|
|
cp ./bin/uxncli $HOME/bin
|
2021-06-23 11:01:24 -04:00
|
|
|
echo "Installed in $HOME/bin"
|
2021-03-22 22:04:31 -04:00
|
|
|
fi
|
2021-02-09 13:06:55 -05:00
|
|
|
|
2021-03-22 22:04:31 -04:00
|
|
|
echo "Assembling.."
|
2021-05-31 17:50:36 -04:00
|
|
|
./bin/uxnasm projects/examples/demos/piano.tal bin/piano.rom
|
2021-01-29 14:17:59 -05:00
|
|
|
|
2021-03-22 22:04:31 -04:00
|
|
|
echo "Running.."
|
2021-05-26 13:02:13 -04:00
|
|
|
./bin/uxnemu bin/piano.rom
|
2021-03-22 19:51:12 -04:00
|
|
|
|
2021-05-18 09:31:05 -04:00
|
|
|
echo "Done."
|