blob: fe8ac934a7e45e4cfe355104359337c27860adc6 (
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
|
.PHONY: default clean check run debug debug-tests
default: dged
headers != find src/ -type f -name '*.h'
srcs != find src/ -type f -name '*.c' ! -name 'main.c'
test_headers != find test/ -type f -name '*.h'
test_srcs != find test/ -type f -name '*.c'
objs-path = objs
objs = $(patsubst %.c,$(objs-path)/%.o, $(srcs))
test_objs = $(patsubst %.c,$(objs-path)/test/%.o, $(test_srcs))
UNAME_S != uname -s
CFLAGS = -Werror -g -std=c99
ifeq ($(UNAME_S),Linux)
DEFINES += -DLINUX -D_XOPEN_SOURCE=700
endif
$(objs-path)/test/%.o: %.c $(headers)
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(DEFINES) -I ./src -I ./test -c $< -o $@
$(objs-path)/%.o: %.c $(headers)
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(DEFINES) -I ./src -c $< -o $@
dged: $(objs) $(objs-path)/src/main.o
$(CC) $(LDFLAGS) $(objs) $(objs-path)/src/main.o -o dged
run-tests: $(test_objs) $(objs)
$(CC) $(LDFLAGS) $(test_objs) $(objs) -o run-tests
check: run-tests
./run-tests
run: dged
./dged
debug: dged
gdb ./dged
debug-tests: run-tests
gdb ./run-tests
clean:
rm -rf $(objs-path) dged run-tests
|