3 ## toolbox for the VLC media player
4 ## $Id: toolbox,v 1.21 2003/04/09 16:05:58 sam Exp $
6 ## Authors: Samuel Hocevar <sam@zoy.org>
9 ### Get a sane environment, just in case
23 --update-changelog update the CVS changelog
24 --update-vc update Microsoft Visual Studio files
25 --update-po update translation files
26 --update-includes [BUILTINS] generate various include files
27 --update-glade generate and fix Glade code
28 --update-glade2 generate and fix Glade 2 code
29 --update-flexml generate and fix flexml and flex code
30 --distclean "make distclean"
36 ## Extract stuff from Makefile.am
40 awk 'BEGIN{a=0}{if(!a&&/^'"$1"'[^-_a-zA-Z0-9]*=/){a=1;print$0;next;}if(a){if(/^[a-zA-Z]/){exit;}print $0}}' < Makefile.am | \
42 sed -ne 's/[^-$()_a-zA-Z0-9][^-$()_a-zA-Z0-9]*\([a-zA-Z]\)/\1/p'
70 --update-glade|--fix-glade)
73 --update-glade2|--update-glade-2|--fix-glade2)
83 echo "$0: unknown option $1"
90 ## Update the CVS changelog
92 if test "${action}" = "changelog"
94 cvs2cl --help >/dev/null 2>&1 || exit 1
96 cvs2cl --utc --hide-filenames --no-wrap -w --stdout | \
97 sed -e 's/^[^0-9]/ /' -e 's/^ *$//' | \
103 ## Update the MSVC project files
105 if test "${action}" = "vc"
107 echo "generating Visual Studio files..."
112 # Variables we get from configure.ac.in
113 LIBVLC_VERSION=`sed -ne '/AC_INIT/s/.*,\(.*\))/\1/p' < configure.ac.in`
114 LIBVLC_CODENAME=`sed -ne '/CODENAME=/s/.*"\(.*\)"/\1/p' < configure.ac.in`
115 LIBVLC_SYMBOL=`echo $LIBVLC_VERSION | sed -e 'y/.-/__/'`
117 # Sources that get built under Win32 - FIXME: anyone wanna deuglify this? :)
118 LIBVLC_SOURCES=`getfiles SOURCES_libvlc_common; getfiles SOURCES_libvlc_win32; getfiles SOURCES_libvlc_dirent; getfiles SOURCES_libvlc_getopt; getfiles SOURCES_libvlc_libc`
120 LIBVLC_HEADERS=`getfiles HEADERS_include; getfiles HEADERS_include_built`
122 LIBVLC_PKG_HEADERS=`getfiles dist_pkginclude_HEADERS`
125 rm -f evc/*.vcp msvc/*.dsp
128 for target in evc/config.h msvc/config.h
132 sed -e "s/@CODENAME@/${LIBVLC_CODENAME}/" \
133 -e "s/@VERSION@/${LIBVLC_VERSION}/" \
134 -e "s/@SYMBOL@/${LIBVLC_SYMBOL}/" < ${target}.in > ${target}
138 for target in evc/libvlc.vcp msvc/libvlc.dsp
141 # Top of the project file
142 perl -pe 'if(/§SOURCES§/){last;}' < ${target}.in > ${target}
144 for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep -v "/.*/"`
146 cat >> ${target} << EOF
147 # Begin Source File${M}
148 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
149 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
150 # End Source File${M}
153 for subdir in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/.*/" | cut -f2 -d/ | sort | uniq`
155 cat >> ${target} << EOF
156 # Begin Group "${subdir}"${M}
158 for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/${subdir}/"`
160 if test "${target}" = "evc/libvlc.vcp"
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 !IF "\$(CFG)" == "libvlc - Win32 (WCE MIPS) Release"${M}
167 # PROP Output_Dir "MIPSRel\\${subdir}"${M}
168 # PROP Intermediate_Dir "MIPSRel\\${subdir}"${M}
169 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE MIPS) Debug"${M}
170 # PROP Output_Dir "MIPSDbg\\${subdir}"${M}
171 # PROP Intermediate_Dir "MIPSDbg\\${subdir}"${M}
172 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH4) Release"${M}
173 # PROP Output_Dir "SH4Rel\\${subdir}"${M}
174 # PROP Intermediate_Dir "SH4Rel\\${subdir}"${M}
175 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH4) Debug"${M}
176 # PROP Output_Dir "SH4Dbg\\${subdir}"${M}
177 # PROP Intermediate_Dir "SH4Dbg\\${subdir}"${M}
178 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH3) Release"${M}
179 # PROP Output_Dir "SH3Rel\\${subdir}"${M}
180 # PROP Intermediate_Dir "SH3Rel\\${subdir}"${M}
181 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH3) Debug"${M}
182 # PROP Output_Dir "SH3Dbg\\${subdir}"${M}
183 # PROP Intermediate_Dir "SH3Dbg\\${subdir}"${M}
184 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARM) Release"${M}
185 # PROP Output_Dir "ARMRel\\${subdir}"${M}
186 # PROP Intermediate_Dir "ARMRel\\${subdir}"${M}
187 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARM) Debug"${M}
188 # PROP Output_Dir "ARMDbg\\${subdir}"${M}
189 # PROP Intermediate_Dir "ARMDbg\\${subdir}"${M}
190 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE x86em) Release"${M}
191 # PROP Output_Dir "X86EMRel\\${subdir}"${M}
192 # PROP Intermediate_Dir "X86EMRel\\${subdir}"${M}
193 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE x86em) Debug"${M}
194 # PROP Output_Dir "X86EMDbg\\${subdir}"${M}
195 # PROP Intermediate_Dir "X86EMDbg\\${subdir}"${M}
197 # End Source File${M}
200 cat >> ${target} << EOF
201 # Begin Source File${M}
202 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
203 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
204 !IF "\$(CFG)" == "libvlc - Win32 Release"${M}
205 # PROP Output_Dir "Release\\${subdir}"${M}
206 # PROP Intermediate_Dir "Release\\${subdir}"${M}
207 !ELSEIF "\$(CFG)" == "libvlc - Win32 Debug"${M}
208 # PROP Output_Dir "Debug\\${subdir}"${M}
209 # PROP Intermediate_Dir "Debug\\${subdir}"${M}
211 # End Source File${M}
215 cat >> ${target} << EOF
220 perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){if(/§HEADERS§/){last;}print $_}' < ${target}.in >> ${target}
221 for file in ${LIBVLC_HEADERS}
223 cat >> ${target} << EOF
224 # Begin Source File${M}
225 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
226 # End Source File${M}
229 cat >> ${target} << EOF
230 # Begin Group "vlc"${M}
232 for file in ${LIBVLC_PKG_HEADERS}
234 cat >> ${target} << EOF
235 # Begin Source File${M}
236 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
237 # End Source File${M}
240 cat >> ${target} << EOF
243 perl -e 'while(<>){if(/§HEADERS§/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
247 grep '^L_[^ ]*_pic =' Modules.am | while read a b c
249 makefile="`echo $c | sed -e 's@/[^/]*$@/Modules.am@'`"
250 plugin="`echo $a | sed 's/L_\(.*\)_pic/\1/'`"
251 # this is an attempt at getting a list of plugin sources... we take the
252 # production and remove everything that does not contain "module", which
253 # means you miss $(NULL), but other variables too.
254 cfiles=`grep -v '[^-_a-zA-Z0-9]*#' ${makefile} | awk 'BEGIN{a=0}{if(!a&&/^SOURCES_'${plugin}'[^-_a-zA-Z0-9]*=/){a=1;print$0;next;}if(a){if(/^[a-zA-Z]/){exit;}print $0}}' | tr '\\ ' '\n\n' | sed -ne 's,/,\\\\,g; s/.*modules/modules/p'`
255 hfiles=`for i in ${cfiles} ; do echo $i ; done | grep '\.h$'`
256 cfiles=`for i in ${cfiles} ; do echo $i ; done | grep -v '\.h$'`
259 test "${dir}" = "evc" && suf="vcp" || suf="dsp"
260 source="${dir}/plugins.${suf}.in"
261 target="${dir}/plugin_${plugin}.${suf}"
263 perl -pe 'if(/§SOURCES§/){last;} s/§PLUGIN§/'${plugin}'/g' < ${source} > ${target}
264 for cfile in ${cfiles}
266 cat >> ${target} << EOF
267 # Begin Source File${M}
268 SOURCE="..\\${cfile}"${M}
269 # ADD CPP /D "__VLC__" /D "__PLUGIN__" /D "MODULE_NAME=${plugin}" /D "MODULE_NAME_IS_${plugin}" ${M}
270 # End Source File${M}
273 # sed is really nicer for this... unfortunately it's broken under cygwin
274 # sed -ne '1,/§SOURCES§/d; /§HEADERS§/,$d; p' < ${source} >> ${target}
275 perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){if(/§HEADERS§/){last;}print $_}' < ${source} >> ${target}
276 for hfile in ${hfiles}
278 cat >> ${target} << EOF
279 # Begin Source File${M}
280 SOURCE="..\\${hfile}"${M}
281 # End Source File${M}
284 # sed -ne '1,/§HEADERS§/d; p' < ${source} >> ${target}
285 perl -e 'while(<>){if(/§HEADERS§/){last;}}while(<>){print $_}' < ${source} >> ${target}
290 for target in evc/vlc.vcp msvc/vlc.dsp
293 # Top of the project file
294 perl -pe 'if(/§SOURCES§/){last;}' < ${target}.in > ${target}
296 if test "${target}" = "evc/vlc.vcp"
298 cat >> ${target} << EOF
299 # Begin Source File${M}
300 SOURCE="..\\evc\\vlc.c"${M}
301 # End Source File${M}
304 cat >> ${target} << EOF
305 # Begin Source File${M}
306 SOURCE="..\\src\\vlc.c"${M}
307 # End Source File${M}
310 # Bottom of the project file - handles resource files too
311 perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
319 ## Update the potfiles because no one ever does it
321 if test "${action}" = "po"
323 # create a fake file containing win32 strings
324 rm -f modules/gui/win32/strings.cpp
325 printf "/* Automatically generated by 'toolbox --update-po', please don't compile */\n" > modules/gui/win32/strings.cpp
326 find modules/gui/win32 -name '*.dfm' | while read file
328 printf "\n/*\n * from $file:\n */\n\n" >> modules/gui/win32/strings.cpp
329 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
335 make vlc.pot || exit 1
336 make update-po || exit 1
343 ## Create include files
345 if test "${action}" = "includes"
349 LIBVLC_HEADERS=`getfiles HEADERS_include`
350 BUILTINS=`while test $# -gt 0; do echo $1; shift; done`
352 file=include/vlc_symbols.h
355 echo '/* DO NOT EDIT THIS FILE! See Makefile.am */' >> ${file}.in
356 echo 'struct module_symbols_t {' >> ${file}.in
357 cat ${LIBVLC_HEADERS} | grep '^ *VLC_EXPORT.*;' | sed -e 's/VLC_EXPORT( *\([^,]*\), *\([^,]*\), *\(.*\));.*/ \1 (* \2_inner) \3;/' >> ${file}.in
358 echo '};' >> ${file}.in
359 echo '#ifdef __PLUGIN__' >> ${file}.in
360 cat ${LIBVLC_HEADERS} | grep '^ *VLC_EXPORT.*;' | sed -e 's/VLC_EXPORT( *\([^,]*\), *\([^,]*\), *\(.*\));.*/# define \2 p_symbols->\2_inner/' >> ${file}.in
361 echo '#endif /* __PLUGIN__ */' >> ${file}.in
362 if ! diff -q ${file} ${file}.in
364 mv -f ${file}.in ${file}
369 file=src/misc/modules_plugin.h
371 rm -f ${file}.tmp && cp ${file}.in ${file}.tmp
372 sed -e 's#.*\$[I][d]:.*# * Automatically generated from '${file}'.in by bootstrap#' < ${file}.in > ${file}.tmp
373 echo '#define STORE_SYMBOLS( p_symbols ) \' >> ${file}.tmp
374 cat ${LIBVLC_HEADERS} | grep '^ *VLC_EXPORT.*;' | sed -e 's/VLC_EXPORT( *\([^,]*\), *\([^,]*\), *\(.*\));.*/ (p_symbols)->\2_inner = \2; \\/' >> ${file}.tmp
375 echo '' >> ${file}.tmp
376 if ! diff -q ${file} ${file}.tmp
378 mv -f ${file}.tmp ${file}
383 file=src/misc/modules_builtin.h
385 rm -f ${file}.tmp && cp ${file}.in ${file}.tmp
386 if test "${BUILTINS}" != ""
388 for i in `echo ${BUILTINS}`
390 echo "int vlc_entry__`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`( module_t* );" >>${file}.tmp
392 echo "" >> ${file}.tmp
394 echo "#define ALLOCATE_ALL_BUILTINS() \\" >> ${file}.tmp
395 echo " do \\" >> ${file}.tmp
396 echo " { \\" >> ${file}.tmp
397 if test "${BUILTINS}" != ""
399 for i in `echo ${BUILTINS}`
401 echo " ALLOCATE_BUILTIN(`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`); \\" >> ${file}.tmp
404 echo " } while( 0 );" >> ${file}.tmp
405 echo "" >> ${file}.tmp
406 if ! diff -q ${file} ${file}.tmp
408 mv -f ${file}.tmp ${file}
417 ## Fix glade-generated files
419 if test "${action}" = "glade"
421 for file in modules/gui/gtk/gnome.glade modules/gui/gtk/gtk.glade modules/gui/familiar/familiar.glade
423 echo "generating code from $file"
424 glade -w $file || exit 1
427 for file in modules/gui/gtk/gnome_interface.c modules/gui/gtk/gtk_interface.c modules/gui/familiar/interface.c
430 if grep "DO NOT EDIT THIS FILE" $file 2>&1 > /dev/null
433 cat > $file.$$.bak << EOF
434 /* This file was created automatically by glade and fixed by bootstrap */
439 -e 's#_(\(".:..:.."\))#\1#' \
440 -e 's#_(\("[a-z0-9]*://[^"]*"\))#\1#' \
441 -e 's#_("---")#"---"#' \
442 -e 's#_("--")#"--"#' \
443 -e 's#_("/dev/dvd")#"/dev/dvd"#' \
444 -e 's#_(\("./."\))#\1#' \
445 < $file >> $file.$$.bak
446 mv -f $file.$$.bak $file
450 for file in modules/gui/gtk/gtk_support.h modules/gui/familiar/support.h
453 if grep "DO NOT EDIT THIS FILE" $file 2>&1 > /dev/null
456 sed -e 's/DO NOT EDIT.*/Created by glade, fixed by bootstrap/' \
457 -e 's,<config.h>,<vlc/vlc.h>,' \
458 -e 's,#if.*ENABLE_NLS.*,#if 0 /* Disabled by bootstrap */,' \
459 -e 's,#else,/* & */,' \
460 < $file > $file.$$.bak
461 mv -f $file.$$.bak $file
469 ## Fix glade2-generated files
471 if test "${action}" = "glade2"
473 for file in modules/gui/gtk2/gnome2.glade modules/gui/gtk2/gtk2.glade
475 echo "generating code from $file"
476 glade-2 -w $file || exit 1
483 ## Fix flexml-generated files
485 if test "${action}" = "flexml"
487 cd modules/gui/skins/parser
488 flexml -SH -a skin.act skin.dtd
489 # comment the dummy main function
491 sed 's@int main@//int main@' < $file > $file.$$.bak
492 mv -f $file.$$.bak $file
493 flex -oflex.c -BLs skin.l
499 if test "${action}" = "distclean"
502 # a naive sanity check to make sure we are in a VLC tree
503 test -f vlc.spec -a -f debian/rules || exit 1
505 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 '{}' ';'
506 (cd autotools && find . -name '[a-z]*' -exec rm -f '{}' ';')
507 (cd debian && find . -type d -name '[a-z]*' -maxdepth 1 -exec rm -Rf '{}' ';')
508 find msvc -type f -name '*.dsp' -exec rm -f '{}' ';'
509 find evc -type f -name '*.vcp' -exec rm -f '{}' ';'
510 #find . -type d -name '.deps' -exec rm -Rf '{}' ';'
511 # there's some more cruft all around
512 rm -f configure.ac config.h config.log config.status
513 rm -f vlc vlc-config Makefile Modules.am
514 rm -Rf autom4te.cache
515 rm -f mozilla/vlcintf.h mozilla/vlcintf.xpt
516 # FIXME: a lot of Makefiles are still there