-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile.v1
56 lines (51 loc) · 2.19 KB
/
makefile.v1
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
# the compiler CC: gcc for C programs, define as g++ for c++
CC = g++
# compiler flags CFLAGS:
# -ggdb - Includes debugging info in the executable,
# allowing you to use tools like GDB (GNU Debugger)
#
# -std=c++23 - Specifies the C++ language standard to be C++23
#
# -pedantic - Generates additional warning and errors to enforce
# strict adherence to the C++ standard. It helps ensure
# portability and compliance with language specifications
#
# -Wall - Enables set of common warnings.
# It stands for "all warnings"
#
# -Weffc++ - Warns about violations of Effective C++ coding
# standards. This set of guidelines aims to improve
# C++ code quality and maintainability
#
# -Wextra - Enables additional warning messages not covered by -Wall
#
# -Wconversion - Warns about implicit type conversions that may
# result in loss of data
#
# -Wsign-conversion - Warns about sign-conversion issues when converting
# between signed and unsigned integers
#
# -Werror - Treats all warning messages as errors, making the
# compilation fail if there are any warnings. Used to
# enforce a strict policy on code quality
#
CFLAGS = -ggdb -std=c++23 -pedantic -Wall -Weffc++ -Wextra -Wconversion -Wsign-conversion -Werror
# The build target. Change HelloWorld depending on the file
TARGET = HelloWorld
# The default target 'all' specifies that when you run 'make' without any target
# it should build the target specified in its dependency list, which is $(TARGET)
all: $(TARGET)
# The rule to build the target $(TARGET). It depends on $(TARGET).cpp
# meaning if $(TARGET).cpp is modified, this rule will be executed to rebuild the target
$(TARGET): $(TARGET).cpp
$(CC) $(CFLAGS) -o $(TARGET) $(TARGET).cpp
# $(CC): Compiler command (g++)
# $(CFLAGS): Compiler flags, including debugging info, C++ standard, warnings, etc
# -o $(TARGET): Specifies the output file name
# $(TARGET).cpp: Input source file
# The 'clean' target, which is used to remove generated files and start fresh
# Runnings 'make clean' will remove the executable
clean:
$(RM) $(TARGET)
# $(RM): Remove command
# $(TARGET): The target file to be removed