-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
87 lines (74 loc) · 1.67 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
.POSIX:
.SUFFIXES:
.PHONY: \
all \
build \
check \
examples \
install \
format \
clean
.SILENT: clean
SUNDER_HOME = $$HOME/.sunder
SUNDER_DEFAULT_ARCH = $$(sh bin/sunder-platform arch)
SUNDER_DEFAULT_HOST = $$(sh bin/sunder-platform host)
SUNDER_DEFAULT_CC = cc
C99_BASE = \
-DSUNDER_DEFAULT_ARCH=$(SUNDER_DEFAULT_ARCH) \
-DSUNDER_DEFAULT_HOST=$(SUNDER_DEFAULT_HOST) \
-DSUNDER_DEFAULT_CC=$(SUNDER_DEFAULT_CC)
C99_DBG = $(C99_BASE) -O0 -g
C99_REL = $(C99_BASE) -DNDEBUG
GNU_BASE = \
$(C99_BASE) \
-std=c99 -pedantic-errors \
-Wall -Wextra \
-Werror=conversion \
-Werror=double-promotion \
-Werror=format \
-Werror=implicit-function-declaration \
-Werror=incompatible-pointer-types \
-Werror=vla
GNU_DBG = $(GNU_BASE) -O0 -g
GNU_REL = $(GNU_BASE) -Os -DNDEBUG
CC = c99
CFLAGS = $(C99_REL)
all: build
build: bin/sunder-compile
SUNDER_COMPILE_OBJS = \
sunder-compile.o \
util.o \
sunder.o \
lex.o \
cst.o \
parse.o \
order.o \
ast.o \
resolve.o \
eval.o \
codegen.o
bin/sunder-compile: $(SUNDER_COMPILE_OBJS)
$(CC) -o $@ $(CFLAGS) $(SUNDER_COMPILE_OBJS)
check: build
SUNDER_HOME="$(realpath .)" \
SUNDER_SEARCH_PATH="$(realpath .)/lib" \
sh bin/sunder-test
examples: build
(cd examples/ && sh examples.build.sh)
install: build
mkdir -p "$(SUNDER_HOME)"
cp -r bin "$(SUNDER_HOME)"
cp -r lib "$(SUNDER_HOME)"
cp env "$(SUNDER_HOME)"
format:
clang-format -i *.h *.c lib/sys/sys.h
clean:
rm -f bin/sunder-compile
rm -f $$(find . -type f -name '*.o')
rm -f $$(find . -type f -name '*.out')
rm -f $$(find . -type f -name '*.tmp')
rm -f $$(find . -type f -name '*.tmp.*')
(cd examples/ && sh examples.clean.sh)
.SUFFIXES: .c .o
.c.o:
$(CC) -o $@ -c $(CFLAGS) $<