80 lines
1.7 KiB
Makefile
80 lines
1.7 KiB
Makefile
# Version 1.2 (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
|
|
# Init submodules
|
|
for subdir in $$(find . -maxdepth 2 -mindepth 2 -name Makefile | sort); do
|
|
$(MAKE) --no-print-directory -C $$(dirname $$subdir) init
|
|
done
|
|
# Create venv if needed
|
|
if [[ -e $(VENV_FLAG) ]]; then
|
|
if [[ ! -e $(VENV_FOLDER) ]]; then
|
|
mkvenv
|
|
fi
|
|
fi
|
|
# Start my init script if needed
|
|
if [[ -x $(INIT_FILE) ]]; then
|
|
$(INIT_FILE)
|
|
fi
|
|
|
|
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"
|
|
|