-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·65 lines (54 loc) · 1.12 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
CXX := g++
OBJ_PATH := obj
SRC_PATH := src
INCLUDE_PATH := include
ifeq ($(OS),Windows_NT)
TARGET := program.exe
else
TARGET := program
endif
CXXFLAGS := -g -Wall -I$(INCLUDE_PATH) -std=c++11
LDFLAGS :=
LDLIBS := -lglfw
SRC := $(foreach x, $(SRC_PATH), $(wildcard $(addprefix $(x)/*,.c*)))
OBJ := $(addprefix $(OBJ_PATH)/, $(addsuffix .o, $(notdir $(basename $(SRC)))))
default: $(TARGET)
ifeq ($(OS),Windows_NT)
$(TARGET): $(OBJ)
$(CXX) $(LDFLAGS) $(OBJ) glfw3.dll -o $@
else
$(TARGET): $(OBJ)
$(CXX) $(LDFLAGS) $(OBJ) $(LDLIBS) -o $@
endif
$(OBJ_PATH)/%.o: $(SRC_PATH)/%.c* $(INCLUDE_PATH)/%.h
@make -s mkdir
$(CXX) $(CXXFLAGS) -c -o $@ $<
$(OBJ_PATH)/%.o: $(SRC_PATH)/%.c*
@make -s mkdir
$(CXX) $(CXXFLAGS) -c -o $@ $<
.PHONY: mkdir
ifeq ($(OS),Windows_NT)
mkdir:
@if not exist $(OBJ_PATH) mkdir $(OBJ_PATH)
else
mkdir:
@mkdir -p $(OBJ_PATH)
endif
.PHONY: clean
ifeq ($(OS),Windows_NT)
clean:
if exist $(OBJ_PATH) del $(OBJ_PATH)\* /s /q
if exist $(TARGET) del $(TARGET)
else
clean:
rm -rf $(OBJ)
rm -f $(TARGET)
endif
.PHONY: run
ifeq ($(OS),Windows_NT)
run: default
$(TARGET)
else
run: default
./$(TARGET)
endif