-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
41 lines (31 loc) · 815 Bytes
/
Copy pathMakefile
File metadata and controls
41 lines (31 loc) · 815 Bytes
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
# Makefile for tinsh - Tiny Shell
# Compiles the shell with debugging symbols and warnings
CC = clang
CFLAGS = -Wall -Wextra -g -std=c99
TARGET = tinsh
SOURCES = main.c shell.c
OBJECTS = $(SOURCES:.c=.o)
# Default target
all: $(TARGET)
# Link the final executable
$(TARGET): $(OBJECTS)
$(CC) $(CFLAGS) -o $(TARGET) $(OBJECTS)
# Compile source files into object files
%.o: %.c shell.h
$(CC) $(CFLAGS) -c $< -o $@
# Clean build artifacts
clean:
rm -f $(OBJECTS) $(TARGET)
# Build and run the shell
run: $(TARGET)
./$(TARGET)
# Install target (optional)
install: $(TARGET)
cp $(TARGET) /usr/local/bin/
# Uninstall target (optional)
uninstall:
rm -f /usr/local/bin/$(TARGET)
# Debug build with additional flags
debug: CFLAGS += -DDEBUG -O0
debug: $(TARGET)
.PHONY: all clean run install uninstall debug