3 ## toolbox for the VLC media player
4 ## $Id: toolbox,v 1.29 2003/06/28 01:17:47 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"
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'
55 --changelog|--update-changelog)
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"
96 cvs2cl --help >/dev/null 2>&1 || exit 1
97 rm -f ChangeLog ChangeLog.tmp
98 cvs2cl --utc --hide-filenames --no-wrap -w --stdout -g -z9 | \
99 sed -e 's/^[^0-9]/ /' -e 's/^ *$//' | \
101 YEAR=`sed -e 's/\(....\)-..-.*/\1/;q' ChangeLog.tmp`
102 LASTYEAR="$((${YEAR} - 1))"
103 sed -ne "/^${YEAR}-..-../,/^${LASTYEAR}-..-../{/^${LASTYEAR}-..-../d;p}" \
104 < ChangeLog.tmp > Changelog
107 # To generate changelog for the year 2001:
108 # sed -ne '/^2001/,/^2000/{/^2000/d;p}'
112 ## Update the MSVC project files
114 if test "${action}" = "vc"
116 echo "generating Visual Studio files..."
121 # Variables we get from configure.ac
122 LIBVLC_VERSION=`sed -ne '/AC_INIT/s/.*,\(.*\))/\1/p' < configure.ac`
123 LIBVLC_CODENAME=`sed -ne '/CODENAME=/s/.*"\(.*\)"/\1/p' < configure.ac`
124 LIBVLC_SYMBOL=`echo $LIBVLC_VERSION | sed -e 'y/.-/__/'`
126 # Sources that get built under Win32 - FIXME: anyone wanna deuglify this? :)
127 LIBVLC_SOURCES=`getfiles SOURCES_libvlc_common; getfiles SOURCES_libvlc_win32; getfiles SOURCES_libvlc_dirent; getfiles SOURCES_libvlc_getopt; getfiles SOURCES_libvlc_libc`
129 LIBVLC_HEADERS=`getfiles HEADERS_include; getfiles HEADERS_include_built`
131 LIBVLC_PKG_HEADERS=`getfiles dist_pkginclude_HEADERS`
134 rm -f evc/*.vcp msvc/*.dsp
137 for target in evc/config.h msvc/config.h
141 sed -e "s/@CODENAME@/${LIBVLC_CODENAME}/" \
142 -e "s/@VERSION@/${LIBVLC_VERSION}/" \
143 -e "s/@SYMBOL@/${LIBVLC_SYMBOL}/" < ${target}.in > ${target}
147 for target in evc/libvlc.vcp msvc/libvlc.dsp
150 # Top of the project file
151 perl -pe 'if(/§SOURCES§/){last;}' < ${target}.in > ${target}
153 for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep -v "/.*/"`
155 cat >> ${target} << EOF
156 # Begin Source File${M}
157 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
158 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
159 # End Source File${M}
162 for subdir in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/.*/" | cut -f2 -d/ | sort | uniq`
164 cat >> ${target} << EOF
165 # Begin Group "${subdir}"${M}
167 for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/${subdir}/"`
169 if test "${target}" = "evc/libvlc.vcp"
171 cat >> ${target} << EOF
172 # Begin Source File${M}
173 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
174 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
175 !IF "\$(CFG)" == "libvlc - Win32 (WCE MIPS) Release"${M}
176 # PROP Output_Dir "MIPSRel\\${subdir}"${M}
177 # PROP Intermediate_Dir "MIPSRel\\${subdir}"${M}
178 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE MIPS) Debug"${M}
179 # PROP Output_Dir "MIPSDbg\\${subdir}"${M}
180 # PROP Intermediate_Dir "MIPSDbg\\${subdir}"${M}
181 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH4) Release"${M}
182 # PROP Output_Dir "SH4Rel\\${subdir}"${M}
183 # PROP Intermediate_Dir "SH4Rel\\${subdir}"${M}
184 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH4) Debug"${M}
185 # PROP Output_Dir "SH4Dbg\\${subdir}"${M}
186 # PROP Intermediate_Dir "SH4Dbg\\${subdir}"${M}
187 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH3) Release"${M}
188 # PROP Output_Dir "SH3Rel\\${subdir}"${M}
189 # PROP Intermediate_Dir "SH3Rel\\${subdir}"${M}
190 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH3) Debug"${M}
191 # PROP Output_Dir "SH3Dbg\\${subdir}"${M}
192 # PROP Intermediate_Dir "SH3Dbg\\${subdir}"${M}
193 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARM) Release"${M}
194 # PROP Output_Dir "ARMRel\\${subdir}"${M}
195 # PROP Intermediate_Dir "ARMRel\\${subdir}"${M}
196 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARM) Debug"${M}
197 # PROP Output_Dir "ARMDbg\\${subdir}"${M}
198 # PROP Intermediate_Dir "ARMDbg\\${subdir}"${M}
199 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE x86em) Release"${M}
200 # PROP Output_Dir "X86EMRel\\${subdir}"${M}
201 # PROP Intermediate_Dir "X86EMRel\\${subdir}"${M}
202 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE x86em) Debug"${M}
203 # PROP Output_Dir "X86EMDbg\\${subdir}"${M}
204 # PROP Intermediate_Dir "X86EMDbg\\${subdir}"${M}
206 # End Source File${M}
209 cat >> ${target} << EOF
210 # Begin Source File${M}
211 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
212 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
213 !IF "\$(CFG)" == "libvlc - Win32 Release"${M}
214 # PROP Output_Dir "Release\\${subdir}"${M}
215 # PROP Intermediate_Dir "Release\\${subdir}"${M}
216 !ELSEIF "\$(CFG)" == "libvlc - Win32 Debug"${M}
217 # PROP Output_Dir "Debug\\${subdir}"${M}
218 # PROP Intermediate_Dir "Debug\\${subdir}"${M}
220 # End Source File${M}
224 cat >> ${target} << EOF
229 perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){if(/§HEADERS§/){last;}print $_}' < ${target}.in >> ${target}
230 for file in ${LIBVLC_HEADERS}
232 cat >> ${target} << EOF
233 # Begin Source File${M}
234 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
235 # End Source File${M}
238 cat >> ${target} << EOF
239 # Begin Group "vlc"${M}
241 for file in ${LIBVLC_PKG_HEADERS}
243 cat >> ${target} << EOF
244 # Begin Source File${M}
245 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
246 # End Source File${M}
249 cat >> ${target} << EOF
252 perl -e 'while(<>){if(/§HEADERS§/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
256 grep '^L_[^ ]*_pic =' Modules.am | while read a b c
258 makefile="`echo $c | sed -e 's@/[^/]*$@/Modules.am@'`"
259 plugin="`echo $a | sed 's/L_\(.*\)_pic/\1/'`"
260 # this is an attempt at getting a list of plugin sources... we take the
261 # production and remove everything that does not contain "module", which
262 # means you miss $(NULL), but other variables too.
263 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'`
264 hfiles=`for i in ${cfiles} ; do echo $i ; done | grep '\.h$'`
265 cfiles=`for i in ${cfiles} ; do echo $i ; done | grep -v '\.h$'`
268 test "${dir}" = "evc" && suf="vcp" || suf="dsp"
269 source="${dir}/plugins.${suf}.in"
270 target="${dir}/plugin_${plugin}.${suf}"
272 perl -pe 'if(/§SOURCES§/){last;} s/§PLUGIN§/'${plugin}'/g' < ${source} > ${target}
273 for cfile in ${cfiles}
275 cat >> ${target} << EOF
276 # Begin Source File${M}
277 SOURCE="..\\${cfile}"${M}
278 # ADD CPP /D "__VLC__" /D "__PLUGIN__" /D "MODULE_NAME=${plugin}" /D "MODULE_NAME_IS_${plugin}" ${M}
279 # End Source File${M}
282 # sed is really nicer for this... unfortunately it's broken under cygwin
283 # sed -ne '1,/§SOURCES§/d; /§HEADERS§/,$d; p' < ${source} >> ${target}
284 perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){if(/§HEADERS§/){last;}print $_}' < ${source} >> ${target}
285 for hfile in ${hfiles}
287 cat >> ${target} << EOF
288 # Begin Source File${M}
289 SOURCE="..\\${hfile}"${M}
290 # End Source File${M}
293 # sed -ne '1,/§HEADERS§/d; p' < ${source} >> ${target}
294 perl -e 'while(<>){if(/§HEADERS§/){last;}}while(<>){print $_}' < ${source} >> ${target}
299 for target in evc/vlc.vcp msvc/vlc.dsp
302 # Top of the project file
303 perl -pe 'if(/§SOURCES§/){last;}' < ${target}.in > ${target}
305 if test "${target}" = "evc/vlc.vcp"
307 cat >> ${target} << EOF
308 # Begin Source File${M}
309 SOURCE="..\\evc\\vlc.c"${M}
310 # End Source File${M}
313 cat >> ${target} << EOF
314 # Begin Source File${M}
315 SOURCE="..\\src\\vlc.c"${M}
316 # End Source File${M}
319 # Bottom of the project file - handles resource files too
320 perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
328 ## Update the potfiles because no one ever does it
330 if test "${action}" = "po"
332 # create a fake file containing win32 strings
333 rm -f modules/gui/win32/strings.cpp
334 #printf "/* Automatically generated by 'toolbox --update-po', please don't compile */\n" > modules/gui/win32/strings.cpp
335 #find modules/gui/win32 -name '*.dfm' | while read file
337 # printf "\n/*\n * from $file:\n */\n\n" >> modules/gui/win32/strings.cpp
338 # 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
340 # find out the source files
342 echo "# automatically created by toolbox --update-po" > po/POTFILES.in
343 echo "" >> po/POTFILES.in
344 echo "# main sources" >> po/POTFILES.in
345 find include src -name '*.[chm]' -o -name '*.[ch]pp' | sort >> po/POTFILES.in
346 echo "" >> po/POTFILES.in
347 echo "# modules" >> po/POTFILES.in
348 find modules -name '*.[chm]' -o -name '*.[ch]pp' | grep -v 'gui/win32/' | sort >> po/POTFILES.in
353 make vlc.pot || exit 1
354 make update-po || exit 1
361 ## Create include files
363 if test "${action}" = "includes"
367 LIBVLC_HEADERS=`getfiles HEADERS_include`
368 BUILTINS=`sed -ne 's/.*builtins *= *" *\([^"]*\)".*/\1/p' vlc-config`
370 file=include/vlc_symbols.h
373 echo '/* DO NOT EDIT THIS FILE! See Makefile.am */' >> ${file}.in
374 echo 'struct module_symbols_t {' >> ${file}.in
375 cat ${LIBVLC_HEADERS} | grep '^ *VLC_EXPORT.*;' | sed -e 's/VLC_EXPORT( *\([^,]*\), *\([^,]*\), *\(.*\));.*/ \1 (* \2_inner) \3;/' >> ${file}.in
376 echo '};' >> ${file}.in
377 echo '#ifdef __PLUGIN__' >> ${file}.in
378 cat ${LIBVLC_HEADERS} | grep '^ *VLC_EXPORT.*;' | sed -e 's/VLC_EXPORT( *\([^,]*\), *\([^,]*\), *\(.*\));.*/# define \2 p_symbols->\2_inner/' >> ${file}.in
379 echo '#endif /* __PLUGIN__ */' >> ${file}.in
380 if diff >/dev/null 2>&1 ${file} ${file}.in
384 echo "creating new ${file}"
385 mv -f ${file}.in ${file}
388 file=src/misc/modules_plugin.h
390 rm -f ${file}.tmp && cp ${file}.in ${file}.tmp
391 sed -e 's#.*\$[I][d]:.*# * Automatically generated from '${file}'.in by bootstrap#' < ${file}.in > ${file}.tmp
392 echo '#define STORE_SYMBOLS( p_symbols ) \' >> ${file}.tmp
393 cat ${LIBVLC_HEADERS} | grep '^ *VLC_EXPORT.*;' | sed -e 's/VLC_EXPORT( *\([^,]*\), *\([^,]*\), *\(.*\));.*/ (p_symbols)->\2_inner = \2; \\/' >> ${file}.tmp
394 echo '' >> ${file}.tmp
395 if diff >/dev/null 2>&1 ${file} ${file}.tmp
399 echo "creating new ${file}"
400 mv -f ${file}.tmp ${file}
403 file=src/misc/modules_builtin.h
405 rm -f ${file}.tmp && cp ${file}.in ${file}.tmp
406 if test "${BUILTINS}" != ""
408 for i in `echo ${BUILTINS}`
410 echo "int vlc_entry__`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`( module_t* );" >>${file}.tmp
412 echo "" >> ${file}.tmp
414 echo "#define ALLOCATE_ALL_BUILTINS() \\" >> ${file}.tmp
415 echo " do \\" >> ${file}.tmp
416 echo " { \\" >> ${file}.tmp
417 if test "${BUILTINS}" != ""
419 for i in `echo ${BUILTINS}`
421 echo " ALLOCATE_BUILTIN(`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`); \\" >> ${file}.tmp
424 echo " } while( 0 );" >> ${file}.tmp
425 echo "" >> ${file}.tmp
426 if diff >/dev/null 2>&1 ${file} ${file}.tmp
430 echo "creating new ${file}"
431 mv -f ${file}.tmp ${file}
438 ## Fix glade-generated files
440 if test "${action}" = "glade"
442 for file in modules/gui/gtk/gnome.glade modules/gui/gtk/gtk.glade modules/gui/familiar/familiar.glade
444 echo "generating code from $file"
445 glade -w $file || exit 1
448 for file in modules/gui/gtk/gnome_interface.c modules/gui/gtk/gtk_interface.c modules/gui/familiar/interface.c
451 if grep "DO NOT EDIT THIS FILE" $file >/dev/null 2>&1
454 cat > $file.$$.bak << EOF
455 /* This file was created automatically by glade and fixed by bootstrap */
460 -e 's#_(\(".:..:.."\))#\1#' \
461 -e 's#_(\("[a-z0-9]*://[^"]*"\))#\1#' \
462 -e 's#_("---")#"---"#' \
463 -e 's#_("--")#"--"#' \
464 -e 's#_("/dev/dvd")#"/dev/dvd"#' \
465 -e 's#_(\("./."\))#\1#' \
466 < $file >> $file.$$.bak
467 mv -f $file.$$.bak $file
471 for file in modules/gui/gtk/gtk_support.h modules/gui/familiar/support.h
474 if grep "DO NOT EDIT THIS FILE" $file >/dev/null 2>&1
477 sed -e 's/DO NOT EDIT.*/Created by glade, fixed by bootstrap/' \
478 -e 's,<config.h>,<vlc/vlc.h>,' \
479 -e 's,#if.*ENABLE_NLS.*,#if 0 /* Disabled by bootstrap */,' \
480 -e 's,#else,/* & */,' \
481 < $file > $file.$$.bak
482 mv -f $file.$$.bak $file
490 ## Fix glade2-generated files
492 if test "${action}" = "glade2"
494 for file in modules/gui/gtk2/gnome2.glade modules/gui/gtk2/gtk2.glade
496 echo "generating code from $file"
497 glade-2 -w $file || exit 1
504 ## Fix flexml-generated files
506 if test "${action}" = "flexml"
508 cd modules/gui/skins/parser
509 flexml -SH -a skin.act skin.dtd
510 # comment the dummy main function
512 sed 's@int main@//int main@' < $file > $file.$$.bak
513 mv -f $file.$$.bak $file
514 flex -oflex.c -BLs skin.l
520 if test "${action}" = "distclean"
523 # a naive sanity check to make sure we are in a VLC tree
524 test -f vlc.spec -a -f debian/rules || exit 1
526 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 '{}' ';'
527 (cd autotools && find . -name '[a-z]*' -exec rm -f '{}' ';')
528 (cd debian && find . -type d -name '[a-z]*' -maxdepth 1 -exec rm -Rf '{}' ';')
529 find msvc -type f -name '*.dsp' -exec rm -f '{}' ';'
530 find evc -type f -name '*.vcp' -exec rm -f '{}' ';'
531 #find . -type d -name '.deps' -exec rm -Rf '{}' ';'
532 # there's some more cruft all around
533 rm -f config.h config.log config.status
534 rm -f vlc vlc-config Makefile Modules.am
535 rm -Rf autom4te.cache
536 rm -f mozilla/vlcintf.h mozilla/vlcintf.xpt
537 # FIXME: a lot of Makefiles are still there