-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
56 lines (40 loc) · 1.07 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
CC := gcc
CFLAGS := --std=gnu11 -Wpedantic -Wall -Wextra -g
SOURCES := main.c codegen.c parse.c tokenize.c type.c diag.c
OBJECTS := $(SOURCES:.c=.o)
TEST_SOURCES := tests/run/arith.c \
tests/run/basics.c \
tests/run/pointers.c \
tests/run/calls.c \
tests/run/types.c \
tests/run/inits.c
TEST_EXES := $(basename $(TEST_SOURCES))
all: scc test
scc: $(OBJECTS)
$(CC) $(OBJECTS) -o scc
selfhost: CFLAGS = -D__SCC__=1 -Wpedantic
selfhost: scc
%.o: %.c scc.h
$(CC) $(CFLAGS) -c -o $@ $<
test-run: $(TEST_EXES)
for exe in $(TEST_EXES); do ./$$exe; done
test-compile:
poetry run lit tests/compile --timeout=2
test: test-compile test-run
tests/run/helpers.o: tests/run/helpers.c
$(CC) -g -O2 -c -o $@ $<
tests/run/%.s: tests/run/%.c
./scc -w $< -o $@
tests/run/%: tests/run/%.s tests/run/helpers.o
$(CC) -static -o $@ $< tests/run/helpers.o
bootstrap: clean
./bootstrap.sh
bootstrap-test: bootstrap test
clean:
rm -f $(OBJECTS)
rm -f $(TEST_EXES)
rm -f $(TEST_SOURCES:.c=.preproc.c)
rm -f $(TEST_SOURCES:.c=.s)
rm -f tests/helpers.o
rm -f scc
rm -rf ./scratch/bootstrap