-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
58 lines (45 loc) · 1.29 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
# File extensions
OBJ_EXT := .o
SOL_EXT := .exe
# Paths
MK_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
CWD_DIR := $(patsubst %/,%,$(dir $(MK_PATH)))
SRC_DIR := ${CWD_DIR}/src
INTER_DIR := ${CWD_DIR}/bin/intermediates
SOL_DIR := ${CWD_DIR}/bin/Release
SOL_NAME := listfiles${SOL_EXT}
# Commands
MKDIR_COMMAND := mkdir
# Compilers
CC := gcc
CXX := g++
CXX := ${CXX}
# Compiler flags
COMP_FLAG := -c
DEBUG_FLAG := -g
OBJ_FLAG := -o
OPT_FLAG := -O2
SYMBOL_FLAG := -s
STD_FLAG := -std=c++17
WARNING_FLAG := -Wall
# Linker flags
RUNTIME_OPT_FLAG := -flto
# Mode Settings
CXX_FLAGS := ${STD_FLAG} ${WARNING_FLAG} ${OPT_FLAG} ${SYMBOL_FLAG} ${RUNTIME_OPT_FLAG}
LINK_FLAGS := ${OPT_FLAG} ${SYMBOL_FLAG} ${RUNTIME_OPT_FLAG}
# Targets
Objects0=$(INTER_DIR)/main$(OBJ_EXT)
Objects=$(Objects0)
# Actions
.PHONY: all make_directories compiling linking
all: make_directories ${Objects} linking
${CXX} --version
@echo ${SRC_DIR}
compiling:
$(INTER_DIR)/main$(OBJ_EXT): ${SRC_DIR}/main.cpp
${CXX} ${COMP_FLAG} "${SRC_DIR}/main.cpp" ${CXX_FLAGS} ${OBJ_FLAG} $(INTER_DIR)/main$(OBJ_EXT)
linking:
${CXX} ${LINK_FLAGS} ${OBJ_FLAG} ${SOL_DIR}/${SOL_NAME} ${Objects}
make_directories:
@if not exist "${INTER_DIR}" ${MKDIR_COMMAND} "${INTER_DIR}"
@if not exist "${SOL_DIR}" ${MKDIR_COMMAND} "${SOL_DIR}"