toolbox 6.75 KB
Newer Older
1 2
#! /bin/sh

3

4
##  toolbox for the VLC media player
Sam Hocevar's avatar
Sam Hocevar committed
5
##  $Id$
6
##
7
##  Copyright (C) 2002-2006  the VideoLAN team
8
##
9
##  Authors: Samuel Hocevar <sam@zoy.org>
10
##           Rémi Denis-Courmont <rem # videolan.org>
11 12 13 14

###
###  Get a sane environment, just in case
###
15 16
LC_ALL=C
export LC_ALL
17 18 19 20 21 22 23 24 25 26 27 28
LANG=C
export LANG
CYGWIN=binmode
export CYGWIN

##
##  Give help
##
help()
{
  cat << EOF
recognized flags are:
Sam Hocevar's avatar
Sam Hocevar committed
29 30 31 32
  --update-po             update translation files
  --update-includes       generate various include files
  --update-glade2         generate and fix Glade 2 code
  --update-flexml         generate and fix flexml and flex code
Sam Hocevar's avatar
Sam Hocevar committed
33
  --distclean             "make distclean" on steroids
34
  --dist-contrib          add the contrib dir to MAKE_DIST
35 36 37 38
EOF
  exit 1
}

39 40 41 42 43
##
##  Extract stuff from Makefile.am
##
getfiles()
{
44
  awk 'BEGIN{a=0}{if(!a&&$0~/^'"$1"'[^-_a-zA-Z0-9]*=/){a=1;print$0;next;}if(a){if($0~/^[a-zA-Z]/){exit;}print $0}}' < "${srcdir}/Makefile.am" | \
45
    tr '\\ ' '\n\n' | \
Sam Hocevar's avatar
Sam Hocevar committed
46 47
    sed -ne 's/[^-$()_a-zA-Z0-9][^-$()_a-zA-Z0-9]*\([a-zA-Z]\)/\1/p' | \
    sed -e "s,^,${srcdir}/,"
48 49
}

50 51 52
###
###  argument check
###
53 54

if test "$1" = ""
55 56 57 58
then
  help
fi

59
case "$1" in
Sam Hocevar's avatar
Sam Hocevar committed
60
  --changelog|--update-changelog)
61
    action=changelog
62 63
    ;;
  --update-po)
64
    action=po
65 66
    ;;
  --update-includes)
67
    action=includes
68
    ;;
69 70 71
  --update-flexml)
    action=flexml
    ;;
72 73 74
  --update-glade2|--update-glade-2|--fix-glade2)
    action=glade2
    ;;
75 76 77
  --distclean)
    action=distclean
    ;;
78 79 80
  --add-include)
    action=include
    ;;
81 82 83
  --dist-contrib)
    action=contrib
    ;;
84 85 86 87 88 89 90 91 92 93
  --help)
    help
    ;;
  *)
    echo "$0: unknown option $1"
    help
    ;;
esac
shift

94 95 96 97 98 99 100 101 102 103 104 105 106
##
##  Add includes to help doxygen
##
if test "${action}" = "include"
then
  case "$1" in
    */vlc_common.h|*/include/vlc/*);;
    */include/*.h) echo "#include <vlc_common.h>" ;;
  esac
  cat $1
  exit 0
fi

107 108 109
##
##  Update the CVS changelog
##
110
if test "${action}" = "changelog"
111
then
Sam Hocevar's avatar
Sam Hocevar committed
112 113
  YEAR="`date +%Y`"
  echo "toolbox --changelog no longer required. use this instead:"
114
  echo " LANG=C svn log -v -r '{$YEAR-12-31}:{$YEAR-01-01}' > ChangeLog"
115
  exit 0
116 117
fi

118 119 120
##
##  Update the potfiles because no one ever does it
##
121
if test "${action}" = "po"
122
then
123
  # find out the source files
124 125 126
  echo "WARNING: you should run \"make update-po\" instead!" >&2
  make update-po
  exit $?
127 128
fi

129 130 131
##
##  Create include files
##
132
if test "${action}" = "includes"
133
then
Sam Hocevar's avatar
Sam Hocevar committed
134
  #set -x
135

Sam Hocevar's avatar
Sam Hocevar committed
136 137 138
  if test -z "${srcdir}"; then
    srcdir="`sed -ne 's/^srcdir *= *//p' < Makefile`"
  fi
139 140 141
  if test -z "${builddir}"; then
    builddir="`sed -ne 's/^top_builddir *= *//p' < Makefile`"
  fi
142
  BUILTINS=`sed -ne 's/.*builtins *= *" *\([^"]*\)".*/\1/p' ${builddir}/vlc-config`
143

144
  file="${builddir}/src/modules/builtin.h"
145

146
  rm -f "${file}.tmp"
147 148
  mkdir -p -- "${builddir}/src/modules"
  cat "${srcdir}/src/modules/builtin.h.in" > "${file}.tmp" || exit 1
Sam Hocevar's avatar
Sam Hocevar committed
149
  if test -n "${BUILTINS}"
150 151 152
  then
    for i in `echo ${BUILTINS}`
    do
153
      echo "int vlc_entry__`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`( module_t* );" >> "${file}.tmp"
154
    done
155
    echo "" >> "${file}.tmp"
156 157
  fi
  echo "#define ALLOCATE_ALL_BUILTINS() \\" >> ${file}.tmp
158 159
  echo "    do \\" >> "${file}.tmp"
  echo "    { \\" >> "${file}.tmp"
Sam Hocevar's avatar
Sam Hocevar committed
160
  if test -n "${BUILTINS}"
