-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (46 loc) · 1.35 KB
/
Copy pathMakefile
File metadata and controls
58 lines (46 loc) · 1.35 KB
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
# Compiler and flags
CC = gcc
CFLAGS = -Wall -Werror -g -Og -I./include
LDFLAGS =
# Directories
SRC_DIR = src
INC_DIR = include
OBJ_DIR = build
BIN_DIR = bin
TEST_DIR = tests
# Target executable
TARGET = $(BIN_DIR)/customShell
# Source files
SRCS = $(wildcard $(SRC_DIR)/*.c)
OBJS = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRCS))
# Header files (for dependency tracking)
DEPS = $(wildcard $(INC_DIR)/*.h)
# Phony targets
.PHONY: all clean test directories help
# Default target
all: directories $(TARGET)
# Link object files to create executable
$(TARGET): $(OBJS)
$(CC) $(OBJS) -o $@ $(LDFLAGS)
@echo "Build successful! Executable is at $@"
# Compile source files into object files
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(DEPS)
$(CC) $(CFLAGS) -c $< -o $@
# Create necessary directories
directories:
@mkdir -p $(OBJ_DIR) $(BIN_DIR)
# Clean build artifacts
clean:
rm -rf $(OBJ_DIR) $(BIN_DIR)
@echo "Cleaned build artifacts."
# Run tests (placeholder - can be expanded)
test: all
@echo "Running basic tests..."
./$(TARGET) < $(TEST_DIR)/test_input.txt || echo "No automated tests yet."
# Help message
help:
@echo "Available targets:"
@echo " all : Build the project (default)"
@echo " clean : Remove build artifacts"
@echo " test : Run tests"
@echo " help : Show this help message"