This repository has been archived by the owner on Jun 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·131 lines (100 loc) · 3.4 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
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
DB=db
INCLUDE=-package batteries,zarith -I $(DB)
MARCH?=x86_64
OCAMLC = ocamlfind c $(INCLUDE) -g -annot
OCAMLOPT = ocamlfind opt $(INCLUDE) -g -annot
OCAMLMKLIB = ocamlfind mklib $(INCLUDE)
OCAMLDEP = ocamlfind dep -slash
CCOPTS = $(addprefix -ccopt ,-Wall -std=c11 -D__USE_MINGW_ANSI_STDIO)
CCLIBS =
ifeq ($(OS),Windows_NT)
# On cygwin + cygwinports, DLLs are searched in the PATH, which is not
# altered to include by default the mingw64 native DLLs. We also need to
# find dllcorecrypto.dll; it is in the current directory, which Windows
# always uses to search for DLLs.
EXTRA_PATH = PATH="/usr/$(MARCH)-w64-mingw32/sys-root/mingw/bin/:$(PATH)"
ARCH = win32
EXTRA_OPTS =
EXTRA_LIBS = -L.
ifeq ($(MARCH),x86_64)
OPENSSL_CONF = CC=x86_64-w64-mingw32-gcc ./Configure mingw64 enable-tls1_3
else
OPENSSL_CONF = CC=i686-w64-mingw32-gcc ./Configure mingw enable-tls1_3
endif
else
# On Unix-like systems, the library search path is LD_LIBRARY_PATH, which is
# correctly setup to find libssleay.so and the like, but never includes the
# current directory, which is where dllcorecrypto.so is located.
EXTRA_PATH = LD_LIBRARY_PATH=.
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
EXTRA_OPTS =
EXTRA_LIBS = -L.
ARCH = osx
OPENSSL_CONF = ./config enable-tls1_3
else
EXTRA_OPTS = -thread -ccopt -fPIC
EXTRA_LIBS = -L.
ARCH = x86_64
# The HACL* test engine directly links with the .o files
OPENSSL_CONF = ./config enable-tls1_3 -fPIC
endif
endif
.PHONY: test dep
# JP 20180913: CoreCrypto is gone, in favor of EverCrypt... for the purposes of
# the Everest build, the only reason why we want to keep this repository is to
# have a working build of OpenSSL
# all: # CoreCrypto.cmxa CoreCrypto.cma
ifdef NO_OPENSSL
all:
else
all: openssl/libcrypto.a
endif
%.cmi: %.mli
$(OCAMLC) -c $<
%.cmo: %.ml
$(OCAMLC) -c $<
%.cmx: %.ml
$(OCAMLOPT) -c $<
$(DB)/DB.cmx: $(DB)/DB.ml
$(MAKE) -C $(DB)
ifdef NO_OPENSSL
CCOPTS += $(addprefix -ccopt ,-DNO_OPENSSL)
openssl_stub.o: openssl_stub.c
$(OCAMLOPT) $(CCOPTS) $(EXTRA_OPTS) $? -o $@
else
CCOPTS += $(addprefix -ccopt ,-Lopenssl -Iopenssl/include)
CCLIBS += $(addprefix -cclib ,-lcrypto)
openssl_stub.o: libcrypto.a openssl_stub.c
$(OCAMLOPT) $(CCOPTS) $(EXTRA_OPTS) -c openssl_stub.c
openssl/Configure:
echo "openssl folder is empty, running git submodule update... no recursion"
git submodule update --init
openssl/libcrypto.a: openssl/Configure
cd openssl && $(OPENSSL_CONF) && $(MAKE) build_libs
libcrypto.a: openssl/libcrypto.a
cp openssl/libcrypto.a .
endif # NO_OPENSSL
DLL_OBJ = CryptoTypes.cmx CoreCrypto.cmx openssl_stub.o
CoreCrypto.cmxa: $(DLL_OBJ)
$(OCAMLMKLIB) $(EXTRA_LIBS) $(CCLIBS) -o CoreCrypto $(DLL_OBJ)
DLL_BYTE = CryptoTypes.cmo CoreCrypto.cmo openssl_stub.o
CoreCrypto.cma: $(DLL_BYTE)
$(OCAMLMKLIB) $(EXTRA_LIBS) $(CCLIBS) -o CoreCrypto $^
TEST_CMX = Tests.cmx
Tests.exe: CoreCrypto.cmxa $(TEST_CMX)
$(OCAMLOPT) $(EXTRA_OPTS) -linkpkg -o $@ \
CoreCrypto.cmxa $(TEST_CMX)
test: Tests.exe
@$(EXTRA_PATH) ./Tests.exe
clean:
$(MAKE) -C $(DB) clean
ifdef PLATFORM
$(MAKE) -C $(PLATFORM) clean
endif
rm -f Tests.exe *.[oa] *.so *.cm[ixoa] *.cmxa *.exe *.dll *.annot *~
.depend:
$(OCAMLDEP) -I $(DB) *.ml *.mli > .depend
include .depend
valgrind: Tests$(EXE)
valgrind --leak-check=yes --suppressions=suppressions ./Tests$(EXE)