For install_{server,slave}, insserv so domtool starts on boot
[hcoop/domtool2.git] / Makefile
CommitLineData
6b718954 1all: mlton bin/vmailpasswd elisp/domtool-tables.el
7aa78013
AC
2
3bin/vmailpasswd: src/mail/vmailpasswd.c
4 $(CC) -lcrypt -o $@ $<
0d2ce070 5
a49a9bfb 6COMMON_DEPS := configDefault/config.sig configDefault/configDefault.sml \
931aae14 7 openssl/openssl_sml.so pcre/pcre_sml.so config.sml
9c8a9ef4 8
4542571e
AC
9EMACS_DIR := /usr/local/share/emacs/site-lisp/domtool-mode
10
9c8a9ef4 11config.sml:
883dd79c 12 /bin/echo -e 'structure Config :> CONFIG = struct\nopen ConfigDefault\nend' > $@
a49a9bfb 13
690a19c3 14.PHONY: all mlton smlnj install install_sos
a49a9bfb 15
44a5ce2f 16mlton: bin/domtool-server bin/domtool-client bin/domtool-slave \
2bc5ed22 17 bin/domtool-admin bin/domtool-doc bin/dbtool bin/vmail \
a8e88df7
CE
18 bin/smtplog bin/setsa bin/mysql-fixperms bin/webbw bin/domtool-tail \
19 bin/fwtool
a49a9bfb 20
931aae14
AC
21smlnj: $(COMMON_DEPS) openssl/smlnj/FFI/libssl.h.cm pcre/smlnj/FFI/libpcre.h.cm \
22 src/domtool.cm
0d2ce070
AC
23
24configDefault/config.sig: src/config.sig.header \
8df2e702
AC
25 configDefault/*.csg configDefault/*.cfs \
26 src/config.sig.footer
27 cat configDefault/*.csg \
28 src/config.sig.header \
0d2ce070
AC
29 configDefault/*.cfs \
30 src/config.sig.footer \
31 >configDefault/config.sig
32
33configDefault/configDefault.sml: src/configDefault.sml.header \
34 configDefault/*.cfg src/configDefault.sml.footer
35 cat src/configDefault.sml.header \
36 configDefault/*.cfg \
37 src/configDefault.sml.footer \
38 >configDefault/configDefault.sml
39
559e89e9
AC
40openssl/openssl_sml.o: openssl/openssl_sml.c
41 gcc -fPIC -c openssl/openssl_sml.c -o openssl/openssl_sml.o
42
43openssl/openssl_sml.so: openssl/openssl_sml.o
44 gcc -shared -Wl,-soname,openssl_sml.so \
45 -o openssl/openssl_sml.so \
46 openssl/openssl_sml.o -lssl
47
931aae14
AC
48pcre/pcre_sml.o: pcre/pcre_sml.c
49 gcc -fPIC -c pcre/pcre_sml.c -o pcre/pcre_sml.o
50
51pcre/pcre_sml.so: pcre/pcre_sml.o
52 gcc -shared -Wl,-soname,pcre_sml.so \
53 -o pcre/pcre_sml.so \
54 pcre/pcre_sml.o -lpcre
55
d541c618 56src/domtool.cm: src/prefix.cm src/sources
a49a9bfb
AC
57 cat src/prefix.cm src/sources >src/domtool.cm
58
7a2b27f0
AC
59MAKE_MLB_BASE := cat src/prefix.mlb src/sources src/suffix.mlb \
60 | sed 's/^\(.*\).grm$$/\1.grm.sig\n\1.grm.sml/' \
61 | sed 's/^\(.*\).lex$$/\1.lex.sml/'
62
d541c618 63src/domtool-server.mlb: src/prefix.mlb src/sources src/suffix.mlb
7a2b27f0 64 $(MAKE_MLB_BASE) >src/domtool-server.mlb
a49a9bfb
AC
65 echo "main-server.sml" >>src/domtool-server.mlb
66
d541c618 67src/domtool-client.mlb: src/prefix.mlb src/sources src/suffix.mlb
7a2b27f0 68 $(MAKE_MLB_BASE) >src/domtool-client.mlb
361a1e7f
AC
69 echo "main-client.sml" >>src/domtool-client.mlb
70
d541c618 71src/domtool-slave.mlb: src/prefix.mlb src/sources src/suffix.mlb
7a2b27f0 72 $(MAKE_MLB_BASE) >src/domtool-slave.mlb
1c246434
AC
73 echo "main-slave.sml" >>src/domtool-slave.mlb
74
d541c618 75src/domtool-admin.mlb: src/prefix.mlb src/sources src/suffix.mlb
5ee41dd0
AC
76 $(MAKE_MLB_BASE) >src/domtool-admin.mlb
77 echo "main-admin.sml" >>src/domtool-admin.mlb
78
d541c618 79src/domtool-doc.mlb: src/prefix.mlb src/sources src/suffix.mlb
44a5ce2f
AC
80 $(MAKE_MLB_BASE) >src/domtool-doc.mlb
81 echo "main-doc.sml" >>src/domtool-doc.mlb
82
d541c618
AC
83src/dbtool.mlb: src/prefix.mlb src/sources src/suffix.mlb
84 $(MAKE_MLB_BASE) >src/dbtool.mlb
85 echo "main-dbtool.sml" >>src/dbtool.mlb
86
08688401
AC
87src/vmail.mlb: src/prefix.mlb src/sources src/suffix.mlb
88 $(MAKE_MLB_BASE) >src/vmail.mlb
89 echo "main-vmail.sml" >>src/vmail.mlb
90
2e96b9d4
AC
91src/setsa.mlb: src/prefix.mlb src/sources src/suffix.mlb
92 $(MAKE_MLB_BASE) >src/setsa.mlb
93 echo "main-setsa.sml" >>src/setsa.mlb
94
2bc5ed22
AC
95src/smtplog.mlb: src/prefix.mlb src/sources src/suffix.mlb
96 $(MAKE_MLB_BASE) >src/smtplog.mlb
97 echo "main-smtplog.sml" >>src/smtplog.mlb
98
00a077ab
AC
99src/mysql-fixperms.mlb: src/prefix.mlb src/sources src/suffix.mlb
100 $(MAKE_MLB_BASE) >src/mysql-fixperms.mlb
101 echo "main-mysql-fixperms.sml" >>src/mysql-fixperms.mlb
102
a8e88df7
CE
103src/fwtool.mlb: src/prefix.mlb src/sources src/suffix.mlb
104 $(MAKE_MLB_BASE) >src/fwtool.mlb
105 echo "main-fwtool.sml" >>src/fwtool.mlb
106
559e89e9
AC
107openssl/smlnj/FFI/libssl.h.cm: openssl/openssl_sml.h
108 cd openssl/smlnj ; ml-nlffigen -d FFI -lh LibsslH.libh -include ../libssl-h.sml \
109 -cm libssl.h.cm -D__builtin_va_list="void*" \
110 ../openssl_sml.h
a49a9bfb
AC
111
112openssl/mlton/FFI/libssl.h.mlb: openssl/openssl_sml.h
113 cd openssl/mlton ; mlnlffigen -dir FFI -libhandle LibsslH.libh -include ../libssl-h.sml \
114 -mlbfile libssl.h.mlb -cppopt -D__builtin_va_list="void*" \
115 ../openssl_sml.h
116
931aae14
AC
117pcre/smlnj/FFI/libpcre.h.cm: pcre/pcre_sml.h
118 cd pcre/smlnj ; ml-nlffigen -d FFI -lh LibpcreH.libh -include ../libpcre-h.sml \
119 -cm libpcre.h.cm -D__builtin_va_list="void*" \
120 ../pcre_sml.h
121
122pcre/mlton/FFI/libpcre.h.mlb: pcre/pcre_sml.h
123 cd pcre/mlton ; mlnlffigen -dir FFI -libhandle LibpcreH.libh -include ../libpcre-h.sml \
124 -mlbfile libpcre.h.mlb -cppopt -D__builtin_va_list="void*" \
125 ../pcre_sml.h
126
a49a9bfb 127%.lex.sml: %.lex
a088cea6 128 mllex $<
a49a9bfb
AC
129
130%.grm.sig %.grm.sml: %.grm
a088cea6 131 mlyacc $<
a49a9bfb 132
7a2b27f0 133COMMON_MLTON_DEPS := openssl/mlton/FFI/libssl.h.mlb \
931aae14 134 pcre/mlton/FFI/libpcre.h.mlb \
7a2b27f0
AC
135 src/domtool.lex.sml \
136 src/domtool.grm.sig src/domtool.grm.sml \
137 $(COMMON_DEPS) src/*.sig src/*.sml \
9ffe2f0f
AC
138 src/plugins/*.sig src/plugins/*.sml \
139 src/mail/*.sig src/mail/*.sml
7a2b27f0 140
e0b80e65
AC
141MLTON := mlton -link-opt -ldl
142
143ifdef DEBUG
144 MLTON += -const 'Exn.keepHistory true'
145endif
146
7a2b27f0 147bin/domtool-server: $(COMMON_MLTON_DEPS) src/domtool-server.mlb
e0b80e65 148 $(MLTON) -output bin/domtool-server src/domtool-server.mlb
361a1e7f 149
7a2b27f0 150bin/domtool-client: $(COMMON_MLTON_DEPS) src/domtool-client.mlb
e0b80e65 151 $(MLTON) -output bin/domtool-client src/domtool-client.mlb
361a1e7f 152
7a2b27f0 153bin/domtool-slave: $(COMMON_MLTON_DEPS) src/domtool-slave.mlb
e0b80e65 154 $(MLTON) -output bin/domtool-slave src/domtool-slave.mlb
1c246434 155
5ee41dd0 156bin/domtool-admin: $(COMMON_MLTON_DEPS) src/domtool-admin.mlb
e0b80e65 157 $(MLTON) -output bin/domtool-admin src/domtool-admin.mlb
5ee41dd0 158
44a5ce2f 159bin/domtool-doc: $(COMMON_MLTON_DEPS) src/domtool-doc.mlb
e0b80e65 160 $(MLTON) -output bin/domtool-doc src/domtool-doc.mlb
44a5ce2f 161
d541c618 162bin/dbtool: $(COMMON_MLTON_DEPS) src/dbtool.mlb
e0b80e65 163 $(MLTON) -output bin/dbtool src/dbtool.mlb
d541c618 164
08688401 165bin/vmail: $(COMMON_MLTON_DEPS) src/vmail.mlb
e0b80e65 166 $(MLTON) -output bin/vmail src/vmail.mlb
08688401 167
2e96b9d4 168bin/setsa: $(COMMON_MLTON_DEPS) src/setsa.mlb
ac64d96d 169 $(MLTON) -output bin/setsa src/setsa.mlb
2e96b9d4 170
2bc5ed22 171bin/smtplog: $(COMMON_MLTON_DEPS) src/smtplog.mlb
e0b80e65 172 $(MLTON) -output bin/smtplog src/smtplog.mlb
2bc5ed22 173
00a077ab
AC
174bin/mysql-fixperms: $(COMMON_MLTON_DEPS) src/mysql-fixperms.mlb
175 $(MLTON) -output bin/mysql-fixperms src/mysql-fixperms.mlb
176
a8e88df7
CE
177bin/fwtool: $(COMMON_MLTON_DEPS) src/fwtool.mlb
178 $(MLTON) -output bin/fwtool src/fwtool.mlb
179
e7957d00 180bin/webbw: $(COMMON_MLTON_DEPS) src/stats/webbw.mlb src/stats/*.sml
f086616f
AC
181 mlton -output bin/webbw src/stats/webbw.mlb
182
e7957d00
AC
183bin/domtool-tail: $(COMMON_MLTON_DEPS) src/tail/tail.mlb src/tail/*.sml
184 mlton -output bin/domtool-tail src/tail/tail.mlb
185
6b718954
AC
186elisp/domtool-tables.el: lib/*.dtl bin/domtool-doc
187 bin/domtool-doc -basis -emacs >$@
188
690a19c3
AC
189install_sos:
190 cp openssl/openssl_sml.so /usr/local/lib/
191 cp pcre/pcre_sml.so /usr/local/lib/
192
193install: install_sos
27e20924 194 cp scripts/domtool-publish /usr/local/sbin/
8ae99fef
AC
195 cp scripts/domtool-reset-global /usr/local/sbin/
196 cp scripts/domtool-reset-local /usr/local/sbin/
385c3534
AC
197 cp scripts/domtool-adduser /usr/local/bin/
198 cp scripts/domtool-addcert /usr/local/bin/
c235081a 199 cp scripts/domtool-readdcerts /usr/local/bin/
385c3534
AC
200 cp scripts/domtool-addacl /usr/local/bin/
201 cp scripts/domtool-rmuser /usr/local/bin/
62260c5f
AC
202 cp scripts/domtool-admin-sudo /usr/local/bin/
203 cp scripts/domtool-server-logged /usr/local/bin/
c9731b9b
AC
204 cp scripts/domtool-slave-logged /usr/local/bin/
205 cp scripts/domtool-server /etc/init.d/
206 cp scripts/domtool-slave /etc/init.d/
76bad1b2
AC
207 -cp bin/domtool-server /usr/local/sbin/
208 -cp bin/domtool-slave /usr/local/sbin/
209 -cp bin/domtool-client /usr/local/bin/domtool
210 -cp bin/domtool-admin /usr/local/bin/
211 -cp bin/domtool-doc /usr/local/bin/
d541c618 212 -cp bin/dbtool /usr/local/bin/
a8e88df7 213 -cp bin/fwtool /usr/local/bin/
08688401 214 -cp bin/vmail /usr/local/bin/
2e96b9d4 215 -cp bin/setsa /usr/local/bin/
2bc5ed22 216 -cp bin/smtplog /usr/local/bin/
00a077ab 217 -cp bin/mysql-fixperms /usr/local/bin/
7aa78013 218 -cp bin/vmailpasswd /usr/local/bin/
f086616f 219 -cp bin/webbw /usr/local/sbin/
e7957d00
AC
220 -cp bin/domtool-tail /usr/local/bin/
221 -chmod +s /usr/local/bin/domtool-tail
d541c618 222 cp src/plugins/domtool-postgres /usr/local/sbin/
ae147938 223 cp src/plugins/domtool-mysql /usr/local/sbin/
e903f398 224 -mkdir -p $(EMACS_DIR)
4542571e 225 cp elisp/*.el $(EMACS_DIR)/
15e529d6 226
5982c377 227.PHONY: grab_lib install_server install_slave
15e529d6
AC
228
229grab_lib:
728f7033 230 rsync -r --delete /afs/hcoop.net/common/etc/domtool/lib/* lib/
5982c377
AC
231
232install_server:
233 sudo /etc/init.d/domtool-server stop
234 sudo make install
bedd19f7 235 sudo insserv domtool-server
5982c377 236 sudo /etc/init.d/domtool-server start
29920c95
AC
237
238install_slave:
239 sudo /etc/init.d/domtool-slave stop
240 sudo make install
bedd19f7 241 sudo insserv domtool-slave
29920c95 242 sudo /etc/init.d/domtool-slave start