-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile.in
108 lines (76 loc) · 3.51 KB
/
Makefile.in
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
# vim:filetype=make
top_srcdir = @top_srcdir@
PKG_NAME = parsercombinator
ARCHIVES = parsercombinator.cma parsercombinator-lwt.cma
XARCHIVES = $(ARCHIVES:.cma=.cmxa)
# First extract the code from README
GEN_ARC_SOURCES = \
ParsersMisc.ml ParsersBoundedSet.ml ParsersCorrections.ml \
Parsers.ml ParsersUsual.ml ParsersPositions.ml \
ParsersConfig.ml
GEN_SOURCES = \
$(GEN_ARC_SOURCES) ParsersLwtConfig.ml test.ml
GEN_FILES = $(GEN_SOURCES) .gensource_stamp README.html
REQUIRES = batteries lwt_ppx lwt.unix ounit2
.PHONY: all distclean clean clear loc doc wc install uninstall reinstall dep check unit-tests
# Do not depends on README.annot so that we do not need to compile test.ml (which requires ounit)
all: $(ARCHIVES) $(XARCHIVES)
# Do not depend on $(GEN_SOURCES:.ml=.cmo) so that we get the .annot file
# even when some file does not compile.
README.annot: $(GEN_SOURCES:.ml=.annot)
cat $(GEN_SOURCES:.ml=.annot) > $@
.gensource_stamp: README.adoc
ocamlfind portia/portia -ignore-missing -libdir "$$(ocamlfind query portia)" -syntax asciidoc -syntax ocaml $<
@touch $@
$(GEN_SOURCES): .gensource_stamp
include $(top_srcdir)/make.common
parsercombinator.cma: $(patsubst %.mli,%.cmo,$(filter %.mli, $(GEN_ARC_SOURCES))) $(patsubst %.ml,%.cmo,$(filter %.ml, $(GEN_ARC_SOURCES)))
$(OCAMLC) -a -o $@ -package "$(REQUIRES)" $(OCAMLFLAGS) $(patsubst %.ml,%.cmo,$(filter %.ml, $(GEN_ARC_SOURCES)))
parsercombinator.cmxa: $(patsubst %.mli,%.cmi,$(filter %.mli, $(GEN_ARC_SOURCES))) $(patsubst %.ml,%.cmx,$(filter %.ml, $(GEN_ARC_SOURCES)))
$(OCAMLOPT) -a -o $@ -package "$(REQUIRES)" $(OCAMLOPTFLAGS) $(patsubst %.ml,%.cmx,$(filter %.ml, $(GEN_ARC_SOURCES)))
ParsersLwtConfig.cmx: parsercombinator.cmxa ParsersLwtConfig.ml
$(OCAMLOPT) $(SYNTAX) -package "$(REQUIRES)" $(OCAMLOPTFLAGS) -c $^
ParsersLwtConfig.cmo: parsercombinator.cma ParsersLwtConfig.ml
$(OCAMLC) $(SYNTAX) -package "$(REQUIRES)" $(OCAMLFLAGS) -c $^
parsercombinator-lwt.cma: ParsersLwtConfig.cmo
$(OCAMLC) -a -o $@ -package "$(REQUIRES)" $(OCAMLFLAGS) $^
parsercombinator-lwt.cmxa: ParsersLwtConfig.cmx
$(OCAMLOPT) -a -o $@ -package "$(REQUIRES)" $(OCAMLOPTFLAGS) $^
ifeq ("@HAVE_OUNIT@", "yes")
unit-tests: test.opt
@echo "Running other unit tests"
@./test.opt
check: unit-tests
test.cmx: test.ml $(XARCHIVES)
$(OCAMLOPT) $(SYNTAX) -package "$(REQUIRES) oUnit" $(OCAMLOPTFLAGS) -c $< -o $@
test.opt: test.cmx $(XARCHIVES)
$(OCAMLOPT) -o $@ -package "$(REQUIRES) oUnit" -ccopt -L$(top_srcdir) $(XARCHIVES) -linkpkg $(OCAMLOPTFLAGS) $^
endif
clean:
$(RM) *.cm[ioxa] *.cmxa *.cmxs *.a *.s *.o test.* .depend *.annot $(GEN_FILES)
distclean: clean
$(RM) *.byte *.opt $(ARCHIVES) $(XARCHIVES)
clear:
sed -i.bak -e 's/[ ]\+$$//' $(wildcard *.adoc)
install: $(ARCHIVES) $(XARCHIVES)
for xarch in $(XARCHIVES) ; do \
if test -f "$$xarch" ; then extra="$$extra $$xarch "`basename "$$xarch" .cmxa`.a ; fi ; \
done ; \
if test -n "$$extra" ; then extra="$$extra *.cmx" ; fi ; \
@OCAMLFIND@ install "$(PKG_NAME)" *.cmi $(ARCHIVES) META $$extra
uninstall:
@OCAMLFIND@ remove $(PKG_NAME)
reinstall: uninstall install
.SUFFIXES: .html .adoc
.adoc.html:
asciidoc -a data-uri -a icons -a toc -a max-width=55em --theme volnitsky -o $@ $<
doc: README.html
wc: README.adoc
@cat $^ | tr -d '[:punct:]' | tr ' ' '\n' | grep -v '^$$' | sort | uniq -c | sort -nr
# Dependencies
dep:
$(RM) $(GEN_SOURCES) .depend
$(MAKE) .depend
.depend: $(GEN_SOURCES)
$(OCAMLDEP) -package "$(REQUIRES)" $(filter %.ml, $(GEN_ARC_SOURCES)) $(filter %.mli, $(GEN_ARC_SOURCES)) > $@
-include .depend