-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
172 lines (142 loc) · 5.67 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
PACKAGES=async fileutils ppx_core ppx_bin_prot ppx_sexp_conv async_shell extunix core core_extended textutils cmdliner ppx_compare ppx_fields_conv ppx_here
# I don't understand warning 18
OCAML_WARNING=+a-4-9-18-41-30-42-44-40
OCAML_WARN_ERROR=+5+10+8+12+20+11
OPTIONS=-no-sanitize -no-links -tag debug -use-ocamlfind \
-cflags -w,$(OCAML_WARNING) -cflags \
-warn-error,$(OCAML_WARN_ERROR) -cflag -bin-annot -j 8 -tag thread \
-tag principal
#OPTIONS += -cflags -warn-error,+a
DIRECTORIES=tests src
OCAMLBUILD=ocamlbuild \
$(addprefix -package ,$(PACKAGES)) \
$(OPTIONS) \
$(addprefix -I ,$(DIRECTORIES)) \
.PHONY: tests monitor.native tests_table.native tests_table.byte
INTERNAL_BINARY=Oci_Copyhard Oci_Default_Master \
Oci_Wrapper Oci_Cmd_Runner Oci_Simple_Exec \
Oci_Generic_Masters_Runner
EXTERNAL_BINARY=Oci_Monitor Oci_Master_Tools
#For testing the library
EXTERNALLY_COMPILED_BINARY=oci_default_master oci_default_client
BINARY=$(INTERNAL_BINARY) $(EXTERNAL_BINARY)
LIBRARY=Oci_Master Oci_Runner Oci_Client
TESTS = tests_runner tests_client tests_master tests_time
LIB= Oci_Common.cmi Oci_Filename.cmi Oci_Std.cmi Oci_pp.cmi \
Oci_Default_Masters.cmxa Oci_Default_Masters.a \
Oci_Generic_Masters.cmi Oci_Generic_Masters_Api.cmi \
Oci_Rootfs.cmi Oci_Rootfs_Api.cmi Oci_Cmd_Runner_Api.cmi \
$(addsuffix .cmxa, $(LIBRARY)) \
$(addsuffix .cmi, $(LIBRARY)) \
$(addsuffix .a, $(LIBRARY)) \
liboci_stubs.a
TOCOMPILE= $(addprefix src/, $(addsuffix .native,$(BINARY)) $(LIB)) \
$(addprefix tests/, $(addsuffix .native,$(TESTS)))
all: compile $(addprefix bin/, $(EXTERNALLY_COMPILED_BINARY))
include .config
sinclude .in_git_repository
compile: .merlin src/Oci_Version.ml META
@rm -rf bin/ lib/ bin-test/
$(OCAMLBUILD) $(TOCOMPILE)
@mkdir -m 777 -p bin/ bin-test/
@mkdir -p lib/oci/
@cp $(addprefix _build/,$(addprefix src/, $(addsuffix .native, $(BINARY)))) \
bin
@cp $(addprefix _build/,$(addprefix tests/, $(addsuffix .native, $(TESTS)))) \
bin-test
@cp $(addprefix _build/,$(addprefix src/, $(LIB))) META lib/oci
install:
rm -rf $(LIB_INSTALL_DIR)/bin
ocamlfind remove oci
@mkdir -p $(VARDIR)/oci-data
@chown $(OCIUSER): $(VARDIR)/oci-data
ocamlfind install oci lib/oci/*
@mkdir -p $(LIB_INSTALL_DIR)/bin $(BINDIR)
install $(addprefix bin/, $(addsuffix .native, $(INTERNAL_BINARY))) $(LIB_INSTALL_DIR)/bin
install bin/oci_default_master $(LIB_INSTALL_DIR)/bin/oci-default-master
install bin/Oci_Monitor.native $(BINDIR)/oci-monitor
install bin/Oci_Master_Tools.native $(BINDIR)/oci-master-tools
install bin/Oci_Master_Tools.native $(VARDIR)/oci-master-tools
install bin/oci_default_client $(BINDIR)/oci-default-client
uninstall:
rm -rf $(LIB_INSTALL_DIR)/bin
ocamlfind remove oci
rm -f $(addprefix $(BINDIR),oci-monitor oci-default-client oci-master-tools)
#force allows to always run the rules that depends on it
.PHONY: force
src/Oci_Version.ml: .config Makefile
@echo "Generating $@ for version $(VERSION)"
@rm -f [email protected]
@echo "(** Autogenerated by Makefile *)" > [email protected]
@echo "let version = \"$(VERSION)\"" >> [email protected]
@echo "let prefix = \"$(prefix)\"" >> [email protected]
@echo "let lib_install_dir = \"$(LIB_INSTALL_DIR)\"" >> [email protected]
@echo "let var_dir = \"$(VARDIR)\"" >> [email protected]
@echo "let default_oci_data = Filename.concat var_dir \"oci-data\" " >> [email protected]
@echo "let oci_user = \"$(OCIUSER)\"" >> [email protected]
@chmod a=r [email protected]
@mv -f [email protected] $@
bin/%.native: src/version.ml force
@mkdir -p `dirname bin/$*.native`
@rm -f $@
@$(OCAMLBUILD) src/$*.native
@ln -rs _build/src/$*.native $@
monitor.byte:
$(OCAMLBUILD) src/monitor/monitor.byte
tests_table.byte:
$(OCAMLBUILD) tests/tests_table.byte
#Because ocamlbuild doesn't give to ocamldoc the .ml when a .mli is present
dep:
cd _build; \
ocamlfind ocamldoc -o dependencies.dot $$(find src -name "*.ml" -or -name "*.mli") \
$(addprefix -package ,$(PACKAGES)) \
$(addprefix -I ,$(DIRECTORIES)) \
-dot -dot-reduce
sed -i -e "s/ \(size\|ratio\|rotate\|fontsize\).*$$//" _build/dependencies.dot
dot _build/dependencies.dot -T svg > dependencies.svg
clean:
rm -rf bin src/Oci_Version.ml
$(OCAMLBUILD) -clean
.merlin: Makefile
@echo "Generating Merlin file"
@rm -f .merlin.tmp
@for PKG in $(PACKAGES); do echo PKG $$PKG >> .merlin.tmp; done
@for SRC in $(DIRECTORIES); do echo S $$SRC >> .merlin.tmp; done
@for SRC in $(DIRECTORIES); do echo B _build/$$SRC >> .merlin.tmp; done
@echo FLG -w $(OCAML_WARNING) >> .merlin.tmp
@echo FLG -w $(OCAML_WARN_ERROR) >> .merlin.tmp
@mv .merlin.tmp .merlin
META: .config Makefile META.in
@echo "Generating META file"
@rm -f [email protected]
@sed -e "s/@(REQUIRES)/$(PACKAGES)/" -e "s/@(VERSION)/$(VERSION)/" [email protected] > [email protected]
@mv [email protected] $@
# We test that the library contains the needed modules
bin/%:tests/library/%.ml force compile
OCAMLPATH=lib:$(OCAMLPATH) \
ocamlfind ocamlopt -thread -linkpkg -package oci.$(patsubst oci_default_%,%,$*) $< -o $@
tests: compile
bin/Oci_Monitor.native --binaries bin-test --master \
bin-test/tests_master.native --oci-data test-oci-data \
--cpuinfo --verbose Debug
.PHONY: headers
define make-header
git ls-files | xargs git check-attr $1 | sed -n -e "s/^\([^:]*\): $1: set/\1/p" \
| xargs headache -c licences/headache_config.txt -h licences/$2
endef
headers:
$(call make-header,header-cea,CEA_LGPL)
$(call make-header,header-why3,WHY3_LGPL)
.config: config.status
./config.status --file .config
config.status: configure
./config.status --recheck
GIT_TARNAME = oci-$(VERSION)
archive:
git archive --format=tar --prefix=$(GIT_TARNAME)/ -o $(GIT_TARNAME).tar HEAD^{tree}
@rm -rf $(GIT_TARNAME)
@mkdir -p $(GIT_TARNAME)
cp configure $(GIT_TARNAME)/
tar rf $(GIT_TARNAME).tar $(GIT_TARNAME)/configure
@rm -r $(GIT_TARNAME)
gzip -f -9 $(GIT_TARNAME).tar