-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (40 loc) · 1.16 KB
/
Makefile
File metadata and controls
58 lines (40 loc) · 1.16 KB
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
.SECONDEXPANSION:
CC = gcc
CFLAGS = -I. -Wall -Wextra -pedantic -std=c11 -g -fsanitize=address,undefined
SRCDIR = src
OUTDIR = out
IMGDIR = img
IMGFMT = png
DOTVER = $(IMGDIR)/dot_version.txt
DOTCMD = dot
SRCS != find $(SRCDIR) -name '*.c'
PROGS := $(patsubst $(SRCDIR)/%.c,$(OUTDIR)/%,$(SRCS))
IMGS := $(patsubst $(SRCDIR)/%.c,$(IMGDIR)/%.$(IMGFMT),$(SRCS))
.PHONY: all clean list progs imgs hook dotver
all: progs imgs
progs: $(PROGS)
imgs: $(IMGS) $(DOTVER)
$(PROGS): $(OUTDIR)/%: $(SRCDIR)/%.c frk.h frk.c | $$(dir $$@)
$(CC) $(CFLAGS) -o $@ $< frk.c
$(IMGS): $(IMGDIR)/%.$(IMGFMT): $(OUTDIR)/% | $$(dir $$@)
$< | $(DOTCMD) -T$(IMGFMT) -o $@
dotver: $(DOTVER)
$(DOTVER): | $(dir $(DOTVER))
$(DOTCMD) -V > $@ 2>&1
$(sort $(dir $(PROGS)) $(dir $(IMGS)) $(dir $(DOTVER))):
mkdir -p $@
clean_dirs = if [ -d $(1) ]; then find $(1) -type d -empty -delete; fi
clean:
rm -f $(PROGS) $(IMGS) $(DOTVER)
$(call clean_dirs,$(OUTDIR))
$(call clean_dirs,$(IMGDIR))
print_var = $(info $(1) = $(sort $($(1))))
list:
$(call print_var,SRCS)
$(call print_var,PROGS)
$(call print_var,IMGS)
@:
hook: .git/hooks/pre-commit
.git/hooks/pre-commit: pre-commit
cp $< $@
chmod +x $@