-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
39 lines (29 loc) · 885 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
# Compiler
CC = gcc
CFLAGS = -Wall -Wextra -Werror -g -Iinclude
# Output executable
TARGET = orus
# Source files (find all .c files in the src directory)
SRCS = $(shell find src -name '*.c')
# Object files (redirecting to the build directory)
OBJS = $(SRCS:src/%.c=build/%.o)
# Default rule: Build the shell
all: $(TARGET)
# Compile source files into object files
build/%.o: src/%.c
@mkdir -p build # Create the build directory if it doesn't exist
$(CC) $(CFLAGS) -c $< -o $@
# Link object files to create the executable with Readline support
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -o $(TARGET) -lreadline # Link against Readline
# Run the shell
run: $(TARGET)
./$(TARGET)
# Check for memory leaks using macOS `leaks`
memcheck: $(TARGET)
leaks --atExit -- ./$(TARGET)
# Clean build artifacts
clean:
rm -rf build $(TARGET)
# Force recompilation
rebuild: clean all