]> git.sesse.net Git - vlc/blob - extras/analyser/zsh_completion.sh
Use var_Inherit* instead of var_CreateGet*.
[vlc] / extras / analyser / zsh_completion.sh
1 #!/usr/bin/env zsh
2 # Helper script to install zsh completion for VLC media player
3 # © 2008 Rafaël Carré <funman@videolanorg>
4
5
6 HOST=`gcc -dumpmachine`
7 case $HOST in
8     *darwin*)
9         SUFFIX=dylib
10     ;;
11     *cygwin*|*mingw*)
12         SUFFIX=dll
13     ;;
14     *linux*|*bsd*)
15         SUFFIX=so
16     ;;
17     *)
18         echo "WARNING: Unknown platform: \'$HOST\', can't check for libraries"
19     ;;
20 esac
21
22 #Distributors can run BUILDDIR=XXX ./zsh_completion.sh
23 [ -z "$BUILDDIR" ] && BUILDDIR=../../
24
25 function find_libvlc {
26     [ -z "$SUFFIX" ] && return 0 # linking will fail if lib isn't found
27     for i in $BUILDDIR/src/.libs/libvlc.$SUFFIX $BUILDDIR/src/libvlc.$SUFFIX; do
28         [ -e $i ] && LIBVLC=$i && return 0
29     done
30     return 1
31 }
32
33 function find_libvlccore {
34     [ -z "$SUFFIX" ] && return 0 # linking will fail if lib isn't found
35     for i in $BUILDDIR/src/.libs/libvlccore.$SUFFIX $BUILDDIR/src/libvlccore.$SUFFIX; do
36         [ -e $i ] && LIBVLCCORE=$i && return 0
37     done
38     return 1
39 }
40
41 while [ -z "$LIBVLC" ]; do
42     if ! find_libvlc; then
43         printf "Please enter the directory where you built vlc: "
44         read BUILDDIR
45     fi
46 done
47
48 if ! find_libvlccore; then
49     echo "libvlccore not found !"
50     exit 1
51 fi
52
53 export LD_LIBRARY_PATH=$BUILDDIR/src/.libs
54
55 if [ -e ../../extras/contrib/config.mak -a ! "`grep HOST ../../extras/contrib/config.mak 2>/dev/null|awk '{print $3}'`" != "$HOST" ]; then
56     CXXFLAGS="-I../../extras/contrib/include"
57 fi
58
59 [ -z "$CXX" ] && CXX=g++
60
61 ZSH_BUILD="$CXX $CXXFLAGS -D__LIBVLC__ -DHAVE_CONFIG_H -I$BUILDDIR -I$BUILDDIR/include -I../../include zsh.cpp $LIBVLC $LIBVLCCORE -o zsh_gen"
62
63 echo $ZSH_BUILD
64 echo
65 eval $ZSH_BUILD || exit 1
66
67 printf "Generating zsh completion in _vlc ... "
68
69 if ! ./zsh_gen --plugin-path=$BUILDDIR >_vlc 2>/dev/null; then
70     echo "
71 ERROR: the generation failed.... :(
72 Please press enter to verify that all the VLC modules are shown"
73     read i
74     ./zsh_gen --plugin-path=$BUILDDIR -vv --list
75     echo "
76 If they are shown, press enter to see if you can debug the problem
77 It will be reproduced by running \"./zsh_gen --plugin-path=$BUILDDIR -vvv\""
78     read i
79     ./zsh_gen --plugin-path=$BUILDDIR -vv
80     exit 1
81 fi
82
83 echo "done"
84
85 ZSH_FPATH=`echo $fpath|cut -d\  -f1`
86 [ -z "$ZSH_FPATH" ] && exit 0 # don't know where to install
87
88 echo "
89 You should now copy _vlc to $ZSH_FPATH and then
90 remove ~/.zcompdump and restart your running zsh instances,
91 or run \"compinit\" to start using vlc completion immediately."