# 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/util_cl.c CLSRC = src/cl/spirt.cl HDR = src/util.h src/util_cl.h LL = ${CLSRC:.cl=.ll} SPV = ${CLSRC:.cl=.spv} OBJ = ${SRC:.c=.o} ${CLSRC:.cl=.o} all: spirt src/util.o: config.mk src/util_cl.o: config.mk src/util.h src/spirt.o: config.mk src/util.h src/util_cl.h src/cl/spirt.o: config.mk spirt: ${OBJ} ${CC} $(LDFLAGS) $^ $(LDLIBS) -o $@ %.o: %.c ${CC} $(CFLAGS) -c -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