# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2023, guoct1@chinatelecom.cn.
#
MAKE := /usr/bin/env make
ODIR := ../../build/bin
subdirs = $(shell find . -maxdepth 1 -mindepth 1 -type d -printf "%f\n")
.phony: all build collect clean %.all %.build %.collect %.clean

all: $(addsuffix .all, $(subdirs))
	echo "uctuts all finished!"
%.all: %
	$(MAKE) -C $* && \
	../../scripts/collect-bin.sh $* $(ODIR)/$* && \
	$(MAKE) -C $* clean
build: $(addsuffix .build, $(subdirs))
	echo "uctuts build finished!"
%.build: %
	$(MAKE) -C $*

collect: $(addsuffix .collect, $(subdirs))
	echo "uctuts collect finished!"
%.collect: %
	../../scripts/collect-bin.sh $* $(ODIR)/$*

clean: $(addsuffix .clean, $(subdirs))
	echo "uctuts clean finished!"
%.clean: %
	$(MAKE) -C $* clean
