Remove automatic insserv in Makefile
[hcoop/domtool2.git] / Makefile
1 all: mlton bin/vmailpasswd elisp/domtool-tables.el
2
3 bin/vmailpasswd: src/mail/vmailpasswd.c
4 $(CC) -lcrypt -o $@ $<
5
6 COMMON_DEPS := configDefault/config.sig configDefault/configDefault.sml \
7 openssl/openssl_sml.so pcre/pcre_sml.so config.sml
8
9 EMACS_DIR := /usr/local/share/emacs/site-lisp/domtool-mode
10
11 config.sml:
12 /bin/echo -e 'structure Config :> CONFIG = struct\nopen ConfigDefault\nend' > $@
13
14 .PHONY: all mlton smlnj install install_sos
15
16 mlton: bin/domtool-server bin/domtool-client bin/domtool-slave \
17 bin/domtool-admin bin/domtool-doc bin/dbtool bin/vmail \
18 bin/smtplog bin/setsa bin/mysql-fixperms bin/webbw bin/domtool-tail \
19 bin/fwtool
20
21 smlnj: $(COMMON_DEPS) openssl/smlnj/FFI/libssl.h.cm pcre/smlnj/FFI/libpcre.h.cm \
22 src/domtool.cm
23
24 configDefault/config.sig: src/config.sig.header \
25 configDefault/*.csg configDefault/*.cfs \
26 src/config.sig.footer
27 cat configDefault/*.csg \
28 src/config.sig.header \
29 configDefault/*.cfs \
30 src/config.sig.footer \
31 >configDefault/config.sig
32
33 configDefault/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
40 openssl/openssl_sml.o: openssl/openssl_sml.c
41 gcc -fPIC -c openssl/openssl_sml.c -o openssl/openssl_sml.o
42
43 openssl/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
48 pcre/pcre_sml.o: pcre/pcre_sml.c
49 gcc -fPIC -c pcre/pcre_sml.c -o pcre/pcre_sml.o
50
51 pcre/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
56 src/domtool.cm: src/prefix.cm src/sources
57 cat src/prefix.cm src/sources >src/domtool.cm
58
59 MAKE_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
63 src/domtool-server.mlb: src/prefix.mlb src/sources src/suffix.mlb
64 $(MAKE_MLB_BASE) >src/domtool-server.mlb
65 echo "main-server.sml" >>src/domtool-server.mlb
66
67 src/domtool-client.mlb: src/prefix.mlb src/sources src/suffix.mlb
68 $(MAKE_MLB_BASE) >src/domtool-client.mlb
69 echo "main-client.sml" >>src/domtool-client.mlb
70
71 src/domtool-slave.mlb: src/prefix.mlb src/sources src/suffix.mlb
72 $(MAKE_MLB_BASE) >src/domtool-slave.mlb
73 echo "main-slave.sml" >>src/domtool-slave.mlb
74
75 src/domtool-admin.mlb: src/prefix.mlb src/sources src/suffix.mlb
76 $(MAKE_MLB_BASE) >src/domtool-admin.mlb
77 echo "main-admin.sml" >>src/domtool-admin.mlb
78
79 src/domtool-doc.mlb: src/prefix.mlb src/sources src/suffix.mlb
80 $(MAKE_MLB_BASE) >src/domtool-doc.mlb
81 echo "main-doc.sml" >>src/domtool-doc.mlb
82
83 src/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
87 src/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
91 src/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
95 src/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
99 src/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
103 src/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
107 openssl/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
111
112 openssl/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
117 pcre/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
122 pcre/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
127 %.lex.sml: %.lex
128 mllex $<
129
130 %.grm.sig %.grm.sml: %.grm
131 mlyacc $<
132
133 COMMON_MLTON_DEPS := openssl/mlton/FFI/libssl.h.mlb \
134 pcre/mlton/FFI/libpcre.h.mlb \
135 src/domtool.lex.sml \
136 src/domtool.grm.sig src/domtool.grm.sml \
137 $(COMMON_DEPS) src/*.sig src/*.sml \
138 src/plugins/*.sig src/plugins/*.sml \
139 src/mail/*.sig src/mail/*.sml
140
141 MLTON := mlton -link-opt -ldl
142
143 ifdef DEBUG
144 MLTON += -const 'Exn.keepHistory true'
145 endif
146
147 bin/domtool-server: $(COMMON_MLTON_DEPS) src/domtool-server.mlb
148 $(MLTON) -output bin/domtool-server src/domtool-server.mlb
149
150 bin/domtool-client: $(COMMON_MLTON_DEPS) src/domtool-client.mlb
151 $(MLTON) -output bin/domtool-client src/domtool-client.mlb
152
153 bin/domtool-slave: $(COMMON_MLTON_DEPS) src/domtool-slave.mlb
154 $(MLTON) -output bin/domtool-slave src/domtool-slave.mlb
155
156 bin/domtool-admin: $(COMMON_MLTON_DEPS) src/domtool-admin.mlb
157 $(MLTON) -output bin/domtool-admin src/domtool-admin.mlb
158
159 bin/domtool-doc: $(COMMON_MLTON_DEPS) src/domtool-doc.mlb
160 $(MLTON) -output bin/domtool-doc src/domtool-doc.mlb
161
162 bin/dbtool: $(COMMON_MLTON_DEPS) src/dbtool.mlb
163 $(MLTON) -output bin/dbtool src/dbtool.mlb
164
165 bin/vmail: $(COMMON_MLTON_DEPS) src/vmail.mlb
166 $(MLTON) -output bin/vmail src/vmail.mlb
167
168 bin/setsa: $(COMMON_MLTON_DEPS) src/setsa.mlb
169 $(MLTON) -output bin/setsa src/setsa.mlb
170
171 bin/smtplog: $(COMMON_MLTON_DEPS) src/smtplog.mlb
172 $(MLTON) -output bin/smtplog src/smtplog.mlb
173
174 bin/mysql-fixperms: $(COMMON_MLTON_DEPS) src/mysql-fixperms.mlb
175 $(MLTON) -output bin/mysql-fixperms src/mysql-fixperms.mlb
176
177 bin/fwtool: $(COMMON_MLTON_DEPS) src/fwtool.mlb
178 $(MLTON) -output bin/fwtool src/fwtool.mlb
179
180 bin/webbw: $(COMMON_MLTON_DEPS) src/stats/webbw.mlb src/stats/*.sml
181 mlton -output bin/webbw src/stats/webbw.mlb
182
183 bin/domtool-tail: $(COMMON_MLTON_DEPS) src/tail/tail.mlb src/tail/*.sml
184 mlton -output bin/domtool-tail src/tail/tail.mlb
185
186 elisp/domtool-tables.el: lib/*.dtl bin/domtool-doc
187 bin/domtool-doc -basis -emacs >$@
188
189 install_sos:
190 cp openssl/openssl_sml.so /usr/local/lib/
191 cp pcre/pcre_sml.so /usr/local/lib/
192
193 install: install_sos
194 cp scripts/domtool-publish /usr/local/sbin/
195 cp scripts/domtool-reset-global /usr/local/sbin/
196 cp scripts/domtool-reset-local /usr/local/sbin/
197 cp scripts/domtool-adduser /usr/local/bin/
198 cp scripts/domtool-addcert /usr/local/bin/
199 cp scripts/domtool-readdcerts /usr/local/bin/
200 cp scripts/domtool-addacl /usr/local/bin/
201 cp scripts/domtool-rmuser /usr/local/bin/
202 cp scripts/domtool-admin-sudo /usr/local/bin/
203 cp scripts/domtool-server-logged /usr/local/bin/
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/
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/
212 -cp bin/dbtool /usr/local/bin/
213 -cp bin/fwtool /usr/local/bin/
214 -cp bin/vmail /usr/local/bin/
215 -cp bin/setsa /usr/local/bin/
216 -cp bin/smtplog /usr/local/bin/
217 -cp bin/mysql-fixperms /usr/local/bin/
218 -cp bin/vmailpasswd /usr/local/bin/
219 -cp bin/webbw /usr/local/sbin/
220 -cp bin/domtool-tail /usr/local/bin/
221 -chmod +s /usr/local/bin/domtool-tail
222 cp src/plugins/domtool-postgres /usr/local/sbin/
223 cp src/plugins/domtool-mysql /usr/local/sbin/
224 -mkdir -p $(EMACS_DIR)
225 cp elisp/*.el $(EMACS_DIR)/
226
227 .PHONY: grab_lib install_server install_slave
228
229 grab_lib:
230 rsync -r --delete /afs/hcoop.net/common/etc/domtool/lib/* lib/
231
232 install_server:
233 sudo /etc/init.d/domtool-server stop
234 sudo make install
235 sudo /etc/init.d/domtool-server start
236
237 install_slave:
238 sudo /etc/init.d/domtool-slave stop
239 sudo make install
240 sudo /etc/init.d/domtool-slave start