Repository navigation
Expand file tree
/
Copy pathmake.common
More file actions
133 lines (102 loc) · 4.8 KB
/
Copy pathmake.common
File metadata and controls
133 lines (102 loc) · 4.8 KB
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
# vim:ft=make
DUPS_IN = $(shell ocamlfind query compiler-libs):$(shell ocamlfind query num)
OCAMLC = OCAMLFIND_IGNORE_DUPS_IN="$(DUPS_IN)" ocamlfind ocamlc -thread
OCAMLOPT = OCAMLFIND_IGNORE_DUPS_IN="$(DUPS_IN)" ocamlfind ocamlopt -thread
OCAMLDEP = OCAMLFIND_IGNORE_DUPS_IN="$(DUPS_IN)" ocamlfind ocamldep
OCAMLDOC = OCAMLFIND_IGNORE_DUPS_IN="$(DUPS_IN)" ocamlfind ocamldoc -html -colorize-code -thread -sort -stars
OCAMLMKTOP = OCAMLFIND_IGNORE_DUPS_IN="$(DUPS_IN)" ocamlfind ocamlmktop -thread -g
QTEST = qtest
DOCDIR ?= docs/
WARNS = -w -40-31+27
override OCAMLOPTFLAGS += $(INCS) $(WARNS) -annot
override OCAMLFLAGS += $(INCS) $(WARNS) -annot
ifndef NDEBUG
override OCAMLOPTFLAGS += -g
override OCAMLFLAGS += -g
endif
CAMLINCLUDE = $(shell ocamlfind printconf stdlib)
CPPFLAGS += -I $(CAMLINCLUDE) -I .
CFLAGS += -O2 -std=c99 -W -Wall -D_GNU_SOURCE
all:
.PHONY: all dep clean clean-spec install uninstall reinstall doc doc-lib doc-spec check clear
ifdef PKG_NAME
LIB_SOURCES_CMO = $(LIB_SOURCES:.ml=.cmo)
LIB_SOURCES_CMX = $(LIB_SOURCES:.ml=.cmx)
LIB_SOURCES_CMI = $(LIB_SOURCES:.ml=.cmi)
ARCHIVE = $(PKG_NAME).cma
XARCHIVE = $(ARCHIVE:.cma=.cmxa)
$(ARCHIVE): $(LIB_SOURCES_CMO) $(CLIB)
$(OCAMLC) $(CLIB) -package "$(REQUIRES)" -custom -linkpkg $(OCAMLFLAGS) $(LIB_SOURCES_CMO) $(LIBS) -a -o $@
# Note: CLIB_SHORT is required for the lib to be recorded in the cmxa file
# (ocamlopt does not record required C libs unless -cclib is used)
$(XARCHIVE): $(LIB_SOURCES_CMX) $(CLIB)
$(OCAMLOPT) -cclib -l$(CLIB_SHORT) -package "$(REQUIRES)" $(OCAMLOPTFLAGS) $(LIB_SOURCES_CMX) $(LIBS) -a -o $@
install: $(ARCHIVE)
if test -f "$(XARCHIVE)" ; then extra="$(XARCHIVE) $(XARCHIVE:.cmxa=.a)" ; fi ; \
ocamlfind install "$(PKG_NAME)" $(LIB_SOURCES_CMI) $(LIB_SOURCES_CMX) $(LIB_SOURCES_CMO) $(PKG_NAME).a $(CLIB) "$(ARCHIVE)" META $$extra
uninstall:
ocamlfind remove $(PKG_NAME)
reinstall: uninstall install
endif
# Common rules
.SUFFIXES: .ml .mli .cmo .cmi .cmx .opt .byte .md .html
%.byte: $(ARCHIVE) %.cmo
$(OCAMLC) -o $@ -package "$(REQUIRES)" $(OCAMLFLAGS) $^
%.opt: $(XARCHIVE) %.cmx
$(OCAMLOPT) -o $@ -I . -linkpkg -package "$(REQUIRES)" $(OCAMLOPTFLAGS) $^
%.cmo %.annot &: %.ml
$(OCAMLC) -package "$(REQUIRES)" $(OCAMLFLAGS) -c $<
%.cmi: %.mli
$(OCAMLC) -package "$(REQUIRES)" $(OCAMLFLAGS) -c $<
%.cmx %.annot &: %.ml
$(OCAMLOPT) -package "$(REQUIRES)" $(OCAMLOPTFLAGS) -c $<
# Tests with qtest
all_tests.byte: all_tests.cmo $(ARCHIVE)
$(OCAMLC) -o $@ -package "$(REQUIRES) qcheck" $(ARCHIVE) -linkpkg $(OCAMLFLAGS) $<
all_tests.cmo: all_tests.ml $(LIB_SOURCES_CMO)
$(OCAMLC) -package "$(REQUIRES) qcheck" $(OCAMLFLAGS) -w -33 -c -impl $<
all_tests.opt: all_tests.cmx $(XARCHIVE)
$(OCAMLOPT) -I . -o $@ -package "$(REQUIRES) qcheck" $(XARCHIVE) -linkpkg $(OCAMLOPTFLAGS) $<
all_tests.cmx: all_tests.ml $(LIB_SOURCES_CMX)
$(OCAMLOPT) -package "$(REQUIRES) qcheck" $(OCAMLOPTFLAGS) -w -33 -c -impl $<
all_tests.ml: $(LIB_SOURCES)
$(QTEST) --shuffle --preamble 'open Batteries;; open Bitstring;; open Tools;; open SimTypes' -o $@ extract $^
check: all_tests.opt $(EXTRA_TESTS)
$(RM) oUnit-anon.cache
@for t in $^; do \
echo "Running $$t" ;\
./$$t ;\
done
# Clean up
clean: clean-spec
$(RM) *.cm[ioxa] *.cmxa *.a *.s *.o *.byte *.opt *.top *.annot .depend all_tests.* *.cache *.log
# Dependencies
dep:
@$(RM) .depend
@$(MAKE) .depend
.depend:
$(OCAMLDEP) -package "$(REQUIRES)" $(SOURCES) > $@
%.html: %.md
md2html --github '$<' > '$@.tmp' && mv -f '$@.tmp' '$@'
# ocamldoc works from the sources it is handed and cannot load a .cmi, so it
# expands neither a functor application nor an [include] over a module from
# outside this library -- Map.Make, Set.Make, Hashtbl.Make, Condition -- and
# says so once per such module. Adding -I does not help; only handing it the
# stdlib's own sources would. Those six are therefore expected, and every other
# warning is a cross-reference that has gone stale, which is worth a broken
# build: keeping the references honest is most of what running this buys.
DOC_EXPECTED = Stdlib\.Map\.Make|Batteries\.Set\.Make|BatSet\.Make|Batteries\.Hashtbl\.Make|Hashtbl\.HashedType|Condition
doc-lib: $(LIB_SOURCES)
@echo "Building doc in $(DOCDIR)..."
mkdir -p $(DOCDIR)
@unexpected=`$(OCAMLDOC) -package "$(REQUIRES)" -d $(DOCDIR) $^ 2>&1 | \
grep -Ev '^Warning: Module (or module )?type ?($(DOC_EXPECTED)) not found$$'` ; \
if [ -n "$$unexpected" ] ; then \
echo "$$unexpected" ; \
echo "ocamldoc: the above is not one of the expected warnings" ; \
exit 1 ; \
fi
#sed -i -e '/^<head>/a<link href="http://fonts.googleapis.com/css?family=Rosarivo:400,400italic|Happy+Monkey|Electrolize" rel="stylesheet" type="text/css">' $(DOCDIR)/*.html
#sed -i -e 's|<center><h1></h1></center>|<h1>$(PKG_NAME)</h1>|' $(DOCDIR)/index.html
doc: doc-lib doc-spec
-include .depend