ligo/test/Makefile.shared
Grégoire Henry 370112f9b8 Makefile: simplify the compilation process.
This patch is co-authored with: cagdas.bozman@ocamlpro.com

With this patch the economic protocol is now compiled as as
"functor-pack", parameterized over the environment. This will ease the
protocol reusability outside of the tezos source tree (e.g. for a
michelson Web IDE) and will allow proper unit testing of the economic
protocol.

This functorization allows to break the dependency of the
'tezos-protocol-compiler' on various '.mli' of the node, and hence
we don't need anymore the unusual compilation schema:

  a.mli -> b.mli -> b.ml -> a.ml

where 'A' is linked after 'B' but 'a.mli' should still be compiled
before 'b.mli'. This will simplify a switch to 'ocp-build' or 'jbuiler'.
2017-10-11 13:44:09 +00:00

116 lines
3.6 KiB
Makefile

ifeq ($(strip ${SRCDIR}),)
$(error "Undefined value for $${SRCDIR}")
endif
.PHONY: build run
all:
@${MAKE} --no-print-directory build
@${MAKE} --no-print-directory run
build: ${addprefix test-,${TESTS}}
run:
@$(patsubst %,${MAKE} --no-print-directory run-test-% && , ${TESTS}) \
echo && echo "Success" && echo
############################################################################
-include ${SRCDIR}/Makefile.local
include ${SRCDIR}/Makefile.config
include ${SRCDIR}/Makefile.files
COVERAGESRCDIR=$(patsubst %, -I %, $(SOURCE_DIRECTORIES))
############################################################################
## External packages
############################################################################
TESTLIB := ${SRCDIR}/../test/lib/testlib.cmxa
${TESTLIB}: $(shell find ${SRCDIR}/../test/lib -name \*.ml -or -name \*.mli)
${MAKE} -C ${SRCDIR}/../test/lib testlib.cmxa
############################################################################
## External packages
############################################################################
PACKERLIB := ${SRCDIR}/packer.cmxa
MINUTILSLIB := ${SRCDIR}/minutils.cmxa
UTILSLIB := ${SRCDIR}/utils.cmxa
COMPILERLIB := ${SRCDIR}/compiler.cmxa
NODELIB := ${SRCDIR}/node.cmxa
CLIENTLIB := ${SRCDIR}/client.cmxa \
$(patsubst ${SRCDIR}/client/embedded/%/, \
${SRCDIR}/client/embedded/client_%.cmx, \
$(shell ls -d ${SRCDIR}/client/embedded/*/))
${MINUTILSLIB} ${UTILSLIB} ${COMPILERLIB} ${NODELIB} ${CLIENTLIB}:
${MAKE} -C ${SRCDIR} $@
${SRCDIR}/minutils/%.cmi: ${SRCDIR}/minutils/%.mli
${MAKE} -C ${SRCDIR} minutils.cmxa
${SRCDIR}/minutils/%.cmx : ${SRCDIR}/minutils/%.ml
${MAKE} -C ${SRCDIR} minutils.cmxa
${SRCDIR}/utils/%.cmi: ${SRCDIR}/utils/%.mli
${MAKE} -C ${SRCDIR} utils.cmxa
${SRCDIR}/utils/%.cmx : ${SRCDIR}/utils/%.ml
${MAKE} -C ${SRCDIR} utils.cmxa
${SRCDIR}/compiler/%.cmi: ${SRCDIR}/compiler/%.mli
${MAKE} -C ${SRCDIR} compiler.cmxa
${SRCDIR}/compiler/%.cmx : ${SRCDIR}/compiler/%.ml
${MAKE} -C ${SRCDIR} compiler.cmxa
${SRCDIR}/node/db/%.cmi: ${SRCDIR}/node/db/%.mli
${MAKE} -C ${SRCDIR} node.cmxa
${SRCDIR}/node/db/%.cmx : ${SRCDIR}/node/db/%.ml
${MAKE} -C ${SRCDIR} node.cmxa
${SRCDIR}/node/net/%.cmi: ${SRCDIR}/node/net/%.mli
${MAKE} -C ${SRCDIR} node.cmxa
${SRCDIR}/node/net/%.cmx : ${SRCDIR}/node/net/%.ml
${MAKE} -C ${SRCDIR} node.cmxa
${SRCDIR}/node/shell/%.cmi: ${SRCDIR}/node/shell/%.mli
${MAKE} -C ${SRCDIR} node.cmxa
${SRCDIR}/node/shell/%.cmx : ${SRCDIR}/node/shell/%.ml
${MAKE} -C ${SRCDIR} node.cmxa
${SRCDIR}/node/updater/%.cmi: ${SRCDIR}/node/updater/%.mli
${MAKE} -C ${SRCDIR} node.cmxa
${SRCDIR}/node/updater/%.cmx : ${SRCDIR}/node/updater/%.ml
${MAKE} -C ${SRCDIR} node.cmxa
${SRCDIR}/client/%.cmi: ${SRCDIR}/client/%.mli
${MAKE} -C ${SRCDIR} client.cmxa
${SRCDIR}/client/%.cmx : ${SRCDIR}/client/%.ml
${MAKE} -C ${SRCDIR} client.cmxa
############################################################################
## Generic rules
############################################################################
%.cmx: %.ml
@echo OCAMLOPT ${TARGET} $(notdir $@)
@$(OCAMLOPT) ${OCAMLFLAGS} -c $<
%.cmo: %.ml
@echo OCAMLC ${TARGET} $(notdir $@)
@$(OCAMLC) ${OCAMLFLAGS} -c $<
%.cmi: %.mli
@echo OCAMLOPT ${TARGET} $(notdir $@)
@$(OCAMLOPT) ${OCAMLFLAGS} -c $<
## Cleaning
.PHONY: clean partial-clean
clean:: partial-clean
partial-clean::
-find . \( -name \*.cm\* -or -name \*.cmp -or -name \*.out -or -name \*~ -or -name \*.o -or -name \*.a \) -delete
-include .depend
.depend: $(shell find . -name \*.mli -or -name \*.ml)
@echo OCAMLDEP "(test/$(notdir $(shell echo $$PWD)))"
@$(OCAMLDEP) -native $(INCLUDES) $^ > .depend
clean::
-rm .depend