-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
62 lines (43 loc) · 1.68 KB
/
Makefile
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
PREFIX = /usr/local
CFLAGS = -std=c11 -g -Wall -Werror
CFLAGS += -O2 -DNDEBUG -march=native -mtune=native -fomit-frame-pointer -s -flto
AMALG = mascara.h mascara.c
EXAMPLES = $(patsubst %.c,%,$(wildcard examples/*))
#--------------------------------------
# Abstract targets
#--------------------------------------
all: $(AMALG) mascara $(EXAMPLES)
clean:
rm -f mascara $(EXAMPLES) test/mascara.so vgcore* core
check: test/mascara.so
cd test && valgrind --leak-check=full --error-exitcode=1 lua test.lua
install: mascara
install -spm 0755 $< $(PREFIX)/bin/mascara
install -pm 0644 cmd/mascara.1 $(PREFIX)/share/man/man1/mascara.1
$(foreach model, $(wildcard models/*), \
install -pDm +r $(model) $(PREFIX)/share/mascara/$(notdir $(model));)
uninstall:
rm -f $(PREFIX)/bin/mascara
rm -f $(PREFIX)/share/man/man1/mascara.1
$(foreach model, $(wildcard models/*), \
rm -f $(PREFIX)/share/mascara/$(notdir $(model));)
rmdir $(PREFIX)/share/mascara/ 2> /dev/null || true
.PHONY: all clean check install uninstall
#--------------------------------------
# Concrete targets
#--------------------------------------
cmd/%.ih: cmd/%.txt
cmd/mkcstring.py < $< > $@
cmd/%.ic: cmd/%.rl
ragel -e -T1 $^ -o $@
mascara.h: src/api.h
cp $< $@
mascara.c: $(wildcard src/*.h src/*.c src/*.cm src/gen/*.ic src/lib/*.c)
src/scripts/mkamalg.py src/*.c src/lib/*.c > $@
mascara: $(AMALG) cmd/mascara.ih cmd/print_str.ic cmd/mascara.c cmd/cmd.c
$(CC) $(CFLAGS) -DMR_HOME='"$(PREFIX)/share/mascara"' mascara.c \
cmd/mascara.c cmd/cmd.c -o $@
examples/%: examples/%.c $(AMALG)
$(CC) $(CFLAGS) $< mascara.c -o $@
test/mascara.so: test/mascara.c $(AMALG)
$(CC) $(CFLAGS) -fPIC -shared $< mascara.c -o $@