blob: d574b4e36a59d523334c607ccb057721ee39ae30 (
plain)
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
|
LEX = flex
YACC = bison
CC = gcc -g
CFLAGS = -DYYDEBUG=1 -fPIC
LIBS = -lreadline -lfl -lm
OBJS = lisp.o lisp.tab.o lex.yy.o
MODULE_SRC = $(wildcard modules/*.c)
MODULE_SO = $(MODULE_SRC:.c=.so)
.SUFFIXES:
main: main.c $(OBJS)
$(CC) $(CFLAGS) -o $@ main.c $(OBJS) $(LIBS)
lisp.o: lisp.c lisp_api.h lisp.h lex.yy.o
$(CC) $(CFLAGS) -c lisp.c
lisp.tab.c lisp.tab.h: lisp.y
$(YACC) -d lisp.y
lex.yy.c lex.yy.h: lisp.l lisp.tab.h
$(LEX) --header-file=lex.yy.h lisp.l
lisp.tab.o: lisp.tab.c
$(CC) $(CFLAGS) -c lisp.tab.c
lex.yy.o: lex.yy.c
$(CC) $(CFLAGS) -c lex.yy.c
clean:
rm -f *.o main test lisp.tab.c lisp.tab.h lex.yy.c lex.yy.h modules/*.so
test: test.o $(OBJS)
$(CC) $(CFLAGS) -o $@ test.o $(OBJS) $(LIBS)
./test
test.o: test.c lisp.h lex.yy.o
$(CC) $(CFLAGS) -c test.c
run: main
./main
run_std: main
./main lisp/standard_functions.lisp
modules: $(MODULE_SO)
@echo "All modules built successfully."
modules/%.so: modules/%.c lisp.o
gcc -fPIC -c $< -o $*.o
gcc -fPIC -shared $*.o lisp.o -o $@
rm $*.o
.PHONY: clean test run
|