-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
32 lines (24 loc) · 881 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
OUT = bin
CFLAGS = -O0 -g -Wall -Wextra -pedantic -fno-strict-aliasing -std=c99
TARGETS = mmap-demo compiling-integers compiling-immediates compiling-unary \
compiling-binary compiling-reader compiling-let compiling-if \
compiling-heap compiling-procedures compiling-closures compiling-elf
BINARIES = $(addprefix $(OUT)/, $(TARGETS))
TESTS = $(addprefix test-, $(TARGETS))
# $@ means the name of the target that caused the rule to run
# $^ means all of the prerequisites with spaces in between
# $< means the name of the first prerequisite
all: $(OUT) $(BINARIES)
test: $(OUT) $(TESTS)
$(OUT):
mkdir -p $@
clean:
rm $(OUT)/*
$(OUT)/%: %.c greatest.h
$(CC) $(CFLAGS) $< -o $@
test-compiling-elf: $(OUT)/compiling-elf
./$< ./$(OUT)/generated-elf
chmod +x ./$(OUT)/generated-elf
@./$(OUT)/generated-elf || if [ $$? -ne 120 ]; then exit 1; fi
test-%: $(OUT)/%
./$<