-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
77 lines (62 loc) · 2.2 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
#
# Rules for compiling and linking the typechecker/evaluator
#
# Type
# make to rebuild the executable file f
# make windows to rebuild the executable file f.exe
# make test to rebuild the executable and run it on input file test.f
# make clean to remove all intermediate and temporary files
# make depend to rebuild the intermodule dependency graph that is used
# by make to determine which order to schedule
# compilations. You should not need to do this unless
# you add new modules or new dependencies between
# existing modules. (The graph is stored in the file
# .depend)
# These are the object files needed to rebuild the main executable file
#
OBJS = support.cmo syntax.cmo frac.cmo core.cmo parser.cmo lexer.cmo main.cmo
# Files that need to be generated from other files
DEPEND += lexer.ml parser.ml
# When "make" is invoked with no arguments, we build an executable
# typechecker, after building everything that it depends on
all: $(DEPEND) $(OBJS) f
# On a Windows machine, we do exactly the same except that the executable
# file that gets built needs to have the extension ".exe"
windows: $(DEPEND) $(OBJS) f.exe
# Include an automatically generated list of dependencies between source files
include .depend
# Build an executable typechecker
f: $(OBJS) main.cmo
@echo Linking $@
ocamlc -o $@ $(COMMONOBJS) $(OBJS)
# Build an executable typechecker for Windows
f.exe: $(OBJS) main.cmo
@echo Linking $@
ocamlc -o $@ $(COMMONOBJS) $(OBJS)
# Build and test
test: all
./f test.f
# Compile an ML module interface
%.cmi : %.mli
ocamlc -c $<
# Compile an ML module implementation
%.cmo : %.ml
ocamlc -c $<
# Generate ML files from a parser definition file
parser.ml parser.mli: parser.mly
@rm -f parser.ml parser.mli
ocamlyacc -v parser.mly
@chmod -w parser.ml parser.mli
# Generate ML files from a lexer definition file
%.ml %.mli: %.mll
@rm -f $@
ocamllex $<
@chmod -w $@
# Clean up the directory
clean::
rm -rf lexer.ml parser.ml parser.mli *.o *.cmo *.cmi parser.output \
f f.exe TAGS *~ *.bak
# Rebuild intermodule dependencies
depend:: $(DEPEND)
ocamldep $(INCLUDE) *.mli *.ml > .depend
#