Adam Borowski wrote: > # Hairy, but safe against locales and changed error messages. > make -f /dev/null build-indep 2>unique-tmp-1 > (debian/rules build-indep && rm unique-tmp-1) 3>&1 1>&2 2>&3 |tee unique-tmp-2 > cmp -s unique-tmp-1 unique-tmp-2 > case $? in > 0) echo "The build-indep target doesn't exist, falling back to 'build'." > debian/rules build;RET=$? ;; > 1) RET=2 ;; > 2) RET=0 ;; > esac
This fails in cases where the makefile emits something to stderr when setting a variable, which can happen even for non-existing rules. Makefiles with global pattern rules (as used with dh) are also misdetected. A more robust method would be to populate unique-tmp-1 by running debian/rules this-dummy-target-better-not-really-exist Or, make could be patched to have a mode where it generates stable, machine-parseable error and status message codes. Then just look for the one that corresponds to "*** No rule to make target" or the one that indicates a rule has been run. -- see shy jo
signature.asc
Description: Digital signature