#!/usr/bin/make -f

thisdir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))

all: $(thisdir)/config.yml
.PHONY: all

$(thisdir)/yq: $(thisdir)/yq.d/go.mod
	cd $(<D) && go build -o $(abspath $@) github.com/mikefarah/yq/v3

$(thisdir)/config.yml: $(thisdir)/yq $(MAKEFILE_LIST) $(thisdir)/config.yml.d $(sort $(wildcard $(thisdir)/config.yml.d/*.yml))
	{ echo '# Generated by `./generate`. DO NOT EDIT.'; echo; $(<D)/$(<F) merge $(filter %.yml,$^); } > $@

.DELETE_ON_ERROR:
.SECONDARY:
