File: Makefile

package info (click to toggle)
ocaml-atd 1.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 668 kB
  • sloc: ml: 1,878; makefile: 183; sh: 24
file content (167 lines) | stat: -rw-r--r-- 3,779 bytes parent folder | download
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
156
157
158
159
160
161
162
163
164
165
166
167
# $Id: Makefile 52901 2010-12-10 18:47:39Z martin $

VERSION = 1.0.1

SOURCES = \
  atd_version.ml \
  atd_ast.mli atd_ast.ml \
  atd_annot.mli atd_annot.ml \
  atd_parser.mli atd_parser.mly \
  atd_lexer.mll \
  atd_print.mli atd_print.ml \
  atd_predef.ml \
  atd_check.ml \
  atd_expand.mli atd_expand.ml \
  atd_inherit.mli atd_inherit.ml \
  atd_tsort.mli atd_tsort.ml \
  atd_util.mli atd_util.ml \
  atd_reflect.mli atd_reflect.ml \
  atd_indent.mli atd_indent.ml

MLY = $(filter %.mly, $(SOURCES))
MLL = $(filter %.mll, $(SOURCES))

MLSOURCES = $(patsubst %.mll,%.ml, $(patsubst %.mly,%.ml, $(SOURCES)))
MLI = $(filter %.mli, $(MLSOURCES))
ML = $(filter %.ml, $(MLSOURCES))
CMI = $(patsubst %.ml,%.cmi, $(ML))
CMO = $(patsubst %.ml,%.cmo, $(ML))
CMX = $(patsubst %.ml,%.cmx, $(ML))
O = $(patsubst %.ml,%.o, $(ML))

OCAMLFLAGS = -dtypes -g
OCAMLPACKS = easy-format unix

DOCFILES = \
  atd_ast \
  atd_annot \
  atd_print \
  atd_expand \
  atd_inherit \
  atd_util \
  atd_reflect \
  atd_indent

DOCSOURCES = $(addsuffix .mli, $(DOCFILES))

ifndef PREFIX
  PREFIX = $(shell dirname $$(dirname $$(which ocamlfind)))
  export PREFIX
endif

ifndef BINDIR
  BINDIR = $(PREFIX)/bin
  export BINDIR
endif

.PHONY: default all opt install uninstall

default: all opt

all: VERSION META atd.cma atdcat.byte

opt: VERSION META atd.cmxa atdcat

install: META
	test ! -f atdcat || cp atdcat $(BINDIR)/
	test ! -f atdcat.exe || cp atdcat.exe $(BINDIR)/
	ocamlfind install atd META \
		`find $(MLI) $(CMI) $(CMO) $(CMX) $(O) atd.cma atd.a atd.cmxa`

uninstall:
	test ! -f $(BINDIR)/atdcat || rm $(BINDIR)/atdcat
	test ! -f $(BINDIR)/atdcat.exe || rm $(BINDIR)/atdcat.exe 
	ocamlfind remove atd

atd_version.ml: Makefile
	echo 'let version = "$(VERSION)"' > atd_version.ml

META: META.in Makefile
	echo 'version = "$(VERSION)"' > META
	cat META.in >> META

VERSION: Makefile
	echo $(VERSION) > VERSION

%.cmi: %.mli
	ocamlfind ocamlc $(OCAMLFLAGS) -c -package "$(OCAMLPACKS)" $<

%.cmi: %.ml
	ocamlfind ocamlc $(OCAMLFLAGS) -c -package "$(OCAMLPACKS)" $<

%.cmo: %.ml
	ocamlfind ocamlc $(OCAMLFLAGS) -c -package "$(OCAMLPACKS)" $<

%.cmx: %.ml
	ocamlfind ocamlopt $(OCAMLFLAGS) -c -package "$(OCAMLPACKS)" $<

atd_parser.mli: atd_parser.mly
	menhir $<

atd_parser.ml: atd_parser.mly
	menhir $<

atd_lexer.ml: atd_lexer.mll
	ocamllex $<

dep: $(SOURCES) Makefile
	ocamlfind ocamldep -package "$(OCAMLPACKS)" $(MLI) $(ML) > dep

ifneq ($(MAKECMDGOALS),clean)
-include dep
endif

atd.cma: dep $(CMI) $(CMO)
	ocamlfind ocamlc $(OCAMLFLAGS) -o atd.cma -a $(CMO)

atd.cmxa: dep $(CMI) $(CMX)
	ocamlfind ocamlopt $(OCAMLFLAGS) -o atd.cmxa -a $(CMX)

atdcat: dep $(CMI) $(CMX) atdcat.ml
	ocamlfind ocamlopt $(OCAMLFLAGS) -o atdcat \
		-package "$(OCAMLPACKS)" -linkpkg \
		$(CMX) atdcat.ml

atdcat.byte: dep $(CMI) $(CMO) atdcat.ml
	ocamlfind ocamlc $(OCAMLFLAGS) -o atdcat \
		-package "$(OCAMLPACKS)" -linkpkg \
		$(CMO) atdcat.ml

.PHONY: doc
doc: odoc/index.html atdcat
	cd manual; $(MAKE)

odoc/index.html: $(CMI)
	mkdir -p odoc
	ocamlfind ocamldoc -d odoc -html \
		-t 'ATD library documentation' \
		-package "$(OCAMLPACKS)" $(DOCSOURCES)

.PHONY: test
test: atdcat test.atd test2.atd
	./atdcat test.atd > test.out
	./atdcat test.out > test.out.out
	cmp test.out test.out.out
	./atdcat -x test2.atd > test2.out

.PHONY: clean
clean:
	rm -f dep
	rm -f $(CMI) $(CMO) $(CMX) $(O)
	rm -f $(patsubst %.mly,%.mli, $(MLY))
	rm -f $(patsubst %.mly,%.ml, $(MLY))
	rm -f $(patsubst %.mll,%.ml, $(MLL))
	rm -f atdcat.cm[ioxa] atdcat.o atdcat.cma atdcat.cmxa
	-$(RM) META
	-$(RM) atd.a atd.cma atd.cmxa atd_version.ml atdcat 
	-$(RM) test.out test.out.out test2.out
	-$(RM) *.annot

.PHONY: distclean
distclean: clean
	rm -rf odoc
	cd manual; $(MAKE) clean

.PHONY: release
release:
	./release.sh