-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmakefile
48 lines (37 loc) · 1.1 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
# Target Executable, Output File
TARGET = aesf
# Compiler Options
CXX = g++
CXXFLAGS = -g -Wall
# Source & Build Directories
SOURCE_DIR = src
OBJECT_DIR = build
# Get List Of Source Files & Corresponding Object Files
SOURCES = $(wildcard $(SOURCE_DIR)/*.cpp)
OBJECTS = $(patsubst $(SOURCE_DIR)/%.cpp, $(OBJECT_DIR)/%.o, $(SOURCES))
# Build Executable
$(TARGET): $(OBJECTS)
$(CXX) $(CXXFLAGS) -o $@ $^
# Compile Dependencies (Individual Source Files)
$(OBJECT_DIR)/%.o : $(SOURCE_DIR)/%.cpp | $(OBJECT_DIR)
$(CXX) $(CXXFLAGS) -c -o $@ $^
# Create Object Directory If It Doesn't Exist
$(OBJECT_DIR):
mkdir $(OBJECT_DIR)
# Fake Targets, Point To Other Targets/Actions
# Rather Than Actual File Targets:
# Default Target
.PHONY: all
all: $(TARGET)
# Clean Files Before Compiling Executable
.PHONY: remake
remake: clean all
# Remove Executable & Compiled Objects
.PHONY: clean
clean:
$(RM) $(OBJECTS) $(TARGET)
# Compile Executable With Optimizations, Removes Debugging Information
# Cleans Files To Ensure Unoptimized Files Are Not Included
.PHONY: release
release: CXXFLAGS = -O2 -s -DNDEBUG
release: clean $(TARGET)