APP_NAME = gmplugin_hello
GAJUMARU_LIB = lib/gajumaru
BUILD_DIR = $(GAJUMARU_LIB)/_build/prod/rel/gajumaru
TARGET_NETWORK = localnet

# steps are
# 1. call rebar3 gm_plugin to build the plugin
# 2. build the node
# 3. start the node with a configuration where it knows it needs to load our plugin
# 4. run a shell in the node context


all: compile

init: submodules

submodules: gajumaru
	git submodule init
	git submodule update
	ln -sfn $(GAJUMARU_LIB) gajumaru

compile:
	rebar3 compile

# adapted from gmp_ix
build-gm-with-my-plugin: init compile
	cp _build/default/$(APP_NAME).ez $(GAJUMARU_LIB)/plugins
	cd $(GAJUMARU_LIB) && make prod-build
	cp -rvf gmconfig/$(TARGET_NETWORK)/gajumaru/* $(BUILD_DIR)

fresh-console: build-gm-with-my-plugin console

console:
	$(BUILD_DIR)/bin/gajumaru console

clean:
	rebar3 clean
	cd $(GAJUMARU_LIB) && make prod-clean
	rm -f $(GAJUMARU_LIB)/plugins/$(APP_NAME).ez
