-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
39 lines (30 loc) · 860 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
CXX=g++
CFLAGS=-c -Wall
LDFLAGS=
SRCS=$(wildcard *.cpp)
DEPS=$(addprefix $(OUTDIR)/, $(SRCS:.cpp=.d))
OBJS=$(addprefix $(OUTDIR)/, $(SRCS:.cpp=.o))
PROG=$(OUTDIR)/non-intrusive-pch.exe
ifdef USE_PCH
PRECOMPILED_HEADER=precompiled.h
PCH_TARGET=$(PRECOMPILED_HEADER).gch
CFLAGS+= -include $(PRECOMPILED_HEADER)
OUTDIR=out/gcc-pch
$(info Building WITH precompiled headers...)
else
$(info Building WITHOUT precompiled headers...)
OUTDIR=out/gcc-no-pch
endif
all: $(PROG)
$(OUTDIR):
mkdir -p $@
$(PROG): $(OBJS)
$(CXX) $(LDFLAGS) $(OBJS) -o $@
$(PCH_TARGET): $(PRECOMPILED_HEADER)
$(CXX) $(CFLAGS) -MP -MMD -MT$(@:.gch=.d) -o $@ $<
$(OUTDIR)/%.o: %.cpp $(PCH_TARGET) | $(OUTDIR)
$(CXX) $(CFLAGS) -MP -MMD -MT$(@:.o=.d) -o $@ $<
clean:
rm -f $(OBJS) $(DEPS) $(PROG) $(PCH_TARGET) $(PCH_TARGET:.gch=.d)
.PHONY: clean all
-include $(DEPS)