fwtool: allow udp/tcp for all user rules
[hcoop/domtool2.git] / Makefile
... / ...
CommitLineData
1# Supported flags
2# BUILD32=1 Target 32-bit x86 (Doesn't Work)
3# TC=1 Stop after typchecking when building using mlton
4# DEBUG=1 Keep debugging information when building using mlton
5
6all: mlton bin/vmailpasswd elisp/domtool-tables.el
7
8bin/vmailpasswd: src/mail/vmailpasswd.c
9 $(CC) $(CFLAGS) -lcrypt -o $@ $<
10
11ifeq ($(BUILD32), 1)
12 CFLAGS += -m32
13endif
14
15COMMON_DEPS := configDefault/config.sig configDefault/configDefault.sml \
16 openssl/openssl_sml.so pcre/pcre_sml.so config.sml
17
18EMACS_DIR := /usr/local/share/emacs/site-lisp/domtool-mode
19
20clean:
21 rm -f bin/*
22 rm -f openssl/openssl_sml.so
23 rm -f openssl/openssl_sml.o
24 rm -f pcre/pcre_sml.so
25 rm -f pcre/pcre_sml.o
26
27config.sml:
28 /bin/echo -e 'structure Config :> CONFIG = struct\nopen ConfigDefault\nend' > $@
29
30.PHONY: all mlton smlnj install install_sos
31
32mlton: bin/domtool-server bin/domtool-client bin/domtool-slave \
33 bin/domtool-admin bin/domtool-doc bin/dbtool bin/vmail \
34 bin/smtplog bin/setsa bin/mysql-fixperms bin/webbw bin/domtool-tail \
35 bin/fwtool bin/domtool-config bin/domtool-portal
36
37smlnj: $(COMMON_DEPS) openssl/smlnj/FFI/libssl.h.cm pcre/smlnj/FFI/libpcre.h.cm \
38 src/domtool.cm
39 CFLAGS += -m32
40
41configDefault/config.sig: config/core/core.sig src/config.sig.header \
42 configDefault/*.csg configDefault/*.cfs \
43 src/config.sig.footer
44 cat configDefault/*.csg \
45 src/config.sig.header \
46 configDefault/*.cfs \
47 src/config.sig.footer \
48 >configDefault/config.sig
49
50configDefault/configDefault.sml: config/core/core.sml src/configDefault.sml.header \
51 configDefault/*.cfg src/configDefault.sml.footer
52 cat src/configDefault.sml.header \
53 configDefault/*.cfg \
54 src/configDefault.sml.footer \
55 >configDefault/configDefault.sml
56
57openssl/openssl_sml.o: openssl/openssl_sml.c
58 gcc $(CFLAGS) -fPIC -c openssl/openssl_sml.c -o openssl/openssl_sml.o
59
60openssl/openssl_sml.so: openssl/openssl_sml.o
61 gcc $(CFLAGS) -shared -Wl,-soname,openssl_sml.so \
62 -o openssl/openssl_sml.so \
63 openssl/openssl_sml.o -lssl
64
65pcre/pcre_sml.o: pcre/pcre_sml.c
66 gcc $(CFLAGS) -fPIC -c pcre/pcre_sml.c -o pcre/pcre_sml.o
67
68pcre/pcre_sml.so: pcre/pcre_sml.o
69 gcc $(CFLAGS) -shared -Wl,-soname,pcre_sml.so \
70 -o pcre/pcre_sml.so \
71 pcre/pcre_sml.o -lpcre
72
73src/domtool.cm: src/prefix.cm src/sources
74 cat src/prefix.cm src/sources >src/domtool.cm
75
76MAKE_MLB_BASE := cat src/prefix.mlb src/sources src/suffix.mlb \
77 | sed 's/^\(.*\).grm$$/\1.grm.sig\n\1.grm.sml/' \
78 | sed 's/^\(.*\).lex$$/\1.lex.sml/'
79
80src/domtool-server.mlb: src/prefix.mlb src/sources src/suffix.mlb
81 $(MAKE_MLB_BASE) >src/domtool-server.mlb
82 echo "main-server.sml" >>src/domtool-server.mlb
83
84src/domtool-client.mlb: src/prefix.mlb src/sources src/suffix.mlb
85 $(MAKE_MLB_BASE) >src/domtool-client.mlb
86 echo "main-client.sml" >>src/domtool-client.mlb
87
88src/domtool-slave.mlb: src/prefix.mlb src/sources src/suffix.mlb
89 $(MAKE_MLB_BASE) >src/domtool-slave.mlb
90 echo "main-slave.sml" >>src/domtool-slave.mlb
91
92src/domtool-admin.mlb: src/prefix.mlb src/sources src/suffix.mlb
93 $(MAKE_MLB_BASE) >src/domtool-admin.mlb
94 echo "main-admin.sml" >>src/domtool-admin.mlb
95
96src/domtool-doc.mlb: src/prefix.mlb src/sources src/suffix.mlb
97 $(MAKE_MLB_BASE) >src/domtool-doc.mlb
98 echo "main-doc.sml" >>src/domtool-doc.mlb
99
100src/dbtool.mlb: src/prefix.mlb src/sources src/suffix.mlb
101 $(MAKE_MLB_BASE) >src/dbtool.mlb
102 echo "main-dbtool.sml" >>src/dbtool.mlb
103
104src/vmail.mlb: src/prefix.mlb src/sources src/suffix.mlb
105 $(MAKE_MLB_BASE) >src/vmail.mlb
106 echo "main-vmail.sml" >>src/vmail.mlb
107
108src/setsa.mlb: src/prefix.mlb src/sources src/suffix.mlb
109 $(MAKE_MLB_BASE) >src/setsa.mlb
110 echo "main-setsa.sml" >>src/setsa.mlb
111
112src/smtplog.mlb: src/prefix.mlb src/sources src/suffix.mlb
113 $(MAKE_MLB_BASE) >src/smtplog.mlb
114 echo "main-smtplog.sml" >>src/smtplog.mlb
115
116src/mysql-fixperms.mlb: src/prefix.mlb src/sources src/suffix.mlb
117 $(MAKE_MLB_BASE) >src/mysql-fixperms.mlb
118 echo "main-mysql-fixperms.sml" >>src/mysql-fixperms.mlb
119
120src/fwtool.mlb: src/prefix.mlb src/sources src/suffix.mlb
121 $(MAKE_MLB_BASE) >src/fwtool.mlb
122 echo "main-fwtool.sml" >>src/fwtool.mlb
123
124src/domtool-config.mlb: src/prefix.mlb src/sources src/suffix.mlb
125 $(MAKE_MLB_BASE) >src/domtool-config.mlb
126 echo "main-config.sml" >>src/domtool-config.mlb
127
128src/domtool-portal.mlb: src/prefix.mlb src/sources src/suffix.mlb
129 $(MAKE_MLB_BASE) >src/domtool-portal.mlb
130 echo "main-portal.sml" >>src/domtool-portal.mlb
131
132openssl/smlnj/FFI/libssl.h.cm: openssl/openssl_sml.h
133 cd openssl/smlnj ; ml-nlffigen -d FFI -lh LibsslH.libh -include ../libssl-h.sml \
134 -cm libssl.h.cm -D__builtin_va_list="void*" \
135 ../openssl_sml.h
136
137openssl/mlton/FFI/libssl.h.mlb: openssl/openssl_sml.h
138 cd openssl/mlton ; mlnlffigen -dir FFI -libhandle LibsslH.libh -include ../libssl-h.sml \
139 -mlbfile libssl.h.mlb -cppopt -D__builtin_va_list="void*" \
140 ../openssl_sml.h
141
142pcre/smlnj/FFI/libpcre.h.cm: pcre/pcre_sml.h
143 cd pcre/smlnj ; ml-nlffigen -d FFI -lh LibpcreH.libh -include ../libpcre-h.sml \
144 -cm libpcre.h.cm -D__builtin_va_list="void*" \
145 ../pcre_sml.h
146
147pcre/mlton/FFI/libpcre.h.mlb: pcre/pcre_sml.h
148 cd pcre/mlton ; mlnlffigen -dir FFI -libhandle LibpcreH.libh -include ../libpcre-h.sml \
149 -mlbfile libpcre.h.mlb -cppopt -D__builtin_va_list="void*" \
150 ../pcre_sml.h
151
152%.lex.sml: %.lex
153 mllex $<
154
155%.grm.sig %.grm.sml: %.grm
156 mlyacc $<
157
158COMMON_MLTON_DEPS := openssl/mlton/FFI/libssl.h.mlb \
159 pcre/mlton/FFI/libpcre.h.mlb \
160 src/domtool.lex.sml \
161 src/domtool.grm.sig src/domtool.grm.sml \
162 $(COMMON_DEPS) src/*.sig src/*.sml \
163 src/plugins/*.sig src/plugins/*.sml \
164 src/mail/*.sig src/mail/*.sml
165
166MLTON := mlton -link-opt -ldl
167
168ifeq ($(BUILD32),1)
169 MLTON += -codegen c -target i386 -cc-opt -m32
170endif
171
172ifeq ($(DEBUG), 1)
173 MLTON += -const 'Exn.keepHistory true'
174endif
175
176ifeq ($(TC), 1)
177 MLTON += -stop tc
178endif
179
180bin/domtool-server: $(COMMON_MLTON_DEPS) src/domtool-server.mlb
181 $(MLTON) -output bin/domtool-server src/domtool-server.mlb
182
183bin/domtool-client: $(COMMON_MLTON_DEPS) src/domtool-client.mlb
184 $(MLTON) -output bin/domtool-client src/domtool-client.mlb
185
186bin/domtool-slave: $(COMMON_MLTON_DEPS) src/domtool-slave.mlb
187 $(MLTON) -output bin/domtool-slave src/domtool-slave.mlb
188
189bin/domtool-admin: $(COMMON_MLTON_DEPS) src/domtool-admin.mlb
190 $(MLTON) -output bin/domtool-admin src/domtool-admin.mlb
191
192bin/domtool-doc: $(COMMON_MLTON_DEPS) src/domtool-doc.mlb
193 $(MLTON) -output bin/domtool-doc src/domtool-doc.mlb
194
195bin/dbtool: $(COMMON_MLTON_DEPS) src/dbtool.mlb
196 $(MLTON) -output bin/dbtool src/dbtool.mlb
197
198bin/vmail: $(COMMON_MLTON_DEPS) src/vmail.mlb
199 $(MLTON) -output bin/vmail src/vmail.mlb
200
201bin/setsa: $(COMMON_MLTON_DEPS) src/setsa.mlb
202 $(MLTON) -output bin/setsa src/setsa.mlb
203
204bin/smtplog: $(COMMON_MLTON_DEPS) src/smtplog.mlb
205 $(MLTON) -output bin/smtplog src/smtplog.mlb
206
207bin/mysql-fixperms: $(COMMON_MLTON_DEPS) src/mysql-fixperms.mlb
208 $(MLTON) -output bin/mysql-fixperms src/mysql-fixperms.mlb
209
210bin/fwtool: $(COMMON_MLTON_DEPS) src/fwtool.mlb
211 $(MLTON) -output bin/fwtool src/fwtool.mlb
212
213bin/webbw: $(COMMON_MLTON_DEPS) src/stats/webbw.mlb src/stats/*.sml
214 mlton -output bin/webbw src/stats/webbw.mlb
215
216bin/domtool-tail: $(COMMON_MLTON_DEPS) src/tail/tail.mlb src/tail/*.sml
217 mlton -output bin/domtool-tail src/tail/tail.mlb
218
219bin/domtool-config: $(COMMON_MLTON_DEPS) src/domtool-config.mlb src/main-config.sml
220 $(MLTON) -output bin/domtool-config src/domtool-config.mlb
221
222bin/domtool-portal: $(COMMON_MLTON_DEPS) src/domtool-portal.mlb src/main-portal.sml
223 $(MLTON) -output bin/domtool-portal src/domtool-portal.mlb
224
225elisp/domtool-tables.el: lib/*.dtl bin/domtool-doc
226 bin/domtool-doc -basis -emacs >$@
227
228install_sos:
229 cp openssl/openssl_sml.so /usr/local/lib/
230 cp pcre/pcre_sml.so /usr/local/lib/
231
232install: install_sos
233 cp scripts/domtool-publish /usr/local/sbin/
234 cp scripts/domtool-reset-global /usr/local/sbin/
235 cp scripts/domtool-reset-local /usr/local/sbin/
236 cp scripts/domtool-vmailpasswd /usr/local/sbin/
237 cp scripts/domtool-adduser /usr/local/bin/
238 cp scripts/domtool-addcert /usr/local/bin/
239 cp scripts/domtool-readdcerts /usr/local/bin/
240 cp scripts/domtool-addacl /usr/local/bin/
241 cp scripts/domtool-rmuser /usr/local/bin/
242 cp scripts/domtool-admin-sudo /usr/local/bin/
243 cp scripts/domtool-server-logged /usr/local/bin/
244 cp scripts/domtool-slave-logged /usr/local/bin/
245 cp scripts/domtool-server /etc/init.d/
246 cp scripts/domtool-slave /etc/init.d/
247 -cp bin/domtool-server /usr/local/sbin/
248 -cp bin/domtool-slave /usr/local/sbin/
249 -cp bin/domtool-client /usr/local/bin/domtool
250 -cp bin/domtool-admin /usr/local/bin/
251 -cp bin/domtool-doc /usr/local/bin/
252 -cp bin/dbtool /usr/local/bin/
253 -cp bin/fwtool /usr/local/bin/
254 -cp bin/vmail /usr/local/bin/
255 -cp bin/setsa /usr/local/bin/
256 -cp bin/smtplog /usr/local/bin/
257 -cp bin/mysql-fixperms /usr/local/bin/
258 -cp bin/vmailpasswd /usr/local/bin/
259 -cp bin/webbw /usr/local/sbin/
260 -cp bin/domtool-tail /usr/local/bin/
261 -chmod +s /usr/local/bin/domtool-tail
262 cp bin/domtool-config /usr/local/bin/
263 cp bin/domtool-portal /usr/local/sbin/
264 cp src/plugins/domtool-postgres /usr/local/sbin/
265 cp src/plugins/domtool-mysql /usr/local/sbin/
266 -mkdir -p $(EMACS_DIR)
267 install -d -m 755 -o domtool -g nogroup /var/domtool
268 cp elisp/*.el $(EMACS_DIR)/
269
270.PHONY: grab_lib install_server install_slave
271
272grab_lib:
273 rsync -r --delete /afs/hcoop.net/common/etc/domtool/lib/* lib/
274
275install_systemd_dispatcher:
276 install -m 644 -o root -g root scripts/domtool-server.service /etc/systemd/system/domtool-server.service
277 systemctl daemon-reload
278
279install_systemd_worker:
280 install -m 644 -o root -g root scripts/domtool-slave.service /etc/systemd/system/domtool-slave.service
281 systemctl daemon-reload
282
283install_serverslave:
284 service domtool-server stop
285 service domtool-slave stop
286 make install
287 service domtool-server start
288 service domtool-slave start
289
290install_server:
291 service domtool-server stop
292 make install
293 service domtool-server start
294
295install_slave:
296 service domtool-slave stop
297 make install
298 service domtool-slave start