-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
42 lines (30 loc) · 740 Bytes
/
makefile
File metadata and controls
42 lines (30 loc) · 740 Bytes
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
# Compiler
CXX = g++
# Compiler flags
CXXFLAGS = -std=c++11 -Wall -I./include
# Directory
SRC_DIR = src
INCLUDE_DIR = include
BUILD_DIR = build
# Source files
SRC_FILES = $(SRC_DIR)/main.cpp $(SRC_DIR)/functions.cpp
# Object files
OBJ_FILES = $(patsubst $(SRC_DIR)/%.cpp, $(BUILD_DIR)/%.o, $(SRC_FILES))
# Executable name
TARGET = main
# Build rule
$(TARGET): $(OBJ_FILES)
$(CXX) $(CXXFLAGS) -o $@ $^
# Compile source files to object files
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp | $(BUILD_DIR)
$(CXX) $(CXXFLAGS) -c -o $@ $<
# Cria diretório de build, se não existir
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
# Clean rule
clean:
rm -rf $(BUILD_DIR) $(TARGET)
# Phony targets
.PHONY: all clean
# Default target
all: $(TARGET)