-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
49 lines (35 loc) · 924 Bytes
/
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
# some parts generated by llama3.1
# Define directories
SRC_DIR := src
BUILD_DIR := build
# Define the C++ compiler
CXX := g++
# Define the C++ flags
CXXFLAGS := -g -Wall
# Define the linker flags
LDFLAGS :=
# Define the libraries
LDLIBS :=
# Find all source files in the source directory
SOURCES := $(wildcard $(SRC_DIR)/*.c)
# Create object files in the build directory
OBJECTS := $(addprefix $(BUILD_DIR)/, $(notdir $(SOURCES:.c=.o)))
# Define the target executable
TARGET := main.exe
# Create the build directory if it does not exist
$(shell mkdir -p $(BUILD_DIR))
# All target
.PHONY: all
all: $(TARGET)
print:
@echo $(SOURCES)
# Compile source files into object files
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
$(CXX) $(CXXFLAGS) -c $< -o $@
# Link object files to create the executable
$(TARGET): $(OBJECTS)
$(CXX) $(LDFLAGS) $^ $(LDLIBS) -o $@
# Clean target
.PHONY: clean
clean:
rm -f $(OBJECTS) $(TARGET)