-
Notifications
You must be signed in to change notification settings - Fork 36
/
Makefile
166 lines (127 loc) · 3.55 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
include ../Makefile.config
include $(PIQI_ROOT)/make/Makefile.ocaml
RESULT = piqilib
LIBINSTALL_FILES += \
$(wildcard $(RESULT).cma $(RESULT).cmxa $(RESULT).$(EXT_LIB) $(RES_CLIB) $(DLLSONAME)) \
$(wildcard *.cmi) \
PACKS = easy-format xmlm base64 sedlex sedlex.ppx
SOURCES = \
piqi_version.ml \
\
piqi_piqirun.ml \
piqi_piqi.ml \
\
piqi_util.ml \
piqloc.ml \
\
piq_piqi.ml \
piq_ast.ml \
\
piqi_impl_piqi.ml \
piqi_boot.ml \
\
piqi_c.ml piqi_c.mli \
piqi_c_impl.c \
\
piqi_config.ml \
piqi_iolist.ml \
piqi_name.ml \
piqi_common.ml \
piqi_file.ml \
piqi_command.ml \
piqi_protobuf.ml \
piqi_db.ml \
\
piqi_utf8.ml \
piq_lexer.ml \
piq_parser.ml \
piq_gen.ml \
\
piqi_json_type.mli \
piqi_xml_type.mli \
\
piqi_objstore.ml \
piqobj.ml \
piqobj_common.ml \
piqobj_to_protobuf.ml \
piqobj_of_protobuf.ml \
piqobj_to_piq.ml \
piqobj_of_piq.ml \
\
piq.ml \
piqi.ml \
\
piqi_pp.ml \
\
piqi_json_parser.mll \
piqi_json_gen.ml \
piqi_json.ml \
\
piqi_base64.ml \
piqobj_to_json.ml \
piqobj_of_json.ml \
\
piqi_xml.ml \
piqobj_to_xml.ml \
piqobj_of_xml.ml \
\
piqi_convert.ml \
piqi_compile.ml \
\
piqi_light.ml \
piqi_getopt.ml \
PRE_TARGETS = piqi_version.ml META
all: ncl
debug: dcl top
# NOTE: when installing, uninstall first to avoid "already installed" error
# also, make sure we have the byte-code version of the library built as well
install: uninstall libinstall
uninstall: libuninstall
piqi_version.ml: ../VERSION
echo "let version = \"`head -1 $<`\"" >$@
META: ../VERSION META.in
echo "version = \"`head -1 $<`\"" >$@
cat META.in >>$@
# re-generate piqi_piqi.ml piqi_impl_piqi.ml and piqi_boot.ml from .piqi and
# also copying the latest version of piqirun.ml -- called manually as "make
# piqi" when there were changes in the .piqi files or to take advantage of new
# versions of piqic-ocaml and the piqirun.pb runtime library
#
# NOTE: expand_piqi_boot is optional and can be safely turned off if it is
# giving troubles
PIQI = ../src/piqi
PIQI_OCAML_DIR ?= ../../piqi-ocaml
PIQIC = $(PIQI_OCAML_DIR)/piqic-ocaml/piqic-ocaml
PIQI_FLAGS = -I $(PIQI_ROOT)
PIQIC_FLAGS = $(PIQI_FLAGS) --runtime Piqi_piqirun
piqi: piqi_files piqi_ml piqi_boot expand_piqi_boot
piqi_files:
cp $(PIQI_OCAML_DIR)/piqic-ocaml/piqi.ocaml.piqi .
cp $(PIQI_OCAML_DIR)/piqirun/piqirun.ml piqi_piqirun.ml
piqi_ml:
$(PIQIC) $(PIQIC_FLAGS) --cc piqi-impl.piqi
$(PIQIC) $(PIQIC_FLAGS) piqi.piqi
$(PIQIC) $(PIQIC_FLAGS) piq.piqi
piqi_boot:
$(PIQI) convert -t pb piqi-lang.piqi
$(PIQI) convert -t pb piqi.piqi
$(PIQI) convert -t pb piq.piqi
ocaml gen_piqi_boot.ml > piqi_boot.ml
rm piqi-lang.piqi.pb piqi.piqi.pb piq.piqi.pb
# turn piqi specs serialized as Protobuf into OCaml data structures (optional)
expand_piqi_boot:
$(MAKE) -f Makefile.expand_piqi_boot top
echo "#print_length 1000000;; #print_depth 1000000;;" > expand_piqi_boot.ocaml
(set -e; export OCAMLTOP_UTF_8=false; \
echo "let piqi_spec ="; \
echo "let t = Piqi_boot.piqi_spec;;" | ./expand_piqi_boot.top -noprompt -init expand_piqi_boot.ocaml | sed -e '1,3d'; \
echo "let piqi_lang ="; \
echo "let t = Piqi_boot.piqi_lang;;" | ./expand_piqi_boot.top -noprompt -init expand_piqi_boot.ocaml | sed -e '1,3d'; \
echo "let piq ="; \
echo "let t = Piqi_boot.piq;;" | ./expand_piqi_boot.top -noprompt -init expand_piqi_boot.ocaml | sed -e '1,3d'; \
) > piqi_boot_expanded.ml
mv piqi_boot_expanded.ml piqi_boot.ml
rm -f expand_piqi_boot.ocaml
$(MAKE) -f Makefile.expand_piqi_boot clean
.PHONY: piqi piqi_files piqi_ml piqi_boot expand_piqi_boot
include $(OCAMLMAKEFILE)