From c3457421216e0f8edef51ec543aa547f0bf123f0 Mon Sep 17 00:00:00 2001 From: neauoire Date: Thu, 10 Aug 2023 21:44:28 -0700 Subject: [PATCH] Replaced shell script with makefile --- build.sh | 63 -------------------------------------------------------- makefile | 40 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 63 deletions(-) delete mode 100755 build.sh create mode 100644 makefile diff --git a/build.sh b/build.sh deleted file mode 100755 index 3c15a93..0000000 --- a/build.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh -e - -RELEASE_FLAGS="-DNDEBUG -O2 -g0 -s" -DEBUG_FLAGS="-std=c89 -D_POSIX_C_SOURCE=199309L -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined" -CORE_DEVICES="src/uxn.c src/devices/system.c src/devices/console.c src/devices/file.c src/devices/datetime.c -lpthread" -EMU_INC="${CORE_DEVICES} src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/uxn11.c -o bin/uxn11 -lX11" -CLI_INC="${CORE_DEVICES} src/uxncli.c -o bin/uxncli" - -# find X11 libs on various systems -if [ -e /usr/X11R6 ]; then - # OpenBSD - RELEASE_FLAGS="-L/usr/X11R6/lib/ -I/usr/X11R6/include/ $RELEASE_FLAGS" - DEBUG_FLAGS="-L/usr/X11R6/lib/ -I/usr/X11R6/include/ $DEBUG_FLAGS" -fi - -if [ "${1}" = '--format' ]; -then - clang-format -i src/uxn11.c - clang-format -i src/uxnasm.c - clang-format -i src/uxncli.c - clang-format -i src/devices/* -fi - -mkdir -p bin - -cc ${RELEASE_FLAGS} src/uxnasm.c -o bin/uxnasm - -if [ "${1}" = '--debug' ]; -then - cc ${C_FLAGS} ${LD_FLAGS} ${DEBUG_FLAGS} ${EMU_INC} - cc ${C_FLAGS} ${LD_FLAGS} ${DEBUG_FLAGS} ${CLI_INC} -else - cc ${C_FLAGS} ${LD_FLAGS} ${RELEASE_FLAGS} ${EMU_INC} - cc ${C_FLAGS} ${LD_FLAGS} ${RELEASE_FLAGS} ${CLI_INC} -fi - -if [ "${1}" = '--install' ]; -then - cp bin/uxn11 bin/uxnasm bin/uxncli $HOME/bin/ -fi - -# bin/uxnasm etc/polycat.tal bin/polycat.rom -# bin/uxn11 bin/polycat.rom -# bin/uxnasm etc/friend.tal bin/friend.rom - -if [ "${1}" = '--norun' ]; then exit; fi - -# Test usage - -./bin/uxnasm -./bin/uxncli -./bin/uxn11 - -# Test version - -./bin/uxnasm -v -./bin/uxncli -v -./bin/uxn11 -v - -# bin/uxnasm etc/mouse.tal bin/res.rom -bin/uxnasm etc/pict.tal bin/res.rom -bin/uxn11 bin/res.rom - diff --git a/makefile b/makefile new file mode 100644 index 0000000..1e97104 --- /dev/null +++ b/makefile @@ -0,0 +1,40 @@ + +CLI_src=src/uxn.c src/devices/system.c src/devices/console.c src/devices/file.c src/devices/datetime.c +EMU_src=${CLI_src} src/devices/screen.c src/devices/controller.c src/devices/mouse.c + +RELEASE_flags=-DNDEBUG -O2 -g0 -s +DEBUG_flags=-std=c89 -D_POSIX_C_SOURCE=199309L -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined + +all: dest uxnasm uxncli uxn11 + +uxnasm: + cc ${RELEASE_flags} src/uxnasm.c -o bin/uxnasm +uxncli: + gcc ${RELEASE_flags} ${CLI_src} src/uxncli.c -o bin/uxncli +uxn11: + gcc ${RELEASE_flags} ${EMU_src} src/uxn11.c -lX11 -o bin/uxn11 + +debug: dest uxnasm-debug uxncli-debug uxn11-debug + +uxnasm-debug: + cc ${DEBUG_flags} src/uxnasm.c -o bin/uxnasm +uxncli-debug: + gcc ${DEBUG_flags} ${CLI_src} src/uxncli.c -o bin/uxncli +uxn11-debug: + gcc ${DEBUG_flags} ${EMU_src} src/uxn11.c -lX11 -o bin/uxn11 + +dest: + mkdir -p bin +rom: + ./bin/uxnasm etc/polycat.tal bin/polycat.rom + +run: uxnasm uxncli uxn11 rom + ./bin/uxn11 bin/polycat.rom +install: uxnasm uxncli uxn11 + cp bin/uxn11 bin/uxnasm bin/uxncli ~/bin/ +uninstall: + rm -f ~/bin/uxn11 ~/bin/uxnasm ~/bin/uxncli +format: + clang-format -i src/uxnasm.c src/uxncli.c src/uxn11.c src/devices/* +clean: + rm -f bin/uxnasm bin/uxncli bin/uxn11 bin/polycat.rom bin/polycat.rom.sym