#  Copyright (C) 2003 Ingo K"ohne
#  
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#  
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#  
#  You should have received a copy of the GNU General Public License along
#  with this program; if not, write to the Free Software Foundation, Inc.,
#  59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

. ../include/common

flavours_C="command ls -1 /boot | sed -n 's/vmlinuz-.*-\([[:alnum:]+.]*\)/\1/p'
command ls -1 /usr/src | sed -n 's/kernel-image-.*-\([[:alnum:]+.]*\)_.*\.deb/\1/p'"
kernelversion_C="if test -f Makefile; then head -3 Makefile | sed -n 's/.* = //;1h;2,\$H;\$g;\$s/\n/./g;\$p'; fi"
targets_C="make-kpkg --targets|sed -n '1,4d;s/^|[[:space:]]\+\([[:alnum:]_]\+\).*$/\1/p'"

cmd=make-kpkg

optcomplete  $cmd help
optcomplete -f  $cmd revision
optcomplete -C "$flavours_C #" $cmd append_to_version
optcomplete -C "$flavours_C #"  $cmd flavour
optcomplete -O, -C 'command ls /usr/src/modules #'  $cmd added_modules
optcomplete -O, -C "find /usr/src/kernel-patches -path \"*/\$(${kernelversion_C})/apply/*\" -o -path \"*/all/apply/*\" -printf '%f\n' #"  $cmd added_patches
optcomplete -C 'if test -d arch; then command ls arch; fi #'  $cmd arch
optcomplete -C "$targets_C #"  $cmd cross_compile
optcomplete -C "if test -f debian/rules; then sed -n 's/^SUBARCH.*=\([a-z0-9]*\)$/\1/p' debian/rules; fi #"  $cmd subarch
optcomplete  $cmd arch_in_name
optcomplete -f  $cmd pgpsign
optcomplete -W 'oldconfig config menuconfig xconfig old menu x'  $cmd config
optcomplete  $cmd targets
optcomplete  $cmd noexec
optcomplete  $cmd zimage
optcomplete  $cmd bzimage
optcomplete -W 'fakeroot sudo'  $cmd rootcmd
optcomplete  $cmd us
optcomplete  $cmd uc
optcomplete -C "$targets_C #" $cmd NONOPT

optcomplete -m long  $cmd

complete -F xpcompfunc  $cmd

unset cmd ${!xpc_*} flavours_C kernelversion_C targets_C
