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/_make42
1 files changed, 36 insertions, 6 deletions
diff --git a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make
index ae91440f0..99c786dc7 100644
--- a/Completion/Unix/Command/_make
+++ b/Completion/Unix/Command/_make
@@ -1,4 +1,4 @@
-#compdef make gmake pmake dmake freebsd-make bmake
+#compdef make gmake gnumake pmake dmake freebsd-make bmake
# TODO: Based on targets given on the command line, show only variables that
# are used in those targets and their dependencies.
@@ -118,10 +118,34 @@ _make-parseMakefile () {
done
}
+_make-parseDataBase () {
+ local input var TAB=$'\t' IFS= skip=0
+
+ while read input
+ do
+ if [[ $skip = 1 ]]; then
+ skip=0
+ continue
+ fi
+ case "$input " in
+ (\# Not a target*|\# environment*)
+ skip=1 # skip next line
+ ;;
+ ([[:alnum:]][[:alnum:]_]#[" "$TAB]#(\?|:|::|)=*)
+ var=${input%%[ $TAB]#(\?|:|::|)=*}
+ VARIABLES[$var]=1
+ ;;
+ ([[*?[:alnum:]$][^$TAB:=%]#:[^=]*)
+ TARGETS+=( ${input%%:*} )
+ ;;
+ esac
+ done
+}
+
_make() {
local prev="$words[CURRENT-1]" file expl tmp is_gnu incl match basedir nul=$'\0'
- local context state state_descr line
+ local curcontext=$curcontext state state_descr line
local -a option_specs
local -A VARIABLES VAR_ARGS opt_args
local -aU TARGETS keys
@@ -152,26 +176,28 @@ _make() {
'(-i --ignore-errors)'{-i,--ignore-errors}'[ignore errors from recipes]'
'*'{-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"'
+ '--jobserver-style=[select the style of jobserver to use]:style:(fifo pipe sem)'
'(-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 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"
'(-O --output-sync)'{-O-,--output-sync=-}'[synchronize output of parallel jobs]::granularity for grouping output:compadd -E 0 none line target recurse'
- '(-p --print-data-base)'{-p,--print-data-base}'[print makes internal database]'
+ '(-p --print-data-base)'{-p,--print-data-base}"[print make's internal database]"
'(-q --question)'{-q,--question}'[run no recipe; exit status says if up to date]'
'(-r --no-builtin-rules)'{-r,--no-builtin-rules}'[disable the built-in implicit rules]'
+ '--shuffle=-[perform shuffle of prerequisites and goals]::seed (integer) or mode:(random reverse none)'
'(-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]'
+ '--trace[print tracing information]'
'(- *)'{-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 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]'
)
else
# Basic make options only.
@@ -185,7 +211,7 @@ _make() {
)
fi
- _arguments -s $option_specs \
+ _arguments -C -S -s $option_specs \
'*:make target:->target' && ret=0
[[ $state = cdir ]] && cdir=-2
@@ -214,6 +240,10 @@ _make() {
;;
(target)
+ # target name starting with '-' is allowed only after '--'
+ if [[ $words[CURRENT] = -* ]] && (( ${words[(i)--]} > CURRENT )); then
+ return ret
+ fi
file=${(v)opt_args[(I)(-f|--file|--makefile)]}
if [[ -n $file ]]
then
@@ -239,7 +269,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" --always-make 2> /dev/null)
+ _make-parseDataBase < <(_call_program targets "$words[1]" -nqp --no-print-directory -f "$file" .DEFAULT 2> /dev/null)
else
_make-parseMakefile < $file
fi