
include libxputty/Build/Makefile.base

NOGOAL := mod install all features clap vst2

SWITCHGOAL := clap vst2

PASS := features 

SUBDIR := Loopino

.PHONY: $(SUBDIR) libxputty rubberband recurse 

$(MAKECMDGOALS) recurse: $(SUBDIR)

check-and-reinit-submodules :
ifeq (,$(filter $(NOGOAL),$(MAKECMDGOALS)))
ifeq (,$(findstring clean,$(MAKECMDGOALS)))
	@if git submodule status 2>/dev/null | egrep -q '^[-]|^[+]' ; then \
		echo "$(red)INFO: Need to reinitialize git submodules$(reset)"; \
		git submodule update --init; \
		echo "$(blue)Done$(reset)"; \
	else echo "$(blue)Submodule up to date$(reset)"; \
	fi
endif
endif

libxputty: check-and-reinit-submodules
ifeq (,$(filter $(NOGOAL),$(MAKECMDGOALS)))
ifeq (,$(wildcard ./libxputty/xputty/resources/dir.png))
	@cp ./Loopino/Resources/*.png ./libxputty/xputty/resources/
endif
	@exec $(MAKE) --no-print-directory -j 1 -C $@ $(MAKECMDGOALS)
endif
ifneq (,$(filter $(SWITCHGOAL),$(MAKECMDGOALS)))
ifeq (,$(wildcard ./libxputty/xputty/resources/dir.png))
	@cp ./Loopino/Resources/*.png ./libxputty/xputty/resources/
endif
	@exec $(MAKE) --no-print-directory -j 1 -C $@ all
endif

rubberband:
ifeq (,$(filter $(PASS),$(MAKECMDGOALS)))
	@exec $(MAKE) --no-print-directory -j 1 -f Makefile.rubberband $(MAKECMDGOALS)
endif

$(SUBDIR): libxputty rubberband
ifeq (,$(filter $(PASS),$(MAKECMDGOALS)))
	@exec $(MAKE) --no-print-directory -j 1 -C $@ $(MAKECMDGOALS)
endif

clean:
	@rm -f ./libxputty/xputty/resources/dir.png
	@rm -f ./libxputty/xputty/resources/exit_.png
	@rm -f ./libxputty/xputty/resources/load_.png
	@rm -f ./libxputty/xputty/resources/save_.png
	@rm -f ./libxputty/xputty/resources/play.png
	@rm -f ./libxputty/xputty/resources/clip_.png
	@rm -f ./libxputty/xputty/resources/quit.png
	@rm -f ./libxputty/xputty/resources/loop.png
	@rm -f ./libxputty/xputty/resources/okay.png
	@rm -f ./libxputty/xputty/resources/plus.png
	@rm -f ./libxputty/xputty/resources/loopino.png
	@rm -f ./libxputty/xputty/resources/presets.png
	@rm -f ./libxputty/xputty/resources/record.png
	@rm -f ./libxputty/xputty/resources/prev.png
	@rm -f ./libxputty/xputty/resources/next.png


features:
