From 5ff9d6184771970c14e682ecf55cbd9d27b2fada Mon Sep 17 00:00:00 2001 From: Aiden Gall Date: Tue, 16 Jan 2024 19:24:18 +0000 Subject: initial commit --- Makefile | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 Makefile (limited to 'Makefile') diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0a49d95 --- /dev/null +++ b/Makefile @@ -0,0 +1,75 @@ +# Copyright (C) 2024 Aiden Gall +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +.POSIX: + +.PHONY: all clean dist install format + +include config.mk + +SRC = src/spirt.c src/util.c src/farbfeld.c +CLSRC = src/cl/spirt.cl +HDR = src/util.h src/farbfeld.h + +LL = ${CLSRC:.cl=.ll} +SPV = ${CLSRC:.cl=.spv} + +OBJ = ${SRC:.c=.o} ${CLSRC:.cl=.o} + +all: spirt + +src/spirt.o: config.mk src/util.h src/farbfeld.h +src/util.o: config.mk +src/farbfeld.o: config.mk src/util.h +src/cl/spirt.o: config.mk + +spirt: ${OBJ} + ${CC} -o $@ $^ ${LDFLAGS} + +%.o: %.c + ${CC} -c ${CFLAGS} $< -o $@ + +%.o: %.spv + objcopy ${OBJFLAGS} $< $@ + +%.spv: %.ll + llvm-spirv $< -o $@ + +%.ll: %.cl + clang -c ${CLFLAGS} $< -o $@ + +compile_commands.json: config.mk + echo ${SRC} | \ + jq -nR "[ inputs | split(\" \").[] | { \ + directory:\".\", \ + command:(\"${CC} -c ${CFLAGS} \" + .), \ + file:. } ]" > $@ + +clean: + rm -f spirt ${OBJ} ${LL} ${SPV} + +dist: clean + mkdir -p spirt-${VERSION} + cp -R LICENSE Makefile config.mk src/ .clang-format spirt-${VERSION} + tar -cf - spirt-${VERSION} | gzip > spirt-${VERSION}.tar.gz + rm -rf spirt-${VERSION} + +install: all + mkdir -p ${DESTDIR}${PREFIX}/bin + cp -f spirt ${DESTDIR}${PREFIX}/bin + chmod 755 ${DESTDIR}${PREFIX}/bin/spirt + +format: + for src in ${SRC} ${HDR} ${CLSRC}; do clang-format -i "$$src"; done -- cgit v1.2.3