ligo/src/Makefile

504 lines
14 KiB
Makefile
Raw Normal View History

2016-09-08 21:13:10 +04:00
include Makefile.config
TZCOMPILER=../tezos-protocol-compiler
TZNODE=../tezos-node
TZCLIENT=../tezos-client
all: ${TZCOMPILER} ${TZNODE} ${TZCLIENT}
############################################################################
## Protocol environment
############################################################################
PROTOCOL_ENV_INTFS := \
$(addprefix proto/environment/, \
2016-09-08 21:13:10 +04:00
pervasives.mli \
compare.mli \
\
array.mli list.mli bytes.mli string.mli \
set.mli map.mli \
int32.mli int64.mli \
buffer.mli \
format.mli \
\
lwt_sequence.mli lwt.mli lwt_list.mli \
\
mBytes.mli \
hex_encode.mli \
\
uri.mli \
data_encoding.mli \
error_monad.mli \
logging.mli \
2016-09-08 21:13:10 +04:00
time.mli \
base48.mli \
hash.mli \
ed25519.mli \
persist.mli \
context.mli \
RPC.mli \
\
fitness.mli \
updater.mli \
)
2016-09-08 21:13:10 +04:00
.INTERMEDIATE: node/updater/environment_gen
.SECONDARY: node/updater/proto_environment.mli
node/updater/environment_gen: node/updater/environment_gen.ml
@echo LINK $(notdir $@)
@$(OCAMLOPT) -o $@ $^
node/updater/proto_environment.mli: \
node/updater/environment_gen $(PROTOCOL_ENV_INTFS)
@echo GENERATING $(notdir $@)
@node/updater/environment_gen node/updater/proto_environment.mli \
$(PROTOCOL_ENV_INTFS)
node/updater/proto_environment.cmi: \
node/updater/proto_environment.mli node/updater/protocol.cmi
@echo OCAMLOPT ${TARGET} $@
@$(OCAMLOPT) -nopervasives -nostdlib -opaque -I tmp -I node/updater -c $<
clean::
rm -f node/updater/proto_environment.mli
rm -f node/updater/environment_gen
############################################################################
## Protocol environment
############################################################################
EMBEDDED_PROTOCOL_LIB_CMIS := \
tmp/camlinternalFormatBasics.cmi \
node/updater/proto_environment.cmi \
node/updater/register.cmi
node/updater/register.cmi: EXTRA_OCAMLFLAGS = -opaque
node/updater/environment.cmi: node/updater/environment.cmx
tmp/camlinternalFormatBasics.cmi:
mkdir -p tmp
ln -sf $(shell ocamlc -where)/camlinternalFormatBasics.cmi $@
.INTERMEDIATE: compiler/embedded_cmis.ml
compiler/embedded_cmis.cmx: compiler/embedded_cmis.cmi
compiler/embedded_cmis.ml: ${EMBEDDED_PROTOCOL_LIB_CMIS}
@echo OCAMLRES ${TARGET} $(notdir $@)
@$(OCAMLRES) -format ocaml -o $@ $^
clean::
rm -f compiler/embedded_cmis.ml
rm -rf tmp
############################################################################
## Minimal utils library compatible with js_of_ocaml
############################################################################
MINUTILS_LIB_INTFS := \
minutils/mBytes.mli \
minutils/hex_encode.mli \
minutils/utils.mli \
minutils/compare.mli \
minutils/data_encoding.mli \
minutils/RPC.mli \
MINUTILS_LIB_IMPLS := \
minutils/mBytes.ml \
minutils/hex_encode.ml \
minutils/utils.ml \
minutils/compare.ml \
minutils/data_encoding.ml \
minutils/RPC.ml \
MINUTILS_PACKAGES := \
cstruct \
lwt \
ocplib-json-typed.bson \
ocplib-resto.directory \
$(COVERAGEPKG) \
MINUTILS_OBJS := \
${MINUTILS_LIB_IMPLS:.ml=.cmx} ${MINUTILS_LIB_IMPLS:.ml=.ml.deps} \
${MINUTILS_LIB_INTFS:.mli=.cmi} ${MINUTILS_LIB_INTFS:.mli=.mli.deps}
${MINUTILS_OBJS}: PACKAGES=${MINUTILS_PACKAGES}
${MINUTILS_OBJS}: SOURCE_DIRECTORIES=minutils
${MINUTILS_OBJS}: TARGET="(minutils.cmxa)"
${MINUTILS_OBJS}: OPENED_MODULES=
minutils.cmxa: ${MINUTILS_LIB_IMPLS:.ml=.cmx}
@echo LINK $(notdir $@)
@${OCAMLOPT} ${OCAMLFLAGS} -a -o $@ $^
2016-09-08 21:13:10 +04:00
############################################################################
## Utils library
2016-09-08 21:13:10 +04:00
############################################################################
UTILS_LIB_INTFS := \
utils/base48.mli \
utils/cli_entries.mli \
utils/data_encoding_ezjsonm.mli \
utils/crypto_box.mli \
2016-09-08 21:13:10 +04:00
utils/time.mli \
utils/hash.mli \
utils/error_monad.mli \
utils/lwt_exit.mli \
2016-09-08 21:13:10 +04:00
utils/logging.mli \
utils/lwt_utils.mli \
2016-11-29 00:46:26 +04:00
utils/lwt_pipe.mli \
2016-09-08 21:13:10 +04:00
utils/IO.mli \
2016-11-29 00:54:32 +04:00
utils/moving_average.mli \
2016-09-08 21:13:10 +04:00
UTILS_LIB_IMPLS := \
2016-10-06 20:30:04 +04:00
utils/base48.ml \
2016-09-08 21:13:10 +04:00
utils/cli_entries.ml \
utils/data_encoding_ezjsonm.ml \
2016-09-08 21:13:10 +04:00
utils/time.ml \
utils/hash.ml \
utils/crypto_box.ml \
2016-09-08 21:13:10 +04:00
utils/error_monad_sig.ml \
utils/error_monad.ml \
utils/lwt_exit.ml \
2016-09-08 21:13:10 +04:00
utils/logging.ml \
utils/lwt_utils.ml \
2016-11-29 00:46:26 +04:00
utils/lwt_pipe.ml \
2016-09-08 21:13:10 +04:00
utils/IO.ml \
2016-11-29 00:54:32 +04:00
utils/moving_average.ml \
2016-09-08 21:13:10 +04:00
UTILS_PACKAGES := \
${MINUTILS_PACKAGES} \
2016-09-08 21:13:10 +04:00
base64 \
calendar \
ezjsonm \
sodium \
zarith \
$(COVERAGEPKG) \
2016-09-08 21:13:10 +04:00
UTILS_OBJS := \
${UTILS_LIB_IMPLS:.ml=.cmx} ${UTILS_LIB_IMPLS:.ml=.ml.deps} \
${UTILS_LIB_INTFS:.mli=.cmi} ${UTILS_LIB_INTFS:.mli=.mli.deps}
${UTILS_OBJS}: PACKAGES=${UTILS_PACKAGES}
${UTILS_OBJS}: SOURCE_DIRECTORIES=minutils utils
2016-09-08 21:13:10 +04:00
${UTILS_OBJS}: TARGET="(utils.cmxa)"
${UTILS_OBJS}: OPENED_MODULES=
utils.cmxa: ${UTILS_LIB_IMPLS:.ml=.cmx}
@echo LINK $(notdir $@)
@${OCAMLOPT} ${OCAMLFLAGS} -a -o $@ $^
############################################################################
## Node protocol compiler (also embedded in the main program)
############################################################################
COMPILER_LIB_INTFS := \
compiler/tezos_compiler.mli \
compiler/embedded_cmis.mli \
COMPILER_LIB_IMPLS := \
compiler/embedded_cmis.ml \
compiler/tezos_compiler.ml \
2016-09-08 21:13:10 +04:00
COMPILER_IMPLS := \
compiler_main.ml \
2016-09-08 21:13:10 +04:00
COMPILER_PACKAGES := \
${UTILS_PACKAGES} \
compiler-libs.optcomp \
config-file \
lwt.unix \
ocplib-endian \
ocplib-ocamlres \
unix \
2016-09-08 21:13:10 +04:00
COMPILER_OBJS := \
${COMPILER_IMPLS:.ml=.cmx} ${COMPILER_IMPLS:.ml=.ml.deps} \
${COMPILER_LIB_IMPLS:.ml=.cmx} ${COMPILER_LIB_IMPLS:.ml=.ml.deps} \
${COMPILER_LIB_INTFS:.mli=.cmi} ${COMPILER_LIB_INTFS:.mli=.mli.deps} \
${TZCOMPILER}
${COMPILER_OBJS}: PACKAGES=${COMPILER_PACKAGES}
${COMPILER_OBJS}: SOURCE_DIRECTORIES=utils minutils compiler
2016-09-08 21:13:10 +04:00
${COMPILER_OBJS}: TARGET="(compiler.cmxa)"
${COMPILER_OBJS}: \
OPENED_MODULES=Error_monad Hash Utils
compiler.cmxa: ${COMPILER_LIB_IMPLS:.ml=.cmx}
@echo LINK $(notdir $@)
@${OCAMLOPT} ${OCAMLFLAGS} -a -o $@ $^
${TZCOMPILER}: minutils.cmxa utils.cmxa compiler.cmxa ${COMPILER_IMPLS:.ml=.cmx}
2016-09-08 21:13:10 +04:00
@echo LINK $(notdir $@)
@$(OCAMLOPT) -linkpkg $(patsubst %, -package %, $(COMPILER_PACKAGES)) -o $@ $^
clean::
rm -f ${TZCOMPILER}
############################################################################
## Node program
############################################################################
NODE_LIB_INTFS := \
\
2016-09-08 21:13:10 +04:00
node/net/p2p.mli \
node/net/RPC_server.mli \
2016-09-08 21:13:10 +04:00
\
node/updater/fitness.mli \
\
node/db/ir_funview.mli \
node/db/persist.mli \
node/db/context.mli \
node/db/store.mli \
node/db/db_proxy.mli \
\
node/updater/protocol.mli \
node/updater/updater.mli \
node/updater/proto_environment.mli \
node/updater/register.mli \
\
node/shell/tezos_p2p.mli \
2016-09-08 21:13:10 +04:00
node/shell/state.mli \
node/shell/prevalidator.mli \
node/shell/validator.mli \
\
node/shell/discoverer.mli \
node/shell/node_rpc_services.mli \
node/shell/node.mli \
node/shell/node_rpc.mli \
NODE_LIB_IMPLS := \
\
2016-09-08 21:13:10 +04:00
compiler/node_compiler_main.ml \
\
node/net/p2p.ml \
node/net/RPC_server.ml \
2016-09-08 21:13:10 +04:00
\
node/updater/fitness.ml \
\
node/db/ir_funview.ml \
node/db/persist.ml \
node/db/store.ml \
node/db/context.ml \
node/db/db_proxy.ml \
\
node/updater/updater.ml \
node/updater/environment.ml \
node/updater/proto_environment.ml \
node/updater/register.ml \
\
node/shell/tezos_p2p.ml \
2016-09-08 21:13:10 +04:00
node/shell/state.ml \
node/shell/prevalidator.ml \
node/shell/validator.ml \
\
node/shell/discoverer.ml \
node/shell/node_rpc_services.ml \
node/shell/node.ml \
node/shell/node_rpc.ml \
NODE_IMPLS := \
node_main.ml \
NODE_PACKAGES := \
$(COMPILER_PACKAGES) \
calendar \
cohttp.lwt \
dynlink \
git \
irmin.unix \
ocplib-resto.directory \
cmdliner \
2016-09-08 21:13:10 +04:00
EMBEDDED_NODE_PROTOCOLS := \
$(patsubst proto/%/,proto/embedded_proto_%.cmxa, \
$(filter-out proto/environment/,$(shell ls -d proto/*/)))
NODE_OBJS := \
${NODE_IMPLS:.ml=.cmx} ${NODE_IMPLS:.ml=.ml.deps} \
${NODE_LIB_IMPLS:.ml=.cmx} ${NODE_LIB_IMPLS:.ml=.ml.deps} \
${NODE_LIB_INTFS:.mli=.cmi} ${NODE_LIB_INTFS:.mli=.mli.deps} \
${TZNODE}
${NODE_OBJS}: PACKAGES=${NODE_PACKAGES}
${NODE_OBJS}: SOURCE_DIRECTORIES=minutils utils compiler node/db node/net node/updater node/shell
2016-09-08 21:13:10 +04:00
${NODE_OBJS}: TARGET="(node.cmxa)"
${NODE_OBJS}: OPENED_MODULES=Error_monad Hash Utils
node.cmxa: ${NODE_LIB_IMPLS:.ml=.cmx}
@echo LINK $(notdir $@)
@${OCAMLOPT} ${OCAMLFLAGS} -a -o $@ $^
${NODE_IMPLS:.ml=.cmx}: ${EMBEDDED_CLIENT_PROTOCOLS}
${TZNODE}: minutils.cmxa utils.cmxa compiler.cmxa node.cmxa ${EMBEDDED_NODE_PROTOCOLS} ${NODE_IMPLS:.ml=.cmx}
2016-09-08 21:13:10 +04:00
@echo LINK $(notdir $@)
@${OCAMLOPT} -linkall -linkpkg ${OCAMLFLAGS} -o $@ $^
clean::
-rm -f proto/*.cm* proto/*.a
## Embedded protocol modules
.SECONDEXPANSION:
proto/embedded_proto_%.cmxa: \
${TZCOMPILER} \
proto/%/TEZOS_PROTOCOL \
$$(wildcard proto/%/*.ml) \
$$(wildcard proto/%/*.mli)
@${TZCOMPILER} -static -build-dir proto/$*/_tzbuild $@ proto/$*/
2016-09-08 21:13:10 +04:00
CLIENT_PROTO_INCLUDES := \
minutils utils node/updater node/db node/net node/shell client \
$(shell ocamlfind query lwt ocplib-json-typed sodium)
2016-09-08 21:13:10 +04:00
proto/client_embedded_proto_%.cmxa: \
${TZCOMPILER} \
node/updater/environment.cmi \
node/updater/environment.cmx \
proto/%/TEZOS_PROTOCOL \
$$(wildcard proto/%/*.ml) \
$$(wildcard proto/%/*.mli)
@./${TZCOMPILER} -static -client -build-dir client/embedded/$*/_tzbuild \
2016-09-08 21:13:10 +04:00
$(addprefix -I , ${CLIENT_PROTO_INCLUDES}) \
$@ proto/$*
clean::
rm -f ${TZNODE}
############################################################################
## Client program
############################################################################
CLIENT_LIB_INTFS := \
client/client_version.mli \
client/client_node_rpcs.mli \
client/client_generic_rpcs.mli \
2016-10-16 23:57:56 +04:00
client/client_helpers.mli \
2016-09-08 21:13:10 +04:00
client/client_aliases.mli \
client/client_keys.mli \
2016-10-25 21:00:03 +04:00
client/client_protocols.mli \
2016-09-08 21:13:10 +04:00
CLIENT_LIB_IMPLS := \
client/client_version.ml \
client/client_config.ml \
client/client_node_rpcs.ml \
client/client_generic_rpcs.ml \
2016-10-16 23:57:56 +04:00
client/client_helpers.ml \
2016-09-08 21:13:10 +04:00
client/client_aliases.ml \
client/client_keys.ml \
2016-10-25 21:00:03 +04:00
client/client_protocols.ml \
2016-09-08 21:13:10 +04:00
CLIENT_IMPLS := \
client_main.ml
CLIENT_PACKAGES := \
${NODE_PACKAGES}
EMBEDDED_CLIENT_PROTOCOLS := \
$(patsubst client/embedded/%/, \
proto/client_embedded_proto_%.cmxa, \
$(shell ls -d client/embedded/*/)) \
$(patsubst client/embedded/%/, \
client/embedded/client_%.cmx , \
$(shell ls -d client/embedded/*/))
CLIENT_OBJS := \
${CLIENT_IMPLS:.ml=.cmx} ${CLIENT_IMPLS:.ml=.ml.deps} \
${CLIENT_LIB_IMPLS:.ml=.cmx} ${CLIENT_LIB_IMPLS:.ml=.ml.deps} \
${CLIENT_LIB_INTFS:.mli=.cmi} ${CLIENT_LIB_INTFS:.mli=.mli.deps} \
${TZCLIENT}
${CLIENT_OBJS}: PACKAGES=${CLIENT_PACKAGES}
${CLIENT_OBJS}: SOURCE_DIRECTORIES=client client/embedded minutils utils node/net node/shell node/updater node/db compiler
2016-09-08 21:13:10 +04:00
${CLIENT_OBJS}: TARGET="(client.cmxa)"
${CLIENT_OBJS}: OPENED_MODULES=Error_monad Hash Utils
client.cmxa: ${CLIENT_LIB_IMPLS:.ml=.cmx}
@echo LINK $(notdir $@)
@${OCAMLOPT} ${OCAMLFLAGS} -a -o $@ $^
${EMBEDDED_CLIENT_PROTOCOLS}: client.cmxa
${CLIENT_IMPLS:.ml=.cmx}: ${EMBEDDED_CLIENT_PROTOCOLS}
${TZCLIENT}: minutils.cmxa utils.cmxa compiler.cmxa node.cmxa \
2016-09-08 21:13:10 +04:00
client.cmxa ${EMBEDDED_CLIENT_PROTOCOLS} \
${CLIENT_IMPLS:.ml=.cmx}
@echo LINK $(notdir $@)
@${OCAMLOPT} -linkpkg ${OCAMLFLAGS} -o $@ $^
clean::
-rm -f ${TZCLIENT}
## Embedded client protocol modules
.SECONDEXPANSION:
client/embedded/client_%.cmx: \
$(patsubst %.ml, %.cmx, $(NODE_LIB_IMPLS) $(CLIENT_LIB_IMPLS)) \
proto/client_embedded_proto_%.cmxa \
$$(shell find client/embedded/% -name \*.ml -or -name \*.mli)
@$(MAKE) -C client/embedded/$* ../client_$*.cmx
clean::
-for d in $$(ls -d client/embedded/*/) ; do make clean -C $$d ; done
-rm -f client/embedded/*.cm* client/embedded/*.o
## Generic rules
%.cmx: %.ml
@echo OCAMLOPT ${TARGET} $(notdir $@)
@$(OCAMLOPT) ${OCAMLFLAGS} -c $<
%.cmo: %.ml
@echo OCAMLOPT ${TARGET} $(notdir $@)
@$(OCAMLC) ${OCAMLFLAGS} -c $<
%.cmi: %.mli
@echo OCAMLOPT ${TARGET} $(notdir $@)
@$(OCAMLOPT) ${OCAMLFLAGS} -c $<
## Cleaning
.PHONY: clean
clean::
-find \( -name \*.cm\* -or -name \*.cmp -or -name \*.out -or -name \*~ -or -name \*.o -or -name \*.a \) -delete
2016-09-08 21:13:10 +04:00
## Dependencies
NO_DEPS := \
compiler/embedded_cmis.ml \
compiler/embedded_cmis.mli
compiler/embedded_cmis.cmx compiler/embedded_cmis.cmi: OPENED_MODULES=
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),build-deps)
-include .depend
endif
endif
DEPENDS := $(filter-out $(NO_DEPS), $(MINUTILS_LIB_INTFS) $(MINUTILS_LIB_IMPLS) \
$(UTILS_LIB_INTFS) $(UTILS_LIB_IMPLS) \
2016-09-08 21:13:10 +04:00
$(COMPILER_LIB_INTFS) $(COMPILER_LIB_IMPLS) \
$(COMPILER_INTFS) $(COMPILER_IMPLS) \
$(NODE_LIB_INTFS) $(NODE_LIB_IMPLS) \
$(NODE_INTFS) $(NODE_IMPLS) \
$(CLIENT_LIB_INTFS) $(CLIENT_LIB_IMPLS) \
$(CLIENT_INTFS) $(CLIENT_IMPLS))
predepend: node/updater/proto_environment.mli
compiler/tezos_compiler.cmo compiler/tezos_compiler.cmx: \
compiler/embedded_cmis.cmi compiler/embedded_cmis.cmx
.SECONDARY: $(patsubst %,%.deps,${DEPENDS})
.depend: $(patsubst %,%.deps,${DEPENDS})
@cat $^ > .depend
%.ml.deps: %.ml | predepend
@echo OCAMLDEP ${TARGET} $(notdir $^)
@$(OCAMLDEP) -native $(INCLUDES) $^ > $@
%.mli.deps: %.mli | predepend
@echo OCAMLDEP ${TARGET} $(notdir $^)
@$(OCAMLDEP) -native $(INCLUDES) $^ > $@
clean::
-rm -f .depend
-find \( -name \*.mli.deps -or -name \*.ml.deps \) -delete