This repository has been archived by the owner on Nov 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
63 lines (47 loc) · 1.49 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
ROOT=./
CFLAGS:=
LFLAGS:=
LIBS:=
ifeq ($(OS),Windows_NT)
CFLAGS:= -Wall -O3 -g $(shell pkg-config --cflags sdl2 SDL2_ttf glew zlib)
LFLAGS:= -g
LIBS:= $(shell pkg-config --libs sdl2 SDL2_ttf glew zlib) -lopengl32 -lm -mconsole
else
# UNAME_S := $(shell uname -s)
# ifeq ($(UNAME_S),Linux)
CFLAGS:= -g -O3 -Wall $(shell pkg-config --cflags sdl2 SDL2_ttf gl glew zlib) -fsanitize=address --no-omit-frame-pointer -std=c++11
LFLAGS:= -g -fsanitize=address -std=c++11
LIBS:= -lm $(shell pkg-config --libs sdl2 SDL2_ttf gl glew zlib) -pthread
# endif
# ifeq ($(UNAME_S),Darwin)
# endif
endif
SRCDIR=$(ROOT)src/
LIBDIR=$(ROOT)lib/
BUILDDIR=$(ROOT)build/
OUTPUTDIR=$(ROOT)bin/
SRC_CPP:=$(wildcard $(SRCDIR)*.cpp)
SRC:=$(wildcard $(SRCDIR)*.c)
_OBJS=$(patsubst $(SRCDIR)%.c,%.o,$(SRC))
OBJS=$(patsubst %,$(BUILDDIR)%,$(_OBJS))
_OBJS_CPP=$(patsubst $(SRCDIR)%.cpp,%.o,$(SRC_CPP))
OBJS_CPP=$(patsubst %,$(BUILDDIR)%,$(_OBJS_CPP))
NAME=blocks
all: $(OUTPUTDIR)$(NAME)
-include $(OBJS:.o=.d)
-include $(OBJS_CPP:.o=.d)
$(BUILDDIR)%.d: $(SRCDIR)%.cpp
$(CXX) $(CFLAGS) -M $< | sed 's,$*\.o[ :]*,\$(BUILDDIR)$*\.o : ,g' > $@
$(BUILDDIR)%.o: $(SRCDIR)%.cpp
$(CXX) $(CFLAGS) -c $< -o $@
$(BUILDDIR)%.o: $(SRCDIR)%.c
$(CXX) $(CFLAGS) -c $< -o $@
$(OUTPUTDIR)$(NAME): $(OBJS_CPP) $(OBJS)
$(CXX) $(LFLAGS) -o $(OUTPUTDIR)$(NAME) $(OBJS_CPP) $(OBJS) $(LIBS)
check-syntax:
$(CXX) -s -o /dev/null -S $(CHK_SOURCES)
run: $(OUTPUTDIR)$(NAME)
$(OUTPUTDIR)$(NAME)
.PHONY: clean
clean:
rm -rf $(BUILDDIR)* $(OUTPUTDIR)blocks