-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
94 lines (70 loc) · 1.87 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
88
89
90
91
92
93
94
CC = gcc
CCFLAGS = -g -W -Wall
FLEX = flex
FLEX_OPTS = -Pdml
BISON = bison
BISON_OPTS = -t -pdml
OBJ_DIR = obj
SRC = Absyn.c Lexer.c Parser.c Printer.c Skeleton.c Enviroment.c Matrix.c Latex.c
OBJS = $(SRC:%.c=$(OBJ_DIR)/%.o)
all: dml
help:
@echo "Welcome to the makefile for dml, a \"declarative matrix language\""
@echo
@echo "Availible make targets:"
@echo " dml --build the interpreter"
@echo " test --test file generated by bnfc"
@echo " lang --build the language (absyn, lexer, parser, etc.)"
@echo " latex --makes the .tex file for the language specification"
@echo " tex --invoke like: \"make tex FILE=myfile.tex OPEN=1\""
@echo " pdf --makes a pdf from the dml.tex"
@echo " help --display this"
test: ${OBJS} $(OBJ_DIR)/Test.o
${CC} ${CCFLAGS} ${OBJS} $(OBJ_DIR)/Test.o -o test
dml: ${OBJS} $(OBJ_DIR)/main.o
${CC} ${CCFLAGS} ${OBJS} $(OBJ_DIR)/main.o -o dml
Lexer.c: bnfc/dml.l
${FLEX} ${FLEX_OPTS} -obnfc/Lexer.c bnfc/dml.l
Parser.c: bnfc/dml.y
${BISON} ${BISON_OPTS} bnfc/dml.y -o bnfc/Parser.c
FILES = Absyn.h Absyn.c Parser.h Printer.h Printer.c dml.y dml.l
lang: dml.cf
bnfc --c dml.cf
@mv $(FILES) bnfc
@sed -i -e 's/#include "/#include "bnfc\//' Test.c
@rm -f Test.c Test.c.bak Test.c-e
@rm -f Skeleton.h Skeleton.c.bak
make Lexer.c
make Parser.c
OPEN ?= 0
FILE ?= 0
tex:
ifeq ($(FILE), 0)
@echo "Specify \"make tex FILE=myfile.tex\""
else
pdflatex ${FILE}
rm *.aux
rm *.log
ifeq ($(OPEN), 1)
open $(FILE:.tex=.pdf)
endif
endif
latex: dml.tex
pdf: dml.tex
pdflatex dml.tex
@rm -f dml.log dml.aux
dml.tex: dml.cf
bnfc --latex dml.cf
#Immediate Directories
$(OBJ_DIR)/%.o: */%.c
${CC} ${CCFLAGS} -c $< -o $@
#Current Directory
$(OBJ_DIR)/%.o: %.c
${CC} ${CCFLAGS} -c $< -o $@
clean:
rm -f $(OBJ_DIR)/*.o dml.tex dml.pdf test dml
deep_clean:
rm -f bnfc/*
rm -f $(OBJ_DIR)/*.o test dml
sense:
@echo "I do make sense."