]> git.sesse.net Git - vlc/blob - toolbox
* Renamed all tags (eg. v0_2_83 -> 0.2.83).
[vlc] / toolbox
1 #! /bin/sh
2
3 ##  toolbox for the VLC media player
4 ##  $Id: toolbox,v 1.20 2003/04/06 23:21:13 massiot 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 EOF
31   exit 1
32 }
33
34 ##
35 ##  Extract stuff from Makefile.am
36 ##
37 getfiles()
38 {
39   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 | \
40     tr '\\ ' '\n\n' | \
41     sed -ne 's/[^-$()_a-zA-Z0-9][^-$()_a-zA-Z0-9]*\([a-zA-Z]\)/\1/p'
42 }
43
44 ###
45 ###  argument check
46 ###
47
48 if test "$1" = ""
49 then
50   help
51 fi
52
53 case "$1" in
54   --update-changelog)
55     action=changelog
56     ;;
57   --update-vc)
58     action=vc
59     ;;
60   --update-po)
61     action=po
62     ;;
63   --update-includes)
64     action=includes
65     ;;
66   --update-flexml)
67     action=flexml
68     ;;
69   --update-glade|--fix-glade)
70     action=glade
71     ;;
72   --update-glade2|--update-glade-2|--fix-glade2)
73     action=glade2
74     ;;
75   --help)
76     help
77     ;;
78   *)
79     echo "$0: unknown option $1"
80     help
81     ;;
82 esac
83 shift
84
85 ##
86 ##  Update the CVS changelog
87 ##
88 if test "${action}" = "changelog"
89 then
90   cvs2cl --help >/dev/null 2>&1 || exit 1
91   rm -f ChangeLog
92   cvs2cl --utc --hide-filenames --no-wrap -w --stdout | \
93     sed -e 's/^[^0-9]/ /' -e 's/^  *$//' | \
94     uniq > ChangeLog
95   exit 0
96 fi
97
98 ##
99 ##  Update the MSVC project files
100 ##
101 if test "${action}" = "vc"
102 then
103   echo "generating Visual Studio files..."
104
105   #  The evil ^M
106   M='\r'
107
108   #  Variables we get from configure.ac.in
109   LIBVLC_VERSION=`sed -ne '/AC_INIT/s/.*,\(.*\))/\1/p' < configure.ac.in`
110   LIBVLC_CODENAME=`sed -ne '/CODENAME=/s/.*"\(.*\)"/\1/p' < configure.ac.in`
111   LIBVLC_SYMBOL=`echo $LIBVLC_VERSION | sed -e 'y/.-/__/'`
112
113   #  Sources that get built under Win32 - FIXME: anyone wanna deuglify this? :)
114   LIBVLC_SOURCES=`getfiles SOURCES_libvlc_common; getfiles SOURCES_libvlc_win32; getfiles SOURCES_libvlc_dirent; getfiles SOURCES_libvlc_getopt; getfiles SOURCES_libvlc_libc`
115
116   LIBVLC_HEADERS=`getfiles HEADERS_include; getfiles HEADERS_include_built`
117
118   LIBVLC_PKG_HEADERS=`getfiles dist_pkginclude_HEADERS`
119
120   # Clean up
121   rm -f evc/*.vcp msvc/*.dsp
122
123   # config files
124   for target in evc/config.h msvc/config.h
125   do
126     echo "${target}"
127     rm -f ${target}
128     sed -e "s/@CODENAME@/${LIBVLC_CODENAME}/" \
129         -e "s/@VERSION@/${LIBVLC_VERSION}/" \
130         -e "s/@SYMBOL@/${LIBVLC_SYMBOL}/" < ${target}.in > ${target}
131   done
132
133   # libvlc files
134   for target in evc/libvlc.vcp msvc/libvlc.dsp
135   do
136     echo "${target}"
137     #  Top of the project file
138     perl -pe 'if(/§SOURCES§/){last;}' < ${target}.in > ${target}
139     #  The source files
140     for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep -v "/.*/"`
141     do
142       cat >> ${target} << EOF
143 # Begin Source File${M}
144 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
145 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
146 # End Source File${M}
147 EOF
148     done
149     for subdir in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/.*/" | cut -f2 -d/ | sort | uniq`
150     do
151       cat >> ${target} << EOF
152 # Begin Group "${subdir}"${M}
153 EOF
154       for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/${subdir}/"`
155       do
156       if test "${target}" = "evc/libvlc.vcp"
157       then
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 !IF "\$(CFG)" == "libvlc - Win32 (WCE MIPS) Release"${M}
163 # PROP Output_Dir "MIPSRel\\${subdir}"${M}
164 # PROP Intermediate_Dir "MIPSRel\\${subdir}"${M}
165 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE MIPS) Debug"${M}
166 # PROP Output_Dir "MIPSDbg\\${subdir}"${M}
167 # PROP Intermediate_Dir "MIPSDbg\\${subdir}"${M}
168 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH4) Release"${M}
169 # PROP Output_Dir "SH4Rel\\${subdir}"${M}
170 # PROP Intermediate_Dir "SH4Rel\\${subdir}"${M}
171 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH4) Debug"${M}
172 # PROP Output_Dir "SH4Dbg\\${subdir}"${M}
173 # PROP Intermediate_Dir "SH4Dbg\\${subdir}"${M}
174 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH3) Release"${M}
175 # PROP Output_Dir "SH3Rel\\${subdir}"${M}
176 # PROP Intermediate_Dir "SH3Rel\\${subdir}"${M}
177 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH3) Debug"${M}
178 # PROP Output_Dir "SH3Dbg\\${subdir}"${M}
179 # PROP Intermediate_Dir "SH3Dbg\\${subdir}"${M}
180 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARM) Release"${M}
181 # PROP Output_Dir "ARMRel\\${subdir}"${M}
182 # PROP Intermediate_Dir "ARMRel\\${subdir}"${M}
183 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARM) Debug"${M}
184 # PROP Output_Dir "ARMDbg\\${subdir}"${M}
185 # PROP Intermediate_Dir "ARMDbg\\${subdir}"${M}
186 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE x86em) Release"${M}
187 # PROP Output_Dir "X86EMRel\\${subdir}"${M}
188 # PROP Intermediate_Dir "X86EMRel\\${subdir}"${M}
189 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE x86em) Debug"${M}
190 # PROP Output_Dir "X86EMDbg\\${subdir}"${M}
191 # PROP Intermediate_Dir "X86EMDbg\\${subdir}"${M}
192 !ENDIF${M}
193 # End Source File${M}
194 EOF
195         else
196           cat >> ${target} << EOF
197 # Begin Source File${M}
198 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
199 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
200 !IF "\$(CFG)" == "libvlc - Win32 Release"${M}
201 # PROP Output_Dir "Release\\${subdir}"${M}
202 # PROP Intermediate_Dir "Release\\${subdir}"${M}
203 !ELSEIF "\$(CFG)" == "libvlc - Win32 Debug"${M}
204 # PROP Output_Dir "Debug\\${subdir}"${M}
205 # PROP Intermediate_Dir "Debug\\${subdir}"${M}
206 !ENDIF${M}
207 # End Source File${M}
208 EOF
209         fi
210       done
211       cat >> ${target} << EOF
212 # End Group${M}
213 EOF
214     done
215     #  The headers
216     perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){if(/§HEADERS§/){last;}print $_}' < ${target}.in >> ${target}
217     for file in ${LIBVLC_HEADERS}
218     do
219       cat >> ${target} << EOF
220 # Begin Source File${M}
221 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
222 # End Source File${M}
223 EOF
224     done
225     cat >> ${target} << EOF
226 # Begin Group "vlc"${M}
227 EOF
228     for file in ${LIBVLC_PKG_HEADERS}
229     do
230       cat >> ${target} << EOF
231 # Begin Source File${M}
232 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
233 # End Source File${M}
234 EOF
235     done
236     cat >> ${target} << EOF
237 # End Group${M}
238 EOF
239     perl -e 'while(<>){if(/§HEADERS§/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
240   done
241
242   # plugins files
243   grep '^L_[^ ]*_pic =' Modules.am | while read a b c
244   do
245     makefile="`echo $c | sed -e 's@/[^/]*$@/Modules.am@'`"
246     plugin="`echo $a | sed 's/L_\(.*\)_pic/\1/'`"
247     # this is an attempt at getting a list of plugin sources... we take the
248     # production and remove everything that does not contain "module", which
249     # means you miss $(NULL), but other variables too.
250     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'`
251     hfiles=`for i in ${cfiles} ; do echo $i ; done | grep '\.h$'`
252     cfiles=`for i in ${cfiles} ; do echo $i ; done | grep -v '\.h$'`
253     for dir in evc msvc
254     do
255       test "${dir}" = "evc" && suf="vcp" || suf="dsp"
256       source="${dir}/plugins.${suf}.in"
257       target="${dir}/plugin_${plugin}.${suf}"
258       echo "${target}"
259       perl -pe 'if(/§SOURCES§/){last;} s/§PLUGIN§/'${plugin}'/g' < ${source} > ${target}
260       for cfile in ${cfiles}
261       do
262         cat >> ${target} << EOF
263 # Begin Source File${M}
264 SOURCE="..\\${cfile}"${M}
265 # ADD CPP /D "__VLC__" /D "__PLUGIN__"  /D "MODULE_NAME=${plugin}" /D "MODULE_NAME_IS_${plugin}" ${M}
266 # End Source File${M}
267 EOF
268       done
269       # sed is really nicer for this... unfortunately it's broken under cygwin
270       # sed -ne '1,/§SOURCES§/d; /§HEADERS§/,$d; p' < ${source} >> ${target}
271       perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){if(/§HEADERS§/){last;}print $_}' < ${source} >> ${target}
272       for hfile in ${hfiles}
273       do
274         cat >> ${target} << EOF
275 # Begin Source File${M}
276 SOURCE="..\\${hfile}"${M}
277 # End Source File${M}
278 EOF
279       done
280       # sed -ne '1,/§HEADERS§/d; p' < ${source} >> ${target}
281       perl -e 'while(<>){if(/§HEADERS§/){last;}}while(<>){print $_}' < ${source} >> ${target}
282     done
283   done
284
285   # vlc files
286   for target in evc/vlc.vcp msvc/vlc.dsp
287   do
288     echo "${target}"
289     #  Top of the project file
290     perl -pe 'if(/§SOURCES§/){last;}' < ${target}.in > ${target}
291     #  The source files
292     if test "${target}" = "evc/vlc.vcp"
293     then
294       cat >> ${target} << EOF
295 # Begin Source File${M}
296 SOURCE="..\\evc\\vlc.c"${M}
297 # End Source File${M}
298 EOF
299     else
300       cat >> ${target} << EOF
301 # Begin Source File${M}
302 SOURCE="..\\src\\vlc.c"${M}
303 # End Source File${M}
304 EOF
305     fi
306     #  Bottom of the project file - handles resource files too
307     perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
308   done
309
310   echo "done."
311   exit 0
312 fi
313
314 ##
315 ##  Update the potfiles because no one ever does it
316 ##
317 if test "${action}" = "po"
318 then
319   # create a fake file containing win32 strings
320   rm -f modules/gui/win32/strings.cpp
321   printf "/* Automatically generated by 'toolbox --update-po', please don't compile */\n" > modules/gui/win32/strings.cpp
322   find modules/gui/win32 -name '*.dfm' | while read file
323   do
324     printf "\n/*\n * from $file:\n */\n\n" >> modules/gui/win32/strings.cpp
325     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
326   done
327   # clean old potfiles
328   cd po
329   rm -f vlc.pot
330   # update
331   make vlc.pot || exit 1
332   make update-po || exit 1
333   cd ..
334
335   exit 0
336 fi
337
338 ##
339 ##  Create include files
340 ##
341 if test "${action}" = "includes"
342 then
343   set -x
344
345   LIBVLC_HEADERS=`getfiles HEADERS_include`
346   BUILTINS=`while test $# -gt 0; do echo $1; shift; done`
347
348   file=include/vlc_symbols.h
349
350   rm -f ${file}.in
351   echo '/* DO NOT EDIT THIS FILE! See Makefile.am */' >> ${file}.in
352   echo 'struct module_symbols_t {' >> ${file}.in
353   cat ${LIBVLC_HEADERS} | grep '^ *VLC_EXPORT.*;' | sed -e 's/VLC_EXPORT( *\([^,]*\), *\([^,]*\), *\(.*\));.*/    \1 (* \2_inner) \3;/' >> ${file}.in
354   echo '};' >> ${file}.in
355   echo '#ifdef __PLUGIN__' >> ${file}.in
356   cat ${LIBVLC_HEADERS} | grep '^ *VLC_EXPORT.*;' | sed -e 's/VLC_EXPORT( *\([^,]*\), *\([^,]*\), *\(.*\));.*/#   define \2 p_symbols->\2_inner/' >> ${file}.in
357   echo '#endif /* __PLUGIN__ */' >> ${file}.in
358   if ! diff -q ${file} ${file}.in
359   then
360     mv -f ${file}.in ${file}
361   else
362     rm -f ${file}.in
363   fi
364
365   file=src/misc/modules_plugin.h
366
367   rm -f ${file}.tmp && cp ${file}.in ${file}.tmp
368   sed -e 's#.*\$[I][d]:.*# * Automatically generated from '${file}'.in by bootstrap#' < ${file}.in > ${file}.tmp
369   echo '#define STORE_SYMBOLS( p_symbols ) \' >> ${file}.tmp
370   cat ${LIBVLC_HEADERS} | grep '^ *VLC_EXPORT.*;' | sed -e 's/VLC_EXPORT( *\([^,]*\), *\([^,]*\), *\(.*\));.*/    (p_symbols)->\2_inner = \2; \\/' >> ${file}.tmp
371   echo '' >> ${file}.tmp
372   if ! diff -q ${file} ${file}.tmp
373   then
374     mv -f ${file}.tmp ${file}
375   else
376     rm -f ${file}.tmp
377   fi
378
379   file=src/misc/modules_builtin.h
380
381   rm -f ${file}.tmp && cp ${file}.in ${file}.tmp
382   if test "${BUILTINS}" != ""
383   then
384     for i in `echo ${BUILTINS}`
385     do
386       echo "int vlc_entry__`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`( module_t* );" >>${file}.tmp
387     done
388     echo "" >> ${file}.tmp
389   fi
390   echo "#define ALLOCATE_ALL_BUILTINS() \\" >> ${file}.tmp
391   echo "    do \\" >> ${file}.tmp
392   echo "    { \\" >> ${file}.tmp
393   if test "${BUILTINS}" != ""
394   then
395     for i in `echo ${BUILTINS}`
396     do
397       echo "        ALLOCATE_BUILTIN(`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`); \\" >> ${file}.tmp
398     done
399   fi
400   echo "    } while( 0 );" >> ${file}.tmp
401   echo "" >> ${file}.tmp
402   if ! diff -q ${file} ${file}.tmp
403   then
404     mv -f ${file}.tmp ${file}
405   else
406     rm -f ${file}.tmp
407   fi
408
409   exit 0
410 fi
411
412 ##
413 ##  Fix glade-generated files
414 ##
415 if test "${action}" = "glade"
416 then
417   for file in modules/gui/gtk/gnome.glade modules/gui/gtk/gtk.glade modules/gui/familiar/familiar.glade
418   do
419     echo "generating code from $file"
420     glade -w $file || exit 1
421   done
422
423   for file in modules/gui/gtk/gnome_interface.c modules/gui/gtk/gtk_interface.c modules/gui/familiar/interface.c
424   do
425     echo "fixing $file"
426     if grep "DO NOT EDIT THIS FILE" $file 2>&1 > /dev/null
427     then
428       rm -f $file.$$.bak
429       cat > $file.$$.bak << EOF
430 /* This file was created automatically by glade and fixed by bootstrap */
431
432 #include <vlc/vlc.h>
433 EOF
434       sed -e 1,7d \
435           -e 's#_(\(".:..:.."\))#\1#' \
436           -e 's#_(\("[a-z0-9]*://[^"]*"\))#\1#' \
437           -e 's#_("---")#"---"#' \
438           -e 's#_("--")#"--"#' \
439           -e 's#_("/dev/dvd")#"/dev/dvd"#' \
440           -e 's#_(\("./."\))#\1#' \
441           < $file >> $file.$$.bak
442       mv -f $file.$$.bak $file
443     fi
444   done
445
446   for file in modules/gui/gtk/gtk_support.h modules/gui/familiar/support.h
447   do
448     echo "fixing $file"
449     if grep "DO NOT EDIT THIS FILE" $file 2>&1 > /dev/null
450     then
451       rm -f $file.$$.bak
452       sed -e 's/DO NOT EDIT.*/Created by glade, fixed by bootstrap/' \
453           -e 's,<config.h>,<vlc/vlc.h>,' \
454           -e 's,#if.*ENABLE_NLS.*,#if 0 /* Disabled by bootstrap */,' \
455           -e 's,#else,/* & */,' \
456           < $file > $file.$$.bak
457       mv -f $file.$$.bak $file
458     fi
459   done
460
461   exit 0
462 fi
463
464 ##
465 ##  Fix glade2-generated files
466 ##
467 if test "${action}" = "glade2"
468 then
469   for file in modules/gui/gtk2/gnome2.glade modules/gui/gtk2/gtk2.glade
470   do
471     echo "generating code from $file"
472     glade-2 -w $file || exit 1
473   done
474
475   exit 0
476 fi
477
478 ##
479 ##  Fix flexml-generated files
480 ##
481 if test "${action}" = "flexml"
482 then
483   cd modules/gui/skins/parser
484   flexml -SH -a skin.act skin.dtd
485   # comment the dummy main function
486   file=skin.c
487   sed 's@int main@//int main@' < $file > $file.$$.bak
488   mv -f $file.$$.bak $file
489   flex -oflex.c -BLs skin.l
490 fi
491