-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmake.inc.in
178 lines (166 loc) · 6.67 KB
/
make.inc.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
# vim: ft=make
# Regroup in this file every file generation that depends on the makefile itself,
# in order to limit spurious rebuilds
debian.control: make.inc
@echo 'Building $@'
@echo 'Package: @PACKAGE_NAME@' > $@
@echo 'Version: @PACKAGE_VERSION@' >> $@
@echo 'Architecture: $(shell dpkg-architecture -qDEB_BUILD_ARCH)' >> $@
@echo 'Maintainer: rixed-github@happyleptic.org' >> $@
@echo 'Depends: g++, gcc, libblas-dev, liblapack-dev, libsasl2-dev, libssl-dev, libsqlite3-0, liblmdb-dev, systemd' >> $@
@echo 'Conflicts: libopenblas-base' >> $@
@echo 'Description: Event processor tailored for human-scale monitoring' >> $@
src/country_of_ip/db_v4.c: IpToCountry.csv make.inc
@echo 'Generating $@'
@echo '/* Generated by Makefile - edition is futile */' > $@
@echo >> $@
@echo '#include "db.h"' >> $@
@echo 'struct db_entry_v4 db_v4[] = {' >> $@
@sed -ne 's/^ *"\([0-9]\+\)","\([0-9]\+\)",.*,\(".."\),"[^"]*","[^"]*" *$$/ { \1, \2, \3 },/p' < $< >> $@
@echo '};' >> $@
src/country_of_ip/db_v4.h: src/country_of_ip/db_v4.c make.inc
@echo 'Generating $@'
@echo '/* Generated by Makefile - edition is futile */' > $@
@echo '#ifndef DB_V4_h_200417' >> $@
@echo '#define DB_V4_h_200417' >> $@
@echo '#include "db.h"' >> $@
@echo >> $@
@echo 'extern struct db_entry_v4 db_v4[' $$(grep -c '^ {' $<) '];' >> $@
@echo >> $@
@echo '#endif' >> $@
src/country_of_ip/db_v6.c: IpToCountry.6R.csv tools/ipcsv.opt make.inc
@echo '/* Generated by Makefile - edition is futile */' > $@
tools/ipcsv.opt $< >> $@
src/country_of_ip/db_v6.h: src/country_of_ip/db_v6.c make.inc
@echo 'Generating $@'
@echo '/* Generated by Makefile - edition is futile */' > $@
@echo '#ifndef DB_V6_h_200417' >> $@
@echo '#define DB_V6_h_200417' >> $@
@echo '#include "db.h"' >> $@
@echo >> $@
@echo 'extern struct db_entry_v6 db_v6[' $$(grep -c '^ {' $<) '];' >> $@
@echo >> $@
@echo '#endif' >> $@
META: make.inc
@echo 'Building findlib configuration (META) for Ramen'
@echo 'description = "Event processor tailored for human-scale monitoring"' > $@
@echo 'version = "$(VERSION)"' >> $@
@echo 'archive(native) = "codegen.cmxa"' >> $@
@echo 'requires = "$(META_REQUIRES)"' >> $@
# embedded compiler version: build a bundle of all libraries
OCAML_WHERE = $(shell dirname $(shell ocamlfind ocamlc -where))
# cut -c X- means to takes all from X, 1st char being 1, thus the leading _:
OCAML_WHERE_LEN = $(shell printf '_%s/' $(OCAML_WHERE) | wc -m | xargs echo)
# This won't work before ramen is installed so that ocamlfind knows its
# dependencies..
# Bootstrapping this is a bit special as ocamlfind needs to know the ramen
# package first. Therefore this file is included with the source package for
# simplicity.
src/RamenDepLibs.ml.frominst: $(OCAML_WHERE)/ramen/META
@echo '(* Generated by Makefile - edition is futile *)' > $@
@echo 'module N = RamenName' >> $@
@echo 'let incdirs = [' >> $@
set -e ; for d in $$(ocamlfind query -recursive -predicates native,mt -format '%d' ramen | sort -u | grep -v -e compiler-libs -e ppx_tools -e /findlib) ; do \
echo $$d | cut -c $(OCAML_WHERE_LEN)- | \
sed -e 's,^\(.*\)$$, N.path "\1" ;,' >> $@ ;\
done ;
# Equivalent to -threads:
@echo ' N.path "ocaml/threads" ;' >> $@
@echo ']' >> $@
@echo 'let objfiles = [' >> $@
set -e ; for d in $$(ocamlfind query -recursive -predicates native,mt -format '%+a' ramen | uniq | grep -v -e compiler-libs -e ppx_tools -e /findlib) ; do \
echo $$d | cut -c $(OCAML_WHERE_LEN)- | \
sed -e 's,^\(.*\)$$, N.path "\1" ;,' >> $@ ;\
done ;
@echo ']' >> $@
# Equivalent to -threads, must come right after unix.cmxa:
sed -i -e '/ocaml\/unix.cmxa/a \ \ N.path "ocaml/threads/threads.cmxa" ;' $@
@if test -e $(OCAML_WHERE)/ramen/META.for_bootstrap ; then \
rm $(OCAML_WHERE)/ramen/META ;\
rm $(OCAML_WHERE)/ramen/META.for_bootstrap ;\
fi
$(OCAML_WHERE)/ramen/META: META
@echo "It seems ramen is not yet installed, bootstrapping ocamlfind..."
mkdir -p $(OCAML_WHERE)/ramen
cp META $@
touch $@.for_bootstrap
src/RamenDepLibs.ml: src/RamenDepLibs.ml.frominst make.inc
ifeq ($(shell uname),Darwin)
sed -e '/inotify/d' $< > $@
else
cp $< $@
endif
src/RamenCompilConfig.ml: make.inc
@echo '(* Generated by Makefile - edition is futile *)' > $@
@echo 'module N = RamenName' >> $@
@echo 'let default_bundle_dir = N.path "$(abspath $(lib_dir))/$(BUNDLE_DIR)/"' >> $@
@echo 'let ocaml_version = "@OCAMLVERSION@"' >> $@
@echo 'let build_path = "$(PATH)"' >> $@
@echo 'let ocamlfind = N.path "@OCAMLFIND@"' >> $@
@echo 'let ocamlpath = "$(OCAMLPATH)"' >> $@
@echo 'let cpp_compiler = "@CXX@"' >> $@
@echo 'let z3_path = "@Z3@"' >> $@
@echo 'let build_date = "$(shell date -R)"' >> $@
@echo 'let build_host = "$(shell hostname)"' >> $@
src/RamenSourceExamples.ml: \
make.inc \
examples/monitoring/network/security.ramen \
examples/monitoring/network/hosts.ramen \
examples/monitoring/network/traffic.ramen \
examples/monitoring/network/minutely.pivot \
examples/generators/network/logs.ramen \
examples/generators/network/aggregated.ramen \
examples/generators/network/resp_time.alert \
examples/generators/network/errors.ramen \
examples/generators/network/error_rate.alert \
examples/generators/basic.ramen
@echo 'Generating $@'
@echo '(* Generated by Makefile - edition is futile *)' > $@
@echo >> $@
@echo 'module Monitoring = struct' >> $@
@echo ' module Network = struct' >> $@
@echo ' let security = {|' >> $@
cat examples/monitoring/network/security.ramen >> $@
@echo '|}' >> $@
@echo >> $@
@echo ' let hosts = {|' >> $@
cat examples/monitoring/network/hosts.ramen >> $@
@echo '|}' >> $@
@echo >> $@
@echo ' let traffic = {|' >> $@
cat examples/monitoring/network/traffic.ramen >> $@
@echo '|}' >> $@
@echo ' let minutely = {|' >> $@
cat examples/monitoring/network/minutely.pivot >> $@
@echo '|}' >> $@
@echo >> $@
@echo ' end' >> $@
@echo 'end' >> $@
@echo >> $@
@echo 'module Generators = struct' >> $@
@echo ' module Network = struct' >> $@
@echo ' let logs = {|' >> $@
cat examples/generators/network/logs.ramen >> $@
@echo '|}' >> $@
@echo >> $@
@echo ' let aggregated = {|' >> $@
cat examples/generators/network/aggregated.ramen >> $@
@echo '|}' >> $@
@echo >> $@
@echo ' let resp_time_alert = {|' >> $@
cat examples/generators/network/resp_time.alert >> $@
@echo '|}' >> $@
@echo ' let errors = {|' >> $@
cat examples/generators/network/errors.ramen >> $@
@echo '|}' >> $@
@echo >> $@
@echo ' let error_rate_alert = {|' >> $@
cat examples/generators/network/error_rate.alert >> $@
@echo '|}' >> $@
@echo ' end' >> $@
@echo >> $@
@echo ' let basic = {|' >> $@
@cat examples/generators/basic.ramen >> $@
@echo '|}' >> $@
@echo 'end' >> $@
sed -i -e ':x /{|$$/{N;s/\n//g; bx}' $@