2021-08-18 23:23:15 +00:00
|
|
|
#!/bin/sh -e
|
2021-01-29 19:17:59 +00:00
|
|
|
|
2022-01-06 12:31:09 +00:00
|
|
|
format=0
|
|
|
|
console=0
|
2022-02-04 03:52:12 +00:00
|
|
|
install=0
|
2022-01-06 12:31:09 +00:00
|
|
|
debug=0
|
|
|
|
norun=0
|
|
|
|
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case $1 in
|
|
|
|
--format)
|
|
|
|
format=1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
|
|
|
--console)
|
|
|
|
console=1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
2022-02-04 03:52:12 +00:00
|
|
|
--install)
|
|
|
|
install=1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
2022-01-06 12:31:09 +00:00
|
|
|
--debug)
|
|
|
|
debug=1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
|
|
|
--no-run)
|
|
|
|
norun=1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
shift
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2021-03-23 02:04:31 +00:00
|
|
|
echo "Cleaning.."
|
2022-03-14 17:21:36 +00:00
|
|
|
rm -f ./bin/*
|
2021-01-29 19:17:59 +00:00
|
|
|
|
2021-06-26 02:03:56 +00:00
|
|
|
# When clang-format is present
|
|
|
|
|
2022-01-06 12:31:09 +00:00
|
|
|
if [ $format = 1 ];
|
2021-06-26 02:03:56 +00:00
|
|
|
then
|
|
|
|
echo "Formatting.."
|
2022-01-05 13:28:22 +00:00
|
|
|
clang-format -i src/devices/system.h
|
2022-01-05 12:59:22 +00:00
|
|
|
clang-format -i src/devices/system.c
|
2021-12-28 21:37:26 +00:00
|
|
|
clang-format -i src/devices/screen.h
|
|
|
|
clang-format -i src/devices/screen.c
|
2021-12-28 21:47:35 +00:00
|
|
|
clang-format -i src/devices/audio.h
|
|
|
|
clang-format -i src/devices/audio.c
|
2021-11-05 21:32:45 +00:00
|
|
|
clang-format -i src/devices/file.h
|
|
|
|
clang-format -i src/devices/file.c
|
2021-12-27 05:02:24 +00:00
|
|
|
clang-format -i src/devices/mouse.h
|
|
|
|
clang-format -i src/devices/mouse.c
|
2021-12-27 17:24:43 +00:00
|
|
|
clang-format -i src/devices/controller.h
|
|
|
|
clang-format -i src/devices/controller.c
|
2022-01-07 18:02:28 +00:00
|
|
|
clang-format -i src/devices/datetime.h
|
|
|
|
clang-format -i src/devices/datetime.c
|
2021-06-26 02:03:56 +00:00
|
|
|
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-11-08 17:31:08 +00:00
|
|
|
CC="${CC:-cc}"
|
2021-11-17 13:12:02 +00:00
|
|
|
CFLAGS="${CFLAGS:--std=c89 -Wall -Wno-unknown-pragmas}"
|
2021-10-10 19:07:40 +00:00
|
|
|
case "$(uname -s 2>/dev/null)" in
|
2021-12-13 23:44:58 +00:00
|
|
|
MSYS_NT*|MINGW*) # MSYS2 on Windows
|
2023-01-31 17:05:01 +00:00
|
|
|
FILE_LDFLAGS="-liberty"
|
2022-01-06 12:31:09 +00:00
|
|
|
if [ $console = 1 ];
|
2021-12-19 11:39:41 +00:00
|
|
|
then
|
|
|
|
UXNEMU_LDFLAGS="-static $(sdl2-config --cflags --static-libs | sed -e 's/ -mwindows//g')"
|
|
|
|
else
|
|
|
|
UXNEMU_LDFLAGS="-static $(sdl2-config --cflags --static-libs)"
|
|
|
|
fi
|
2021-10-10 19:07:40 +00:00
|
|
|
;;
|
|
|
|
Darwin) # macOS
|
|
|
|
CFLAGS="${CFLAGS} -Wno-typedef-redefinition"
|
2021-12-12 20:30:33 +00:00
|
|
|
UXNEMU_LDFLAGS="$(brew --prefix)/lib/libSDL2.a $(sdl2-config --cflags --static-libs | sed -e 's/-lSDL2 //')"
|
2021-10-10 19:07:40 +00:00
|
|
|
;;
|
|
|
|
Linux|*)
|
2021-07-27 20:13:12 +00:00
|
|
|
UXNEMU_LDFLAGS="-L/usr/local/lib $(sdl2-config --cflags --libs)"
|
2021-10-10 19:07:40 +00:00
|
|
|
;;
|
|
|
|
esac
|
2021-06-26 02:03:56 +00:00
|
|
|
|
2022-01-06 12:31:09 +00:00
|
|
|
if [ $debug = 1 ];
|
2021-03-23 02:04:31 +00:00
|
|
|
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"
|
2022-01-02 23:05:28 +00:00
|
|
|
CORE='src/uxn.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-11-08 17:31:08 +00:00
|
|
|
${CC} ${CFLAGS} src/uxnasm.c -o bin/uxnasm
|
2023-01-31 17:05:01 +00:00
|
|
|
${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/devices/mouse.c src/devices/controller.c src/devices/screen.c src/devices/audio.c src/uxnemu.c ${UXNEMU_LDFLAGS} ${FILE_LDFLAGS} -o bin/uxnemu
|
|
|
|
${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/uxncli.c ${FILE_LDFLAGS} -o bin/uxncli
|
2021-05-12 03:30:03 +00:00
|
|
|
|
2022-02-04 03:52:12 +00:00
|
|
|
if [ $install = 1 ]
|
2021-05-12 03:30:03 +00:00
|
|
|
then
|
2021-06-26 02:03:56 +00:00
|
|
|
echo "Installing in $HOME/bin"
|
2021-08-19 05:08:09 +00:00
|
|
|
cp bin/uxnemu bin/uxnasm bin/uxncli $HOME/bin/
|
2021-03-23 02:04:31 +00:00
|
|
|
fi
|
2021-02-09 18:06:55 +00:00
|
|
|
|
2022-01-11 04:35:34 +00:00
|
|
|
echo "Assembling(launcher).."
|
|
|
|
./bin/uxnasm projects/software/launcher.tal bin/launcher.rom
|
2021-10-08 01:28:06 +00:00
|
|
|
echo "Assembling(asma).."
|
|
|
|
./bin/uxnasm projects/software/asma.tal bin/asma.rom
|
|
|
|
|
2022-01-06 12:31:09 +00:00
|
|
|
if [ $norun = 1 ]; then exit; fi
|
2021-10-14 22:38:29 +00:00
|
|
|
|
2021-10-08 01:28:06 +00:00
|
|
|
echo "Assembling(piano).."
|
2023-01-07 19:59:00 +00:00
|
|
|
./bin/uxnasm projects/software/piano.tal bin/piano.rom
|
2021-01-29 19:17:59 +00:00
|
|
|
|
2021-03-23 02:04:31 +00:00
|
|
|
echo "Running.."
|
2023-01-01 21:19:40 +00:00
|
|
|
./bin/uxnemu bin/piano.rom
|
2021-03-22 23:51:12 +00:00
|
|
|
|
2021-05-18 13:31:05 +00:00
|
|
|
echo "Done."
|