-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
41 lines (30 loc) · 855 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
include config.mk
.PHONY: default all clean cloc
# default: $(TARGET)
default: all
all: options tags $(TARGET)
SOURCES = $(wildcard $(SRCDIR)/*.c)
OBJECTS = $(patsubst $(SRCDIR)/%, $(OBJDIR)/%, $(patsubst %.c, %.o, $(SOURCES)))
HEADERS = $(wildcard $(SRCDIR)/*.h)
DEPENDS = $(OBJECTS:.o=.d)
-include $(DEPENDS)
$(OBJDIR)/%.o: $(SRCDIR)/%.c $(HEADERS)
$(CC) $(CFLAGS) -c $< -o $@
$(CC) $(CFLAGS) -MM $< -o $(@:.o=.d)
.PRECIOUS: $(TARGET) $(OBJECTS)
$(TARGET): $(OBJECTS)
$(CC) $(OBJECTS) -Wall $(LDFLAGS) -o $@
clean:
rm -rf tags
rm -rf $(DEPENDS)
rm -rf $(OBJECTS)
rm -rf $(TARGET)
cloc:
cloc --not-match-f=tags --not-match-f=ycm --not-match-d=build .
options:
@echo build options:
@echo "CFLAGS = $(CFLAGS)"
@echo "LDFLAGS = $(LDFLAGS)"
@echo "CC = $(CC)"
tags: src/*
ctags --recurse --fields=+l --langmap=c:.c.h ./src/*