# variables
PROJECT_DIR := tuxbake
DATE = date +%Y%m%d
REPOSITORY := docker.io
CONTAINER := buildah

##  buildah command to build containers with two different tags \
	tag - 1 = repository/project-dir/container-dir:latest \
	tag - 2 = repository/project-dir/container-dir:yyyymmdd \

list := centos-8 \
       debian-bookworm debian-trixie debian-forky \
       fedora-43 fedora-44 \
       opensuse-leap-15.2 \
       ubuntu-18.04 ubuntu-20.04 ubuntu-22.04 ubuntu-24.04

help:
	@echo "Makefile arguments:"
	@echo ""
	@echo "list=$(list)"
	@echo "specify one target by add that to the list."
	@echo ""
	@echo ""
	@echo "Make commands:"
	@echo ""
	@echo "build"
	@echo "publish"
	@echo "all"
	@echo ""
	@echo "Example command:"
	@echo ""
	@echo "make all"
	@echo "make list=ubuntu-20.04 build"

.DEFAULT_GOAL := all

build:
	for os in $(list); do echo $$os ; $(CONTAINER) build --sbom syft --sbom-output sbom-$$os.json -t $(REPOSITORY)/$(PROJECT_DIR)/$$os:latest -t $(REPOSITORY)/$(PROJECT_DIR)/$$os:$$($(DATE)) $$os/. ; done

publish: build
	for os in $(list); do echo $$os ; $(CONTAINER) push $(REPOSITORY)/$(PROJECT_DIR)/$$os:latest ; done

all: build
