-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathOMakeroot
153 lines (117 loc) · 3.68 KB
/
OMakeroot
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
open build/Common
open build/OCaml
.PHONY: lib doc examples tests \
install install_lib install_doc \
uninstall uninstall_lib \
clean distclean \
print_config
install: install_lib
uninstall: uninstall_lib
clean:
rm -rf _build
distclean: clean
rm -rf OMakeroot.omc .omakedb .omakedb.lock
################################################################################
# General Project Information
PROJECT = riakc
VERSION = 3.0.1-dev
LIB_NAME = $(PROJECT)
LIB_DESCRIPTION = Riak client.
LIB_MODULES[] =
$(removesuffix $(basename $(ls src/lib/*.ml)))
LIB_PACKAGES = core async async_unix bitstring.syntax protobuf
EXAMPLES[] =
$(removesuffix $(basename $(ls src/examples/*.ml)))
################################################################################
# Directory and File Names
DEFAULT_PREFIX=_build/usr
DefineCommandVars()
if $(not $(defined PREFIX))
PREFIX = $(DEFAULT_PREFIX)
export
if $(not $(defined BIN_DIR))
BIN_DIR = $(PREFIX)/bin
export
if $(not $(defined DOC_DIR))
DOC_DIR = $(PREFIX)/doc
export
print_config:
echo "PREFIX = $(PREFIX)"
echo "BIN_DIR = $(BIN_DIR)"
echo "DOC_DIR = $(DOC_DIR)"
################################################################################
# Build Parameters
USE_OCAMLFIND = true
if $(not $(OCAMLFIND_EXISTS))
eprintln(Required package ocamlfind not found.)
exit 1
NATIVE_ENABLED = $(OCAMLOPT_EXISTS)
BYTE_ENABLED = $(OCAMLC_EXISTS)
OCAMLFLAGS = -bin-annot -annot -warn-error P -thread
OCAMLCFLAGS =
OCAMLOPTFLAGS =
OCAML_LINK_FLAGS +=
OCAML_BYTE_LINK_FLAGS =
OCAML_NATIVE_LINK_FLAGS =
OCAMLFINDFLAGS = -syntax camlp4o
OCAMLPACKS[] = $(LIB_PACKAGES)
.SUBDIRS: .
mkdir -p _build/lib
mkdir -p _build/examples
mkdir -p _build/tests
mkdir -p _build/doc
vmount(-l, src/, _build/)
##############################################################################
# Library
.SUBDIRS: _build/lib
META:
echo "description = \"$(LIB_DESCRIPTION)\"" > $@
echo "version = \"$(VERSION)\"" >> $@
echo "archive(byte) = \"$(LIB_NAME).cma\"" >> $@
echo "archive(native) = \"$(LIB_NAME).cmxa\"" >> $@
echo "requires = \"$(LIB_PACKAGES)\"" >> $@
lib: $(OCamlLibrary $(LIB_NAME), $(LIB_MODULES))
.DEFAULT: lib META
install_lib: $(LIB_NAME).cma $(LIB_NAME).cmxa META uninstall_lib
ocamlfind install $(PROJECT) META \
*.cm[iox] *.o $(LIB_NAME).cma $(LIB_NAME).cmxa *.a
uninstall_lib:
ocamlfind remove $(PROJECT)
##############################################################################
# Examples
.SUBDIRS: _build/examples
OCAML_LIBS = ../lib/$(LIB_NAME)
OCAMLINCLUDES += $(dir ../lib)
foreach (example => ..., $(EXAMPLES))
.DEFAULT: $(OCamlProgram $(example), $(example))
##############################################################################
# Tests
.SUBDIRS: _build/tests
OCAML_LIBS = ../lib/$(LIB_NAME)
OCAMLINCLUDES += $(dir ../lib)
.DEFAULT: $(OCamlProgram all_tests, all_tests)
##############################################################################
# API Documentation
.SUBDIRS: _build/doc
api/index.html: ../lib/riakc/$(LIB_NAME).cma
rm -rf api
mkdir api
ocamlfind ocamldoc \
$(OCAMLFINDFLAGS) \
-package $(concat \,, $(LIB_PACKAGES)) \
-thread \
-charset UTF-8 \
-d api \
-t "OCaml Riak $(VERSION)" \
-keep-code \
-colorize-code \
-sort \
-html \
-I ../lib/riakc \
../lib/riakc/*.ml
doc: api/index.html
install_doc: doc
echo "Installing documentation in $(DOC_DIR)"
rm -rf $(DOC_DIR)
mkdir -p $(DOC_DIR)
cp -r _build/doc/api $(DOC_DIR)/