2011-11-01 22:14:45 +02:00
|
|
|
# gcc(1) completion -*- shell-script -*-
|
2009-06-05 21:41:31 +02:00
|
|
|
#
|
|
|
|
# The only unusual feature is that we don't parse "gcc --help -v" output
|
|
|
|
# directly, because that would include the options of all the other backend
|
|
|
|
# tools (linker, assembler, preprocessor, etc) without any indication that
|
|
|
|
# you cannot feed such options to the gcc driver directly. (For example, the
|
|
|
|
# linker takes a -z option, but you must type -Wl,-z for gcc.) Instead, we
|
|
|
|
# ask the driver ("g++") for the name of the compiler ("cc1"), and parse the
|
|
|
|
# --help output of the compiler.
|
2009-10-01 20:54:51 +03:00
|
|
|
|
2009-06-05 21:41:31 +02:00
|
|
|
_gcc()
|
|
|
|
{
|
2011-04-20 17:02:27 +03:00
|
|
|
local cur prev words cword
|
|
|
|
_init_completion || return
|
2009-06-05 21:41:31 +02:00
|
|
|
|
2009-10-04 19:42:50 +02:00
|
|
|
_expand || return 0
|
2009-06-05 21:41:31 +02:00
|
|
|
|
2011-04-20 17:02:27 +03:00
|
|
|
local cc backend
|
|
|
|
|
2009-12-30 00:39:59 +01:00
|
|
|
case $1 in
|
2009-10-04 19:42:50 +02:00
|
|
|
gcj)
|
|
|
|
backend=jc1
|
|
|
|
;;
|
|
|
|
gpc)
|
|
|
|
backend=gpc1
|
|
|
|
;;
|
|
|
|
*77)
|
|
|
|
backend=f771
|
|
|
|
;;
|
2013-09-08 23:28:00 +04:00
|
|
|
*95)
|
|
|
|
backend=f951
|
|
|
|
;;
|
2009-10-04 19:42:50 +02:00
|
|
|
*)
|
|
|
|
backend=cc1 # (near-)universal backend
|
|
|
|
;;
|
|
|
|
esac
|
2009-06-05 21:41:31 +02:00
|
|
|
|
2009-10-04 19:42:50 +02:00
|
|
|
if [[ "$cur" == -* ]]; then
|
add_members, bk, gcc, mtx, munin-run, munindoc, mutt, p4, portinstall, postmap, ri, ypmatch: Avoid stderr spewage when needed commands/dirs are not available.
2011-10-22 11:48:23 +03:00
|
|
|
cc=$( $1 -print-prog-name=$backend 2>/dev/null )
|
|
|
|
[[ $cc ]] || return
|
2009-10-04 19:42:50 +02:00
|
|
|
# sink stderr:
|
|
|
|
# for C/C++/ObjectiveC it's useless
|
|
|
|
# for FORTRAN/Java it's an error
|
2011-12-21 01:03:21 +04:00
|
|
|
COMPREPLY=( $( compgen -W "$( $cc --help 2>/dev/null | tr '\t' ' ' |\
|
|
|
|
sed -e '/^ *-/!d' -e 's/ *-\([^][ <>]*\).*/-\1/' )" -- "$cur" ) )
|
2011-12-20 00:09:02 +04:00
|
|
|
[[ $COMPREPLY == *= ]] && compopt -o nospace
|
2009-10-04 19:42:50 +02:00
|
|
|
else
|
|
|
|
_filedir
|
|
|
|
fi
|
2009-06-05 21:41:31 +02:00
|
|
|
} &&
|
2013-09-08 23:28:00 +04:00
|
|
|
complete -F _gcc gcc g++ gfortran g77 g95 gcj gpc &&
|
2011-12-20 00:36:39 +02:00
|
|
|
{
|
2014-01-06 17:45:48 +02:00
|
|
|
cc --version 2>/dev/null | command grep -q GCC || \
|
2013-09-07 10:05:03 +03:00
|
|
|
[[ $( _realcommand cc ) == *gcc* ]] && \
|
2013-09-07 09:56:38 +03:00
|
|
|
complete -F _gcc cc || complete -F _minimal cc
|
2014-01-06 17:45:48 +02:00
|
|
|
c++ --version 2>/dev/null | command grep -q GCC || \
|
2013-09-07 10:05:03 +03:00
|
|
|
[[ $( _realcommand c++ ) == *g++* ]] && \
|
2013-09-07 09:56:38 +03:00
|
|
|
complete -F _gcc c++ || complete -F _minimal c++
|
2014-01-06 17:45:48 +02:00
|
|
|
f77 --version 2>/dev/null | command grep -q GCC || \
|
2013-09-08 23:28:00 +04:00
|
|
|
[[ $( _realcommand f77 ) == *gfortran* ]] && \
|
|
|
|
complete -F _gcc f77 || complete -F _minimal f77
|
2014-01-06 17:45:48 +02:00
|
|
|
f95 --version 2>/dev/null | command grep -q GCC || \
|
2013-09-08 23:28:00 +04:00
|
|
|
[[ $( _realcommand f95 ) == *gfortran* ]] && \
|
|
|
|
complete -F _gcc f95 || complete -F _minimal f95
|
2011-12-20 00:36:39 +02:00
|
|
|
}
|
2009-10-01 20:54:51 +03:00
|
|
|
|
2009-10-04 19:42:50 +02:00
|
|
|
# ex: ts=4 sw=4 et filetype=sh
|