-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathMakefile
More file actions
57 lines (44 loc) · 1.62 KB
/
Makefile
File metadata and controls
57 lines (44 loc) · 1.62 KB
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
# Adaptado de http://stackoverflow.com/a/30142139
GPP := g++
SFML_VERSION := 2.5.1
SFML_LIB := /usr/local/lib/SFML-$(SFML_VERSION)/lib
SFML_HEADERS := /usr/local/lib/SFML-$(SFML_VERSION)/include
FLAGS := -O2 -march=native -Wall -Werror -Wextra -pedantic -std=c++23 -L $(SFML_LIB) -I $(SFML_HEADERS)
LIBS := -lsfml-graphics -lsfml-window -lsfml-system
# Final binary
BIN := editor
# Put all auto generated stuff to this build dir.
BUILD_DIR := ./build
# List of all .cpp source files.
# CPP = main.cpp $(wildcard dir1/*.cpp) $(wildcard dir2/*.cpp)
CPP := Editor.cpp $(wildcard src/*.cpp)
# All .o files go to build dir.
OBJ := $(CPP:%.cpp=$(BUILD_DIR)/%.o)
# Gcc/Clang will create these .d files containing dependencies.
DEP := $(OBJ:%.o=%.d)
# Default target named after the binary.
$(BIN): $(BUILD_DIR)/$(BIN)
# Actual target of the binary - depends on all .o files.
$(BUILD_DIR)/$(BIN): $(OBJ)
# Create build directories - same structure as sources.
@mkdir -p $(@D)
# Just link all the object files.
$(GPP) $(FLAGS) $^ -o $@ $(LIBS)
# Solo por conveniencia, para poder hacer ./editor facilmente
@mv $(BUILD_DIR)/$(BIN) $(BIN)
# Include all .d files
-include $(DEP)
# Build target for every single object file.
# The potential dependency on header files is covered
# by calling `-include $(DEP)`.
$(BUILD_DIR)/%.o: %.cpp
@mkdir -p $(@D)
# The -MMD flags additionaly creates a .d file with
# the same name as the .o file.
$(GPP) $(FLAGS) -MMD -c $< -I src/ -o $@
.PHONY: clean
clean:
# This should remove all generated files.
-rm -f $(BUILD_DIR)/$(BIN) $(OBJ) $(DEP)
rm -f editor #Why remove the executable too?
rmdir build/src build