-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathMakefile
155 lines (125 loc) · 4.65 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# Figure out which version of OCaml is being used
OCAML_VERSION=$(shell ocamlc --version)
# Figure out which version of sedlex is being used
SEDLEX_VERSION=$(shell opam info sedlex --version)
# Set up correct incantation for sedlex
SEDLEX=$(shell if [ "$(SEDLEX_VERSION)" \< "2.0" ] ; then echo "sedlex" ; else echo "sedlex.ppx"; fi)
#warnings disabled:
# 4: fragile pattern matching (we try to stick to it but don't always)
#27: innocuous unused variable
#29: non-escaped end-of-line in string constant
#50: unexpected documentation comment
# Use this to not die on all warnings
#OCAMLBUILD_FLAGS = -j 4 -lib unix -cflags -g,-annot,-w,+a-4-27-29-50 -use-ocamlfind -pkg menhirLib -pkg $(SEDLEX)
OCAMLBUILD_FLAGS = -j 4 -lib unix -cflags -g,-annot,-w,+a-4-27-29-50,"-warn-error +a" -use-ocamlfind -pkg menhirLib -pkg $(SEDLEX)
# The --strict flag prevents --explain, so we make a separate Makefile target to get
# menhir explanations
OCAMLBUILD_MENHIRFLAGS = -use-menhir -menhir "menhir --strict"
OCAMLBUILD_MENHIRFLAGS_EXPLAIN = -use-menhir -menhir "menhir --explain"
all: andromeda.native
opt: andromeda.native
default: andromeda.native
byte: andromeda.byte
debug: andromeda.d.byte
profile: andromeda.p.native
andromeda.byte andromeda.native andromeda.d.byte andromeda.p.native: src/build.ml
ocamlbuild $(OCAMLBUILD_MENHIRFLAGS) $(OCAMLBUILD_FLAGS) $@
menhir-explain:
ocamlbuild $(OCAMLBUILD_MENHIRFLAGS_EXPLAIN) $(OCAMLBUILD_FLAGS) src/parser/parser.ml
# "make test" to see if anything broke
test: default
cd tests && sh ./test.sh
# "make test-validate" to see if anything broke
# and ask for validation of possibly broken things.
test-validate: default
cd tests && sh ./test.sh -v
PREFIX ?= /usr
BIN_DIR ?= $(PREFIX)/bin
DOC_DIR ?= $(PREFIX)/doc
LIB_DIR ?= $(PREFIX)/lib
SHARE_DIR ?= $(PREFIX)/share
DOC_DIR := $(DOC_DIR)/andromeda
LIB_DIR := $(LIB_DIR)/andromeda
EXAMPLE_DIR := $(LIB_DIR)/examples
THEORIES_DIR := $(LIB_DIR)/theories
version:
@git describe --always --long
src/build.ml:
/bin/echo -n 'let version = "' > $@
$(MAKE) -s version | egrep -v '^make' | tr -d '\n' >> $@
/bin/echo '" ;;' >> $@
echo "let lib_dir = \""$(LIB_DIR)"\" ;;" >> $@
emacs-autoloads:
cd etc && emacs --batch --eval '(setq backup-inhibited t)' --eval '(update-file-autoloads "andromeda.el" t "'`pwd`'/andromeda-autoloads.el")'
andromeda.odocl:
find src/ -name '*.mli' -exec basename {} '.mli' \; | perl -p -e 's/^(.)/\u\1/' > andromeda.odocl
doc: andromeda.odocl
ocamlbuild $(OCAMLBUILD_FLAGS) andromeda.docdir/index.html
andromeda.docdir/andromeda.dot: andromeda.odocl
ocamlbuild $(OCAMLBUILD_FLAGS) andromeda.docdir/andromeda.dot
perl -i -p -e 's/digraph G/digraph Andromeda/; s/rotate=90;//' _build/andromeda.docdir/andromeda.dot
graph: andromeda.docdir/andromeda.dot
dot -Tsvg < _build/andromeda.docdir/andromeda.dot > andromeda.svg
install: install-binary install-lib install-theories install-examples install-project-info install-emacs
uninstall: uninstall-binary uninstall-lib uninstall-theories uninstall-examples uninstall-project-info uninstall-emacs
install-binary: opt
install -d $(BIN_DIR)
install _build/src/andromeda.native $(BIN_DIR)/andromeda
uninstall-binary:
rm -f $(BIN_DIR)/andromeda
install-doc: doc
install -d $(DOC_DIR)
install -m 644 doc/theory.pdf $(DOC_DIR)/theory.pdf
uninstall-doc:
rm -f $(DOC_DIR)/andromeda-theory.pdf
rmdir $(DOC_DIR) || true
install-project-info:
install -d $(DOC_DIR)
install -m 644 README.markdown $(DOC_DIR)/README.markdown
uninstall-project-info:
rm -f $(DOC_DIR)/README.markdown
rmdir $(DOC_DIR) || true
install-emacs:
install -d $(SHARE_DIR)/emacs/site-lisp
install -m 644 etc/andromeda.el $(SHARE_DIR)/emacs/site-lisp
install -m 644 etc/andromeda-autoloads.el $(SHARE_DIR)/emacs/site-lisp
uninstall-emacs:
rm -f $(SHARE_DIR)/emacs/site-lisp/andromeda.el $(SHARE_DIR)/emacs/site-lisp/andromeda-autoloads.el
install-lib:
install -d $(LIB_DIR)/stdlib
install -m 644 prelude.m31 $(LIB_DIR)/prelude.m31
cp -r stdlib/* $(LIB_DIR)/stdlib/
uninstall-lib:
rm -rf $(LIB_DIR)/stdlib/*
rm -f $(LIB_DIR)/prelude.m31
rmdir $(LIB_DIR) || true
install-examples:
install -d $(EXAMPLE_DIR)
cp -r examples/* $(EXAMPLE_DIR)
uninstall-examples:
rm -rf $(EXAMPLE_DIR)/* || true
rmdir $(EXAMPLE_DIR) || true
install-theories:
install -d $(THEORIES_DIR)
cp -r theories/* $(THEORIES_DIR)
uninstall-theories:
rm -rf $(THEORIES_DIR)/* || true
rmdir $(THEORIES_DIR) || true
clean:
ocamlbuild -clean
.PHONY: andromeda.byte \
andromeda.docdir/andromeda.dot \
andromeda.native \
andromeda.odocl \
clean \
doc \
install \
install-binary \
install-doc \
install-examples \
install-theories \
install-lib \
menhir-explain \
src/build.ml \
uninstall \
version