-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile.in
183 lines (140 loc) · 4.31 KB
/
Makefile.in
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
173
174
175
176
177
178
179
180
181
182
183
# Configuration
VERSION = @PACKAGE_VERSION@
OCAMLC = OCAMLRUNPARAM= ocamlfind ocamlc
OCAMLOPT = OCAMLRUNPARAM= ocamlfind ocamlopt
OCAMLDEP = OCAMLRUNPARAM= ocamlfind ocamldep
QTEST = qtest
PORTIA = ocamlfind portia/portia
#WARNS = -w -40+27
OCAMLFLAGS = @OCAMLFLAGS@ -I src $(WARNS) -annot -bin-annot
ifdef NDEBUG
OCAMLFLAGS += -noassert -O2
OCAMLCFLAGS += -noassert -O2
else
OCAMLFLAGS += -g
OCAMLCFLAGS += -g
endif
PACKAGES = \
batteries,cmdliner,dessser,kafka
GEN_SOURCES = \
src/datasino_cli.ml \
src/datasino_main.ml \
src/datasino_tools.ml
OTHER_SOURCES = \
src/datasino_config.ml
INSTALLED_BIN = datasino
INSTALLED_LIB = \
src/datasino_tools.cmx \
src/datasino_tools.cmi \
src/datasino_tools.cmt \
src/datasino_main.cmx \
src/datasino_main.cmi \
src/datasino_main.cmt
INSTALLED = \
$(INSTALLED_BIN) \
$(INSTALLED_LIB) \
META
bin_dir ?= /usr/bin/
.PHONY: doc clean clean-dist all dep install uninstall reinstall \
docker docker-push
# Main targets
all: $(INSTALLED)
doc: README.html
# Source extraction from the documentation
$(GEN_SOURCES): README.adoc
@echo 'Extracting $@'
@mkdir -p src
$(PORTIA) \
-libdir '$(shell ocamlfind query portia)' \
-syntax asciidoc -syntax ocaml \
-outdir src $<
src/datasino_config.ml: Makefile
@echo 'Generating $@'
@echo '(* Generated by Makefile - edition is futile *)' > $@
@echo 'let version = "$(VERSION)"' >> $@
@echo 'let ocaml_version = "@OCAMLVERSION@"' >> $@
@echo 'let ocamlfind = "@OCAMLFIND@"' >> $@
@echo 'let ocamlpath = "$(OCAMLPATH)"' >> $@
@echo 'let build_date = "$(shell date -R)"' >> $@
@echo 'let build_host = "$(shell hostname)"' >> $@
META: Makefile
@echo 'Building findlib configuration ($@)'
@echo 'description = "Data generator for arbitrary types and various formats"' > $@
@echo 'version = "$(VERSION)"' >> $@
# Generic rules
.SUFFIXES: .html .adoc .ml .cmi .cmo .cmx .cmxs .cmt .annot .type
%.html: %.adoc
asciidoc -a data-uri -a icons -a toc -a max-width=55em \
--theme volnitsky -o $@ $<
%.cmi: %.cmx
@true
%.cmx %.cmt %.annot: %.ml
@echo 'Compiling $@ (native)'
$(OCAMLOPT) $(OCAMLFLAGS) -package '$(PACKAGES)' -c $<
# Dependencies
dep:
@$(RM) .depend
@$(MAKE) .depend
.depend:
@echo 'Generating dependencies'
@$(OCAMLDEP) -I src -package '$(PACKAGES)' $(filter %.ml, $(OTHER_SOURCES)) > $@
include .depend
# Dependencies for generated sources are handled manually to avoid circular
# deps within the makefile
src/datasino_cli.cmx: \
src/datasino_config.cmx src/datasino_tools.cmx src/datasino_main.cmx
src/datasino_main.cmx: src/datasino_tools.cmx
src/datasino_tools.cmx:
# Compiling
datasino: \
src/datasino_config.cmx \
src/datasino_tools.cmx \
src/datasino_main.cmx \
src/datasino_cli.cmx
@echo 'Compiling datasino $@ (native)'
$(OCAMLOPT) $(OCAMLFLAGS) -I src -linkpkg -package '$(PACKAGES)' -package dynlink $^ -o $@
README.annot:
src/datasino_config.annot \
src/datasino_tools.annot \
src/datasino_main.annot \
src/datasino_cli.annot
@echo 'Building main annot file'
cat $^ > $@
# Installation
install-bin: $(INSTALLED_BIN)
@echo 'Installing binaries into $(prefix)$(bin_dir)'
@install -d '$(prefix)$(bin_dir)'
@install $(INSTALLED_BIN) '$(prefix)$(bin_dir)'/
install-lib: $(INSTALLED_LIB) META
ocamlfind install datasino $^
install: install-bin install-lib
uninstall:
@echo Uninstalling
@ocamlfind remove datasino
@for f in $(INSTALLED_BIN); do \
$(RM) "$(prefix)$(bin_dir)/$$f" ;\
done
reinstall: uninstall install
# Docker image
docker: docker/Dockerfile
@echo 'Building docker image'
docker build -t rixed/datasino:latest -f $< docker/
docker tag rixed/datasino:latest localhost:5000/datasino
docker tag rixed/datasino:latest rixed/datasino:v$(VERSION)
docker-push:
@echo 'Pushing docker image (local)'
docker push localhost:5000/datasino
@echo 'Pushing docker images (dockerhub)'
docker push rixed/datasino:v$(VERSION)
# Cleaning
clean:
@echo 'Cleaning all build files'
@$(RM) src/*.cmo src/*.s src/*.annot src/*.o src/*.cmt
@$(RM) src/*.cma src/*.cmx src/*.cmxa src/*.cmxs src/*.cmi
@$(RM) *.opt src/all_tests.* perf.data* gmon.out
@$(RM) oUnit-anon.cache qtest.targets.log
@$(RM) .depend src/*.opt src/*.byte src/*.top
@$(RM) README.html META
clean-dist: clean
@echo 'Making it extra clean'
@$(RM) $(GEN_SOURCES) src/datasino_config.ml $(INSTALLED)