161 162 163
  then
    for i in `echo ${BUILTINS}`
    do
164
      echo "        ALLOCATE_BUILTIN(`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`); \\" >> "${file}.tmp"
165 166
    done
  fi
167 168 169
  echo "    } while( 0 );" >> "${file}.tmp"
  echo "" >> "${file}.tmp" || exit 1
  if diff >/dev/null 2>&1 "${file}" "${file}.tmp"
170
  then
171
    rm -f "${file}.tmp"
172
  else
Sam Hocevar's avatar
Sam Hocevar committed
173
    echo "creating new ${file}"
174
    mv -f "${file}.tmp" "${file}"
175 176 177 178 179
  fi

  exit 0
fi

180 181 182 183 184
##
##  Fix glade2-generated files
##
if test "${action}" = "glade2"
then
185 186 187
  file="modules/gui/pda/pda.glade"
  echo "generating code from $file"
  glade-2 -w "$file" || exit 1
188

189 190 191 192 193 194
  file="modules/gui/pda/pda_interface.c"
  echo "fixing $file"
  if grep "DO NOT EDIT THIS FILE" "$file" >/dev/null 2>&1
  then
    rm -f -- "$file.$$.bak"
    cat > "$file.$$.bak" << EOF
Sam Hocevar's avatar
Sam Hocevar committed
195 196
/* This file was created automatically by glade2 and fixed by bootstrap */

197 198 199 200
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

Sam Hocevar's avatar
Sam Hocevar committed
201 202
#include <vlc/vlc.h>
EOF
203 204 205 206 207 208 209 210 211 212
    sed -e 1,7d \
        -e 's#_(\(".:..:.."\))#\1#' \
        -e 's#_(\("[a-z0-9]*://[^"]*"\))#\1#' \
        -e 's#_("---")#"---"#' \
        -e 's#_("--")#"--"#' \
        -e 's#_(\("/dev/[^"]*"\))#\1#' \
        -e 's#_(\("./."\))#\1#' \
        < "$file" >> "$file.$$.bak"
    mv -f "$file.$$.bak" "$file"
  fi
Sam Hocevar's avatar
Sam Hocevar committed
213

214 215 216
  exit 0
fi

217 218 219 220 221 222 223
##
##  Make distclean
##
if test "${action}" = "distclean"
then
  set -x
  # a naive sanity check to make sure we are in a VLC tree
224
  test -f vlc-config.in.in -a -f src/libvlc.c || exit 1
225
  # let's rock!
Rafaël Carré's avatar
Rafaël Carré committed
226
  find . -false -path './extras/contrib/*' -type f '(' -name '*.[oa]' -o -name '*.l[oa]' -o -name '*.so' -o -name '*.sl' -o -name '*.dylib' -o -name '*.dll' -o -name .dirstamp -o '(' '(' ! -path '\./doc/developer/Makefile\.in' ')' -a -name Makefile.in ')' -o -name 'stamp-h*' -o -name '*~' -o -name '*.bak' -o -name '*.moc.cpp' ')' -exec rm -f '{}' ';'
227
  (cd autotools && find . -maxdepth 1 -name '[a-z]*' -not -name 'config.rpath' -exec rm -f '{}' ';')
228
  find . -type d -name '.deps' -exec rm -Rf '{}' ';'
229
  find . -type d -name '.libs' -exec rm -Rf '{}' ';'
230
  # there's some more cruft all around
231
  rm -f config.h config.log config.status
232 233
  rm -f vlc vlc-config Makefile Modules.am
  rm -Rf autom4te.cache
234 235 236
  echo "\`toolbox --distclean\' is known to be broken."
  echo "Don't complain if it does not work, or better yet, don't use it."
  echo "You were warned."
237 238 239
  # FIXME: a lot of Makefiles are still there
fi

240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
##
## Add the extras/contrib dir to the distribution
##
if test "${action}" = "contrib"
then
  set -x
  if test ! -d "${distdir}/extras"
  then
    mkdir "${distdir}/extras"
  fi
  if test ! -d "${distdir}/extras/contrib"
  then
    mkdir "${distdir}/extras/contrib"
  fi
  cp "${srcdir}/extras/contrib/Makefile" "${distdir}/extras/contrib/Makefile"
  cp "${srcdir}/extras/contrib/README" "${distdir}/extras/contrib/README"
  cp "${srcdir}/extras/contrib/bootstrap" "${distdir}/extras/contrib/bootstrap"
  cp "${srcdir}/extras/contrib/change_prefix.sh" "${distdir}/extras/contrib/change_prefix.sh"
  if test ! -d "${distdir}/extras/contrib/src"
  then
    mkdir "${distdir}/extras/contrib/src"
  fi
  cp "${srcdir}/extras/contrib/src/Makefile" "${distdir}/extras/contrib/src/Makefile"
  cp "${srcdir}/extras/contrib/src/packages.mak" "${distdir}/extras/contrib/src/packages.mak"
  if test ! -d "${distdir}/extras/contrib/src/Patches"
  then
    mkdir "${distdir}/extras/contrib/src/Patches"
  fi
  cp ${srcdir}/extras/contrib/src/Patches/* "${distdir}/extras/contrib/src/Patches/"
269 270 271 272 273
  if test ! -d "${distdir}/extras/contrib/src/Distributions"
  then
    mkdir "${distdir}/extras/contrib/src/Distributions"
  fi
  cp ${srcdir}/extras/contrib/src/Distributions/* "${distdir}/extras/contrib/src/Distributions/"
274 275
fi