2021-08-18 19:23:15 -04:00
|
|
|
#!/bin/sh -e
|
2021-01-29 14:17:59 -05:00
|
|
|
|
2022-01-06 07:31:09 -05:00
|
|
|
format=0
|
|
|
|
console=0
|
2022-02-03 22:52:12 -05:00
|
|
|
install=0
|
2022-01-06 07:31:09 -05:00
|
|
|
debug=0
|
|
|
|
norun=0
|
|
|
|
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case $1 in
|
|
|
|
--format)
|
|
|
|
format=1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
|
|
|
--console)
|
|
|
|
console=1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
2022-02-03 22:52:12 -05:00
|
|
|
--install)
|
|
|
|
install=1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
2022-01-06 07:31:09 -05:00
|
|
|
--debug)
|
|
|
|
debug=1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
|
|
|
--no-run)
|
|
|
|
norun=1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
shift
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2022-03-14 13:21:36 -04:00
|
|
|
rm -f ./bin/*
|
2021-01-29 14:17:59 -05:00
|
|
|
|
2021-06-25 22:03:56 -04:00
|
|
|
# When clang-format is present
|
|
|
|
|
2022-01-06 07:31:09 -05:00
|
|
|
if [ $format = 1 ];
|
2021-06-25 22:03:56 -04:00
|
|
|
then
|
|
|
|
clang-format -i src/uxnasm.c
|
|
|
|
clang-format -i src/uxncli.c
|
2023-06-08 12:31:01 -04:00
|
|
|
clang-format -i src/uxnemu.c
|
|
|
|
clang-format -i src/devices/*
|
2021-06-25 22:03:56 -04:00
|
|
|
fi
|
|
|
|
|
2021-03-22 22:04:31 -04:00
|
|
|
mkdir -p bin
|
2021-11-08 12:31:08 -05:00
|
|
|
CC="${CC:-cc}"
|
2023-10-10 10:12:47 -04:00
|
|
|
CFLAGS="${CFLAGS:--std=c89 -Wall -Wno-unknown-pragmas}"
|
2021-10-10 15:07:40 -04:00
|
|
|
case "$(uname -s 2>/dev/null)" in
|
2021-12-13 18:44:58 -05:00
|
|
|
MSYS_NT*|MINGW*) # MSYS2 on Windows
|
2023-01-31 12:05:01 -05:00
|
|
|
FILE_LDFLAGS="-liberty"
|
2022-01-06 07:31:09 -05:00
|
|
|
if [ $console = 1 ];
|
2021-12-19 06:39:41 -05: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 15:07:40 -04:00
|
|
|
;;
|
|
|
|
Darwin) # macOS
|
2023-05-15 10:33:33 -04:00
|
|
|
CFLAGS="${CFLAGS} -Wno-typedef-redefinition -D_C99_SOURCE"
|
2023-10-29 16:18:22 -04:00
|
|
|
UXNEMU_LDFLAGS="$(sdl2-config --cflags --static-libs)"
|
2021-10-10 15:07:40 -04:00
|
|
|
;;
|
|
|
|
Linux|*)
|
2021-07-27 16:13:12 -04:00
|
|
|
UXNEMU_LDFLAGS="-L/usr/local/lib $(sdl2-config --cflags --libs)"
|
2021-10-10 15:07:40 -04:00
|
|
|
;;
|
|
|
|
esac
|
2021-06-25 22:03:56 -04:00
|
|
|
|
2022-01-06 07:31:09 -05:00
|
|
|
if [ $debug = 1 ];
|
2021-03-22 22:04:31 -04:00
|
|
|
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-03-22 22:04:31 -04:00
|
|
|
else
|
2023-03-02 19:56:49 -05:00
|
|
|
CFLAGS="${CFLAGS} -DNDEBUG -O2 -g0 -s"
|
2021-05-11 23:30:03 -04:00
|
|
|
fi
|
2021-06-25 22:03:56 -04:00
|
|
|
|
2021-11-08 12:31:08 -05:00
|
|
|
${CC} ${CFLAGS} src/uxnasm.c -o bin/uxnasm
|
2023-08-08 17:13:07 -04:00
|
|
|
${CC} ${CFLAGS} src/uxn.c src/devices/system.c src/devices/console.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} src/uxn.c src/devices/system.c src/devices/console.c src/devices/file.c src/devices/datetime.c src/uxncli.c ${FILE_LDFLAGS} -o bin/uxncli
|
2021-05-11 23:30:03 -04:00
|
|
|
|
2022-02-03 22:52:12 -05:00
|
|
|
if [ $install = 1 ]
|
2021-05-11 23:30:03 -04:00
|
|
|
then
|
2021-08-19 01:08:09 -04:00
|
|
|
cp bin/uxnemu bin/uxnasm bin/uxncli $HOME/bin/
|
2021-03-22 22:04:31 -04:00
|
|
|
fi
|
2021-02-09 13:06:55 -05:00
|
|
|
|
2022-01-10 23:35:34 -05:00
|
|
|
./bin/uxnasm projects/software/launcher.tal bin/launcher.rom
|
2021-10-07 21:28:06 -04:00
|
|
|
./bin/uxnasm projects/software/asma.tal bin/asma.rom
|
|
|
|
|
2022-01-06 07:31:09 -05:00
|
|
|
if [ $norun = 1 ]; then exit; fi
|
2021-10-14 18:38:29 -04:00
|
|
|
|
2023-08-08 18:56:40 -04:00
|
|
|
# Test usage
|
|
|
|
|
2023-08-08 19:35:35 -04:00
|
|
|
./bin/uxnasm
|
2023-08-08 18:56:40 -04:00
|
|
|
./bin/uxncli
|
|
|
|
./bin/uxnemu
|
|
|
|
|
|
|
|
# Test version
|
|
|
|
|
2023-08-08 19:35:35 -04:00
|
|
|
./bin/uxnasm -v
|
2023-08-08 18:56:40 -04:00
|
|
|
./bin/uxncli -v
|
|
|
|
./bin/uxnemu -v
|
|
|
|
|
2023-10-10 08:54:44 -04:00
|
|
|
./bin/uxnasm projects/examples/devices/audio-tests.tal bin/audio-tests.rom
|
2021-01-29 14:17:59 -05:00
|
|
|
|
2023-10-10 08:54:44 -04:00
|
|
|
./bin/uxnemu -2x bin/audio-tests.rom
|