forked from peanut-lang/peanut
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
85 lines (63 loc) · 1.38 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
# Makefile of peanut
OS=$(shell uname -s)
ifeq ($(OS), Linux)
DEBUGSYMBOL= -rdynamic
endif
ifeq ($(OS), Darwin)
DEBUGSYMBOL=
endif
.PHONY: directories
BUILD=out
LEX= flex
LFLAGS=
YACC= bison
YFLAGS= -v -d
CC= gcc
CFLAGS= -g $(DEBUGSYMBOL) -Wall -std=gnu99
LIBS= -lm
.SUFFIXES: .c .o
BIN=peanut
dir_guard=@mkdir -p $(BUILD)
OBJS= \
$(BUILD)/lex.yy.o \
$(BUILD)/peanut.tab.o \
$(BUILD)/world.o \
$(BUILD)/eval.o \
$(BUILD)/hash.o \
$(BUILD)/list.o \
$(BUILD)/stack.o \
$(BUILD)/strtable.o \
$(BUILD)/pnobject.o \
$(BUILD)/pninteger.o \
$(BUILD)/pnreal.o \
$(BUILD)/pnstring.o \
$(BUILD)/pnbool.o \
$(BUILD)/pnfunction.o \
$(BUILD)/pnnull.o \
$(BUILD)/pnlist.o \
$(BUILD)/pnhash.o \
$(BUILD)/pnstdio.o
all: $(BIN)
$(BIN): $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
$(BUILD)/lex.yy.o: $(BUILD)/lex.yy.c $(BUILD)/peanut.tab.h $(BUILD)/peanut.tab.o
$(dir_guard)
$(CC) $(CFLAGS) -Isrc -o $@ -c $(BUILD)/lex.yy.c
$(BUILD)/lex.yy.c: src/lex.l
$(dir_guard)
$(LEX) $(LFLAGS) -o $@ $<
$(BUILD)/peanut.tab.h: src/peanut.y
$(BUILD)/peanut.tab.c: src/peanut.y
$(dir_guard)
$(YACC) $(YFLAGS) -o $@ $<
$(BUILD)/peanut.tab.o: $(BUILD)/peanut.tab.c
$(dir_guard)
$(CC) $(CFLAGS) -Isrc -o $@ -c $<
$(BUILD)/%.o: src/%.c
$(dir_guard)
$(CC) $(CFLAGS) -Isrc -c $< -o $@
test: $(BIN)
./$(BIN) -t tests/example1.pn tests/example2.pn < tests/input.txt
clean:
rm -f $(BIN)
rm -rf $(BUILD)