-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
44 lines (31 loc) · 864 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
# vim: noexpandtab filetype=make
TARGET = insoluble
DEPDIR := .d
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td
CC = gcc
CFLAGS = -g -std=c11 -pedantic-errors -Wall $(DEPFLAGS)
LINKER = gcc -o
LFLAGS = -g -Wall
SRCDIR = src
OBJDIR = obj
BINDIR = bin
SOURCES := $(wildcard $(SRCDIR)/*.c)
INCLUDES := $(wildcard $(SRCDIR)/*.h)
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
rm = rm -f
POSTCOMPILE = @mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d && touch $@
$(shell mkdir -p $(DEPDIR) >/dev/null)
$(BINDIR)/$(TARGET): $(OBJECTS)
$(LINKER) $@ $(LFLAGS) $(OBJECTS)
$(OBJDIR)/%.o : $(SRCDIR)/%.c
$(OBJDIR)/%.o : $(SRCDIR)/%.c $(DEPDIR)/%.d
$(CC) $(CFLAGS) -c $< -o $@
$(POSTCOMPILE)
$(DEPDIR)/%.d: ;
.PRECIOUS: $(DEPDIR)/%.d
.PHONEY: clean
clean:
$(rm) $(wildcard $(DEPDIR)/*.d)
$(rm) $(OBJECTS)
$(rm) $(BINDIR)/$(TARGET)
include $(wildcard $(DEPDIR)/*.d)