-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
39 lines (29 loc) · 1.06 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
TARGET = $(if $(MAKECMDGOALS),$(basename $(firstword $(MAKECMDGOALS))),test)
# CCACHE = /usr/local/bin/ccache
# For Windows set it as 'exe'
OUT_EXT = $(if ($(OS),Windows_NT),exe,out)
ifneq ($(filter $(MAKECMDGOALS),clean),clean)
SOURCES = $(addsuffix .cpp,$(if $(MAKECMDGOALS),$(basename $(MAKECMDGOALS)),$(TARGET)))
HEADERS = $(wildcard *.h)
OBJS = $(filter %.o, $(SOURCES:.cpp=.o)) $(filter %.o, $(SOURCES:.c=.o))
else
# To clean only target you have to call: make <target.out> <clean>
# Use 'true' to skip compile, so we avoid any errors if firstly need to build target.out file.
CCACHE = @true
endif
# SOURCES += glad.c
CXXFLAGS += -Wall -std=gnu++11 -g
# LDLIBS = -lGL -lX11 -lglfw -lpthread -lXrandr -ldl -lXi -lm
ifeq ($(filter $(OS),Windows_NT),Windows_NT)
RM=del /q /f
endif
%.o: %.cpp $(HEADERS)
$(CCACHE) $(CXX) -c $(CXXFLAGS) $< -o $@
%.o: %.c $(HEADERS)
$(CCACHE) $(CC) -c $(CFLAGS) $< -o $@
$(TARGET).$(OUT_EXT): $(OBJS)
$(CCACHE) $(CXX) $(CXXFLAGS) $^ $(LDLIBS) -o $@
clean:
$(RM) $(TARGET).o $(TARGET).$(OUT_EXT)
clean-all:
$(RM) *.o */*.o *.$(OUT_EXT)