-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmakefile
53 lines (34 loc) · 1001 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
46
47
48
49
50
51
52
53
CXX = g++
OUT = captain-cleiton
SOURCES_PATH = *.cpp src/*.cpp
IDIR = -I./include
OBJDIR = obj
CXXFLAGS = -Wall -std=c++0x -O3 $(IDIR)
LIBS = -lsfml-audio -lsfml-graphics -lsfml-window -lsfml-system
define listar_os_sources
$(foreach source,$1,$(wildcard $(source)))
endef
define listar_as_pastas
$(foreach source,$1,$(dir $(source)))
endef
define listar_os_objetos
$(foreach source, $1,$(patsubst %.cpp,%.o,$(source)))
endef
define adicionar_pasta_obj
$(foreach source, $1,$(addprefix $(OBJDIR)/,$(source)))
endef
SOURCES := $(call listar_os_sources,$(SOURCES_PATH))
OBJS := $(call listar_os_objetos,$(SOURCES))
OBJS := $(call adicionar_pasta_obj,$(OBJS))
DIRLIST := $(call listar_as_pastas,$(SOURCES_PATH))
DIRLIST := $(call adicionar_pasta_obj,$(DIRLIST))
install: create_dir compile
create_dir:
@mkdir -p $(DIRLIST)
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
compile: $(OBJS)
$(CXX) -o $(OUT) $^ $(CXXFLAGS) $(LIBS)
remove:
@rm -f $(OUT)
@rm -rdf $(OBJDIR)