my-env/gen-makefile

93 lines
2.4 KiB
Plaintext
Raw Normal View History

#!/bin/bash
mv Makefile Makefile.bak
2022-08-26 00:25:55 +00:00
CHR_UPGRADE='^'
CHR_UNINSTALL='/'
2022-08-19 13:26:09 +00:00
cat << EOF >> Makefile
# Autogenerated at $(date +'%d.%m.%Y %H:%M') using ${BASH_SOURCE[0]}
.DEFAULT_GOAL := help
#===============================================
# Scripts listed in ./packs
#===============================================
2022-08-19 13:26:09 +00:00
EOF
2022-07-04 11:34:00 +00:00
for file in ./packs/*; do
cat "$file" >> Makefile
2022-07-04 14:22:05 +00:00
echo >> Makefile
2022-07-04 11:34:00 +00:00
done;
cat << EOF >> Makefile
#===============================================
# Scripts listed in ./install
#===============================================
EOF
2022-07-04 11:34:00 +00:00
for file in ./install/*; do
name=${file##*/}
name=${name%.sh}
2022-07-04 11:08:37 +00:00
desc=$(grep -m 1 -oP "(?<=^##makedesc:\s).*$" ${file})
[ -z "$desc" ] && desc='<no description>'
2022-08-25 14:33:02 +00:00
echo -e "# ${desc}\n${name}:\n\t@${file}\n" >> Makefile
done;
2022-08-26 00:25:55 +00:00
cat << EOF >> Makefile
#===============================================
# Scripts listed in ./upgrade
#===============================================
EOF
for file in ./upgrade/*; do
name=${file##*/}
name=${name%.sh}
desc=$(grep -m 1 -oP "(?<=^##makedesc:\s).*$" ${file})
[ -z "$desc" ] && desc='<no description>'
echo -e "# ${desc}\n${CHR_UPGRADE}${name}:\n\t@${file}\n" >> Makefile
done;
cat << EOF >> Makefile
#===============================================
# Scripts listed in ./uninstall
#===============================================
EOF
for file in ./uninstall/*; do
name=${file##*/}
name=${name%.sh}
desc=$(grep -m 1 -oP "(?<=^##makedesc:\s).*$" ${file})
[ -z "$desc" ] && desc='<no description>'
echo -e "# ${desc}\n${CHR_UNINSTALL}${name}:\n\t@${file}\n" >> Makefile
done;
cat << EOF >> Makefile
#===============================================
# Service goals
#===============================================
self:
@./gen-makefile
2022-08-25 14:33:02 +00:00
help: Makefile
@echo "Ubuntu software installator"
@echo
2022-08-26 00:25:55 +00:00
@echo "Usage:\n \
make help|- show this help\n \
make self|- regenerate Makefile (alias of ./gen-makefile)\n \
make GOAL|- install software\n \
make ${CHR_UPGRADE}GOAL|- upgrade software\n \
make ${CHR_UNINSTALL}GOAL|- uninstall software" | column -ts '|'
@echo "\nYou can combine GOALs, here are some examples:"
@echo "\tmake @docker docker"
@echo "\tmake php @docker ^omz"
@echo "\nAvailable GOALs:"
2022-08-25 14:33:02 +00:00
@sed -n '/^#/{N;s/# *\(.*\)\n\([^# .].*:\)/\t\2\1/p}' $< | column -ts ':'
EOF
echo "New ./Makefile has been generated!"
echo "Old one has been saved as ./Makefile.bak"
2022-08-26 00:25:55 +00:00
echo "Now run 'make' to get help"