summaryrefslogtreecommitdiff
path: root/Completion/Unix/Command/_make
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Unix/Command/_make')
-rw-r--r--Completion/Unix/Command/_make65
1 files changed, 21 insertions, 44 deletions
diff --git a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make
index e23906373..21ed56184 100644
--- a/Completion/Unix/Command/_make
+++ b/Completion/Unix/Command/_make
@@ -118,40 +118,14 @@ _make-parseMakefile () {
done
}
-_make-findBasedir () {
- local file index basedir
- basedir=$PWD
- for (( index=0; index < $#@; index++ ))
- do
- if [[ $@[index] == -C ]]
- then
- file=${~@[index+1]} 2>/dev/null
- if [[ -z $file ]]
- then
- # make returns with an error if an empty arg is given
- # even if the concatenated path is a valid directory
- return
- elif [[ $file == /* ]]
- then
- # Absolute path, replace base directory
- basedir=$file
- else
- # Relative, concatenate path
- basedir=$basedir/$file
- fi
- fi
- done
- print -- $basedir
-}
-
_make() {
- local prev="$words[CURRENT-1]" file expl tmp is_gnu incl match
+ local prev="$words[CURRENT-1]" file expl tmp is_gnu incl match basedir nul=$'\0'
local context state state_descr line
local -a option_specs
local -A VARIABLES VAR_ARGS opt_args
local -aU TARGETS keys
- local ret=1
+ local -i cdir=-1 ret=1
# VAR=VAL on the current command line
for tmp in $words; do
@@ -168,18 +142,18 @@ _make() {
incl="(-|)include"
option_specs=(
'(-B --always-make)'{-B,--always-make}'[unconditionally make all targets]'
- '*'{-C,--directory=}'[change directory first]:change to directory:->dir'
+ '*'{-C,--directory=}'[change directory first]:change to directory:->cdir'
'-d[print lots of debug information]'
'--debug=-[print various types of debug information]:debug options:->debug'
'(-e --environment-overrides)'{-e,--environment-overrides}'[environment variables override makefiles]'
- '--eval=-[evaluate STRING as a makefile statement]:STRING'
- '(-f --file --makefile)'{-f,--file=,--makefile=}'[read FILE as a makefile]:makefile:->file'
+ \*{-E+,--eval=-}'[evaluate string as a makefile statement]:string'
+ '(-f --file --makefile)'{-f,--file=,--makefile=}'[read specified file as a makefile]:makefile:->file'
'(- *)'{-h,--help}'[print help message and exit]'
'(-i --ignore-errors)'{-i,--ignore-errors}'[ignore errors from recipes]'
- '*'{-I,--include-dir=}'[search DIRECTORY for included makefiles]:search path for included makefile:->dir'
- '(-j --jobs)'{-j+,--jobs=}'[allow N jobs at once; infinite jobs with no arg]:number of jobs'
+ '*'{-I,--include-dir=}'[search specified directory for included makefiles]:search path for included makefile:->dir'
+ '(-j --jobs)'{-j+,--jobs=}'[allow specified number of parallel jobs; unlimited jobs with no arg]:: : _guard "[0-9]#" "number of jobs"'
'(-k --keep-going)'{-k,--keep-going}"[keep going when some targets can't be made]"
- '(-l --load-average --max-load)'{-l,--load-average=,--max-load}"[don't start multiple jobs unless load is below N]:load"
+ '(-l --load-average --max-load)'{-l,--load-average=,--max-load}"[don't start multiple jobs unless load is below specified value]:load"
'(-L --check-symlink-times)'{-L,--check-symlink-times}'[use the latest mtime between symlinks and target]'
'(-n --just-print --dry-run --recon)'{-n,--just-print,--dry-run,--recon}"[don't actually run any recipe; just print them]"
'*'{-o,--old-file=,--assume-old=}"[consider specified file to be old and don't remake it]:file not to remake:->file"
@@ -189,12 +163,13 @@ _make() {
'(-r --no-builtin-rules)'{-r,--no-builtin-rules}'[disable the built-in implicit rules]'
'(-R --no-builtin-variables)'{-R,--no-builtin-variables}'[disable the built-in variable settings]'
'(-s --silent --quiet)'{-s,--silent,--quiet}"[don't echo recipes]"
+ '--no-silent[echo recipes (disable --silent mode)]'
'(-S --no-keep-going --stop)'{-S,--no-keep-going,--stop}'[turns off -k]'
'(-t --touch)'{-t,--touch}'[touch targets instead of remaking them]'
'(- *)'{-v,--version}'[print the version number of make and exit]'
'(-w --print-directory)'{-w,--print-directory}'[print the current directory]'
'--no-print-directory[turn off -w, even if it was turned on implicitly]'
- '*'{-W,--what-if=,--new-file=,--assume-new=}'[consider FILE to be infinitely new]:file to treat as modified:->file'
+ '*'{-W,--what-if=,--new-file=,--assume-new=}'[consider specified file to be infinitely new]:file to treat as modified:->file'
'--warn-undefined-variables[warn when an undefined variable is referenced]'
'--warn-undefined-functions[warn when an undefined user function is called]'
)
@@ -202,7 +177,7 @@ _make() {
# Basic make options only.
incl=.include
option_specs=(
- '-C[change directory first]:directory:->dir'
+ '-C[change directory first]:directory:->cdir'
'-I[include directory for makefiles]:directory:->dir'
'-f[specify makefile]:makefile:->file'
'-o[specify file not to remake]:file not to remake:->file'
@@ -213,15 +188,19 @@ _make() {
_arguments -s $option_specs \
'*:make target:->target' && ret=0
+ [[ $state = cdir ]] && cdir=-2
+ basedir=${(j./.)${${~"${(@s.:.):-$PWD:${(Q)${opt_args[-C]:-$opt_args[--directory]}//\\:/$nul}}"}[(R)/*,cdir]}//$nul/:}
+ VAR_ARGS[CURDIR]="${basedir}"
+
case $state in
- (dir)
+ (*dir)
_description directories expl "$state_descr"
- _files "$expl[@]" -W ${(q)$(_make-findBasedir ${words[1,CURRENT-1]})} -/ && ret=0
+ _files "$expl[@]" -W $basedir -/ && ret=0
;;
(file)
_description files expl "$state_descr"
- _files "$expl[@]" -W ${(q)$(_make-findBasedir $words)} && ret=0
+ _files "$expl[@]" -W $basedir && ret=0
;;
(debug)
@@ -238,11 +217,9 @@ _make() {
file=${(v)opt_args[(I)(-f|--file|--makefile)]}
if [[ -n $file ]]
then
- [[ $file == [^/]* ]] && file=${(q)$(_make-findBasedir $words)}/$file
+ [[ $file == [^/]* ]] && file=$basedir/$file
[[ -r $file ]] || file=
else
- local basedir
- basedir=${$(_make-findBasedir $words)}
if [[ $is_gnu == gnu && -r $basedir/GNUmakefile ]]
then
file=$basedir/GNUmakefile
@@ -262,7 +239,7 @@ _make() {
if [[ $is_gnu == gnu ]]
then
if zstyle -t ":completion:${curcontext}:targets" call-command; then
- _make-parseMakefile < <(_call_program targets "$words[1]" -nsp --no-print-directory -f "$file" .PHONY 2> /dev/null)
+ _make-parseMakefile < <(_call_program targets "$words[1]" -nsp --no-print-directory -f "$file" --always-make 2> /dev/null)
else
_make-parseMakefile < $file
fi
@@ -286,7 +263,7 @@ _make() {
_alternative \
'targets:make target:compadd -Q -a TARGETS' \
'variables:make variable:compadd -S = -F keys -k VARIABLES' \
- '*:file:_files' && ret=0
+ '*:file:_files -W $basedir' && ret=0
fi
esac