starter/Makefile

80 lines
1.6 KiB
Makefile

# Version 1.1 (2025-08-05)
default: help
.ONESHELL:
SHELL = /usr/bin/bash
.SILENT:
GIT_FLAG = ./.git
VENV_FLAG = ./.venv_required
VENV_FOLDER = ./venv
INIT_FILE = ./init
help:
echo "Possible options are: init, status, venv_flag, clean, cleanall"
init: print_head
# Init git repo
if [[ -e $(GIT_FLAG) ]]; then
git submodule init
git submodule update
fi
# Create venv if needed
if [[ -e $(VENV_FLAG) ]]; then
if [[ ! -e $(VENV_FOLDER) ]]; then
mkvenv
fi
fi
if [[ -x $(INIT_FILE) ]]; then
$(INIT_FILE)
fi
initall:
for subdir in $$(find . -maxdepth 2 -mindepth 2 -name Makefile | sort); do
$(MAKE) --no-print-directory -C $$(dirname $$subdir) init
done
status: print_head
giti
echo "Submodules:"
echo "-----------"
git submodule --quiet foreach giti
statusall:
for subdir in $$(find . -maxdepth 2 -mindepth 2 -name Makefile | sort); do
$(MAKE) --no-print-directory -C $$(dirname $$subdir) status
done
clean:
if [[ ! -e $(VENV_FLAG) ]]; then
if [[ -d $(VENV_FOLDER) ]]; then
rm -rf $(VENV_FOLDER)
fi
fi
cleanall: clean
for subdir in $$(find . -maxdepth 2 -mindepth 2 -name Makefile | sort); do
$(MAKE) --no-print-directory -C $$(dirname $$subdir) cleanall
done
venv_flag:
if [[ ! -e $(VENV_FLAG) ]]; then
touch $(VENV_FLAG)
if [[ -e $(GIT_FLAG) ]]; then
git add $(VENV_FLAG)
fi
fi
print_head:
DIRNAME=$$(basename $$(pwd))
DIRLENGTH=$${#DIRNAME}
echo -ne "\n\n\033[1;34m╔═"
for i in $$(seq 1 $$DIRLENGTH); do echo -n "═"; done
echo -e "═╗"
echo -e "$$DIRNAME ║"
echo -ne "╚═"
for i in $$(seq 1 $$DIRLENGTH); do echo -n "═"; done
echo -e "═╝\033[00m"