2009-05-21 01:37:14 +02:00
|
|
|
# bash completion for GNU make
|
|
|
|
|
2011-04-05 00:35:51 +03:00
|
|
|
have make || have gmake || have gnumake || have pmake || return
|
|
|
|
|
2009-05-21 01:37:14 +02:00
|
|
|
_make()
|
|
|
|
{
|
2011-05-01 22:18:40 +03:00
|
|
|
local cur prev words cword split
|
|
|
|
_init_completion -s || return
|
2009-05-21 01:37:14 +02:00
|
|
|
|
2011-05-01 22:18:40 +03:00
|
|
|
local file makef makef_dir="." makef_inc i
|
2009-05-21 01:37:14 +02:00
|
|
|
|
2009-10-04 19:42:50 +02:00
|
|
|
case $prev in
|
2009-11-22 11:43:26 +01:00
|
|
|
-f|-o|-W|--file|--makefile|--old-file|--new-file|--assume-old|--assume-new|--what-if)
|
2009-10-04 19:42:50 +02:00
|
|
|
_filedir
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
-I|-C|--directory|--include-dir)
|
|
|
|
_filedir -d
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
2009-05-21 01:37:14 +02:00
|
|
|
|
2009-10-04 19:42:50 +02:00
|
|
|
$split && return 0
|
2009-05-21 01:37:14 +02:00
|
|
|
|
2009-10-04 19:42:50 +02:00
|
|
|
if [[ "$cur" == -* ]]; then
|
|
|
|
COMPREPLY=( $( compgen -W '-b -m -B -C -d -e -f -h -i -I\
|
|
|
|
-j -l -k -n -o -p -q -r -R - s -S -t -v -w -W \
|
|
|
|
--always-make --directory --debug \
|
|
|
|
--environment-overrides --file --makefile --help \
|
|
|
|
--ignore-errors --include-dir --jobs --load-average \
|
|
|
|
--max-load --keep-going --just-print --dry-run \
|
|
|
|
--recon --old-file --assume-old --print-data-base \
|
|
|
|
--question --no-builtin-rules --no-builtin-variables \
|
|
|
|
--silent --quiet --no-keep-goind --stop --touch \
|
|
|
|
--version --print-directory --no-print-directory \
|
|
|
|
--what-if --new-file --assume-new \
|
|
|
|
--warn-undefined-variables' -- "$cur" ) )
|
|
|
|
else
|
|
|
|
# before we check for makefiles, see if a path was specified
|
2010-01-19 23:14:46 +02:00
|
|
|
# with -C/--directory
|
2011-04-20 22:42:55 +03:00
|
|
|
for (( i=0; i < ${#words[@]}; i++ )); do
|
|
|
|
if [[ ${words[i]} == -@(C|-directory) ]]; then
|
2009-10-04 19:42:50 +02:00
|
|
|
# eval for tilde expansion
|
2011-04-20 22:42:55 +03:00
|
|
|
eval makef_dir=${words[i+1]}
|
2009-10-04 19:42:50 +02:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2009-05-21 01:37:14 +02:00
|
|
|
|
2009-10-04 19:42:50 +02:00
|
|
|
# before we scan for targets, see if a Makefile name was
|
2010-01-19 23:14:46 +02:00
|
|
|
# specified with -f/--file/--makefile
|
2011-04-20 22:42:55 +03:00
|
|
|
for (( i=0; i < ${#words[@]}; i++ )); do
|
|
|
|
if [[ ${words[i]} == -@(f|-?(make)file) ]]; then
|
2009-10-04 19:42:50 +02:00
|
|
|
# eval for tilde expansion
|
2011-04-20 22:42:55 +03:00
|
|
|
eval makef=${words[i+1]}
|
2009-10-04 19:42:50 +02:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2009-05-21 01:37:14 +02:00
|
|
|
|
2009-10-04 19:42:50 +02:00
|
|
|
[ -n "$makef" ] && makef="-f ${makef}"
|
|
|
|
[ -n "$makef_dir" ] && makef_dir="-C ${makef_dir}"
|
2009-07-25 13:38:42 +03:00
|
|
|
|
2009-10-04 19:42:50 +02:00
|
|
|
COMPREPLY=( $( compgen -W "$( 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]}' )" \
|
|
|
|
-- "$cur" ) )
|
2009-05-21 01:37:14 +02:00
|
|
|
|
2009-10-04 19:42:50 +02:00
|
|
|
fi
|
2009-05-21 01:37:14 +02:00
|
|
|
} &&
|
2010-11-01 19:26:53 +02:00
|
|
|
complete -F _make make gmake gnumake pmake
|
2009-10-01 20:54:51 +03:00
|
|
|
|
|
|
|
# Local variables:
|
|
|
|
# mode: shell-script
|
2009-10-04 19:42:50 +02:00
|
|
|
# sh-basic-offset: 4
|
2009-10-01 20:54:51 +03:00
|
|
|
# sh-indent-comment: t
|
2009-10-04 19:42:50 +02:00
|
|
|
# indent-tabs-mode: nil
|
2009-10-01 20:54:51 +03:00
|
|
|
# End:
|
2009-10-04 19:42:50 +02:00
|
|
|
# ex: ts=4 sw=4 et filetype=sh
|