minor bugfixes, Makefile name parameter for do_make

This commit is contained in:
Jörn-Michael Miehe 2019-09-21 00:55:03 +02:00
parent e782a6f5ea
commit ac0d9d08b5

View file

@ -4,27 +4,28 @@
g_watchroot="$(readlink -f "${1:-.}")" g_watchroot="$(readlink -f "${1:-.}")"
# compile using bare make command # compile using bare make command
do_make() { # $1:DIR $2:OBJECT do_make() { # $1:DIR $2:MAKEFILE $3:OBJECT
# extract params # extract params
local dir="$1" local dir="$1"
local object="$2" local makefile="$2"
local object="$3"
# extract Makefile 'source pattern' # extract Makefile 'source pattern'
local srcpat="$(grep -E "^#@SRCPAT" "${dir}/Makefile" | tail -n 1 | sed -r "s/^#@SRCPAT\s+//")" local srcpat="$(grep -E "^#@SRCPAT" "${dir}/${makefile}" | tail -n 1 | sed -r "s/^#@SRCPAT\s+//")"
if [ -z "${srcpat}" ]; then if [ -z "${srcpat}" ]; then
echo "Empty source pattern! Makefile needs '#@SRCPAT' annotation!" echo "Empty source pattern, check '#@SRCPAT' annotation!"
elif [[ "${object}" =~ ${srcpat} ]]; then elif [[ "${object}" =~ ${srcpat} ]]; then
# check for autodoc target # check for autodoc target
local target="$(grep -E "^autodoc:" "${dir}/Makefile" | sed -r "s/:.*$//")" local target="$(grep -E "^autodoc:" "${dir}/${makefile}" | sed -r "s/:.*$//")"
local target="${target:-all}" # local target="${target:-all}" # fallback target: all
echo "SRCPAT OK, building '${target}'." echo "Making '${target}'."
make --no-print-directory -C "${dir}" -j "${target}" make --no-print-directory -C "${dir}" -j ${target}
else else
echo "SRCPAT mismatch '${srcpat}'." echo "SRCPAT '${srcpat}' mismatch."
fi fi
} }
@ -39,16 +40,15 @@ do_compile() { # $1:DIR $2:OBJECT $3:DONE
if [ -r "${dir}/Makefile" ]; then if [ -r "${dir}/Makefile" ]; then
# Makefile found # Makefile found
echo -n "Using '${dir}/Makefile'. " echo -n "Found '${dir}/Makefile'. "
do_make "${dir}" "${object}" do_make "${dir}" "Makefile" "${object}"
local done="1" local done="1"
fi fi
# search parent dir for more build instructions # never leave $g_watchroot
if [ "${dir}" != "${g_watchroot}" ]; then if [ "${dir}" != "${g_watchroot}" ]; then
# never leave $g_watchroot # search parent dir for more build instructions
local dir="$(dirname "${dir}")" do_compile "$(dirname "${dir}")" "${object}" "${done}"
do_compile "${dir}" "${object}" "${done}"
elif [ "${done}" == "0" ]; then elif [ "${done}" == "0" ]; then
# hit $g_watchroot # hit $g_watchroot