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
# A simple C application for testing.
# This Makefile finds all .c files in the current directory and all subdirectories,
# compiles them into object files, and then links them into a single library.
# Add the Rust output directory to path. Link statically if static=true is provided
LIB_PATHS ?=
LDFLAGS =
static ?=
LDFLAGS +=
endif
LDFLAGS +=
LDFLAGS +=
endif
LDFLAGS +=
# Define the compiler and flags
CXX ?=
CXXFLAGS =
# Define the name of the executable to be created
TARGET ?=
# Use the 'find' command to locate all .cpp files in the 'src' directory and subdirectories.
# This is a robust way to handle multiple nested folders.
SOURCES =
# Automatically generate the names of the object files from the source files.
# The `patsubst` function replaces the .cpp suffix with .o
OBJECTS =
# ----------------------------------------------------------------------------
# Main targets
# ----------------------------------------------------------------------------
# The main target is the executable, which depends on all object files.
# The `-o` flag specifies the output file name.
: # A generic rule to compile each .c file into its corresponding .o file.
# The `<` variable refers to the prerequisite (the .c file)
# The `$`@ variable refers to the target (the .o file)
# The `-c` flag tells the compiler to compile and assemble but not to link.
: # ----------------------------------------------------------------------------
# Cleanup and utility targets
# ----------------------------------------------------------------------------
# Remove all generated object files and the executable.
: :
# Mark these targets as phony, as they do not correspond to files to be created.
: :