-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
72 lines (54 loc) · 1.7 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
64
65
66
67
68
69
70
71
72
# Babak Poursartip
# Aug 11, 2019
# warning flags: -Wall -Wextra -Wpedantic -Wunused
# Definitions
CXX := -c++
CXXFLAGS := -std=c++17 -pedantic-errors -Wall -Wextra #-Werror
LDFLAGS := -L/usr/lib -lstdc++ -lm
BUILD := ./build
OBJ_DIR := $(BUILD)/objects
APP_DIR := $(BUILD)/apps
TARGET := main
INCLUDE := -Iinclude/
LIBS := -L/usr/local/lib
# modify this line based on the different modules
# if there is no modules, delete the second line
SRC := \
$(wildcard src/io/*.cpp) \
$(wildcard src/*.cpp)
# ===============================================
OBJECTS := $(SRC:%.cpp=$(OBJ_DIR)/%.o)
all: build $(APP_DIR)/$(TARGET)
$(OBJ_DIR)/%.o: %.cpp
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $(INCLUDE) -o $@ -c $<
$(APP_DIR)/$(TARGET): $(OBJECTS)
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $(INCLUDE) $(LDFLAGS) -o $(APP_DIR)/$(TARGET) $(OBJECTS)
# ===============================================
.PHONY: all build clean debug release test help dep
# ===============================================
build:
@mkdir -p $(APP_DIR)
@mkdir -p $(OBJ_DIR)
debug: CXXFLAGS += -DDEBUG -g -O0
debug: all
release: CXXFLAGS += -O3
release: all
clean:
-@rm -rvf $(OBJ_DIR)/*
-@rm -rvf $(APP_DIR)/*
test:
@echo "Sources are: " $(SRC)
@echo "Objects are: " $(OBJECTS)
help:
@echo "usage:"
@echo " make -> build"
@echo " make debug -> debug executable"
@echo " make release -> release executable"
@echo " make dep -> generates dependencies using gccmakedep"
@echo " make clean -> removes objects, executable"
@echo " make test -> lists source files"
dep :
gccmakedep $(INC) $(SRCS)
# End