3 ## toolbox for the VLC media player
4 ## $Id: toolbox,v 1.38 2003/07/05 14:47:53 sam Exp $
6 ## Authors: Samuel Hocevar <sam@zoy.org>
9 ### Get a sane environment, just in case
23 --update-vc update Microsoft Visual Studio files
24 --update-po update translation files
25 --update-includes generate various include files
26 --update-glade generate and fix Glade code
27 --update-glade2 generate and fix Glade 2 code
28 --update-flexml generate and fix flexml and flex code
29 --changelog update the CVS changelog
30 --distclean "make distclean"
31 --make-woody <dir> change distdir <dir> to a woody distdir
37 ## Extract stuff from Makefile.am
41 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" | \
43 sed -ne 's/[^-$()_a-zA-Z0-9][^-$()_a-zA-Z0-9]*\([a-zA-Z]\)/\1/p' | \
44 sed -e "s,^,${srcdir}/,"
57 --changelog|--update-changelog)
72 --update-glade|--fix-glade)
75 --update-glade2|--update-glade-2|--fix-glade2)
88 echo "$0: unknown option $1"
95 ## Update the CVS changelog
97 if test "${action}" = "changelog"
101 cvs2cl --help >/dev/null 2>&1 || exit 1
102 rm -f ChangeLog ChangeLog.tmp
103 cvs2cl --utc --hide-filenames --no-wrap -w --stdout -g -z9 | \
104 sed -e 's/^[^0-9]/ /' -e 's/^ *$//' | \
106 YEAR=`sed -e 's/\(....\)-..-.*/\1/;q' ChangeLog.tmp`
107 LASTYEAR="$((${YEAR} - 1))"
108 sed -ne "/^${YEAR}-..-../,/^${LASTYEAR}-..-../{/^${LASTYEAR}-..-../d;p}" \
109 < ChangeLog.tmp > Changelog
112 # To generate changelog for the year 2001:
113 # sed -ne '/^2001/,/^2000/{/^2000/d;p}'
117 ## Update the MSVC project files
119 if test "${action}" = "vc"
121 echo "generating Visual Studio files..."
123 srcdir="`sed -ne 's/^srcdir *= *//p' < Makefile`"
128 # Variables we get from configure.ac
129 LIBVLC_VERSION=`sed -ne '/AC_INIT/s/.*,\(.*\))/\1/p' < configure.ac`
130 LIBVLC_CODENAME=`sed -ne '/CODENAME=/s/.*"\(.*\)"/\1/p' < configure.ac`
131 LIBVLC_SYMBOL=`echo $LIBVLC_VERSION | sed -e 'y/.-/__/'`
133 # Sources that get built under Win32 - FIXME: anyone wanna deuglify this? :)
134 LIBVLC_SOURCES=`getfiles SOURCES_libvlc_common; getfiles SOURCES_libvlc_win32; getfiles SOURCES_libvlc_dirent; getfiles SOURCES_libvlc_getopt; getfiles SOURCES_libvlc_libc`
136 LIBVLC_HEADERS=`getfiles HEADERS_include; getfiles HEADERS_include_built`
138 LIBVLC_PKG_HEADERS=`getfiles dist_pkginclude_HEADERS`
141 rm -f evc/*.vcp msvc/*.dsp
144 for target in evc/config.h msvc/config.h
148 sed -e "s/@CODENAME@/${LIBVLC_CODENAME}/" \
149 -e "s/@VERSION@/${LIBVLC_VERSION}/" \
150 -e "s/@SYMBOL@/${LIBVLC_SYMBOL}/" < ${target}.in > ${target}
154 for target in evc/libvlc.vcp msvc/libvlc.dsp
157 # Top of the project file
158 perl -pe 'if(/§SOURCES§/){last;}' < ${target}.in > ${target}
160 for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep -v "/.*/"`
162 cat >> ${target} << EOF
163 # Begin Source File${M}
164 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
165 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
166 # End Source File${M}
169 for subdir in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/.*/" | cut -f2 -d/ | sort | uniq`
171 cat >> ${target} << EOF
172 # Begin Group "${subdir}"${M}
174 for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/${subdir}/"`
176 if test "${target}" = "evc/libvlc.vcp"
178 cat >> ${target} << EOF
179 # Begin Source File${M}
180 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
181 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
182 !IF "\$(CFG)" == "libvlc - Win32 (WCE MIPS) Release"${M}
183 # PROP Output_Dir "MIPSRel\\${subdir}"${M}
184 # PROP Intermediate_Dir "MIPSRel\\${subdir}"${M}
185 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE MIPS) Debug"${M}
186 # PROP Output_Dir "MIPSDbg\\${subdir}"${M}
187 # PROP Intermediate_Dir "MIPSDbg\\${subdir}"${M}
188 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH4) Release"${M}
189 # PROP Output_Dir "SH4Rel\\${subdir}"${M}
190 # PROP Intermediate_Dir "SH4Rel\\${subdir}"${M}
191 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH4) Debug"${M}
192 # PROP Output_Dir "SH4Dbg\\${subdir}"${M}
193 # PROP Intermediate_Dir "SH4Dbg\\${subdir}"${M}
194 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH3) Release"${M}
195 # PROP Output_Dir "SH3Rel\\${subdir}"${M}
196 # PROP Intermediate_Dir "SH3Rel\\${subdir}"${M}
197 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH3) Debug"${M}
198 # PROP Output_Dir "SH3Dbg\\${subdir}"${M}
199 # PROP Intermediate_Dir "SH3Dbg\\${subdir}"${M}
200 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARM) Release"${M}
201 # PROP Output_Dir "ARMRel\\${subdir}"${M}
202 # PROP Intermediate_Dir "ARMRel\\${subdir}"${M}
203 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARM) Debug"${M}
204 # PROP Output_Dir "ARMDbg\\${subdir}"${M}
205 # PROP Intermediate_Dir "ARMDbg\\${subdir}"${M}
206 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE x86em) Release"${M}
207 # PROP Output_Dir "X86EMRel\\${subdir}"${M}
208 # PROP Intermediate_Dir "X86EMRel\\${subdir}"${M}
209 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE x86em) Debug"${M}
210 # PROP Output_Dir "X86EMDbg\\${subdir}"${M}
211 # PROP Intermediate_Dir "X86EMDbg\\${subdir}"${M}
213 # End Source File${M}
216 cat >> ${target} << EOF
217 # Begin Source File${M}
218 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
219 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
220 !IF "\$(CFG)" == "libvlc - Win32 Release"${M}
221 # PROP Output_Dir "Release\\${subdir}"${M}
222 # PROP Intermediate_Dir "Release\\${subdir}"${M}
223 !ELSEIF "\$(CFG)" == "libvlc - Win32 Debug"${M}
224 # PROP Output_Dir "Debug\\${subdir}"${M}
225 # PROP Intermediate_Dir "Debug\\${subdir}"${M}
227 # End Source File${M}
231 cat >> ${target} << EOF
236 perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){if(/§HEADERS§/){last;}print $_}' < ${target}.in >> ${target}
237 for file in ${LIBVLC_HEADERS}
239 cat >> ${target} << EOF
240 # Begin Source File${M}
241 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
242 # End Source File${M}
245 cat >> ${target} << EOF
246 # Begin Group "vlc"${M}
248 for file in ${LIBVLC_PKG_HEADERS}
250 cat >> ${target} << EOF
251 # Begin Source File${M}
252 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
253 # End Source File${M}
256 cat >> ${target} << EOF
259 perl -e 'while(<>){if(/§HEADERS§/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
263 grep '^L_[^ ]*_pic =' Modules.am | while read a b c
265 makefile="`echo $c | sed -e 's@/[^/]*$@/Modules.am@'`"
266 plugin="`echo $a | sed 's/L_\(.*\)_pic/\1/'`"
267 # this is an attempt at getting a list of plugin sources... we take the
268 # production and remove everything that does not contain "module", which
269 # means you miss $(NULL), but other variables too.
270 cfiles=`grep -v '[^-_a-zA-Z0-9]*#' ${makefile} | awk 'BEGIN{a=0}{if(!a&&$0~/^SOURCES_'${plugin}'[^-_a-zA-Z0-9]*=/){a=1;print$0;next;}if(a){if($0~/^[a-zA-Z]/){exit;}print $0}}' | tr '\\ ' '\n\n' | sed -ne 's,/,\\\\,g; s/.*modules/modules/p'`
271 hfiles=`for i in ${cfiles} ; do echo $i ; done | grep '\.h$'`
272 cfiles=`for i in ${cfiles} ; do echo $i ; done | grep -v '\.h$'`
275 test "${dir}" = "evc" && suf="vcp" || suf="dsp"
276 source="${dir}/plugins.${suf}.in"
277 target="${dir}/plugin_${plugin}.${suf}"
279 perl -pe 'if(/§SOURCES§/){last;} s/§PLUGIN§/'${plugin}'/g' < ${source} > ${target}
280 for cfile in ${cfiles}
282 cat >> ${target} << EOF
283 # Begin Source File${M}
284 SOURCE="..\\${cfile}"${M}
285 # ADD CPP /D "__VLC__" /D "__PLUGIN__" /D "MODULE_NAME=${plugin}" /D "MODULE_NAME_IS_${plugin}" ${M}
286 # End Source File${M}
289 # sed is really nicer for this... unfortunately it's broken under cygwin
290 # sed -ne '1,/§SOURCES§/d; /§HEADERS§/,$d; p' < ${source} >> ${target}
291 perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){if(/§HEADERS§/){last;}print $_}' < ${source} >> ${target}
292 for hfile in ${hfiles}
294 cat >> ${target} << EOF
295 # Begin Source File${M}
296 SOURCE="..\\${hfile}"${M}
297 # End Source File${M}
300 # sed -ne '1,/§HEADERS§/d; p' < ${source} >> ${target}
301 perl -e 'while(<>){if(/§HEADERS§/){last;}}while(<>){print $_}' < ${source} >> ${target}
306 for target in evc/vlc.vcp msvc/vlc.dsp
309 # Top of the project file
310 perl -pe 'if(/§SOURCES§/){last;}' < ${target}.in > ${target}
312 if test "${target}" = "evc/vlc.vcp"
314 cat >> ${target} << EOF
315 # Begin Source File${M}
316 SOURCE="..\\evc\\vlc.c"${M}
317 # End Source File${M}
320 cat >> ${target} << EOF
321 # Begin Source File${M}
322 SOURCE="..\\src\\vlc.c"${M}
323 # End Source File${M}
326 # Bottom of the project file - handles resource files too
327 perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
335 ## Update the potfiles because no one ever does it
337 if test "${action}" = "po"
339 # create a fake file containing win32 strings
340 rm -f modules/gui/win32/strings.cpp
341 #printf "/* Automatically generated by 'toolbox --update-po', please don't compile */\n" > modules/gui/win32/strings.cpp
342 #find modules/gui/win32 -name '*.dfm' | while read file
344 # printf "\n/*\n * from $file:\n */\n\n" >> modules/gui/win32/strings.cpp
345 # perl -ne 'chop; chop; if( / (Caption|Text|Hint) / || $buffer =~ /[+=] *$/ ) { $buffer =~ s/\+ *$//; $buffer .= $_; } if( $buffer =~ /'"'"' *$/) { $buffer =~ s/'"'"'/"/g; $buffer =~ s/\\/\\\\/g; $buffer =~ s/=/= _(/; print $buffer." );\n"; $buffer = "";}' < $file | grep -v '"-*"' | grep -v '"http://' | grep -v '"vlcs"' >> modules/gui/win32/strings.cpp || exit 1
347 # find out the source files
349 echo "# automatically created by toolbox --update-po" > po/POTFILES.in
350 echo "" >> po/POTFILES.in
351 echo "# main sources" >> po/POTFILES.in
352 find include src -name '*.[chm]' -o -name '*.[ch]pp' | sort >> po/POTFILES.in
353 echo "" >> po/POTFILES.in
354 echo "# modules" >> po/POTFILES.in
355 find modules -name '*.[chm]' -o -name '*.[ch]pp' | grep -v 'gui/win32/' | sort >> po/POTFILES.in
360 make vlc.pot || exit 1
361 make update-po || exit 1
368 ## Create include files
370 if test "${action}" = "includes"
374 srcdir="`sed -ne 's/^srcdir *= *//p' < Makefile`"
375 LIBVLC_HEADERS=`getfiles HEADERS_include`
376 BUILTINS=`sed -ne 's/.*builtins *= *" *\([^"]*\)".*/\1/p' vlc-config`
378 file="${srcdir}/include/vlc_symbols.h"
381 echo '/* DO NOT EDIT THIS FILE! See Makefile.am */' >> ${file}.in
382 echo 'struct module_symbols_t {' >> ${file}.in
383 cat ${LIBVLC_HEADERS} | grep '^ *VLC_EXPORT.*;' | sed -e 's/VLC_EXPORT( *\([^,]*\), *\([^,]*\), *\(.*\));.*/ \1 (* \2_inner) \3;/' >> ${file}.in
384 echo '};' >> ${file}.in
385 echo '#ifdef __PLUGIN__' >> ${file}.in
386 cat ${LIBVLC_HEADERS} | grep '^ *VLC_EXPORT.*;' | sed -e 's/VLC_EXPORT( *\([^,]*\), *\([^,]*\), *\(.*\));.*/# define \2 p_symbols->\2_inner/' >> ${file}.in
387 echo '#endif /* __PLUGIN__ */' >> ${file}.in
388 if diff >/dev/null 2>&1 ${file} ${file}.in
392 echo "creating new ${file}"
393 mv -f ${file}.in ${file}
396 file="${srcdir}/src/misc/modules_plugin.h"
398 rm -f ${file}.tmp && cp ${file}.in ${file}.tmp
399 sed -e 's#.*\$[I][d]:.*# * Automatically generated from '${file}'.in by bootstrap#' < ${file}.in > ${file}.tmp
400 echo '#define STORE_SYMBOLS( p_symbols ) \' >> ${file}.tmp
401 cat ${LIBVLC_HEADERS} | grep '^ *VLC_EXPORT.*;' | sed -e 's/VLC_EXPORT( *\([^,]*\), *\([^,]*\), *\(.*\));.*/ (p_symbols)->\2_inner = \2; \\/' >> ${file}.tmp
402 echo '' >> ${file}.tmp
403 if diff >/dev/null 2>&1 ${file} ${file}.tmp
407 echo "creating new ${file}"
408 mv -f ${file}.tmp ${file}
411 file="${srcdir}/src/misc/modules_builtin.h"
413 rm -f ${file}.tmp && cp ${file}.in ${file}.tmp
414 if test -n "${BUILTINS}"
416 for i in `echo ${BUILTINS}`
418 echo "int vlc_entry__`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`( module_t* );" >>${file}.tmp
420 echo "" >> ${file}.tmp
422 echo "#define ALLOCATE_ALL_BUILTINS() \\" >> ${file}.tmp
423 echo " do \\" >> ${file}.tmp
424 echo " { \\" >> ${file}.tmp
425 if test -n "${BUILTINS}"
427 for i in `echo ${BUILTINS}`
429 echo " ALLOCATE_BUILTIN(`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`); \\" >> ${file}.tmp
432 echo " } while( 0 );" >> ${file}.tmp
433 echo "" >> ${file}.tmp
434 if diff >/dev/null 2>&1 ${file} ${file}.tmp
438 echo "creating new ${file}"
439 mv -f ${file}.tmp ${file}
446 ## Fix glade-generated files
448 if test "${action}" = "glade"
450 for file in modules/gui/gtk/gnome.glade modules/gui/gtk/gtk.glade modules/gui/familiar/familiar.glade
452 echo "generating code from $file"
453 glade -w $file || exit 1
456 for file in modules/gui/gtk/gnome_interface.c modules/gui/gtk/gtk_interface.c modules/gui/familiar/interface.c
459 if grep "DO NOT EDIT THIS FILE" $file >/dev/null 2>&1
462 cat > $file.$$.bak << EOF
463 /* This file was created automatically by glade and fixed by bootstrap */
468 -e 's#_(\(".:..:.."\))#\1#' \
469 -e 's#_(\("[a-z0-9]*://[^"]*"\))#\1#' \
470 -e 's#_("---")#"---"#' \
471 -e 's#_("--")#"--"#' \
472 -e 's#_("/dev/dvd")#"/dev/dvd"#' \
473 -e 's#_(\("./."\))#\1#' \
474 < $file >> $file.$$.bak
475 mv -f $file.$$.bak $file
479 for file in modules/gui/gtk/gtk_support.h modules/gui/familiar/support.h
482 if grep "DO NOT EDIT THIS FILE" $file >/dev/null 2>&1
485 sed -e 's/DO NOT EDIT.*/Created by glade, fixed by bootstrap/' \
486 -e 's,<config.h>,<vlc/vlc.h>,' \
487 -e 's,#if.*ENABLE_NLS.*,#if 0 /* Disabled by bootstrap */,' \
488 -e 's,#else,/* & */,' \
489 < $file > $file.$$.bak
490 mv -f $file.$$.bak $file
498 ## Fix glade2-generated files
500 if test "${action}" = "glade2"
502 for file in modules/gui/gtk2/gnome2.glade modules/gui/gtk2/gtk2.glade
504 echo "generating code from $file"
505 glade-2 -w $file || exit 1
512 ## Fix flexml-generated files
514 if test "${action}" = "flexml"
516 cd modules/gui/skins/parser
517 flexml -SH -a skin.act skin.dtd
518 # comment the dummy main function
520 sed 's@int main@//int main@' < $file > $file.$$.bak
521 mv -f $file.$$.bak $file
522 flex -oflex.c -BLs skin.l
528 if test "${action}" = "distclean"
531 # a naive sanity check to make sure we are in a VLC tree
532 test -f vlc.spec.mdk -a -f debian/rules || exit 1
534 find . -type f '(' -name '*.[oa]' -o -name '*.so' -o -name '*.sl' -o -name '*.dylib' -o -name '*.dll' -o -name .dirstamp -o -name Makefile.in -o -name 'stamp-h*' -o -name '*~' -o -name '*.bak' -o -name '*.moc.cpp' ')' -exec rm -f '{}' ';'
535 (cd autotools && find . -name '[a-z]*' -exec rm -f '{}' ';')
536 (cd debian && find . -type d -name '[a-z]*' -maxdepth 1 -exec rm -Rf '{}' ';')
537 find msvc -type f -name '*.dsp' -exec rm -f '{}' ';'
538 find evc -type f -name '*.vcp' -exec rm -f '{}' ';'
539 #find . -type d -name '.deps' -exec rm -Rf '{}' ';'
540 # there's some more cruft all around
541 rm -f config.h config.log config.status
542 rm -f vlc vlc-config Makefile Modules.am
543 rm -Rf autom4te.cache
544 rm -f mozilla/vlcintf.h mozilla/vlcintf.xpt
545 # FIXME: a lot of Makefiles are still there
548 if test "${action}" = "woody"
553 # changelog: replace (1.2.3-4) with (1.2.3-0woody.4)
554 sed -e 's/^vlc (\([^)]*\)-\([^-)]*\))/vlc-woody (\1-0woody.\2)/' \
555 -e 's/ unstable; / stable; /' \
556 < "$1/debian/changelog" > "$1/debian/changelog.woody"
557 mv "$1/debian/changelog.woody" "$1/debian/changelog"
559 # control: replace liba52-*-dev with a52dec-dev (>=0.7.3)
560 # libdv*-dev with libdv-dev
561 # kdelibs4-dev with kdelibs-dev
562 # libqt3-mt-dev libqt3-compat-headers with libqt-dev
563 # libarts1-dev with libarts-dev
564 # libdvdread3-dev with libdvdread2-dev
565 # libdvdplay0-dev (>=1.0.1-2) with libdvdplay0-dev
566 # remove libwxgtk2.4-dev
568 # libidl0 (workaround for mozilla-dev's bad deps)
569 # libglib2.0-0 (workaround for mozilla-dev's bad deps)
571 # change Source: vlc with Source: vlc-woody
572 # Section: gnome with Section: graphics
573 # Section: kde with Section: kde
574 # Section: libdevel with Section: devel
575 sed -e 's/liba52-[^-]*-dev/a52dec-dev (>=0.7.3)/' \
576 -e 's/libdv[0-9]*-dev/libdv-dev/' \
577 -e 's/kdelibs[0-9]*-dev/kdelibs-dev/' \
578 -e 's/libqt[0-9]*-mt-dev/libqt-dev/' \
579 -e 's/, libqt[0-9]*-compat-headers[^,]*//' \
580 -e 's/libarts[0-9]*-dev/libarts-dev/' \
581 -e 's/libdvdread[0-9]*-dev/libdvdread2-dev/' \
582 -e 's/, libdvdplay0-dev[^,]*/, libdvdplay0-dev/' \
583 -e 's/, libwx[^,]*//' \
584 -e '/Package: wxvlc/,/^ *$/d' \
585 -e 's/, libflac-dev[^,]*//' \
586 -e 's/, libidl0[^,]*//' \
587 -e 's/, libglib2.0-0[^,]*//' \
588 -e 's/, libmatroska-dev[^,]*//' \
589 -e 's/Source: vlc/Source: vlc-woody/' \
590 -e 's/Section: gnome/Section: graphics/' \
591 -e 's/Section: kde/Section: graphics/' \
592 -e 's/Section: libdevel/Section: devel/' \
593 < "$1/debian/control" > "$1/debian/control.woody"
594 mv "$1/debian/control.woody" "$1/debian/control"
596 # rules: remove wxwindows and skins stuff
597 # remove flac support
598 # remove matroska support
599 sed -e '/# Package: wxvlc/,/^ *$/d' \
600 -e 's,--enable-wxwindows,--disable-wxwindows,' \
601 -e 's,--enable-skins,--disable-skins,' \
602 -e 's,--enable-flac,--disable-flac,' \
603 -e 's,--enable-mkv,--disable-mkv,' \
604 < "$1/debian/rules" > "$1/debian/rules.woody"
605 mv "$1/debian/rules.woody" "$1/debian/rules"
606 chmod 0755 "$1/debian/rules"