-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
45 lines (31 loc) · 926 Bytes
/
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
.DEFAULT_GOAL := all
include config.mk
SRC := $(wildcard *.c) $(wildcard $(patsubst %,%/*.c, $(MODULES)))
OBJS := $(SRC:.c=.o)
DOBJS := $(SRC:.c=.do)
DEPS := $(SRC:.c=.d)
all: release
release: CFLAGS += $(CFLAGS.release)
release: LDFLAGS += $(LDFLAGS.release)
release: $(PROG)
debug: CFLAGS += $(CFLAGS.debug)
debug: LDFLAGS += $(LDFLAGS.debug)
debug: $(PROG)-debug
$(PROG): $(OBJS)
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
$(PROG)-debug: $(DOBJS)
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
# Compile and generate dependency info
%.o: %.c
$(CC) -c $(CFLAGS) $*.c -o $*.o
$(CPP) -MM $(DEPFLAGS) -MT $@ $*.c -MF $*.d
%.do: %.c
$(CC) -c $(CFLAGS) $*.c -o $*.do
$(CPP) -MM $(DEPFLAGS) -MT $@ $*.c -MF $*.d
# Include dependency info for *existing* object files
-include $(DEPS)
clean:
$(RM) -rf $(PROG) $(PROG)-debug $(OBJS) $(DOBJS) $(DEPS) $(TAGFILE)
tags:
ctags -R -f $(TAGFILE) .
.PHONY: all release debug clean tags