]> git.sesse.net Git - vlc/blob - extras/analyser/zsh_completion.sh
decoder: factor some common code into DecoderUpdateFormatLocked()
[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 VLC_PLUGIN_PATH="$BUILDDIR"
26 export VLC_PLUGIN_PATH
27
28 function find_libvlc {
29     [ -z "$SUFFIX" ] && return 0 # linking will fail if lib isn't found
30     for i in $BUILDDIR/lib/.libs/libvlc.$SUFFIX $BUILDDIR/lib/libvlc.$SUFFIX; do
31         [ -e $i ] && LIBVLC=$i && return 0
32     done
33     return 1
34 }
35
36 function find_libvlccore {
37     [ -z "$SUFFIX" ] && return 0 # linking will fail if lib isn't found
38     for i in $BUILDDIR/src/.libs/libvlccore.$SUFFIX $BUILDDIR/src/libvlccore.$SUFFIX; do
39         [ -e $i ] && LIBVLCCORE=$i && return 0
40     done
41     return 1
42 }
43
44 while [ -z "$LIBVLC" ]; do
45     if ! find_libvlc; then
46         printf "Please enter the directory where you built vlc: "
47         read BUILDDIR
48     fi
49 done
50
51 if ! find_libvlccore; then
52     echo "libvlccore not found !"
53     exit 1
54 fi
55
56 export LD_LIBRARY_PATH=$BUILDDIR/src/.libs:$BUILDDIR/lib/.libs
57 CXXFLAGS="$CXXFLAGS -g -O0"
58
59 if [ -e ../../extras/contrib/config.mak -a ! "`grep HOST ../../extras/contrib/config.mak 2>/dev/null|awk '{print $3}'`" != "$HOST" ]; then
60     CXXFLAGS="-I../../extras/contrib/include"
61 fi
62
63 [ -z "$CXX" ] && CXX=g++
64
65 ZSH_BUILD="$CXX $CXXFLAGS -DHAVE_CONFIG_H -I$BUILDDIR -I$BUILDDIR/include -I../../include zsh.cpp $LIBVLC $LIBVLCCORE -o zsh_gen"
66
67 echo $ZSH_BUILD
68 echo
69 eval $ZSH_BUILD || exit 1
70
71 printf "Generating zsh completion in _vlc ... "
72
73 VLC_PLUGIN_PATH=$BUILDDIR/modules
74 if ! ./zsh_gen >_vlc 2>/dev/null; then
75     echo "
76 ERROR: the generation failed.... :(
77 Please press enter to verify that all the VLC modules are shown"
78     read i
79     ./zsh_gen -vv --list
80     echo "
81 If they are shown, press enter to see if you can debug the problem
82 It will be reproduced by running \"./zsh_gen -vv\""
83     read i
84     ./zsh_gen -vv
85     exit 1
86 fi
87
88 echo "done"
89
90 ZSH_FPATH=`echo $fpath|cut -d\  -f1`
91 [ -z "$ZSH_FPATH" ] && exit 0 # don't know where to install
92
93 echo "
94 You should now copy _vlc to $ZSH_FPATH and then
95 remove ~/.zcompdump and restart your running zsh instances,
96 or run \"compinit\" to start using vlc completion immediately."