1f780a417a1235d4cc320132310ae6c5bd4dcd88
[hcoop/domtool2.git] / Makefile
1 all: mlton
2
3 COMMON_DEPS := configDefault/config.sig configDefault/configDefault.sml \
4 openssl/openssl_sml.so
5
6 .PHONY: all mlton smlnj install
7
8 mlton: bin/domtool-server bin/domtool-client bin/domtool-slave \
9 bin/domtool-admin bin/domtool-doc bin/dbtool
10
11 smlnj: $(COMMON_DEPS) openssl/smlnj/FFI/libssl.h.cm src/domtool.cm
12
13 configDefault/config.sig: src/config.sig.header \
14 configDefault/*.csg configDefault/*.cfs \
15 src/config.sig.footer
16 cat configDefault/*.csg \
17 src/config.sig.header \
18 configDefault/*.cfs \
19 src/config.sig.footer \
20 >configDefault/config.sig
21
22 configDefault/configDefault.sml: src/configDefault.sml.header \
23 configDefault/*.cfg src/configDefault.sml.footer
24 cat src/configDefault.sml.header \
25 configDefault/*.cfg \
26 src/configDefault.sml.footer \
27 >configDefault/configDefault.sml
28
29 openssl/openssl_sml.o: openssl/openssl_sml.c
30 gcc -fPIC -c openssl/openssl_sml.c -o openssl/openssl_sml.o
31
32 openssl/openssl_sml.so: openssl/openssl_sml.o
33 gcc -shared -Wl,-soname,openssl_sml.so \
34 -o openssl/openssl_sml.so \
35 openssl/openssl_sml.o -lssl
36
37 src/domtool.cm: src/prefix.cm src/sources
38 cat src/prefix.cm src/sources >src/domtool.cm
39
40 MAKE_MLB_BASE := cat src/prefix.mlb src/sources src/suffix.mlb \
41 | sed 's/^\(.*\).grm$$/\1.grm.sig\n\1.grm.sml/' \
42 | sed 's/^\(.*\).lex$$/\1.lex.sml/'
43
44 src/domtool-server.mlb: src/prefix.mlb src/sources src/suffix.mlb
45 $(MAKE_MLB_BASE) >src/domtool-server.mlb
46 echo "main-server.sml" >>src/domtool-server.mlb
47
48 src/domtool-client.mlb: src/prefix.mlb src/sources src/suffix.mlb
49 $(MAKE_MLB_BASE) >src/domtool-client.mlb
50 echo "main-client.sml" >>src/domtool-client.mlb
51
52 src/domtool-slave.mlb: src/prefix.mlb src/sources src/suffix.mlb
53 $(MAKE_MLB_BASE) >src/domtool-slave.mlb
54 echo "main-slave.sml" >>src/domtool-slave.mlb
55
56 src/domtool-admin.mlb: src/prefix.mlb src/sources src/suffix.mlb
57 $(MAKE_MLB_BASE) >src/domtool-admin.mlb
58 echo "main-admin.sml" >>src/domtool-admin.mlb
59
60 src/domtool-doc.mlb: src/prefix.mlb src/sources src/suffix.mlb
61 $(MAKE_MLB_BASE) >src/domtool-doc.mlb
62 echo "main-doc.sml" >>src/domtool-doc.mlb
63
64 src/dbtool.mlb: src/prefix.mlb src/sources src/suffix.mlb
65 $(MAKE_MLB_BASE) >src/dbtool.mlb
66 echo "main-dbtool.sml" >>src/dbtool.mlb
67
68 openssl/smlnj/FFI/libssl.h.cm: openssl/openssl_sml.h
69 cd openssl/smlnj ; ml-nlffigen -d FFI -lh LibsslH.libh -include ../libssl-h.sml \
70 -cm libssl.h.cm -D__builtin_va_list="void*" \
71 ../openssl_sml.h
72
73 openssl/mlton/FFI/libssl.h.mlb: openssl/openssl_sml.h
74 cd openssl/mlton ; mlnlffigen -dir FFI -libhandle LibsslH.libh -include ../libssl-h.sml \
75 -mlbfile libssl.h.mlb -cppopt -D__builtin_va_list="void*" \
76 ../openssl_sml.h
77
78 %.lex.sml: %.lex
79 mllex $<
80
81 %.grm.sig %.grm.sml: %.grm
82 mlyacc $<
83
84 COMMON_MLTON_DEPS := openssl/mlton/FFI/libssl.h.mlb \
85 src/domtool.lex.sml \
86 src/domtool.grm.sig src/domtool.grm.sml \
87 $(COMMON_DEPS) src/*.sig src/*.sml \
88 src/plugins/*.sig src/plugins/*.sml
89
90 bin/domtool-server: $(COMMON_MLTON_DEPS) src/domtool-server.mlb
91 mlton -output bin/domtool-server -link-opt -ldl src/domtool-server.mlb
92
93 bin/domtool-client: $(COMMON_MLTON_DEPS) src/domtool-client.mlb
94 mlton -output bin/domtool-client -link-opt -ldl src/domtool-client.mlb
95
96 bin/domtool-slave: $(COMMON_MLTON_DEPS) src/domtool-slave.mlb
97 mlton -output bin/domtool-slave -link-opt -ldl src/domtool-slave.mlb
98
99 bin/domtool-admin: $(COMMON_MLTON_DEPS) src/domtool-admin.mlb
100 mlton -output bin/domtool-admin -link-opt -ldl src/domtool-admin.mlb
101
102 bin/domtool-doc: $(COMMON_MLTON_DEPS) src/domtool-doc.mlb
103 mlton -output bin/domtool-doc -link-opt -ldl src/domtool-doc.mlb
104
105 bin/dbtool: $(COMMON_MLTON_DEPS) src/dbtool.mlb
106 mlton -output bin/dbtool -link-opt -ldl src/dbtool.mlb
107
108 install:
109 cp scripts/domtool-publish /usr/local/sbin/
110 cp scripts/domtool-reset-global /usr/local/sbin/
111 cp scripts/domtool-reset-local /usr/local/sbin/
112 cp scripts/domtool-adduser /usr/local/bin/
113 cp scripts/domtool-addcert /usr/local/bin/
114 cp scripts/domtool-addacl /usr/local/bin/
115 cp scripts/domtool-rmuser /usr/local/bin/
116 cp openssl/openssl_sml.so /usr/local/lib/
117 -cp bin/domtool-server /usr/local/sbin/
118 -cp bin/domtool-slave /usr/local/sbin/
119 -cp bin/domtool-client /usr/local/bin/domtool
120 -cp bin/domtool-admin /usr/local/bin/
121 -cp bin/domtool-doc /usr/local/bin/
122 -cp bin/dbtool /usr/local/bin/
123 cp src/plugins/domtool-postgres /usr/local/sbin/
124
125 .PHONY: grab_lib
126
127 grab_lib:
128 rsync --delete /afs/hcoop.net/common/etc/domtool/lib/* lib/