blob: cc67800bb0e573a512ddba2db8503d308c95a1da (
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
|
CFLAGS = -Wall -Wextra -Wno-unused-variable -Werror -pedantic -ansi -D_POSIX_C_SOURCE=200809L
LDFLAGS =
TARG = dwrt
OBJ = parse.o util.o ast.o dwrt.o ast_nodes.o repl.o
SRC = $(OBJ:%.o=%.c)
PREFIX = /usr/local
ifeq (${DEBUG}, 1)
CFLAGS += -ggdb
endif
ifeq (${COV}, 1)
CFLAGS += -g -ftest-coverage -fprofile-arcs
endif
all: $(TARG)
ast_nodes.o: ast_nodes.c
$(CC) $(CFLAGS) -lm -o $@ -c $^
%.o: %.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ -c $^
cov: $(TARG)
@test -f "dwrt.gcda" || echo "Run make COV=1 to generate coverage information"
@test -d lcov || mkdir lcov
gcov $(SRC) $(TARG)
lcov -c -d . -o lcov/lcov.info
genhtml -o lcov/ lcov/lcov.info
format:
for f in $(SRC); do\
knfmt -i $$f;\
done
memcheck: $(TARG)
valgrind --leak-check=full ./$(TARG) x
test: $(OBJ)
$(MAKE) -C test CFLAGS="$(CFLAGS)" test
$(TARG): main.c $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
clean:
rm -f $(TARG) *.o *.gcov *.gcda *.gcno
rm -rf lcov/*
$(MAKE) -C test clean
tags:
etags *.c *.h
check-syntax:
$(CC) $(CFLAGS) -fsyntax-only $(CHK_SOURCES)
install: all
mkdir -p ${DESTDIR}${PREFIX}/bin
cp -f $(TARG) ${DESTDIR}${PREFIX}/bin
chmod 755 ${DESTDIR}${PREFIX}/bin/$(TARG)
uninstall:
rm -f ${DESTDIR}${PREFIX}/bin/$(TARG)
.PHONY: all clean tags check-syntax install uninstall
|