forked from dsheets/ocaml-sodium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
70 lines (51 loc) · 1.53 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
.PHONY: all build test prep pack install reinstall uninstall clean
NAME=sodium
VERSION=0.1.0
PKGS=ctypes.foreign,bigarray
OBJS=sodium
TESTS=test_crypto_box
TESTT=native
CMIS=$(addprefix lib/,$(addsuffix .cmi,${OBJS}))
CMOS=$(addprefix lib/,$(addsuffix .cmo,${OBJS}))
CMXS=$(addprefix lib/,$(addsuffix .cmx,${OBJS}))
CMA=lib/${NAME}.cma
CMXA=lib/${NAME}.cmxa
A=lib/${NAME}.a
B=_build/lib/
INSTALL=META $(addprefix _build/,${CMA} ${CMXA} ${A} ${CMIS} dll${NAME}.so)
build: prep ${CMA} ${CMXA} ${A}
all: build test install
test: build $(addprefix lib_test/,$(addsuffix .${TESTT},${TESTS}))
lib_test/test_%.${TESTT}: lib_test/test_%.ml
ocamlbuild -use-ocamlfind -lflags -cclib,-lsodium -pkgs ${PKGS},oUnit \
-I lib $@
${MAKE} -C lib_test
./test_$*.${TESTT}
prep: _build/.stamp
@ :
_build/.stamp:
mkdir -p _build/lib
@touch $@
%.cmo: %.ml %.mli
ocamlbuild -use-ocamlfind -pkgs ${PKGS} $@
%.cma: ${CMOS}
ocamlbuild -use-ocamlfind -lflags -dllib,-lsodium -pkgs ${PKGS} $@
%.cmx: %.ml %.mli
ocamlbuild -use-ocamlfind -pkgs ${PKGS} $@
%.cmxa: ${CMXS}
ocamlbuild -use-ocamlfind -lflags -cclib,-lsodium -pkgs ${PKGS} $@
%.a: ${CMXS}
ocamlbuild -use-ocamlfind -lflags -cclib,-lsodium -pkgs ${PKGS} $@
%.so:
$(CC) -shared -o $@ -lsodium
META: META.in
sed s/%%VERSION%%/${VERSION}/ < META.in \
| sed s/%%PACKAGES%%/${PKGS}/ > META
install: build ${INSTALL}
ocamlfind install ${NAME} ${INSTALL}
reinstall: uninstall install
uninstall:
ocamlfind remove ${NAME}
clean:
${MAKE} -C lib_test clean
rm -rf _build META $(addsuffix .${TESTT},${TESTS})