vmailpasswd
[hcoop/domtool2.git] / Makefile
1 all: mlton bin/vmailpasswd
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 config.sml
8
9 config.sml:
10 echo -e 'structure Config :> CONFIG = struct\nopen ConfigDefault\nend' > $@
11
12 .PHONY: all mlton smlnj install
13
14 mlton: bin/domtool-server bin/domtool-client bin/domtool-slave \
15 bin/domtool-admin bin/domtool-doc bin/dbtool bin/vmail \
16 bin/smtplog bin/setsa bin/mysql-fixperms
17
18 smlnj: $(COMMON_DEPS) openssl/smlnj/FFI/libssl.h.cm src/domtool.cm
19
20 configDefault/config.sig: src/config.sig.header \
21 configDefault/*.csg configDefault/*.cfs \
22 src/config.sig.footer
23 cat configDefault/*.csg \
24 src/config.sig.header \
25 configDefault/*.cfs \
26 src/config.sig.footer \
27 >configDefault/config.sig
28
29 configDefault/configDefault.sml: src/configDefault.sml.header \
30 configDefault/*.cfg src/configDefault.sml.footer
31 cat src/configDefault.sml.header \
32 configDefault/*.cfg \
33 src/configDefault.sml.footer \
34 >configDefault/configDefault.sml
35
36 openssl/openssl_sml.o: openssl/openssl_sml.c
37 gcc -fPIC -c openssl/openssl_sml.c -o openssl/openssl_sml.o
38
39 openssl/openssl_sml.so: openssl/openssl_sml.o
40 gcc -shared -Wl,-soname,openssl_sml.so \
41 -o openssl/openssl_sml.so \
42 openssl/openssl_sml.o -lssl
43
44 src/domtool.cm: src/prefix.cm src/sources
45 cat src/prefix.cm src/sources >src/domtool.cm
46
47 MAKE_MLB_BASE := cat src/prefix.mlb src/sources src/suffix.mlb \
48 | sed 's/^\(.*\).grm$$/\1.grm.sig\n\1.grm.sml/' \
49 | sed 's/^\(.*\).lex$$/\1.lex.sml/'
50
51 src/domtool-server.mlb: src/prefix.mlb src/sources src/suffix.mlb
52 $(MAKE_MLB_BASE) >src/domtool-server.mlb
53 echo "main-server.sml" >>src/domtool-server.mlb
54
55 src/domtool-client.mlb: src/prefix.mlb src/sources src/suffix.mlb
56 $(MAKE_MLB_BASE) >src/domtool-client.mlb
57 echo "main-client.sml" >>src/domtool-client.mlb
58
59 src/domtool-slave.mlb: src/prefix.mlb src/sources src/suffix.mlb
60 $(MAKE_MLB_BASE) >src/domtool-slave.mlb
61 echo "main-slave.sml" >>src/domtool-slave.mlb
62
63 src/domtool-admin.mlb: src/prefix.mlb src/sources src/suffix.mlb
64 $(MAKE_MLB_BASE) >src/domtool-admin.mlb
65 echo "main-admin.sml" >>src/domtool-admin.mlb
66
67 src/domtool-doc.mlb: src/prefix.mlb src/sources src/suffix.mlb
68 $(MAKE_MLB_BASE) >src/domtool-doc.mlb
69 echo "main-doc.sml" >>src/domtool-doc.mlb
70
71 src/dbtool.mlb: src/prefix.mlb src/sources src/suffix.mlb
72 $(MAKE_MLB_BASE) >src/dbtool.mlb
73 echo "main-dbtool.sml" >>src/dbtool.mlb
74
75 src/vmail.mlb: src/prefix.mlb src/sources src/suffix.mlb
76 $(MAKE_MLB_BASE) >src/vmail.mlb
77 echo "main-vmail.sml" >>src/vmail.mlb
78
79 src/setsa.mlb: src/prefix.mlb src/sources src/suffix.mlb
80 $(MAKE_MLB_BASE) >src/setsa.mlb
81 echo "main-setsa.sml" >>src/setsa.mlb
82
83 src/smtplog.mlb: src/prefix.mlb src/sources src/suffix.mlb
84 $(MAKE_MLB_BASE) >src/smtplog.mlb
85 echo "main-smtplog.sml" >>src/smtplog.mlb
86
87 src/mysql-fixperms.mlb: src/prefix.mlb src/sources src/suffix.mlb
88 $(MAKE_MLB_BASE) >src/mysql-fixperms.mlb
89 echo "main-mysql-fixperms.sml" >>src/mysql-fixperms.mlb
90
91 openssl/smlnj/FFI/libssl.h.cm: openssl/openssl_sml.h
92 cd openssl/smlnj ; ml-nlffigen -d FFI -lh LibsslH.libh -include ../libssl-h.sml \
93 -cm libssl.h.cm -D__builtin_va_list="void*" \
94 ../openssl_sml.h
95
96 openssl/mlton/FFI/libssl.h.mlb: openssl/openssl_sml.h
97 cd openssl/mlton ; mlnlffigen -dir FFI -libhandle LibsslH.libh -include ../libssl-h.sml \
98 -mlbfile libssl.h.mlb -cppopt -D__builtin_va_list="void*" \
99 ../openssl_sml.h
100
101 %.lex.sml: %.lex
102 mllex $<
103
104 %.grm.sig %.grm.sml: %.grm
105 mlyacc $<
106
107 COMMON_MLTON_DEPS := openssl/mlton/FFI/libssl.h.mlb \
108 src/domtool.lex.sml \
109 src/domtool.grm.sig src/domtool.grm.sml \
110 $(COMMON_DEPS) src/*.sig src/*.sml \
111 src/plugins/*.sig src/plugins/*.sml \
112 src/mail/*.sig src/mail/*.sml
113
114 MLTON := mlton -link-opt -ldl
115
116 ifdef DEBUG
117 MLTON += -const 'Exn.keepHistory true'
118 endif
119
120 bin/domtool-server: $(COMMON_MLTON_DEPS) src/domtool-server.mlb
121 $(MLTON) -output bin/domtool-server src/domtool-server.mlb
122
123 bin/domtool-client: $(COMMON_MLTON_DEPS) src/domtool-client.mlb
124 $(MLTON) -output bin/domtool-client src/domtool-client.mlb
125
126 bin/domtool-slave: $(COMMON_MLTON_DEPS) src/domtool-slave.mlb
127 $(MLTON) -output bin/domtool-slave src/domtool-slave.mlb
128
129 bin/domtool-admin: $(COMMON_MLTON_DEPS) src/domtool-admin.mlb
130 $(MLTON) -output bin/domtool-admin src/domtool-admin.mlb
131
132 bin/domtool-doc: $(COMMON_MLTON_DEPS) src/domtool-doc.mlb
133 $(MLTON) -output bin/domtool-doc src/domtool-doc.mlb
134
135 bin/dbtool: $(COMMON_MLTON_DEPS) src/dbtool.mlb
136 $(MLTON) -output bin/dbtool src/dbtool.mlb
137
138 bin/vmail: $(COMMON_MLTON_DEPS) src/vmail.mlb
139 $(MLTON) -output bin/vmail src/vmail.mlb
140
141 bin/setsa: $(COMMON_MLTON_DEPS) src/setsa.mlb
142 $(MLTON) -output bin/setsa src/setsa.mlb
143
144 bin/smtplog: $(COMMON_MLTON_DEPS) src/smtplog.mlb
145 $(MLTON) -output bin/smtplog src/smtplog.mlb
146
147 bin/mysql-fixperms: $(COMMON_MLTON_DEPS) src/mysql-fixperms.mlb
148 $(MLTON) -output bin/mysql-fixperms src/mysql-fixperms.mlb
149
150 install:
151 cp scripts/domtool-publish /usr/local/sbin/
152 cp scripts/domtool-reset-global /usr/local/sbin/
153 cp scripts/domtool-reset-local /usr/local/sbin/
154 cp scripts/domtool-adduser /usr/local/bin/
155 cp scripts/domtool-addcert /usr/local/bin/
156 cp scripts/domtool-addcert-daemon /usr/local/bin/
157 cp scripts/domtool-addacl /usr/local/bin/
158 cp scripts/domtool-rmuser /usr/local/bin/
159 cp scripts/domtool-admin-sudo /usr/local/bin/
160 cp scripts/domtool-server-logged /usr/local/bin/
161 cp scripts/domtool-slave-logged /usr/local/bin/
162 cp scripts/domtool-server /etc/init.d/
163 cp scripts/domtool-slave /etc/init.d/
164 cp openssl/openssl_sml.so /usr/local/lib/
165 -cp bin/domtool-server /usr/local/sbin/
166 -cp bin/domtool-slave /usr/local/sbin/
167 -cp bin/domtool-client /usr/local/bin/domtool
168 -cp bin/domtool-admin /usr/local/bin/
169 -cp bin/domtool-doc /usr/local/bin/
170 -cp bin/dbtool /usr/local/bin/
171 -cp bin/vmail /usr/local/bin/
172 -cp bin/setsa /usr/local/bin/
173 -cp bin/smtplog /usr/local/bin/
174 -cp bin/mysql-fixperms /usr/local/bin/
175 -cp bin/vmailpasswd /usr/local/bin/
176 cp src/plugins/domtool-postgres /usr/local/sbin/
177 cp src/plugins/domtool-mysql /usr/local/sbin/
178
179 .PHONY: grab_lib install_server install_slave
180
181 grab_lib:
182 rsync -r --delete /afs/hcoop.net/common/etc/domtool/lib/* lib/
183
184 install_server:
185 sudo /etc/init.d/domtool-server stop
186 sudo make install
187 sudo /etc/init.d/domtool-server start
188
189 install_slave:
190 sudo /etc/init.d/domtool-slave stop
191 sudo make install
192 sudo /etc/init.d/domtool-slave start