Skip to content
This repository was archived by the owner on Nov 26, 2020. It is now read-only.

Commit da25039

Browse files
committed
Move build system to just make to get more control
1 parent 333cc5e commit da25039

File tree

6 files changed

+95
-17
lines changed

6 files changed

+95
-17
lines changed

META.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version = "0.0.1"
2+
description = "Binding to libsodium, a shared library wrapper for djb's NaCl"
3+
requires = "ctypes.foreign"
4+
archive(byte) = "sodium.cma"
5+
archive(byte, plugin) = "sodium.cma"
6+
archive(native) = "sodium.cmxa"
7+
exists_if = "sodium.cma"

Makefile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
.PHONY: all build prep pack install uninstall clean
2+
3+
NAME=sodium
4+
PKGS=ctypes.foreign
5+
OBJS=crypto_box
6+
7+
OCAMLOPT=ocamlopt
8+
OCAMLC=ocamlc
9+
10+
CMOS=$(addprefix lib/,$(addsuffix .cmo,${OBJS}))
11+
CMXS=$(addprefix lib/,$(addsuffix .cmx,${OBJS}))
12+
B=_build/lib/
13+
INSTALL=META $(addprefix ${B},${NAME}.cma ${NAME}.cmxa ${NAME}.cmi dll${NAME}.so)
14+
15+
build: prep pack
16+
17+
all: prep pack install
18+
19+
prep:
20+
mkdir -p _build/lib
21+
22+
pack: ${B}${NAME}.cma ${B}${NAME}.cmxa
23+
24+
%.cmxa: ${CMXS}
25+
${OCAMLOPT} -pack -o ${B}${NAME}.cmx $(addprefix _build/,${CMXS})
26+
${OCAMLOPT} -a -cclib -lsodium -o ${B}${NAME}.cmxa ${B}${NAME}.cmx
27+
28+
%.cma: ${CMOS}
29+
${OCAMLC} -pack -o ${B}${NAME}.cmo $(addprefix _build/,${CMOS})
30+
${OCAMLC} -a -dllib -lsodium -o ${B}${NAME}.cma ${B}${NAME}.cmo
31+
32+
%.cmo: %.ml %.mli
33+
ocamlbuild -use-ocamlfind -pkgs ${PKGS} $@
34+
35+
%.cmx: %.ml %.mli
36+
ocamlbuild -use-ocamlfind -pkgs ${PKGS} $@
37+
38+
%.so:
39+
cc -shared -o $@ -lsodium
40+
41+
META: META.in
42+
cp META.in META
43+
44+
install: ${INSTALL}
45+
ocamlfind install ${NAME} ${INSTALL}
46+
47+
uninstall:
48+
ocamlfind remove ${NAME}
49+
50+
clean:
51+
rm -rf _build META

_oasis

Lines changed: 0 additions & 17 deletions
This file was deleted.

_tags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<lib/*.cmx>: for-pack(Sodium)

lib/crypto_box.ml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
(*
2+
* Copyright (c) 2013 David Sheets <sheets@alum.mit.edu>
3+
*
4+
* Permission to use, copy, modify, and distribute this software for any
5+
* purpose with or without fee is hereby granted, provided that the above
6+
* copyright notice and this permission notice appear in all copies.
7+
*
8+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15+
*
16+
*)
17+
118
open Ctypes
219
open PosixTypes
320
open Foreign

lib/crypto_box.mli

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
val crypto_module : string
2+
val ciphersuite : string
3+
val impl : string
4+
val prefix : string
5+
val box_fn_type :
6+
(string -> string -> Unsigned.ullong -> string -> string -> string -> int)
7+
Ctypes.fn
8+
val box_afternm_type :
9+
(string -> string -> Unsigned.ullong -> string -> string -> int) Ctypes.fn
10+
val box_c :
11+
string -> string -> Unsigned.ullong -> string -> string -> string -> int
12+
val box_open_c :
13+
string -> string -> Unsigned.ullong -> string -> string -> string -> int
14+
val box_keypair_c : string -> string -> int
15+
val box_beforenm_c : string -> string -> string -> int
16+
val box_afternm_c :
17+
string -> string -> Unsigned.ullong -> string -> string -> int
18+
val box_open_afternm_c :
19+
string -> string -> Unsigned.ullong -> string -> string -> int

0 commit comments

Comments
 (0)