From 1ca84fa680dce0d6b467eb5ba7d02b3f6f11fde2 Mon Sep 17 00:00:00 2001 From: David Paleino Date: Thu, 11 Dec 2008 20:13:16 +0100 Subject: [PATCH] * Merge from Gentoo: - use make -qp to parse the Makefile for us, so we get proper completion on things like pattern rules. Patch by Mike Kelly . --- bash_completion | 29 +++++++---------------------- debian/changelog | 4 +++- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/bash_completion b/bash_completion index a211ef76..a4df9a9a 100644 --- a/bash_completion +++ b/bash_completion @@ -2851,17 +2851,6 @@ _make() fi done - # make reads `GNUmakefile', then `makefile', then `Makefile' - if [ -f ${makef_dir}/GNUmakefile ]; then - makef=${makef_dir}/GNUmakefile - elif [ -f ${makef_dir}/makefile ]; then - makef=${makef_dir}/makefile - elif [ -f ${makef_dir}/Makefile ]; then - makef=${makef_dir}/Makefile - else - makef=${makef_dir}/*.mk # local convention - fi - # before we scan for targets, see if a Makefile name was # specified with -f for (( i=0; i < ${#COMP_WORDS[@]}; i++ )); do @@ -2872,18 +2861,14 @@ _make() fi done - [ ! -f $makef ] && return 0 + [ -n "$makef" ] && makef="-f ${makef}" + [ -n "$makef_dir" ] && makef_dir="-C ${makef_dir}" + + COMPREPLY=( $( make -qp $makef $makef_dir 2>/dev/null | \ + awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ \ + {split($1,A,/ /);for(i in A)print A[i]}' | \ + command grep "^$cur" )) - # deal with included Makefiles - makef_inc=$( grep -E '^-?include' $makef | sed -e "s,^.* ,"$makef_dir"/," ) - - for file in $makef_inc; do - [ -f $file ] && makef="$makef $file" - done - - COMPREPLY=( $( awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ \ - {split($1,A,/ /);for(i in A)print A[i]}' \ - $makef 2>/dev/null | command grep "^$cur" )) fi } && complete -f -F _make $filenames make gmake gnumake pmake diff --git a/debian/changelog b/debian/changelog index ee26b6bd..1893b72e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -49,13 +49,15 @@ bash-completion (200811xx) UNRELEASED; urgency=low * Merge from Gentoo: - fix 'find' completion so that it properly completes on -?(i)whilename. Patch by Ciaran McCreesh. + - use make -qp to parse the Makefile for us, so we get proper completion + on things like pattern rules. Patch by Mike Kelly . * debian/links fixed (Closes: #494292) * debian/control: - fixed typo in the long description * debian/install: - correctly install contrib/* under /etc/bash_completion.d/ - -- David Paleino Tue, 25 Nov 2008 13:40:03 +0100 + -- David Paleino Thu, 11 Dec 2008 20:12:21 +0100 bash-completion (20080705) unstable; urgency=low