Change the version in a way requiring less maintenance
[vlc.git] / toolbox
blobcdac5ed62c4d1dc7d2d2e603b17596236db8af93
1 #! /bin/sh
4 ## toolbox for the VLC media player
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>
12 ###
13 ### Get a sane environment, just in case
14 ###
15 LC_ALL=C
16 export LC_ALL
17 LANG=C
18 export LANG
19 CYGWIN=binmode
20 export CYGWIN
23 ## Give help
25 help()
27 cat << EOF
28 recognized flags are:
29 --update-po update translation files
30 --update-includes generate various include files
31 --update-glade2 generate and fix Glade 2 code
32 --update-flexml generate and fix flexml and flex code
33 --distclean "make distclean" on steroids
34 --dist-contrib add the contrib dir to MAKE_DIST
35 EOF
36 exit 1
40 ## Extract stuff from Makefile.am
42 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' | \
46 sed -ne 's/[^-$()_a-zA-Z0-9][^-$()_a-zA-Z0-9]*\([a-zA-Z]\)/\1/p' | \
47 sed -e "s,^,${srcdir}/,"
50 ###
51 ### argument check
52 ###
54 if test "$1" = ""
55 then
56 help
59 case "$1" in
60 --changelog|--update-changelog)
61 action=changelog
63 --update-po)
64 action=po
66 --update-includes)
67 action=includes
69 --update-flexml)
70 action=flexml
72 --update-glade2|--update-glade-2|--fix-glade2)
73 action=glade2
75 --distclean)
76 action=distclean
78 --add-include)
79 action=include
81 --dist-contrib)
82 action=contrib
84 --help)
85 help
88 echo "$0: unknown option $1"
89 help
91 esac
92 shift
95 ## Add includes to help doxygen
97 if test "${action}" = "include"
98 then
99 case "$1" in
100 */vlc_common.h|*/include/vlc/*);;
101 */include/*.h) echo "#include <vlc_common.h>" ;;
102 esac
103 cat $1
104 exit 0
108 ## Update the CVS changelog
110 if test "${action}" = "changelog"
111 then
112 YEAR="`date +%Y`"
113 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
119 ## Update the potfiles because no one ever does it
121 if test "${action}" = "po"
122 then
123 # find out the source files
124 echo "WARNING: you should run \"make update-po\" instead!" >&2
125 make update-po
126 exit $?
130 ## Create include files
132 if test "${action}" = "includes"
133 then
134 #set -x
136 if test -z "${srcdir}"; then
137 srcdir="`sed -ne 's/^srcdir *= *//p' < Makefile`"
139 if test -z "${builddir}"; then
140 builddir="`sed -ne 's/^top_builddir *= *//p' < Makefile`"
142 BUILTINS=`sed -ne 's/.*builtins *= *" *\([^"]*\)".*/\1/p' ${builddir}/vlc-config`
144 file="${builddir}/src/modules/builtin.h"
146 rm -f "${file}.tmp"
147 mkdir -p -- "${builddir}/src/modules"
148 cat "${srcdir}/src/modules/builtin.h.in" > "${file}.tmp" || exit 1
149 if test -n "${BUILTINS}"
150 then
151 for i in `echo ${BUILTINS}`
153 echo "int vlc_entry__`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`( module_t* );" >> "${file}.tmp"
154 done
155 echo "" >> "${file}.tmp"
157 echo "#define ALLOCATE_ALL_BUILTINS() \\" >> ${file}.tmp
158 echo " do \\" >> "${file}.tmp"
159 echo " { \\" >> "${file}.tmp"
160 if test -n "${BUILTINS}"
161 then
162 for i in `echo ${BUILTINS}`
164 echo " ALLOCATE_BUILTIN(`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`); \\" >> "${file}.tmp"
165 done
167 echo " } while( 0 );" >> "${file}.tmp"
168 echo "" >> "${file}.tmp" || exit 1
169 if diff >/dev/null 2>&1 "${file}" "${file}.tmp"
170 then
171 rm -f "${file}.tmp"
172 else
173 echo "creating new ${file}"
174 mv -f "${file}.tmp" "${file}"
177 exit 0
181 ## Fix glade2-generated files
183 if test "${action}" = "glade2"
184 then
185 file="modules/gui/pda/pda.glade"
186 echo "generating code from $file"
187 glade-2 -w "$file" || exit 1
189 file="modules/gui/pda/pda_interface.c"
190 echo "fixing $file"
191 if grep "DO NOT EDIT THIS FILE" "$file" >/dev/null 2>&1
192 then
193 rm -f -- "$file.$$.bak"
194 cat > "$file.$$.bak" << EOF
195 /* This file was created automatically by glade2 and fixed by bootstrap */
197 #include <vlc/vlc.h>
199 sed -e 1,7d \
200 -e 's#_(\(".:..:.."\))#\1#' \
201 -e 's#_(\("[a-z0-9]*://[^"]*"\))#\1#' \
202 -e 's#_("---")#"---"#' \
203 -e 's#_("--")#"--"#' \
204 -e 's#_(\("/dev/[^"]*"\))#\1#' \
205 -e 's#_(\("./."\))#\1#' \
206 < "$file" >> "$file.$$.bak"
207 mv -f "$file.$$.bak" "$file"
210 exit 0
214 ## Make distclean
216 if test "${action}" = "distclean"
217 then
218 set -x
219 # a naive sanity check to make sure we are in a VLC tree
220 test -f vlc.mandriva.spec -a -f vlc.win32.nsi.in || exit 1
221 # let's rock!
222 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 '{}' ';'
223 (cd autotools && find . -maxdepth 1 -name '[a-z]*' -exec rm -f '{}' ';')
224 find . -type d -name '.deps' -exec rm -Rf '{}' ';'
225 find . -type d -name '.libs' -exec rm -Rf '{}' ';'
226 # there's some more cruft all around
227 rm -f config.h config.log config.status
228 rm -f vlc vlc-config Makefile Modules.am
229 rm -Rf autom4te.cache
230 echo "\`toolbox --distclean\' is known to be broken."
231 echo "Don't complain if it does not work, or better yet, don't use it."
232 echo "You were warned."
233 # FIXME: a lot of Makefiles are still there
237 ## Add the extras/contrib dir to the distribution
239 if test "${action}" = "contrib"
240 then
241 set -x
242 if test ! -d "${distdir}/extras"
243 then
244 mkdir "${distdir}/extras"
246 if test ! -d "${distdir}/extras/contrib"
247 then
248 mkdir "${distdir}/extras/contrib"
250 cp "${srcdir}/extras/contrib/Makefile" "${distdir}/extras/contrib/Makefile"
251 cp "${srcdir}/extras/contrib/README" "${distdir}/extras/contrib/README"
252 cp "${srcdir}/extras/contrib/bootstrap" "${distdir}/extras/contrib/bootstrap"
253 cp "${srcdir}/extras/contrib/change_prefix.sh" "${distdir}/extras/contrib/change_prefix.sh"
254 if test ! -d "${distdir}/extras/contrib/src"
255 then
256 mkdir "${distdir}/extras/contrib/src"
258 cp "${srcdir}/extras/contrib/src/Makefile" "${distdir}/extras/contrib/src/Makefile"
259 cp "${srcdir}/extras/contrib/src/packages.mak" "${distdir}/extras/contrib/src/packages.mak"
260 if test ! -d "${distdir}/extras/contrib/src/Patches"
261 then
262 mkdir "${distdir}/extras/contrib/src/Patches"
264 cp ${srcdir}/extras/contrib/src/Patches/* "${distdir}/extras/contrib/src/Patches/"