]> git.sesse.net Git - vlc/blob - toolbox
* ./doc/skins/events-howto.txt: added some events
[vlc] / toolbox
1 #! /bin/sh
2
3 ##  toolbox for the VLC media player
4 ##  $Id: toolbox,v 1.25 2003/05/24 12:34:31 sam Exp $
5 ##
6 ##  Authors: Samuel Hocevar <sam@zoy.org>
7
8 ###
9 ###  Get a sane environment, just in case
10 ###
11 LANG=C
12 export LANG
13 CYGWIN=binmode
14 export CYGWIN
15
16 ##
17 ##  Give help
18 ##
19 help()
20 {
21   cat << EOF
22 recognized flags are:
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"
31 EOF
32   exit 1
33 }
34
35 ##
36 ##  Extract stuff from Makefile.am
37 ##
38 getfiles()
39 {
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 | \
41     tr '\\ ' '\n\n' | \
42     sed -ne 's/[^-$()_a-zA-Z0-9][^-$()_a-zA-Z0-9]*\([a-zA-Z]\)/\1/p'
43 }
44
45 ###
46 ###  argument check
47 ###
48
49 if test "$1" = ""
50 then
51   help
52 fi
53
54 case "$1" in
55   --update-changelog)
56     action=changelog
57     ;;
58   --update-vc)
59     action=vc
60     ;;
61   --update-po)
62     action=po
63     ;;
64   --update-includes)
65     action=includes
66     ;;
67   --update-flexml)
68     action=flexml
69     ;;
70   --update-glade|--fix-glade)
71     action=glade
72     ;;
73   --update-glade2|--update-glade-2|--fix-glade2)
74     action=glade2
75     ;;
76   --distclean)
77     action=distclean
78     ;;
79   --help)
80     help
81     ;;
82   *)
83     echo "$0: unknown option $1"
84     help
85     ;;
86 esac
87 shift
88
89 ##
90 ##  Update the CVS changelog
91 ##
92 if test "${action}" = "changelog"
93 then
94   cvs2cl --help >/dev/null 2>&1 || exit 1
95   rm -f ChangeLog
96   cvs2cl --utc --hide-filenames --no-wrap -w --stdout | \
97     sed -e 's/^[^0-9]/ /' -e 's/^  *$//' | \
98     uniq > ChangeLog
99   exit 0
100 fi
101
102 ##
103 ##  Update the MSVC project files
104 ##
105 if test "${action}" = "vc"
106 then
107   echo "generating Visual Studio files..."
108
109   #  The evil ^M
110   M='\r'
111
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/.-/__/'`
116
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`
119
120   LIBVLC_HEADERS=`getfiles HEADERS_include; getfiles HEADERS_include_built`
121
122   LIBVLC_PKG_HEADERS=`getfiles dist_pkginclude_HEADERS`
123
124   # Clean up
125   rm -f evc/*.vcp msvc/*.dsp
126
127   # config files
128   for target in evc/config.h msvc/config.h
129   do
130     echo "${target}"
131     rm -f ${target}
132     sed -e "s/@CODENAME@/${LIBVLC_CODENAME}/" \
133         -e "s/@VERSION@/${LIBVLC_VERSION}/" \
134         -e "s/@SYMBOL@/${LIBVLC_SYMBOL}/" < ${target}.in > ${target}
135   done
136
137   # libvlc files
138   for target in evc/libvlc.vcp msvc/libvlc.dsp
139   do
140     echo "${target}"
141     #  Top of the project file
142     perl -pe 'if(/§SOURCES§/){last;}' < ${target}.in > ${target}
143     #  The source files
144     for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep -v "/.*/"`
145     do
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}
151 EOF
152     done
153     for subdir in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/.*/" | cut -f2 -d/ | sort | uniq`
154     do
155       cat >> ${target} << EOF
156 # Begin Group "${subdir}"${M}
157 EOF
158       for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/${subdir}/"`
159       do
160       if test "${target}" = "evc/libvlc.vcp"
161       then
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}
196 !ENDIF${M}
197 # End Source File${M}
198 EOF
199         else
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}
210 !ENDIF${M}
211 # End Source File${M}
212 EOF
213         fi
214       done
215       cat >> ${target} << EOF
216 # End Group${M}
217 EOF
218     done
219     #  The headers
220     perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){if(/§HEADERS§/){last;}print $_}' < ${target}.in >> ${target}
221     for file in ${LIBVLC_HEADERS}
222     do
223       cat >> ${target} << EOF
224 # Begin Source File${M}
225 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
226 # End Source File${M}
227 EOF
228     done
229     cat >> ${target} << EOF
230 # Begin Group "vlc"${M}
231 EOF
232     for file in ${LIBVLC_PKG_HEADERS}
233     do
234       cat >> ${target} << EOF
235 # Begin Source File${M}
236 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
237 # End Source File${M}
238 EOF
239     done
240     cat >> ${target} << EOF
241 # End Group${M}
242 EOF
243     perl -e 'while(<>){if(/§HEADERS§/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
244   done
245
246   # plugins files
247   grep '^L_[^ ]*_pic =' Modules.am | while read a b c
248   do
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$'`
257     for dir in evc msvc
258     do
259       test "${dir}" = "evc" && suf="vcp" || suf="dsp"
260       source="${dir}/plugins.${suf}.in"
261       target="${dir}/plugin_${plugin}.${suf}"
262       echo "${target}"
263       perl -pe 'if(/§SOURCES§/){last;} s/§PLUGIN§/'${plugin}'/g' < ${source} > ${target}
264       for cfile in ${cfiles}
265       do
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}
271 EOF
272       done
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}
277       do
278         cat >> ${target} << EOF
279 # Begin Source File${M}
280 SOURCE="..\\${hfile}"${M}
281 # End Source File${M}
282 EOF
283       done
284       # sed -ne '1,/§HEADERS§/d; p' < ${source} >> ${target}
285       perl -e 'while(<>){if(/§HEADERS§/){last;}}while(<>){print $_}' < ${source} >> ${target}
286     done
287   done
288
289   # vlc files
290   for target in evc/vlc.vcp msvc/vlc.dsp
291   do
292     echo "${target}"
293     #  Top of the project file
294     perl -pe 'if(/§SOURCES§/){last;}' < ${target}.in > ${target}
295     #  The source files
296     if test "${target}" = "evc/vlc.vcp"
297     then
298       cat >> ${target} << EOF
299 # Begin Source File${M}
300 SOURCE="..\\evc\\vlc.c"${M}
301 # End Source File${M}
302 EOF
303     else
304       cat >> ${target} << EOF
305 # Begin Source File${M}
306 SOURCE="..\\src\\vlc.c"${M}
307 # End Source File${M}
308 EOF
309     fi
310     #  Bottom of the project file - handles resource files too
311     perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
312   done
313
314   echo "done."
315   exit 0
316 fi
317
318 ##
319 ##  Update the potfiles because no one ever does it
320 ##
321 if test "${action}" = "po"
322 then
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
327   #do
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
330   #done
331   # find out the source files
332   rm -f po/POTFILES.in
333   echo "# automatically created by toolbox --update-po" > po/POTFILES.in
334   echo "" >> po/POTFILES.in
335   echo "# main sources" >> po/POTFILES.in
336   find include src -name '*.[chm]' -o -name '*.[hc]pp' | sort >> po/POTFILES.in
337   echo "" >> po/POTFILES.in
338   echo "# modules" >> po/POTFILES.in
339   find modules -name '*.[chm]' -o -name '*.[hc]pp' | grep -v 'gui/win32/' | sort >> po/POTFILES.in
340   # clean old potfiles
341   cd po
342   rm -f vlc.pot
343   # update
344   make vlc.pot || exit 1
345   make update-po || exit 1
346   cd ..
347
348   exit 0
349 fi
350
351 ##
352 ##  Create include files
353 ##
354 if test "${action}" = "includes"
355 then
356   set -x
357
358   LIBVLC_HEADERS=`getfiles HEADERS_include`
359   BUILTINS=`while test $# -gt 0; do echo $1; shift; done`
360
361   file=include/vlc_symbols.h
362
363   rm -f ${file}.in
364   echo '/* DO NOT EDIT THIS FILE! See Makefile.am */' >> ${file}.in
365   echo 'struct module_symbols_t {' >> ${file}.in
366   cat ${LIBVLC_HEADERS} | grep '^ *VLC_EXPORT.*;' | sed -e 's/VLC_EXPORT( *\([^,]*\), *\([^,]*\), *\(.*\));.*/    \1 (* \2_inner) \3;/' >> ${file}.in
367   echo '};' >> ${file}.in
368   echo '#ifdef __PLUGIN__' >> ${file}.in
369   cat ${LIBVLC_HEADERS} | grep '^ *VLC_EXPORT.*;' | sed -e 's/VLC_EXPORT( *\([^,]*\), *\([^,]*\), *\(.*\));.*/#   define \2 p_symbols->\2_inner/' >> ${file}.in
370   echo '#endif /* __PLUGIN__ */' >> ${file}.in
371   if diff 2>&1 >/dev/null ${file} ${file}.in
372   then
373     rm -f ${file}.in
374   else
375     mv -f ${file}.in ${file}
376   fi
377
378   file=src/misc/modules_plugin.h
379
380   rm -f ${file}.tmp && cp ${file}.in ${file}.tmp
381   sed -e 's#.*\$[I][d]:.*# * Automatically generated from '${file}'.in by bootstrap#' < ${file}.in > ${file}.tmp
382   echo '#define STORE_SYMBOLS( p_symbols ) \' >> ${file}.tmp
383   cat ${LIBVLC_HEADERS} | grep '^ *VLC_EXPORT.*;' | sed -e 's/VLC_EXPORT( *\([^,]*\), *\([^,]*\), *\(.*\));.*/    (p_symbols)->\2_inner = \2; \\/' >> ${file}.tmp
384   echo '' >> ${file}.tmp
385   if diff 2>&1 >/dev/null ${file} ${file}.tmp
386   then
387     rm -f ${file}.tmp
388   else
389     mv -f ${file}.tmp ${file}
390   fi
391
392   file=src/misc/modules_builtin.h
393
394   rm -f ${file}.tmp && cp ${file}.in ${file}.tmp
395   if test "${BUILTINS}" != ""
396   then
397     for i in `echo ${BUILTINS}`
398     do
399       echo "int vlc_entry__`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`( module_t* );" >>${file}.tmp
400     done
401     echo "" >> ${file}.tmp
402   fi
403   echo "#define ALLOCATE_ALL_BUILTINS() \\" >> ${file}.tmp
404   echo "    do \\" >> ${file}.tmp
405   echo "    { \\" >> ${file}.tmp
406   if test "${BUILTINS}" != ""
407   then
408     for i in `echo ${BUILTINS}`
409     do
410       echo "        ALLOCATE_BUILTIN(`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`); \\" >> ${file}.tmp
411     done
412   fi
413   echo "    } while( 0 );" >> ${file}.tmp
414   echo "" >> ${file}.tmp
415   if diff 2>&1 >/dev/null ${file} ${file}.tmp
416   then
417     rm -f ${file}.tmp
418   else
419     mv -f ${file}.tmp ${file}
420   fi
421
422   exit 0
423 fi
424
425 ##
426 ##  Fix glade-generated files
427 ##
428 if test "${action}" = "glade"
429 then
430   for file in modules/gui/gtk/gnome.glade modules/gui/gtk/gtk.glade modules/gui/familiar/familiar.glade
431   do
432     echo "generating code from $file"
433     glade -w $file || exit 1
434   done
435
436   for file in modules/gui/gtk/gnome_interface.c modules/gui/gtk/gtk_interface.c modules/gui/familiar/interface.c
437   do
438     echo "fixing $file"
439     if grep "DO NOT EDIT THIS FILE" $file 2>&1 > /dev/null
440     then
441       rm -f $file.$$.bak
442       cat > $file.$$.bak << EOF
443 /* This file was created automatically by glade and fixed by bootstrap */
444
445 #include <vlc/vlc.h>
446 EOF
447       sed -e 1,7d \
448           -e 's#_(\(".:..:.."\))#\1#' \
449           -e 's#_(\("[a-z0-9]*://[^"]*"\))#\1#' \
450           -e 's#_("---")#"---"#' \
451           -e 's#_("--")#"--"#' \
452           -e 's#_("/dev/dvd")#"/dev/dvd"#' \
453           -e 's#_(\("./."\))#\1#' \
454           < $file >> $file.$$.bak
455       mv -f $file.$$.bak $file
456     fi
457   done
458
459   for file in modules/gui/gtk/gtk_support.h modules/gui/familiar/support.h
460   do
461     echo "fixing $file"
462     if grep "DO NOT EDIT THIS FILE" $file 2>&1 > /dev/null
463     then
464       rm -f $file.$$.bak
465       sed -e 's/DO NOT EDIT.*/Created by glade, fixed by bootstrap/' \
466           -e 's,<config.h>,<vlc/vlc.h>,' \
467           -e 's,#if.*ENABLE_NLS.*,#if 0 /* Disabled by bootstrap */,' \
468           -e 's,#else,/* & */,' \
469           < $file > $file.$$.bak
470       mv -f $file.$$.bak $file
471     fi
472   done
473
474   exit 0
475 fi
476
477 ##
478 ##  Fix glade2-generated files
479 ##
480 if test "${action}" = "glade2"
481 then
482   for file in modules/gui/gtk2/gnome2.glade modules/gui/gtk2/gtk2.glade
483   do
484     echo "generating code from $file"
485     glade-2 -w $file || exit 1
486   done
487
488   exit 0
489 fi
490
491 ##
492 ##  Fix flexml-generated files
493 ##
494 if test "${action}" = "flexml"
495 then
496   cd modules/gui/skins/parser
497   flexml -SH -a skin.act skin.dtd
498   # comment the dummy main function
499   file=skin.c
500   sed 's@int main@//int main@' < $file > $file.$$.bak
501   mv -f $file.$$.bak $file
502   flex -oflex.c -BLs skin.l
503 fi
504
505 ##
506 ##  Make distclean
507 ##
508 if test "${action}" = "distclean"
509 then
510   set -x
511   # a naive sanity check to make sure we are in a VLC tree
512   test -f vlc.spec -a -f debian/rules || exit 1
513   # let's rock!
514   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 '{}' ';'
515   (cd autotools && find . -name '[a-z]*' -exec rm -f '{}' ';')
516   (cd debian && find . -type d -name '[a-z]*' -maxdepth 1 -exec rm -Rf '{}' ';')
517   find msvc -type f -name '*.dsp' -exec rm -f '{}' ';'
518   find evc -type f -name '*.vcp' -exec rm -f '{}' ';'
519   #find . -type d -name '.deps' -exec rm -Rf '{}' ';'
520   # there's some more cruft all around
521   rm -f configure.ac config.h config.log config.status
522   rm -f vlc vlc-config Makefile Modules.am
523   rm -Rf autom4te.cache
524   rm -f mozilla/vlcintf.h mozilla/vlcintf.xpt
525   # FIXME: a lot of Makefiles are still there
526 fi
527