3 ## toolbox for the VLC media player
4 ## $Id: toolbox,v 1.15 2003/03/17 16:59:46 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
33 ## Extract stuff from Makefile.am
37 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 | \
39 sed -ne 's/[^$-_a-zA-Z0-9][^$-_a-zA-Z0-9]*\([a-zA-Z]\)/\1/p'
64 --update-glade|--fix-glade)
71 echo "$0: unknown option $1"
78 ## Update the CVS changelog
80 if test "${action}" = "changelog"
82 cvs2cl --help >/dev/null 2>&1 || exit 1
84 cvs2cl --hide-filenames --no-wrap -w --stdout | \
85 sed -e 's/^[^0-9]/ /' -e 's/^ *$//' | \
91 ## Update the MSVC project files
93 if test "${action}" = "vc"
95 echo "generating Visual Studio files..."
100 # Variables we get from configure.ac.in
101 LIBVLC_VERSION=`sed -ne '/AC_INIT/s/.*,\(.*\))/\1/p' < configure.ac.in`
102 LIBVLC_CODENAME=`sed -ne '/CODENAME=/s/.*"\(.*\)"/\1/p' < configure.ac.in`
103 LIBVLC_SYMBOL=`echo $LIBVLC_VERSION | sed -e 'y/.-/__/'`
105 # Sources that get built under Win32 - FIXME: anyone wanna deuglify this? :)
106 LIBVLC_SOURCES=`getfiles SOURCES_libvlc_common; getfiles SOURCES_libvlc_win32; getfiles SOURCES_libvlc_dirent; getfiles SOURCES_libvlc_getopt; getfiles SOURCES_libvlc_libc`
108 LIBVLC_HEADERS=`getfiles HEADERS_include; getfiles HEADERS_include_built`
110 LIBVLC_PKG_HEADERS=`getfiles dist_pkginclude_HEADERS`
113 rm -f evc/*.vcp msvc/*.dsp
116 for target in evc/config.h msvc/config.h
120 sed -e "s/@CODENAME@/${LIBVLC_CODENAME}/" \
121 -e "s/@VERSION@/${LIBVLC_VERSION}/" \
122 -e "s/@SYMBOL@/${LIBVLC_SYMBOL}/" < ${target}.in > ${target}
126 for target in evc/libvlc.vcp msvc/libvlc.dsp
129 # Top of the project file
130 perl -pe 'if(/§SOURCES§/){last;}' < ${target}.in > ${target}
132 for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep -v "/.*/"`
134 cat >> ${target} << EOF
135 # Begin Source File${M}
136 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
137 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
138 # End Source File${M}
141 for subdir in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/.*/" | cut -f2 -d/ | sort | uniq`
143 cat >> ${target} << EOF
144 # Begin Group "${subdir}"${M}
146 for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/${subdir}/"`
148 if test "${target}" = "evc/libvlc.vcp"
150 cat >> ${target} << EOF
151 # Begin Source File${M}
152 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
153 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
154 !IF "\$(CFG)" == "libvlc - Win32 (WCE MIPS) Release"${M}
155 # PROP Output_Dir "MIPSRel\\${subdir}"${M}
156 # PROP Intermediate_Dir "MIPSRel\\${subdir}"${M}
157 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE MIPS) Debug"${M}
158 # PROP Output_Dir "MIPSDbg\\${subdir}"${M}
159 # PROP Intermediate_Dir "MIPSDbg\\${subdir}"${M}
160 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH4) Release"${M}
161 # PROP Output_Dir "SH4Rel\\${subdir}"${M}
162 # PROP Intermediate_Dir "SH4Rel\\${subdir}"${M}
163 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH4) Debug"${M}
164 # PROP Output_Dir "SH4Dbg\\${subdir}"${M}
165 # PROP Intermediate_Dir "SH4Dbg\\${subdir}"${M}
166 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH3) Release"${M}
167 # PROP Output_Dir "SH3Rel\\${subdir}"${M}
168 # PROP Intermediate_Dir "SH3Rel\\${subdir}"${M}
169 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH3) Debug"${M}
170 # PROP Output_Dir "SH3Dbg\\${subdir}"${M}
171 # PROP Intermediate_Dir "SH3Dbg\\${subdir}"${M}
172 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARM) Release"${M}
173 # PROP Output_Dir "ARMRel\\${subdir}"${M}
174 # PROP Intermediate_Dir "ARMRel\\${subdir}"${M}
175 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARM) Debug"${M}
176 # PROP Output_Dir "ARMDbg\\${subdir}"${M}
177 # PROP Intermediate_Dir "ARMDbg\\${subdir}"${M}
178 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE x86em) Release"${M}
179 # PROP Output_Dir "X86EMRel\\${subdir}"${M}
180 # PROP Intermediate_Dir "X86EMRel\\${subdir}"${M}
181 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE x86em) Debug"${M}
182 # PROP Output_Dir "X86EMDbg\\${subdir}"${M}
183 # PROP Intermediate_Dir "X86EMDbg\\${subdir}"${M}
185 # End Source File${M}
188 cat >> ${target} << EOF
189 # Begin Source File${M}
190 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
191 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
192 !IF "\$(CFG)" == "libvlc - Win32 Release"${M}
193 # PROP Output_Dir "Release\\${subdir}"${M}
194 # PROP Intermediate_Dir "Release\\${subdir}"${M}
195 !ELSEIF "\$(CFG)" == "libvlc - Win32 Debug"${M}
196 # PROP Output_Dir "Debug\\${subdir}"${M}
197 # PROP Intermediate_Dir "Debug\\${subdir}"${M}
199 # End Source File${M}
203 cat >> ${target} << EOF
208 perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){if(/§HEADERS§/){last;}print $_}' < ${target}.in >> ${target}
209 for file in ${LIBVLC_HEADERS}
211 cat >> ${target} << EOF
212 # Begin Source File${M}
213 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
214 # End Source File${M}
217 cat >> ${target} << EOF
218 # Begin Group "vlc"${M}
220 for file in ${LIBVLC_PKG_HEADERS}
222 cat >> ${target} << EOF
223 # Begin Source File${M}
224 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
225 # End Source File${M}
228 cat >> ${target} << EOF
231 perl -e 'while(<>){if(/§HEADERS§/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
235 grep '^L_[^ ]*_pic =' Modules.am | while read a b c
237 makefile="`echo $c | sed -e 's@/[^/]*$@/Modules.am@'`"
238 plugin="`echo $a | sed 's/L_\(.*\)_pic/\1/'`"
239 # this is an attempt at getting a list of plugin sources... we take the
240 # production and remove everything that does not contain "module", which
241 # means you miss $(NULL), but other variables too.
242 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'`
243 hfiles=`for i in ${cfiles} ; do echo $i ; done | grep '\.h$'`
244 cfiles=`for i in ${cfiles} ; do echo $i ; done | grep -v '\.h$'`
247 test "${dir}" = "evc" && suf="vcp" || suf="dsp"
248 source="${dir}/plugins.${suf}.in"
249 target="${dir}/plugin_${plugin}.${suf}"
251 perl -pe 'if(/§SOURCES§/){last;} s/§PLUGIN§/'${plugin}'/g' < ${source} > ${target}
252 for cfile in ${cfiles}
254 cat >> ${target} << EOF
255 # Begin Source File${M}
256 SOURCE="..\\${cfile}"${M}
257 # ADD CPP /D "__VLC__" /D "__PLUGIN__" /D "MODULE_NAME=${plugin}" /D "MODULE_NAME_IS_${plugin}" ${M}
258 # End Source File${M}
261 # sed is really nicer for this... unfortunately it's broken under cygwin
262 # sed -ne '1,/§SOURCES§/d; /§HEADERS§/,$d; p' < ${source} >> ${target}
263 perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){if(/§HEADERS§/){last;}print $_}' < ${source} >> ${target}
264 for hfile in ${hfiles}
266 cat >> ${target} << EOF
267 # Begin Source File${M}
268 SOURCE="..\\${hfile}"${M}
269 # End Source File${M}
272 # sed -ne '1,/§HEADERS§/d; p' < ${source} >> ${target}
273 perl -e 'while(<>){if(/§HEADERS§/){last;}}while(<>){print $_}' < ${source} >> ${target}
278 for target in evc/vlc.vcp msvc/vlc.dsp
281 # Top of the project file
282 perl -pe 'if(/§SOURCES§/){last;}' < ${target}.in > ${target}
284 if test "${target}" = "evc/vlc.vcp"
286 cat >> ${target} << EOF
287 # Begin Source File${M}
288 SOURCE="..\\evc\\vlc.c"${M}
289 # End Source File${M}
292 cat >> ${target} << EOF
293 # Begin Source File${M}
294 SOURCE="..\\src\\vlc.c"${M}
295 # End Source File${M}
298 # Bottom of the project file - handles resource files too
299 perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
307 ## Update the potfiles because no one ever does it
309 if test "${action}" = "po"
311 # create a fake file containing win32 strings
312 rm -f modules/gui/win32/strings.cpp
313 printf "/* Automatically generated by 'toolbox --update-po', please don't compile */\n" > modules/gui/win32/strings.cpp
314 find modules/gui/win32 -name '*.dfm' | while read file
316 printf "\n/*\n * from $file:\n */\n\n" >> modules/gui/win32/strings.cpp
317 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
323 make vlc.pot || exit 1
324 make update-po || exit 1
331 ## Create include files
333 if test "${action}" = "includes"
337 LIBVLC_HEADERS=`getfiles HEADERS_include`
338 BUILTINS=`while test $# -gt 0; do echo $1; shift; done`
340 file=include/vlc_symbols.h
343 echo '/* DO NOT EDIT THIS FILE! See Makefile.am */' >> ${file}.in
344 echo 'struct module_symbols_t {' >> ${file}.in
345 cat ${LIBVLC_HEADERS} | grep '^ *VLC_EXPORT.*;' | sed -e 's/VLC_EXPORT( *\([^,]*\), *\([^,]*\), *\(.*\));.*/ \1 (* \2_inner) \3;/' >> ${file}.in
346 echo '};' >> ${file}.in
347 echo '#ifdef __PLUGIN__' >> ${file}.in
348 cat ${LIBVLC_HEADERS} | grep '^ *VLC_EXPORT.*;' | sed -e 's/VLC_EXPORT( *\([^,]*\), *\([^,]*\), *\(.*\));.*/# define \2 p_symbols->\2_inner/' >> ${file}.in
349 echo '#endif /* __PLUGIN__ */' >> ${file}.in
350 if ! diff -q ${file} ${file}.in
352 mv -f ${file}.in ${file}
357 file=src/misc/modules_plugin.h
359 rm -f ${file}.tmp && cp ${file}.in ${file}.tmp
360 sed -e 's#.*\$[I][d]:.*# * Automatically generated from '${file}'.in by bootstrap#' < ${file}.in > ${file}.tmp
361 echo '#define STORE_SYMBOLS( p_symbols ) \' >> ${file}.tmp
362 cat ${LIBVLC_HEADERS} | grep '^ *VLC_EXPORT.*;' | sed -e 's/VLC_EXPORT( *\([^,]*\), *\([^,]*\), *\(.*\));.*/ (p_symbols)->\2_inner = \2; \\/' >> ${file}.tmp
363 echo '' >> ${file}.tmp
364 if ! diff -q ${file} ${file}.tmp
366 mv -f ${file}.tmp ${file}
371 file=src/misc/modules_builtin.h
373 rm -f ${file}.tmp && cp ${file}.in ${file}.tmp
374 if test "${BUILTINS}" != ""
376 for i in `echo ${BUILTINS}`
378 echo "int vlc_entry__`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`( module_t* );" >>${file}.tmp
380 echo "" >> ${file}.tmp
382 echo "#define ALLOCATE_ALL_BUILTINS() \\" >> ${file}.tmp
383 echo " do \\" >> ${file}.tmp
384 echo " { \\" >> ${file}.tmp
385 if test "${BUILTINS}" != ""
387 for i in `echo ${BUILTINS}`
389 echo " ALLOCATE_BUILTIN(`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`); \\" >> ${file}.tmp
392 echo " } while( 0 );" >> ${file}.tmp
393 echo "" >> ${file}.tmp
394 if ! diff -q ${file} ${file}.tmp
396 mv -f ${file}.tmp ${file}
405 ## Fix glade-generated files
407 if test "${action}" = "glade"
409 for file in modules/gui/gtk/gnome.glade modules/gui/gtk/gtk.glade modules/gui/familiar/familiar.glade
411 echo "generating code from $file"
412 glade -w $file || exit 1
415 for file in modules/gui/gtk/gnome_interface.c modules/gui/gtk/gtk_interface.c modules/gui/familiar/interface.c
418 if grep "DO NOT EDIT THIS FILE" $file 2>&1 > /dev/null
421 cat > $file.$$.bak << EOF
422 /* This file was created automatically by glade and fixed by bootstrap */
427 -e 's#_(\(".:..:.."\))#\1#' \
428 -e 's#_(\("[a-z0-9]*://[^"]*"\))#\1#' \
429 -e 's#_("---")#"---"#' \
430 -e 's#_("--")#"--"#' \
431 -e 's#_("/dev/dvd")#"/dev/dvd"#' \
432 -e 's#_(\("./."\))#\1#' \
433 < $file >> $file.$$.bak
434 mv -f $file.$$.bak $file
438 for file in modules/gui/gtk/gtk_support.h modules/gui/familiar/support.h
441 if grep "DO NOT EDIT THIS FILE" $file 2>&1 > /dev/null
444 sed -e 's/DO NOT EDIT.*/Created by glade, fixed by bootstrap/' \
445 -e 's,<config.h>,<vlc/vlc.h>,' \
446 -e 's,#if.*ENABLE_NLS.*,#if 0 /* Disabled by bootstrap */,' \
447 -e 's,#else,/* & */,' \
448 < $file > $file.$$.bak
449 mv -f $file.$$.bak $file