-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
53 lines (39 loc) · 1.09 KB
/
Makefile
File metadata and controls
53 lines (39 loc) · 1.09 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
# Compiler and flags
CC = gcc
CFLAGS = -Wall -Wextra -g -Iinclude
# Directories
SRCDIR = src
BUILDDIR = build
# Find all source files in the source directory
SOURCES = $(wildcard $(SRCDIR)/*.c)
# Convert source file names to corresponding object file names in the build directory
OBJECTS = $(patsubst $(SRCDIR)/%.c, $(BUILDDIR)/%.o, $(SOURCES))
# Final executable name
TARGET = tsh
# Additional executables
MYINT = myint
MYSPIN = myspin
MYSPLIT = mysplit
MYSTOP = mystop
# Default rule to build all executables
all: $(TARGET) $(MYINT) $(MYSPIN) $(MYSPLIT) $(MYSTOP)
$(TARGET): $(OBJECTS)
$(CC) $(CFLAGS) -o $@ $^
# Pattern rule to compile source files into object files in the build folder
$(BUILDDIR)/%.o: $(SRCDIR)/%.c
@mkdir -p $(BUILDDIR)
$(CC) $(CFLAGS) -c $< -o $@
$(MYINT): myint.c
$(CC) $(CFLAGS) -o $@ $<
$(MYSPIN): myspin.c
$(CC) $(CFLAGS) -o $@ $<
$(MYSPLIT): mysplit.c
$(CC) $(CFLAGS) -o $@ $<
$(MYSTOP): mystop.c
$(CC) $(CFLAGS) -o $@ $<
test:
python3 grader.py
# Clean up build artifacts
.PHONY: clean test
clean:
rm -rf $(BUILDDIR) $(TARGET) $(MYINT) $(MYSPIN) $(MYSPLIT) $(MYSTOP)