96 lines
2.5 KiB
Makefile
96 lines
2.5 KiB
Makefile
# git helper Makefile: Version 1.5 (2025-08-05)
|
|
default: help
|
|
|
|
.ONESHELL:
|
|
SHELL = /usr/bin/bash
|
|
.SILENT:
|
|
|
|
-include make.d/*.mk
|
|
|
|
GIT_FLAG = ./.git
|
|
VENV_FLAG = ./.venv_required
|
|
VENV_FOLDER = ./venv
|
|
|
|
localhelp:
|
|
|
|
help:
|
|
echo "Possible common options are:"
|
|
echo " - init - Initialise the repository and all folders below with a Makefile"
|
|
echo " - giti - Get the git status of all submodules including their submodules"
|
|
echo " - update_submodules - Set all submodules to remote master"
|
|
echo " - venv_flag - Set the venev flag for the base folder. A venv will be generated"
|
|
echo " - clean - clean up"
|
|
echo " - deepclean - clean up this and all Makefiles below"
|
|
$(MAKE) localhelp
|
|
echo "You are able to create files make.d/*.mk and add local rules there. "
|
|
echo " - localinit: print_head - Will be executed as last step in the init process."
|
|
echo " - localhelp: print_head - Will be executed in th middle of the help text generation"
|
|
echo " - localclean:print_head - Will be executed before the clean rule"
|
|
|
|
localinit:
|
|
|
|
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 local init
|
|
$(MAKE) localinit
|
|
|
|
update_submodules:
|
|
git submodule foreach "git checkout master && git pull && git submodule init && git submodule update"
|
|
|
|
giti_sub: print_head
|
|
giti
|
|
echo " Submodules:"
|
|
git submodule --quiet foreach "echo -n ' ' && giti"
|
|
|
|
giti:
|
|
git submodule --quiet foreach make --no-print-directory giti_sub
|
|
|
|
localclean:
|
|
|
|
clean: localclean
|
|
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"
|
|
|