From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27153 invoked from network); 10 Apr 2000 23:35:25 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 10 Apr 2000 23:35:25 -0000 Received: (qmail 5824 invoked by alias); 10 Apr 2000 23:35:15 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10628 Received: (qmail 5805 invoked from network); 10 Apr 2000 23:35:13 -0000 From: "Bart Schaefer" Message-Id: <1000410233504.ZM31215@candle.brasslantern.com> Date: Mon, 10 Apr 2000 23:35:03 +0000 X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-workers@sunsite.auc.dk Subject: PATCH: Use "make -p" to get targets MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii I wrote: > We'll just have to set up a style, as in _diff. Strictly speaking, the _is_gnu branch would work for Solaris make as well (as long as nobody actually created a target named .PHONY that had any real rules). I suppose you can fake it with the version style: zstyle ':completion:*:make:version' echo GNU Somebody please "make" a better suggestion. Index: Doc/Zsh/compsys.yo =================================================================== @@ -715,6 +715,11 @@ when completing a value out of a set of values (or a list of such values) ) +kindex(version, completion tag) +item(tt(version))( +used by tt(_call) to look up the command to run to determine the installed +version of various other commands (currently tt(diff) and tt(make)). +) kindex(warnings, completion tag) item(tt(warnings))( used to look up the tt(format) style for warnings Index: Completion/User/_make =================================================================== @@ -1,7 +1,18 @@ -#compdef make gmake pmake +#compdef make gmake pmake dmake local prev="$words[CURRENT-1]" file expl tmp +(( $+_is_gnu )) || typeset -gA _is_gnu + +if (( ! $+_is_gnu[$1] )); then + if [[ $(_call version $1 -v -f /dev/null /dev/null) = *GNU* ]] + then + _is_gnu[$1]=yes + else + _is_gnu[$1]= + fi +fi + if [[ "$prev" = -[CI] ]]; then _files -/ elif [[ "$prev" = -[foW] ]]; then @@ -14,17 +25,23 @@ file=Makefile elif [[ -e makefile ]]; then file=makefile + elif [[ -e GNUmakefile ]]; then + file=GNUmakefile else file='' fi if [[ -n "$file" ]] && _wanted targets; then - tmp=( - $(awk '/^[a-zA-Z0-9][^\/\t]+:/ {print $1} + if [[ -n "$_is_gnu[$1]" ]]; then + tmp=( $(make -nsp --no-print-directory -f "$file" .PHONY | awk '/^[a-zA-Z0-9][^\/\t=]+:/ {print $1}' FS=:) ) + else + tmp=( + $(awk '/^[a-zA-Z0-9][^\/\t=]+:/ {print $1} /^\.include */ || /^\.include *".*mk\/bsd\.pkg\.(subdir\.)?mk"/ { print "fetch fetch-list extract patch configure build install reinstall deinstall package describe checkpatch checksum makesum" }' \ FS=: $file) - ) + ) + fi _all_labels targets expl 'make target' compadd "$tmp[@]" && return 0 fi compset -P 1 '*=' -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com