Correct tilde expansion
[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
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 openssl/smlnj/FFI/libssl.h.cm: openssl/openssl_sml.h
85 cd openssl/smlnj ; ml-nlffigen -d FFI -lh LibsslH.libh -include ../libssl-h.sml \
86 -cm libssl.h.cm -D__builtin_va_list="void*" \
87 ../openssl_sml.h
88
89 openssl/mlton/FFI/libssl.h.mlb: openssl/openssl_sml.h
90 cd openssl/mlton ; mlnlffigen -dir FFI -libhandle LibsslH.libh -include ../libssl-h.sml \
91 -mlbfile libssl.h.mlb -cppopt -D__builtin_va_list="void*" \
92 ../openssl_sml.h
93
94 %.lex.sml: %.lex
95 mllex $<
96
97 %.grm.sig %.grm.sml: %.grm
98 mlyacc $<
99
100 COMMON_MLTON_DEPS := openssl/mlton/FFI/libssl.h.mlb \
101 src/domtool.lex.sml \
102 src/domtool.grm.sig src/domtool.grm.sml \
103 $(COMMON_DEPS) src/*.sig src/*.sml \
104 src/plugins/*.sig src/plugins/*.sml \
105 src/mail/*.sig src/mail/*.sml
106
107 MLTON := mlton -link-opt -ldl
108
109 ifdef DEBUG
110 MLTON += -const 'Exn.keepHistory true'
111 endif
112
113 bin/domtool-server: $(COMMON_MLTON_DEPS) src/domtool-server.mlb
114 $(MLTON) -output bin/domtool-server src/domtool-server.mlb
115
116 bin/domtool-client: $(COMMON_MLTON_DEPS) src/domtool-client.mlb
117 $(MLTON) -output bin/domtool-client src/domtool-client.mlb
118
119 bin/domtool-slave: $(COMMON_MLTON_DEPS) src/domtool-slave.mlb
120 $(MLTON) -output bin/domtool-slave src/domtool-slave.mlb
121
122 bin/domtool-admin: $(COMMON_MLTON_DEPS) src/domtool-admin.mlb
123 $(MLTON) -output bin/domtool-admin src/domtool-admin.mlb
124
125 bin/domtool-doc: $(COMMON_MLTON_DEPS) src/domtool-doc.mlb
126 $(MLTON) -output bin/domtool-doc src/domtool-doc.mlb
127
128 bin/dbtool: $(COMMON_MLTON_DEPS) src/dbtool.mlb
129 $(MLTON) -output bin/dbtool src/dbtool.mlb
130
131 bin/vmail: $(COMMON_MLTON_DEPS) src/vmail.mlb
132 $(MLTON) -output bin/vmail src/vmail.mlb
133
134 bin/setsa: $(COMMON_MLTON_DEPS) src/setsa.mlb
135 $(MLTON) -output bin/setsa src/setsa.mlb
136
137 bin/smtplog: $(COMMON_MLTON_DEPS) src/smtplog.mlb
138 $(MLTON) -output bin/smtplog src/smtplog.mlb
139
140 install:
141 cp scripts/domtool-publish /usr/local/sbin/
142 cp scripts/domtool-reset-global /usr/local/sbin/
143 cp scripts/domtool-reset-local /usr/local/sbin/
144 cp scripts/domtool-adduser /usr/local/bin/
145 cp scripts/domtool-addcert /usr/local/bin/
146 cp scripts/domtool-addacl /usr/local/bin/
147 cp scripts/domtool-rmuser /usr/local/bin/
148 cp scripts/domtool-admin-sudo /usr/local/bin/
149 cp scripts/domtool-server-logged /usr/local/bin/
150 cp scripts/domtool-slave-logged /usr/local/bin/
151 cp scripts/domtool-server /etc/init.d/
152 cp scripts/domtool-slave /etc/init.d/
153 cp openssl/openssl_sml.so /usr/local/lib/
154 -cp bin/domtool-server /usr/local/sbin/
155 -cp bin/domtool-slave /usr/local/sbin/
156 -cp bin/domtool-client /usr/local/bin/domtool
157 -cp bin/domtool-admin /usr/local/bin/
158 -cp bin/domtool-doc /usr/local/bin/
159 -cp bin/dbtool /usr/local/bin/
160 -cp bin/vmail /usr/local/bin/
161 -cp bin/setsa /usr/local/bin/
162 -cp bin/smtplog /usr/local/bin/
163 cp src/plugins/domtool-postgres /usr/local/sbin/
164 cp src/plugins/domtool-mysql /usr/local/sbin/
165
166 .PHONY: grab_lib
167
168 grab_lib:
169 rsync --delete /afs/hcoop.net/common/etc/domtool/lib/* lib/