Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: zsh make(1) completion on FreeBSD



Hi Daniel,

> I'd like to see this fixed but I'm not on FreeBSD right now.  Any chance
> you could write a patch?  I think there are two approaches, either (a)
> figure out what incantation of BSD make is equivalent to «gmake -nspf
> $file», or (b) use the -d switch to ask make what are the targets,
> variables, and other things that _make-parseMakefile extracts.

Baptiste (cc'ed) kindly sent me a patch he uses to get targets
completion [1]. Using it and adding variable completion, I got to the
following:

````
--- /usr/ports/shells/zsh/work/zsh-5.2/Completion/Unix/Command/_make
 2015-08-08 14:51:33.000000000 -0300
+++ /usr/local/share/zsh/5.2/functions/Completion/Unix/_make
2016-10-11 20:14:43.403084000 -0300
@@ -268,7 +268,14 @@
       else
         case "$OSTYPE" in
           freebsd*)
-          _make-parseMakefile $PWD < <(_call_program targets
"$words[1]" -nsp -f "$file" .PHONY 2> /dev/null)
+          if [[ $words[1] == *'gmake'* ]]
+          then
+            args="-nsp"
+          else
+            args="-nsdg1Fstdout"
+            TARGETS+=(${=${(f)"$(_call_program targets \"$words[1]\"
-s -f "$file" -V.ALLTARGETS 2> /dev/null)"}})
+          fi
+          _make-parseMakefile $PWD < <(_call_program targets
"$words[1]" $args -f "$file" .PHONY 2> /dev/null)
     ;;
     *)
           _make-parseMakefile $PWD < $file
````

It works well for bmake without breaking gmake.

[1] https://people.freebsd.org/~bapt/_make.diff



Messages sorted by: Reverse Date, Date, Thread, Author