-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
50 lines (34 loc) · 1.05 KB
/
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
46
47
48
49
TARGET=global-illumination
CC=g++ -std=c++11
RM=rm -f
DEPDIR=.depend
OBJDIR=build
# Copy source folder structure to build and depend stores
$(shell mkdir -p $(DEPDIR) >/dev/null)
$(shell find src -type d -exec mkdir -p -- $(DEPDIR)/{} \;)
$(shell mkdir -p $(OBJDIR) >/dev/null)
$(shell find src -type d -exec mkdir -p -- $(OBJDIR)/{} \;)
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.dep.tmp
CFLAGS=$(shell bash config --cflags)
LFLAGS=$(shell bash config --lflags)
LIBS=$(shell bash config --libs)
COMPILE = $(CC) $(DEPFLAGS) $(CFLAGS) -c -o $@
POSTCOMPILE = mv -f $(DEPDIR)/$*.dep.tmp $(DEPDIR)/$*.dep
SRCS=$(shell find src -type f -name \*.cpp)
OBJS=$(addprefix $(OBJDIR)/,$(subst .cpp,.o,$(SRCS)))
.PHONY: all
all: $(TARGET)
$(OBJDIR)/%.o: %.cpp
$(OBJDIR)/%.o: %.cpp $(DEPDIR)/%.dep config
$(COMPILE) $<
$(POSTCOMPILE)
%.dep: ;
$(TARGET): $(OBJS) config
$(CC) $(DEBUG) $(LFLAGS) -o $(TARGET) $(OBJS) $(LIBS)
config:;
clean:
$(RM) -R $(OBJDIR)
distclean: clean
$(RM) -R $(DEPDIR)
.PRECIOUS: %.dep
-include $(patsubst %,$(DEPDIR)/%.dep,$(basename $(SRCS)))