my-env/gen-makefile

35 lines
838 B
Plaintext
Raw Normal View History

#!/bin/bash
mv Makefile Makefile.bak
2022-07-04 11:08:37 +00:00
echo -e "# Autogenerated at $(date +'%d.%m.%Y %H:%M') using ${BASH_SOURCE[0]}\n" > Makefile
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;
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-07-04 11:34:00 +00:00
echo -e "##${name}: ${desc}\n${name}:\n\t${file}\n" >> Makefile
done;
cat << EOF >> Makefile
2022-07-04 11:34:00 +00:00
##help: Show this help message
help: Makefile
@echo "Usage:"
@echo "\tmake <goal>\n"
@echo "Available goals:"
2022-07-04 15:53:39 +00:00
@sed -n 's/^##//p' \$< | column -t -s ':' | sed -e "s/^/\t/"
2022-07-04 14:22:05 +00:00
##<goal>_: Same as 'cat ./install/<goal>'
%_:
2022-07-04 14:22:05 +00:00
@cat ./install/\$*
EOF
echo "New ./Makefile has been generated!"
echo "Old one has been saved as ./Makefile.bak"
echo
make help