zsh: export the LD_LIBRARY_PATH (so ldd can find the libs).
[vlc/asuraparaju-public.git] / extras / analyser / zsh_completion.sh
blob5d75569e871ef01fbddd54a41b86ecfc83aa3e39
1 #!/usr/bin/env zsh
2 # Helper script to install zsh completion for VLC media player
3 # © 2008 Rafaël Carré <funman@videolanorg>
6 HOST=`gcc -dumpmachine`
7 case $HOST in
8 *darwin*)
9 SUFFIX=dylib
11 *cygwin*|*mingw*)
12 SUFFIX=dll
14 *linux*|*bsd*)
15 SUFFIX=so
18 echo WARNING: Unknown platform: \'$HOST\'
20 esac
22 if test -z "$SUFFIX"; then
23 echo "ERROR: unknown suffix for shared objects
24 Please run \"SUFFIX=xxx $0\"
25 where xxx is the shared object extension on your platform."
26 exit 1
29 #Distributors can run BUILDDIR=XXX ./zsh_completion.sh
30 if test -z "$BUILDDIR"; then
31 BUILDDIR=../../
34 function find_libvlc {
35 for i in $BUILDDIR/src/.libs/libvlc.$SUFFIX $BUILDDIR/src/libvlc.$SUFFIX; do
36 test -e $i && LIBVLC=$i && return 0
37 done
38 return 1
41 function find_libvlccore {
42 for i in $BUILDDIR/src/.libs/libvlccore.$SUFFIX $BUILDDIR/src/libvlccore.$SUFFIX; do
43 test -e $i && LIBVLCCORE=$i && return 0
44 done
45 return 1
48 while test -z "$LIBVLC"; do
49 if ! find_libvlc; then
50 /bin/echo -n "Please enter the directory where you built vlc: "
51 read BUILDDIR
53 done
55 echo "libvlc found !"
57 if ! find_libvlccore; then
58 /bin/echo -n "libvlccore not found ! Linking will fail !"
61 export LD_LIBRARY_PATH=$BUILDDIR/src/.libs
63 if test -e ../../extras/contrib/config.mak -a ! "`grep HOST ../../extras/contrib/config.mak 2>/dev/null|awk '{print $3}'`" != "$HOST"; then
64 echo "contribs found !"
65 CPPFLAGS="-I../../extras/contrib/include"
68 if test -z "$CXX"; then
69 CXX=g++
72 ZSH_BUILD="$CXX $CPPFLAGS $CXXFLAGS -D__LIBVLC__ -DHAVE_CONFIG_H -I$BUILDDIR -I$BUILDDIR/include -I../../include zsh.cpp $LIBVLC $LIBVLCCORE -o zsh_gen"
74 echo "Building zsh completion generator ... "
75 echo $ZSH_BUILD
76 echo
77 eval $ZSH_BUILD || exit 1
79 echo "Generating zsh completion ..."
80 if ! ./zsh_gen --plugin-path=$BUILDDIR >_vlc 2>/dev/null; then
81 echo "ERROR: the generation failed.... :(
82 Please press enter to verify that all the VLC modules are shown"
83 read i
84 ./zsh_gen --plugin-path=$BUILDDIR -vvv --list
85 echo "
86 If they are shown, press enter to see if you can debug the problem
87 It will be reproduced by running \"./zsh_gen --plugin-path=$BUILDDIR -vvv\""
88 read i
89 ./zsh_gen --plugin-path=$BUILDDIR -vvv
90 exit 1
93 echo "zsh completion is `echo \`wc -l _vlc\`` lines long !"
95 test -z "$NOINSTALL" || exit 0
96 #Distributors can run NOINSTALL=mg ./zsh_completion.sh
98 if ! /usr/bin/which zsh >/dev/null 2>&1; then
99 echo "ERROR: zsh not found, you'll have to copy the _vlc file manually"
100 exit 1
103 test -z "$ZSH_FPATH" && ZSH_FPATH=`zsh -c "echo \\$fpath|cut -d\" \" -f1"`
104 if test -z "$ZSH_FPATH"; then
105 echo "ERROR: Could not find a directory where to install completion
106 Please run \"ZSH_FPATH=path $0\"
107 where path is the directory where you want to install completion"
108 exit 1
111 echo "completion will be installed in $ZSH_FPATH , using root privileges
112 Press Ctrl+C to abort installation, and copy _vlc manually"
113 read i
114 echo "Installing completion ..."
115 sudo sh -c "chown 0:0 _vlc && chmod 0644 _vlc && mv _vlc $ZSH_FPATH" || exit 1
117 echo "zsh completion for VLC successfully installed :)
118 Restart running zsh instances, or run \"compinit\" to start using it."