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