-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
45 lines (36 loc) · 1010 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
#Make Arguments
CXX = g++
NAME = game
BUILD = build
SOURCE = source
INCLUDE = include library
ifeq ($(OS),Windows_NT)
CXXFLAGS = -static -mwindows
LDFLAGS = -static -mwindows ./library/PDCurses/wingui/pdcurses.a
else
LDFLAGS = -lncursesw
endif
CXXFLAGS += -Wall -Wextra -finput-charset=UTF-8 -std=c++11 $(addprefix -I,$(INCLUDE))
DEPFLAGS = -MMD -MP -MF $(BUILD)/$*.d
#Make Rules
src = $(wildcard $(SOURCE)/*.cpp) $(wildcard $(SOURCE)/*/*.cpp)
obj = $(src:$(SOURCE)/%.cpp=$(BUILD)/%.o)
dep = $(src:$(SOURCE)/%.cpp=$(BUILD)/%.d)
$(NAME): $(obj)
$(info *** Please read README if your console appears blank ***)
$(CXX) -o $@ $^ $(LDFLAGS)
$(BUILD)/%.o: $(SOURCE)/%.cpp
$(BUILD)/%.o: $(SOURCE)/%.cpp $(BUILD)/%.d
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) $(DEPFLAGS) -c -o $@ $<
$(BUILD)/%.d: ;
.PRECIOUS: $(BUILD)/%.d
.PHONY: clean
clean:
rm -rf $(BUILD) $(NAME)
-include $(dep)
#Make Notes
#$@ - Rule
#$< - First Dependency
#$^ - All Dependencies
#$* - Stem (dir/a.foo.b, pattern a.%.b, stem dir/foo)