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