INSTALL_DIR := /usr/sbin
CURR_DIR := $(shell pwd)
TOOLS := $(wildcard $(CURR_DIR)/mx-*)
DEP_LIBS = mx-gpio-lib mx-common-lib

.PHONY: install $(TOOLS) clean

all: install

install: $(TOOLS) install_dep_libs

$(TOOLS): install_dep_libs
	@echo "Install $(notdir $@) to $(INSTALL_DIR)"
	@install -m 755 $@ $(INSTALL_DIR)

install_dep_libs:
	@make -C $(SRC_DIR)/lib/ LIBS="$(DEP_LIBS)"

clean:
	@rm -f $(addprefix $(INSTALL_DIR)/, $(notdir $(TOOLS)))
	@make -C $(SRC_DIR)/lib clean
