3 ## toolbox for the VLC media player
4 ## $Id: toolbox,v 1.36 2003/07/01 19:17:32 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&&$0~/^'"$1"'[^-_a-zA-Z0-9]*=/){a=1;print$0;next;}if(a){if($0~/^[a-zA-Z]/){exit;}print $0}}' < "${srcdir}/Makefile.am" | \
42 sed -ne 's/[^-$()_a-zA-Z0-9][^-$()_a-zA-Z0-9]*\([a-zA-Z]\)/\1/p' | \
43 sed -e "s,^,${srcdir}/,"
56 --changelog|--update-changelog)
71 --update-glade|--fix-glade)
74 --update-glade2|--update-glade-2|--fix-glade2)
84 echo "$0: unknown option $1"
91 ## Update the CVS changelog
93 if test "${action}" = "changelog"
97 cvs2cl --help >/dev/null 2>&1 || exit 1
98 rm -f ChangeLog ChangeLog.tmp
99 cvs2cl --utc --hide-filenames --no-wrap -w --stdout -g -z9 | \
100 sed -e 's/^[^0-9]/ /' -e 's/^ *$//' | \
102 YEAR=`sed -e 's/\(....\)-..-.*/\1/;q' ChangeLog.tmp`
103 LASTYEAR="$((${YEAR} - 1))"
104 sed -ne "/^${YEAR}-..-../,/^${LASTYEAR}-..-../{/^${LASTYEAR}-..-../d;p}" \
105 < ChangeLog.tmp > Changelog
108 # To generate changelog for the year 2001:
109 # sed -ne '/^2001/,/^2000/{/^2000/d;p}'
113 ## Update the MSVC project files
115 if test "${action}" = "vc"
117 echo "generating Visual Studio files..."
119 srcdir="`sed -ne 's/^srcdir *= *//p' < Makefile`"
124 # Variables we get from configure.ac
125 LIBVLC_VERSION=`sed -ne '/AC_INIT/s/.*,\(.*\))/\1/p' < configure.ac`
126 LIBVLC_CODENAME=`sed -ne '/CODENAME=/s/.*"\(.*\)"/\1/p' < configure.ac`
127 LIBVLC_SYMBOL=`echo $LIBVLC_VERSION | sed -e 'y/.-/__/'`
129 # Sources that get built under Win32 - FIXME: anyone wanna deuglify this? :)
130 LIBVLC_SOURCES=`getfiles SOURCES_libvlc_common; getfiles SOURCES_libvlc_win32; getfiles SOURCES_libvlc_dirent; getfiles SOURCES_libvlc_getopt; getfiles SOURCES_libvlc_libc`
132 LIBVLC_HEADERS=`getfiles HEADERS_include; getfiles HEADERS_include_built`
134 LIBVLC_PKG_HEADERS=`getfiles dist_pkginclude_HEADERS`
137 rm -f evc/*.vcp msvc/*.dsp
140 for target in evc/config.h msvc/config.h
144 sed -e "s/@CODENAME@/${LIBVLC_CODENAME}/" \
145 -e "s/@VERSION@/${LIBVLC_VERSION}/" \
146 -e "s/@SYMBOL@/${LIBVLC_SYMBOL}/" < ${target}.in > ${target}
150 for target in evc/libvlc.vcp msvc/libvlc.dsp
153 # Top of the project file
154 perl -pe 'if(/§SOURCES§/){last;}' < ${target}.in > ${target}
156 for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep -v "/.*/"`
158 cat >> ${target} << EOF
159 # Begin Source File${M}
160 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
161 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
162 # End Source File${M}
165 for subdir in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/.*/" | cut -f2 -d/ | sort | uniq`
167 cat >> ${target} << EOF
168 # Begin Group "${subdir}"${M}
170 for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/${subdir}/"`
172 if test "${target}" = "evc/libvlc.vcp"
174 cat >> ${target} << EOF
175 # Begin Source File${M}
176 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
177 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
178 !IF "\$(CFG)" == "libvlc - Win32 (WCE MIPS) Release"${M}
179 # PROP Output_Dir "MIPSRel\\${subdir}"${M}
180 # PROP Intermediate_Dir "MIPSRel\\${subdir}"${M}
181 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE MIPS) Debug"${M}
182 # PROP Output_Dir "MIPSDbg\\${subdir}"${M}
183 # PROP Intermediate_Dir "MIPSDbg\\${subdir}"${M}
184 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH4) Release"${M}
185 # PROP Output_Dir "SH4Rel\\${subdir}"${M}
186 # PROP Intermediate_Dir "SH4Rel\\${subdir}"${M}
187 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH4) Debug"${M}
188 # PROP Output_Dir "SH4Dbg\\${subdir}"${M}
189 # PROP Intermediate_Dir "SH4Dbg\\${subdir}"${M}
190 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH3) Release"${M}
191 # PROP Output_Dir "SH3Rel\\${subdir}"${M}
192 # PROP Intermediate_Dir "SH3Rel\\${subdir}"${M}
193 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH3) Debug"${M}
194 # PROP Output_Dir "SH3Dbg\\${subdir}"${M}
195 # PROP Intermediate_Dir "SH3Dbg\\${subdir}"${M}
196 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARM) Release"${M}
197 # PROP Output_Dir "ARMRel\\${subdir}"${M}
198 # PROP Intermediate_Dir "ARMRel\\${subdir}"${M}
199 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARM) Debug"${M}
200 # PROP Output_Dir "ARMDbg\\${subdir}"${M}
201 # PROP Intermediate_Dir "ARMDbg\\${subdir}"${M}
202 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE x86em) Release"${M}
203 # PROP Output_Dir "X86EMRel\\${subdir}"${M}
204 # PROP Intermediate_Dir "X86EMRel\\${subdir}"${M}
205 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE x86em) Debug"${M}
206 # PROP Output_Dir "X86EMDbg\\${subdir}"${M}
207 # PROP Intermediate_Dir "X86EMDbg\\${subdir}"${M}
209 # End Source File${M}
212 cat >> ${target} << EOF
213 # Begin Source File${M}
214 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
215 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
216 !IF "\$(CFG)" == "libvlc - Win32 Release"${M}
217 # PROP Output_Dir "Release\\${subdir}"${M}
218 # PROP Intermediate_Dir "Release\\${subdir}"${M}
219 !ELSEIF "\$(CFG)" == "libvlc - Win32 Debug"${M}
220 # PROP Output_Dir "Debug\\${subdir}"${M}
221 # PROP Intermediate_Dir "Debug\\${subdir}"${M}
223 # End Source File${M}
227 cat >> ${target} << EOF
232 perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){if(/§HEADERS§/){last;}print $_}' < ${target}.in >> ${target}
233 for file in ${LIBVLC_HEADERS}
235 cat >> ${target} << EOF
236 # Begin Source File${M}
237 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
238 # End Source File${M}
241 cat >> ${target} << EOF
242 # Begin Group "vlc"${M}
244 for file in ${LIBVLC_PKG_HEADERS}
246 cat >> ${target} << EOF
247 # Begin Source File${M}
248 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
249 # End Source File${M}
252 cat >> ${target} << EOF
255 perl -e 'while(<>){if(/§HEADERS§/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
259 grep '^L_[^ ]*_pic =' Modules.am | while read a b c
261 makefile="`echo $c | sed -e 's@/[^/]*$@/Modules.am@'`"
262 plugin="`echo $a | sed 's/L_\(.*\)_pic/\1/'`"
263 # this is an attempt at getting a list of plugin sources... we take the
264 # production and remove everything that does not contain "module", which
265 # means you miss $(NULL), but other variables too.
266 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'`
267 hfiles=`for i in ${cfiles} ; do echo $i ; done | grep '\.h$'`
268 cfiles=`for i in ${cfiles} ; do echo $i ; done | grep -v '\.h$'`
271 test "${dir}" = "evc" && suf="vcp" || suf="dsp"
272 source="${dir}/plugins.${suf}.in"
273 target="${dir}/plugin_${plugin}.${suf}"
275 perl -pe 'if(/§SOURCES§/){last;} s/§PLUGIN§/'${plugin}'/g' < ${source} > ${target}
276 for cfile in ${cfiles}
278 cat >> ${target} << EOF
279 # Begin Source File${M}
280 SOURCE="..\\${cfile}"${M}
281 # ADD CPP /D "__VLC__" /D "__PLUGIN__" /D "MODULE_NAME=${plugin}" /D "MODULE_NAME_IS_${plugin}" ${M}
282 # End Source File${M}
285 # sed is really nicer for this... unfortunately it's broken under cygwin
286 # sed -ne '1,/§SOURCES§/d; /§HEADERS§/,$d; p' < ${source} >> ${target}
287 perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){if(/§HEADERS§/){last;}print $_}' < ${source} >> ${target}
288 for hfile in ${hfiles}
290 cat >> ${target} << EOF
291 # Begin Source File${M}
292 SOURCE="..\\${hfile}"${M}
293 # End Source File${M}
296 # sed -ne '1,/§HEADERS§/d; p' < ${source} >> ${target}
297 perl -e 'while(<>){if(/§HEADERS§/){last;}}while(<>){print $_}' < ${source} >> ${target}
302 for target in evc/vlc.vcp msvc/vlc.dsp
305 # Top of the project file
306 perl -pe 'if(/§SOURCES§/){last;}' < ${target}.in > ${target}
308 if test "${target}" = "evc/vlc.vcp"
310 cat >> ${target} << EOF
311 # Begin Source File${M}
312 SOURCE="..\\evc\\vlc.c"${M}
313 # End Source File${M}
316 cat >> ${target} << EOF
317 # Begin Source File${M}
318 SOURCE="..\\src\\vlc.c"${M}
319 # End Source File${M}
322 # Bottom of the project file - handles resource files too
323 perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
331 ## Update the potfiles because no one ever does it
333 if test "${action}" = "po"
335 # create a fake file containing win32 strings
336 rm -f modules/gui/win32/strings.cpp
337 #printf "/* Automatically generated by 'toolbox --update-po', please don't compile */\n" > modules/gui/win32/strings.cpp
338 #find modules/gui/win32 -name '*.dfm' | while read file
340 # printf "\n/*\n * from $file:\n */\n\n" >> modules/gui/win32/strings.cpp
341 # 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
343 # find out the source files
345 echo "# automatically created by toolbox --update-po" > po/POTFILES.in
346 echo "" >> po/POTFILES.in
347 echo "# main sources" >> po/POTFILES.in
348 find include src -name '*.[chm]' -o -name '*.[ch]pp' | sort >> po/POTFILES.in
349 echo "" >> po/POTFILES.in
350 echo "# modules" >> po/POTFILES.in
351 find modules -name '*.[chm]' -o -name '*.[ch]pp' | grep -v 'gui/win32/' | sort >> po/POTFILES.in
356 make vlc.pot || exit 1
357 make update-po || exit 1
364 ## Create include files
366 if test "${action}" = "includes"
370 srcdir="`sed -ne 's/^srcdir *= *//p' < Makefile`"
371 LIBVLC_HEADERS=`getfiles HEADERS_include`
372 BUILTINS=`sed -ne 's/.*builtins *= *" *\([^"]*\)".*/\1/p' vlc-config`
374 file="${srcdir}/include/vlc_symbols.h"
377 echo '/* DO NOT EDIT THIS FILE! See Makefile.am */' >> ${file}.in
378 echo 'struct module_symbols_t {' >> ${file}.in
379 cat ${LIBVLC_HEADERS} | grep '^ *VLC_EXPORT.*;' | sed -e 's/VLC_EXPORT( *\([^,]*\), *\([^,]*\), *\(.*\));.*/ \1 (* \2_inner) \3;/' >> ${file}.in
380 echo '};' >> ${file}.in
381 echo '#ifdef __PLUGIN__' >> ${file}.in
382 cat ${LIBVLC_HEADERS} | grep '^ *VLC_EXPORT.*;' | sed -e 's/VLC_EXPORT( *\([^,]*\), *\([^,]*\), *\(.*\));.*/# define \2 p_symbols->\2_inner/' >> ${file}.in
383 echo '#endif /* __PLUGIN__ */' >> ${file}.in
384 if diff >/dev/null 2>&1 ${file} ${file}.in
388 echo "creating new ${file}"
389 mv -f ${file}.in ${file}
392 file="${srcdir}/src/misc/modules_plugin.h"
394 rm -f ${file}.tmp && cp ${file}.in ${file}.tmp
395 sed -e 's#.*\$[I][d]:.*# * Automatically generated from '${file}'.in by bootstrap#' < ${file}.in > ${file}.tmp
396 echo '#define STORE_SYMBOLS( p_symbols ) \' >> ${file}.tmp
397 cat ${LIBVLC_HEADERS} | grep '^ *VLC_EXPORT.*;' | sed -e 's/VLC_EXPORT( *\([^,]*\), *\([^,]*\), *\(.*\));.*/ (p_symbols)->\2_inner = \2; \\/' >> ${file}.tmp
398 echo '' >> ${file}.tmp
399 if diff >/dev/null 2>&1 ${file} ${file}.tmp
403 echo "creating new ${file}"
404 mv -f ${file}.tmp ${file}
407 file="${srcdir}/src/misc/modules_builtin.h"
409 rm -f ${file}.tmp && cp ${file}.in ${file}.tmp
410 if test -n "${BUILTINS}"
412 for i in `echo ${BUILTINS}`
414 echo "int vlc_entry__`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`( module_t* );" >>${file}.tmp
416 echo "" >> ${file}.tmp
418 echo "#define ALLOCATE_ALL_BUILTINS() \\" >> ${file}.tmp
419 echo " do \\" >> ${file}.tmp
420 echo " { \\" >> ${file}.tmp
421 if test -n "${BUILTINS}"
423 for i in `echo ${BUILTINS}`
425 echo " ALLOCATE_BUILTIN(`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`); \\" >> ${file}.tmp
428 echo " } while( 0 );" >> ${file}.tmp
429 echo "" >> ${file}.tmp
430 if diff >/dev/null 2>&1 ${file} ${file}.tmp
434 echo "creating new ${file}"
435 mv -f ${file}.tmp ${file}
442 ## Fix glade-generated files
444 if test "${action}" = "glade"
446 for file in modules/gui/gtk/gnome.glade modules/gui/gtk/gtk.glade modules/gui/familiar/familiar.glade
448 echo "generating code from $file"
449 glade -w $file || exit 1
452 for file in modules/gui/gtk/gnome_interface.c modules/gui/gtk/gtk_interface.c modules/gui/familiar/interface.c
455 if grep "DO NOT EDIT THIS FILE" $file >/dev/null 2>&1
458 cat > $file.$$.bak << EOF
459 /* This file was created automatically by glade and fixed by bootstrap */
464 -e 's#_(\(".:..:.."\))#\1#' \
465 -e 's#_(\("[a-z0-9]*://[^"]*"\))#\1#' \
466 -e 's#_("---")#"---"#' \
467 -e 's#_("--")#"--"#' \
468 -e 's#_("/dev/dvd")#"/dev/dvd"#' \
469 -e 's#_(\("./."\))#\1#' \
470 < $file >> $file.$$.bak
471 mv -f $file.$$.bak $file
475 for file in modules/gui/gtk/gtk_support.h modules/gui/familiar/support.h
478 if grep "DO NOT EDIT THIS FILE" $file >/dev/null 2>&1
481 sed -e 's/DO NOT EDIT.*/Created by glade, fixed by bootstrap/' \
482 -e 's,<config.h>,<vlc/vlc.h>,' \
483 -e 's,#if.*ENABLE_NLS.*,#if 0 /* Disabled by bootstrap */,' \
484 -e 's,#else,/* & */,' \
485 < $file > $file.$$.bak
486 mv -f $file.$$.bak $file
494 ## Fix glade2-generated files
496 if test "${action}" = "glade2"
498 for file in modules/gui/gtk2/gnome2.glade modules/gui/gtk2/gtk2.glade
500 echo "generating code from $file"
501 glade-2 -w $file || exit 1
508 ## Fix flexml-generated files
510 if test "${action}" = "flexml"
512 cd modules/gui/skins/parser
513 flexml -SH -a skin.act skin.dtd
514 # comment the dummy main function
516 sed 's@int main@//int main@' < $file > $file.$$.bak
517 mv -f $file.$$.bak $file
518 flex -oflex.c -BLs skin.l
524 if test "${action}" = "distclean"
527 # a naive sanity check to make sure we are in a VLC tree
528 test -f vlc.spec -a -f debian/rules || exit 1
530 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 '{}' ';'
531 (cd autotools && find . -name '[a-z]*' -exec rm -f '{}' ';')
532 (cd debian && find . -type d -name '[a-z]*' -maxdepth 1 -exec rm -Rf '{}' ';')
533 find msvc -type f -name '*.dsp' -exec rm -f '{}' ';'
534 find evc -type f -name '*.vcp' -exec rm -f '{}' ';'
535 #find . -type d -name '.deps' -exec rm -Rf '{}' ';'
536 # there's some more cruft all around
537 rm -f config.h config.log config.status
538 rm -f vlc vlc-config Makefile Modules.am
539 rm -Rf autom4te.cache
540 rm -f mozilla/vlcintf.h mozilla/vlcintf.xpt
541 # FIXME: a lot of Makefiles are still there