-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
102 lines (83 loc) · 3.34 KB
/
Makefile
File metadata and controls
102 lines (83 loc) · 3.34 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
NAME_PROGRAMME = DeepSec
VERSION = 2.0.2
SOURCE = Source/
SCRIPTS = script/
BINDIR = ~
PACKAGES = -package str -package unix
TEMP = *.native *.p.native *.d.byte result
# for profiling or advanced debugging, set the variables below to 1
PROFILE= # seems broken on OSX 10.9 or later
ADVDEBUG=
EXTENSION=$(if $(PROFILE),p.native,$(if $(ADVDEBUG),d.byte,native))
GITC = $(shell git rev-parse HEAD 2> /dev/null)
ifeq ($(GITC),)
GITCOMMIT="not_available"
else
GITCOMMIT = $(GITC)
endif
GITB = $(shell git branch 2> /dev/null | grep \* | sed -E "s/^\* \(?//" | sed -E "s/\)$$//" )
ifeq ($(GITB),)
GITBRANCH="not_available"
else
GITBRANCH = $(GITB)
endif
PHYSICALCORE_SCRIPT = $(shell $(SCRIPTS)/cpu_linux_osx 2> /dev/null)
ifeq ($(PHYSICALCORE_SCRIPT),0)
PHYSICALCORE = 1
else
PHYSICALCORE = $(PHYSICALCORE_SCRIPT)
endif
OSTYPE = $(shell uname)
NBLINE = $(shell find Source -name "*.ml" -or -name "*.mli" -or -name "*.mly" -or -name "*.mll" | xargs cat | wc -l)
.PHONY: check
# whole compilation
all:
@printf "\e[1mCompilation of DeepSec $(VERSION)\e[0m\n"
@echo
@make -s core_check git_check
@printf "\e[1mBuilding sources$(if $(PROFILE), (PROFILE on),$(if $(ADVDEBUG), (ADVDEBUG on),))...\e[0m\n"
@make -s config compil
# same, but activates debugging functions in the code (for development only)
debug:
@printf "\e[1mCompiling DeepSec (debugging functions on)...\e[0m\n"
@make -s config
@sed /debug_activated/s/false/true/ Source/core_library/config.ml > .tmp.ml
@mv .tmp.ml Source/core_library/config.ml
@make -s compil
# Check the number of physical core
core_check:
@if [ $(PHYSICALCORE_SCRIPT) -eq 0 ]; then \
if [ $(OSTYPE) = 'Darwin' ]; then \
printf "\e[33m\e[1mWarning:\e[0m Could not detect the number of physical core of your machine (most probably sysctl is not installed). Set to 1.\n"; \
else \
printf "\e[33m\e[1mWarning:\e[0m Could not detect the number of physical core of your machine (most probably lscpu is not installed). Set to 1.\n"; \
fi \
fi
git_check:
@if [ -z "$(GITCOMMIT)" ]; then \
printf "\e[33m\e[1mWarning:\e[0m Could not detect the git branch or git commit. Cloning the git repository is recommended for bug report and updates.\n"; \
fi
# Check the presen
# generates config.ml
config:
@sed -e "s/VERSION/${VERSION}/g" -e "s/GITCOMMIT/${GITCOMMIT}/g" -e "s/GITBRANCH/${GITBRANCH}/g" -e "s/PHYSICALCORE/${PHYSICALCORE}/g" -e "s/OSTYPE/${OSTYPE}/g" < Source/core_library/config.ml.in > Source/core_library/config.ml
# configures and compiles
compil:
@ocamlbuild $(PACKAGES) main.$(EXTENSION) worker.$(EXTENSION) main_api.$(EXTENSION)
@mv _build/Source/main.$(EXTENSION) deepsec
@mv _build/Source/main_api.$(EXTENSION) deepsec_api
@mv _build/Source/distributed/worker.$(EXTENSION) deepsec_worker
rm main.$(EXTENSION) main_api.$(EXTENSION) worker.$(EXTENSION)
@printf "\e[32m\e[1mBuild successful!\033[0m You can invoke ./deepsec alone or with option --help to display version data and usage information.\n\033[1mNumber of lines in the source code: $(NBLINE)\e[0m\n"
# checks installation requirements
check:
@printf "\e[1mChecking installation requirements...\e[0m\n"
@$(SCRIPTS)check
# moving executables
install:
@cp deepsec $(BINDIR)
@cp deepsec_api $(BINDIR)
@cp deepsec_worker $(BINDIR)
# removes automatically generated files
clean:
rm -rf _build $(SOURCE)core_library/config.ml $(TEMP) deepsec deepsec_worker deepsec_api