blob: 0a49d95411af8435672dbc609394f56dd998eb9f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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 <http://www.gnu.org/licenses/>.
.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
|