]> git.sesse.net Git - vlc/blob - toolbox
Add real SRTP unit test (85% coverage let alone SRTCP)
[vlc] / toolbox
1 #! /bin/sh
2
3
4 ##  toolbox for the VLC media player
5 ##  $Id$
6 ##
7 ##  Copyright (C) 2002-2006  the VideoLAN team
8 ##
9 ##  Authors: Samuel Hocevar <sam@zoy.org>
10 ##           RĂ©mi Denis-Courmont <rem # videolan.org>
11
12 ###
13 ###  Get a sane environment, just in case
14 ###
15 LC_ALL=C
16 export LC_ALL
17 LANG=C
18 export LANG
19 CYGWIN=binmode
20 export CYGWIN
21
22 ##
23 ##  Give help
24 ##
25 help()
26 {
27   cat << EOF
28 recognized flags are:
29   --update-vc             update Microsoft Visual Studio files
30   --update-vc7            update Microsoft Visual .NET files
31   --update-po             update translation files
32   --update-includes       generate various include files
33   --update-version        generate src/misc/version.c
34   --update-glade2         generate and fix Glade 2 code
35   --update-flexml         generate and fix flexml and flex code
36   --distclean             "make distclean" on steroids
37   --dist-contrib          add the contrib dir to MAKE_DIST
38 EOF
39   exit 1
40 }
41
42 ##
43 ##  Extract stuff from Makefile.am
44 ##
45 getfiles()
46 {
47   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" | \
48     tr '\\ ' '\n\n' | \
49     sed -ne 's/[^-$()_a-zA-Z0-9][^-$()_a-zA-Z0-9]*\([a-zA-Z]\)/\1/p' | \
50     sed -e "s,^,${srcdir}/,"
51 }
52
53 ###
54 ###  argument check
55 ###
56
57 if test "$1" = ""
58 then
59   help
60 fi
61
62 case "$1" in
63   --changelog|--update-changelog)
64     action=changelog
65     ;;
66   --update-vc)
67     action=vc
68     ;;
69   --update-vc7)
70     action=vc7
71     ;;
72   --update-po)
73     action=po
74     ;;
75   --update-includes)
76     action=includes
77     ;;
78   --update-version)
79     action=version
80     ;;
81   --update-flexml)
82     action=flexml
83     ;;
84   --update-glade2|--update-glade-2|--fix-glade2)
85     action=glade2
86     ;;
87   --distclean)
88     action=distclean
89     ;;
90   --add-include)
91     action=include
92     ;;
93   --dist-contrib)
94     action=contrib
95     ;;
96   --help)
97     help
98     ;;
99   *)
100     echo "$0: unknown option $1"
101     help
102     ;;
103 esac
104 shift
105
106 ##
107 ##  Add includes to help doxygen
108 ##
109 if test "${action}" = "include"
110 then
111   case "$1" in
112     */vlc_common.h|*/include/vlc/*);;
113     */include/*.h) echo "#include <vlc_common.h>" ;;
114   esac
115   cat $1
116   exit 0
117 fi
118
119 ##
120 ##  Update the CVS changelog
121 ##
122 if test "${action}" = "changelog"
123 then
124   YEAR="`date +%Y`"
125   echo "toolbox --changelog no longer required. use this instead:"
126   echo " LANG=C svn log -v -r '{$YEAR-12-31}:{$YEAR-01-01}' > ChangeLog"
127   exit 0
128 fi
129
130 ##
131 ##  Update the MSVC project files
132 ##
133 if test "${action}" = "vc"
134 then
135   echo "generating Visual Studio files"
136
137   if test -z "${srcdir}"; then
138     srcdir="`sed -ne 's/^srcdir *= *//p' < Makefile`"
139   fi
140
141   #  The evil ^M. printf '\r' does not work in Cygwin.
142   M='\r'
143
144   #  Variables we get from configure.ac
145   LIBVLC_VERSION=`sed -ne '/AC_INIT/s/.*,\(.*\))/\1/p' < configure.ac`
146   LIBVLC_CODENAME=`sed -ne '/CODENAME=/s/.*"\(.*\)"/\1/p' < configure.ac`
147   LIBVLC_SYMBOL=`echo $LIBVLC_VERSION | sed -e 'y/.-/__/'`
148
149   #  Sources that get built under Win32 - FIXME: anyone wanna deuglify this? :)
150   LIBVLC_SOURCES=`getfiles SOURCES_libvlc_common; getfiles SOURCES_libvlc_win32; getfiles SOURCES_libvlc_dirent; getfiles SOURCES_libvlc_getopt; getfiles SOURCES_libvlc_libc`
151
152   LIBVLC_HEADERS=`getfiles HEADERS_include; getfiles HEADERS_include_built`
153
154   LIBVLC_PKG_HEADERS=`getfiles dist_pkginclude_HEADERS`
155
156   # Clean up
157   rm -f evc/*.vcp msvc/*.dsp msvc/*.vcproj msvc/*.sln msvc/*.ncb
158
159   # config files
160   for target in evc/config.h msvc/config.h
161   do
162     printf "."
163     rm -f ${target}
164     sed -e "s/@CODENAME@/${LIBVLC_CODENAME}/" \
165         -e "s/@VERSION@/${LIBVLC_VERSION}/" \
166         -e "s/@SYMBOL@/${LIBVLC_SYMBOL}/" < ${target}.in > ${target}
167   done
168
169   # libvlc files
170   for target in evc/libvlc.vcp msvc/libvlc.dsp
171   do
172     printf "."
173     #  Top of the project file
174     perl -pe 'if(/ZSOURCESZ/){last;}' < ${target}.in > ${target}
175     #  The source files
176     for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep -v "/.*/"`
177     do
178       cat >> ${target} << EOF
179 # Begin Source File${M}
180 SOURCE="..\\`echo ${file} | sed -e 's%/%\\\\%g'`"${M}
181 # ADD CPP /D "__LIBVLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
182 # End Source File${M}
183 EOF
184     done
185     for subdir in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/.*/" | cut -f2 -d/ | sort | uniq`
186     do
187       cat >> ${target} << EOF
188 # Begin Group "${subdir}"${M}
189 EOF
190       for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/${subdir}/"`
191       do
192       subdir="`echo ${file} | sed -e 's%/[^/]*$%/%' | sed -e 's%/%\\\\%g'`"
193       if test "${target}" = "evc/libvlc.vcp"
194       then
195         cat >> ${target} << EOF
196 # Begin Source File${M}
197 SOURCE="..\\`echo ${file} | sed -e 's%/%\\\\%g'`"${M}
198 # ADD CPP /D "__LIBVLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
199 !IF "\$(CFG)" == "libvlc - Win32 (WCE MIPS) Release"${M}
200 # PROP Output_Dir "MIPSRel\\${subdir}"${M}
201 # PROP Intermediate_Dir "MIPSRel\\${subdir}"${M}
202 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE MIPS) Debug"${M}
203 # PROP Output_Dir "MIPSDbg\\${subdir}"${M}
204 # PROP Intermediate_Dir "MIPSDbg\\${subdir}"${M}
205 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH4) Release"${M}
206 # PROP Output_Dir "SH4Rel\\${subdir}"${M}
207 # PROP Intermediate_Dir "SH4Rel\\${subdir}"${M}
208 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH4) Debug"${M}
209 # PROP Output_Dir "SH4Dbg\\${subdir}"${M}
210 # PROP Intermediate_Dir "SH4Dbg\\${subdir}"${M}
211 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH3) Release"${M}
212 # PROP Output_Dir "SH3Rel\\${subdir}"${M}
213 # PROP Intermediate_Dir "SH3Rel\\${subdir}"${M}
214 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH3) Debug"${M}
215 # PROP Output_Dir "SH3Dbg\\${subdir}"${M}
216 # PROP Intermediate_Dir "SH3Dbg\\${subdir}"${M}
217 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARM) Release"${M}
218 # PROP Output_Dir "ARMRel\\${subdir}"${M}
219 # PROP Intermediate_Dir "ARMRel\\${subdir}"${M}
220 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARM) Debug"${M}
221 # PROP Output_Dir "ARMDbg\\${subdir}"${M}
222 # PROP Intermediate_Dir "ARMDbg\\${subdir}"${M}
223 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARMV4) Release"${M}
224 # PROP Output_Dir "ARMV4Rel\\${subdir}"${M}
225 # PROP Intermediate_Dir "ARMV4Rel\\${subdir}"${M}
226 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARMV4) Debug"${M}
227 # PROP Output_Dir "ARMV4Dbg\\${subdir}"${M}
228 # PROP Intermediate_Dir "ARMV4Dbg\\${subdir}"${M}
229 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE x86em) Release"${M}
230 # PROP Output_Dir "X86EMRel\\${subdir}"${M}
231 # PROP Intermediate_Dir "X86EMRel\\${subdir}"${M}
232 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE x86em) Debug"${M}
233 # PROP Output_Dir "X86EMDbg\\${subdir}"${M}
234 # PROP Intermediate_Dir "X86EMDbg\\${subdir}"${M}
235 !ELSEIF  "\$(CFG)" == "libvlc - Win32 (WCE emulator) Debug"${M}
236 # PROP Output_Dir "emulatorDbg\\${subdir}"${M}
237 # PROP Intermediate_Dir "emulatorDbg\\${subdir}"${M}
238 !ELSEIF  "\$(CFG)" == "libvlc - Win32 (WCE emulator) Release"${M}
239 # PROP Output_Dir "emulatorRel\\${subdir}"${M}
240 # PROP Intermediate_Dir "emulatorRel\\${subdir}"${M}
241 !ELSEIF  "\$(CFG)" == "libvlc - Win32 (WCE x86) Debug"${M}
242 # PROP Output_Dir "X86Dbg\\${subdir}"${M}
243 # PROP Intermediate_Dir "X86Dbg\\${subdir}"${M}
244 !ELSEIF  "\$(CFG)" == "libvlc - Win32 (WCE x86) Release"${M}
245 # PROP Output_Dir "X86Rel\\${subdir}"${M}
246 # PROP Intermediate_Dir "X86Rel\\${subdir}"${M}
247 !ENDIF${M}
248 # End Source File${M}
249 EOF
250         else
251           cat >> ${target} << EOF
252 # Begin Source File${M}
253 SOURCE="..\\`echo ${file} | sed -e 's%/%\\\\%g'`"${M}
254 # ADD CPP /D "__LIBVLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
255 !IF "\$(CFG)" == "libvlc - Win32 Release"${M}
256 # PROP Output_Dir "Release\\${subdir}"${M}
257 # PROP Intermediate_Dir "Release\\${subdir}"${M}
258 !ELSEIF "\$(CFG)" == "libvlc - Win32 Debug"${M}
259 # PROP Output_Dir "Debug\\${subdir}"${M}
260 # PROP Intermediate_Dir "Debug\\${subdir}"${M}
261 !ENDIF${M}
262 # End Source File${M}
263 EOF
264         fi
265       done
266       cat >> ${target} << EOF
267 # End Group${M}
268 EOF
269     done
270     #  The headers
271     perl -e 'while(<>){if(/ZSOURCESZ/){last;}}while(<>){if(/ZHEADERSZ/){last;}print $_}' < ${target}.in >> ${target}
272     for file in ${LIBVLC_HEADERS}
273     do
274       cat >> ${target} << EOF
275 # Begin Source File${M}
276 SOURCE="..\\`echo ${file} | sed -e 's%/%\\\\%g'`"${M}
277 # End Source File${M}
278 EOF
279     done
280     cat >> ${target} << EOF
281 # Begin Group "vlc"${M}
282 EOF
283     for file in ${LIBVLC_PKG_HEADERS}
284     do
285       cat >> ${target} << EOF
286 # Begin Source File${M}
287 SOURCE="..\\`echo ${file} | sed -e 's%/%\\\\%g'`"${M}
288 # End Source File${M}
289 EOF
290     done
291     cat >> ${target} << EOF
292 # End Group${M}
293 EOF
294     perl -e 'while(<>){if(/ZHEADERSZ/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
295   done
296
297   # plugins files
298   for dir in `sed -ne 's,modules/\(.*\)/Makefile,\1,p' ${srcdir}/configure.ac`
299   do
300     mf="${srcdir}/modules/${dir}/Modules.am"
301     for mod in `sed -n -e 's/^ *SOURCES_\([^ ]*\).*/\1/p' < ${mf}`
302     do
303       # this is an attempt at getting a list of plugin sources... we take the
304       # production and remove everything that does not contain "module", which
305       # means you miss $(NULL), but other variables too.
306       allfiles=`grep -v '[^-_a-zA-Z0-9]*#' ${mf} | awk 'BEGIN{a=0}{if(!a&&$0~/^SOURCES_'${mod}'[^-_a-zA-Z0-9]*=/){a=1;print$0;next;}if(a){if($0~/^[a-zA-Z]/){exit;}print $0}}' | tr '\\ ' '\n\n' | grep '\.'`
307       hfiles=`for i in ${allfiles} ; do echo "$i" ; done | grep '\.h$'`
308       cfiles=`for i in ${allfiles} ; do echo "$i" ; done | grep -v '\.h$'`
309       for msdir in evc msvc
310       do
311         test "${msdir}" = "evc" && suf="vcp" || suf="dsp"
312         source="${msdir}/plugins.${suf}.in"
313         target="${msdir}/plugin_${mod}.${suf}"
314         printf "."
315         perl -pe 'if(/ZSOURCESZ/){last;} s/ZPLUGINZ/'${mod}'/g' < ${source} > ${target}
316         for cfile in ${cfiles}
317         do
318           cat >> ${target} << EOF
319 # Begin Source File${M}
320 SOURCE="..\\modules\\`echo ${dir}/${cfile} | sed 's,/,\\\\,g'`"${M}
321 # ADD CPP /D "__LIBVLC__" /D "__PLUGIN__"  /D "MODULE_NAME=${mod}" /D "MODULE_NAME_IS_${mod}" ${M}
322 !IF "\$(CFG)" == "plugin_${mod} - Win32 Release"${M}
323 # PROP Output_Dir "Release\\modules\\`echo ${dir} | sed 's,/,\\\\,g'`"${M}
324 # PROP Intermediate_Dir "Release\\modules\\`echo ${dir} | sed 's,/,\\\\,g'`"${M}
325 !ELSEIF "\$(CFG)" == "plugin_${mod} - Win32 Debug"${M}
326 # PROP Output_Dir "Debug\\modules\\`echo ${dir} | sed 's,/,\\\\,g'`"${M}
327 # PROP Intermediate_Dir "Debug\\modules\\`echo ${dir} | sed 's,/,\\\\,g'`"${M}
328 # End Source File${M}
329 EOF
330         done
331         # sed is really nicer for this... unfortunately it's broken under cygwin
332         # sed -ne '1,/ZSOURCESZ/d; /ZHEADERSZ/,$d; p' < ${source} >> ${target}
333         perl -e 'while(<>){if(/ZSOURCESZ/){last;}}while(<>){if(/ZHEADERSZ/){last;}print $_}' < ${source} >> ${target}
334         for hfile in ${hfiles}
335         do
336           cat >> ${target} << EOF
337 # Begin Source File${M}
338 SOURCE="..\\modules\\`echo ${dir}/${hfile} | sed 's,/,\\\\,g'`"${M}
339 # End Source File${M}
340 EOF
341         done
342         # sed -ne '1,/ZHEADERSZ/d; p' < ${source} >> ${target}
343         perl -e 'while(<>){if(/ZHEADERSZ/){last;}}while(<>){print $_}' < ${source} >> ${target}
344       done
345     done
346   done
347
348   # vlc files
349   for target in evc/vlc.vcp msvc/vlc.dsp
350   do
351     printf "."
352     #  Top of the project file
353     perl -pe 'if(/ZSOURCESZ/){last;}' < ${target}.in > ${target}
354     #  The source files
355       cat >> ${target} << EOF
356 # Begin Source File${M}
357 SOURCE="..\\src\\vlc.c"${M}
358 # End Source File${M}
359 EOF
360     #  Bottom of the project file - handles resource files too
361     perl -e 'while(<>){if(/ZSOURCESZ/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
362   done
363
364   echo " done."
365   exit 0
366 fi
367
368 ##
369 ##  Update the MSVC (.NET) project files
370 ##
371 if test "${action}" = "vc7"
372 then
373   echo "generating Visual .NET files"
374
375   srcdir=.
376
377   #  The evil ^M. printf '\r' does not work in Cygwin.
378   M='
379 '
380
381   #  Variables we get from configure.ac
382   LIBVLC_VERSION=`sed -ne '/AC_INIT/s/.*,\(.*\))/\1/p' < configure.ac`
383   LIBVLC_CODENAME=`sed -ne '/CODENAME=/s/.*"\(.*\)"/\1/p' < configure.ac`
384   LIBVLC_SYMBOL=`echo $LIBVLC_VERSION | sed -e 'y/.-/__/'`
385
386   #  Sources that get built under Win32 - FIXME: anyone wanna deuglify this? :)
387   LIBVLC_SOURCES=`getfiles SOURCES_libvlc_common; getfiles SOURCES_libvlc_win32; getfiles SOURCES_libvlc_dirent; getfiles SOURCES_libvlc_getopt; getfiles SOURCES_libvlc_libc`
388
389   LIBVLC_HEADERS=`getfiles HEADERS_include; getfiles HEADERS_include_built`
390
391   LIBVLC_PKG_HEADERS=`getfiles dist_pkginclude_HEADERS`
392
393   # Clean up
394   rm -f msvc/*.vcproj
395
396   # config files
397   for target in msvc/config.h
398   do
399     printf "."
400     rm -f ${target}
401     sed -e "s/@CODENAME@/${LIBVLC_CODENAME}/" \
402         -e "s/@VERSION@/${LIBVLC_VERSION}/" \
403         -e "s/@SYMBOL@/${LIBVLC_SYMBOL}/" < ${target}.in > ${target}
404   done
405
406  # vlc files
407   target="msvc/vlc.vcproj"
408   printf "."
409   #  Top of the project file
410   guid=`perl -e 'sub r {return sprintf("%X", int rand(65536))} print r.r."-".r."-".r."-".r."-".r.r.r'`
411   perl -pe 'if(/ZSOURCESZ/){last;} s/ZGUIDZ/'${guid}'/g' < ${target}.in > ${target}
412   #  The source files
413   cat >> ${target} << EOF
414 <File RelativePath="..\\src\\vlc.c"></File>${M}
415 EOF
416   #  Bottom of the project file - handles resource files too
417   perl -e 'while(<>){if(/ZSOURCESZ/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
418   
419   # libvlc files
420   target=msvc/libvlc.vcproj
421   printf "."
422   #  Top of the project file
423   guid=`perl -e 'sub r {return sprintf("%X", int rand(65536))} print r.r."-".r."-".r."-".r."-".r.r.r'`
424   perl -pe 'if(/ZSOURCESZ/){last;} s/ZGUIDZ/'${guid}'/g' < ${target}.in > ${target}
425   #  The source files
426   for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep -v "/.*/"`
427   do
428     cat >> ${target} << EOF
429 <File RelativePath="..\\`echo ${dir}/${file} | sed 's,/,\\\\,g'`"></File>${M}
430 EOF
431   done
432   for subdir in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/.*/" | cut -f2 -d/ | sort | uniq`
433   do
434     cat >> ${target} << EOF
435 <Filter Name="`echo ${subdir} | sed s,/,_,g`" Filter="c;cpp">${M}
436 EOF
437     for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/${subdir}/"`
438     do
439       cat >> ${target} << EOF
440 <File RelativePath="..\\`echo ${file} | sed 's,/,\\\\,g'`">${M}
441 EOF
442       if echo ${file} | grep -q '.c$'
443       then
444         cat >> ${target} << EOF
445         <FileConfiguration Name="Debug|Win32">${M}
446                 <Tool Name="VCCLCompilerTool" ObjectFile="\$(IntDir)/\$(ProjectName)/`echo ${file} | sed -e s/\.c$/.obj/`"/>${M}
447         </FileConfiguration>${M}
448 EOF
449       fi
450       cat >> ${target} << EOF
451 </File>${M}
452 EOF
453     done
454     cat >> ${target} << EOF
455 </Filter>${M}
456 EOF
457   done
458   #  The headers
459   perl -e 'while(<>){if(/ZSOURCESZ/){last;}}while(<>){if(/ZHEADERSZ/){last;}print $_}' < ${target}.in >> ${target}
460   for file in ${LIBVLC_HEADERS}
461   do
462     cat >> ${target} << EOF
463 <File RelativePath="..\\`echo ${file} | sed 's,/,\\\\,g'`"></File>${M}
464 EOF
465   done
466   cat >> ${target} << EOF
467 <Filter Name="vlc" Filter="h;hpp">${M}
468 EOF
469   for file in ${LIBVLC_PKG_HEADERS}
470   do
471     cat >> ${target} << EOF
472 <File RelativePath="..\\`echo ${file} | sed 's,/,\\\\,g'`"></File>${M}
473 EOF
474   done
475   cat >> ${target} << EOF
476 </Filter>${M}
477 EOF
478   perl -e 'while(<>){if(/ZHEADERSZ/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
479
480   # plugins files
481   for dir in `sed -ne 's,modules/\(.*\)/Makefile,\1,p' ${srcdir}/configure.ac`
482   do
483     mf="${srcdir}/modules/${dir}/Modules.am"
484     for mod in `sed -n -e 's/^ *SOURCES_\([^ ]*\).*/\1/p' < ${mf}`
485     do
486       # this is an attempt at getting a list of plugin sources... we take the
487       # production and remove everything that does not contain "module", which
488       # means you miss $(NULL), but other variables too.
489       allfiles=`grep -v '[^-_a-zA-Z0-9]*#' ${mf} | awk 'BEGIN{a=0}{if(!a&&$0~/^SOURCES_'${mod}'[^-_a-zA-Z0-9]*=/){a=1;print$0;next;}if(a){if($0~/^[a-zA-Z]/){exit;}print $0}}' | tr '\\ ' '\n\n' | grep '\.'`
490       hfiles=`for i in ${allfiles} ; do echo "$i" ; done | grep '\.h$'`
491       cfiles=`for i in ${allfiles} ; do echo "$i" ; done | grep -v '\.h$'`
492       for msdir in msvc
493       do
494         source="${msdir}/plugins.vcproj.in"
495         target="${msdir}/plugin_${mod}.vcproj"
496         printf "."
497         guid=`perl -e 'sub r {return sprintf("%X", int rand(65536))} print r.r."-".r."-".r."-".r."-".r.r.r'`
498         perl -pe 'if(/ZSOURCESZ/){last;} s/ZPLUGINZ/'${mod}'/g' < ${source} | sed 's,ZGUIDZ,'${guid}',' > ${target}
499         for cfile in ${cfiles}
500         do
501           cat >> ${target} << EOF
502 <File RelativePath="..\\modules\\`echo ${dir}/${cfile} | sed 's,/,\\\\,g'`"></File>${M}
503 EOF
504         done
505         # sed is really nicer for this... unfortunately it's broken under cygwin
506         # sed -ne '1,/ZSOURCESZ/d; /ZHEADERSZ/,$d; p' < ${source} >> ${target}
507         perl -e 'while(<>){if(/ZSOURCESZ/){last;}}while(<>){if(/ZHEADERSZ/){last;}print $_}' < ${source} >> ${target}
508         for hfile in ${hfiles}
509         do
510           cat >> ${target} << EOF
511 <File RelativePath="..\\modules\\`echo ${dir}/${hfile} | sed 's,/,\\\\,g'`"></File>${M}
512 EOF
513         done
514         # sed -ne '1,/ZHEADERSZ/d; p' < ${source} >> ${target}
515         perl -e 'while(<>){if(/ZHEADERSZ/){last;}}while(<>){print $_}' < ${source} >> ${target}
516       done
517     done
518   done
519
520   echo " done."
521   exit 0
522 fi
523
524 ##
525 ##  Update the potfiles because no one ever does it
526 ##
527 if test "${action}" = "po"
528 then
529   # find out the source files
530   echo "WARNING: you should run \"make update-po\" instead!" >&2
531   make update-po
532   exit $?
533 fi
534
535 ##
536 ##  Create include files
537 ##
538 if test "${action}" = "includes"
539 then
540   #set -x
541
542   if test -z "${srcdir}"; then
543     srcdir="`sed -ne 's/^srcdir *= *//p' < Makefile`"
544   fi
545   if test -z "${builddir}"; then
546     builddir="`sed -ne 's/^top_builddir *= *//p' < Makefile`"
547   fi
548   BUILTINS=`sed -ne 's/.*builtins *= *" *\([^"]*\)".*/\1/p' ${builddir}/vlc-config`
549
550   file="${builddir}/src/modules/builtin.h"
551
552   rm -f "${file}.tmp"
553   mkdir -p -- "${builddir}/src/modules"
554   cat "${srcdir}/src/modules/builtin.h.in" > "${file}.tmp" || exit 1
555   if test -n "${BUILTINS}"
556   then
557     for i in `echo ${BUILTINS}`
558     do
559       echo "int vlc_entry__`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`( module_t* );" >> "${file}.tmp"
560     done
561     echo "" >> "${file}.tmp"
562   fi
563   echo "#define ALLOCATE_ALL_BUILTINS() \\" >> ${file}.tmp
564   echo "    do \\" >> "${file}.tmp"
565   echo "    { \\" >> "${file}.tmp"
566   if test -n "${BUILTINS}"
567   then
568     for i in `echo ${BUILTINS}`
569     do
570       echo "        ALLOCATE_BUILTIN(`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`); \\" >> "${file}.tmp"
571     done
572   fi
573   echo "    } while( 0 );" >> "${file}.tmp"
574   echo "" >> "${file}.tmp" || exit 1
575   if diff >/dev/null 2>&1 "${file}" "${file}.tmp"
576   then
577     rm -f "${file}.tmp"
578   else
579     echo "creating new ${file}"
580     mv -f "${file}.tmp" "${file}"
581   fi
582
583   exit 0
584 fi
585
586 ##
587 ##  Create version file
588 ##
589 if test "${action}" = "version"
590 then
591   if test -z "${srcdir}"; then
592     srcdir="`sed -ne 's/^srcdir *= *//p' < Makefile`"
593   fi
594   if test -z "${builddir}"; then
595     builddir="`sed -ne 's/^top_builddir *= *//p' < Makefile`"
596   fi
597   if test -z "${CC}"; then
598     CC="`sed -ne 's/^CC *= *//p' < Makefile`"
599   fi
600
601   file="${builddir}/src/misc/version.c"
602   if which svnversion 2>&1 >/dev/null; then
603     VLC_CHANGESET=`svnversion $srcdir`
604   else
605     VLC_CHANGESET='exported'
606   fi
607
608   rm -f ${file}.tmp
609   mkdir -p -- "${builddir}/src/misc"
610   cat > ${file}.tmp << EOF
611 /* DO NOT EDIT THIS FILE - IT IS REGENERATED AT EVERY COMPILE -
612  * IT GIVES BETTER TRACKING OF VLC STABLE AND DEVELOPMENT VERSIONS
613  * WHETHER THEY ARE BUILT BY OTHERS OR DURING DEVELOPMENT OR FOR THE
614  * OFFICIAL VLC STABLE RELEASES.
615  */
616 const char psz_vlc_changeset[] = "${VLC_CHANGESET}";
617
618 EOF
619   if diff >/dev/null 2>&1 ${file} ${file}.tmp
620   then
621     rm -f ${file}.tmp
622   else
623     echo "creating new ${file}"
624     mv -f ${file}.tmp ${file}
625   fi
626
627   exit 0
628 fi
629
630 ##
631 ##  Fix glade2-generated files
632 ##
633 if test "${action}" = "glade2"
634 then
635   file="modules/gui/pda/pda.glade"
636   echo "generating code from $file"
637   glade-2 -w "$file" || exit 1
638
639   file="modules/gui/pda/pda_interface.c"
640   echo "fixing $file"
641   if grep "DO NOT EDIT THIS FILE" "$file" >/dev/null 2>&1
642   then
643     rm -f -- "$file.$$.bak"
644     cat > "$file.$$.bak" << EOF
645 /* This file was created automatically by glade2 and fixed by bootstrap */
646
647 #include <vlc/vlc.h>
648 EOF
649     sed -e 1,7d \
650         -e 's#_(\(".:..:.."\))#\1#' \
651         -e 's#_(\("[a-z0-9]*://[^"]*"\))#\1#' \
652         -e 's#_("---")#"---"#' \
653         -e 's#_("--")#"--"#' \
654         -e 's#_(\("/dev/[^"]*"\))#\1#' \
655         -e 's#_(\("./."\))#\1#' \
656         < "$file" >> "$file.$$.bak"
657     mv -f "$file.$$.bak" "$file"
658   fi
659
660   exit 0
661 fi
662
663 ##
664 ##  Make distclean
665 ##
666 if test "${action}" = "distclean"
667 then
668   set -x
669   # a naive sanity check to make sure we are in a VLC tree
670   test -f vlc.mandriva.spec -a -f vlc.win32.nsi.in || exit 1
671   # let's rock!
672   find . -false -path './extras/contrib/*' -type f '(' -name '*.[oa]' -o -name '*.l[oa]' -o -name '*.so' -o -name '*.sl' -o -name '*.dylib' -o -name '*.dll' -o -name .dirstamp -o '(' '(' ! -path '\./doc/developer/Makefile\.in' ')' -a -name Makefile.in ')' -o -name 'stamp-h*' -o -name '*~' -o -name '*.bak' -o -name '*.moc.cpp' ')' -exec rm -f '{}' ';'
673   (cd autotools && find . -maxdepth 1 -name '[a-z]*' -exec rm -f '{}' ';')
674   find msvc -type f -name '*.dsp' -exec rm -f '{}' ';'
675   find evc -type f -name '*.vcp' -exec rm -f '{}' ';'
676   find . -type d -name '.deps' -exec rm -Rf '{}' ';'
677   find . -type d -name '.libs' -exec rm -Rf '{}' ';'
678   # there's some more cruft all around
679   rm -f config.h config.log config.status
680   rm -f vlc vlc-config Makefile Modules.am
681   rm -Rf autom4te.cache
682   echo "\`toolbox --distclean\' is known to be broken."
683   echo "Don't complain if it does not work, or better yet, don't use it."
684   echo "You were warned."
685   # FIXME: a lot of Makefiles are still there
686 fi
687
688 ##
689 ## Add the extras/contrib dir to the distribution
690 ##
691 if test "${action}" = "contrib"
692 then
693   set -x
694   if test ! -d "${distdir}/extras"
695   then
696     mkdir "${distdir}/extras"
697   fi
698   if test ! -d "${distdir}/extras/contrib"
699   then
700     mkdir "${distdir}/extras/contrib"
701   fi
702   cp "${srcdir}/extras/contrib/Makefile" "${distdir}/extras/contrib/Makefile"
703   cp "${srcdir}/extras/contrib/README" "${distdir}/extras/contrib/README"
704   cp "${srcdir}/extras/contrib/bootstrap" "${distdir}/extras/contrib/bootstrap"
705   cp "${srcdir}/extras/contrib/change_prefix.sh" "${distdir}/extras/contrib/change_prefix.sh"
706   if test ! -d "${distdir}/extras/contrib/src"
707   then
708     mkdir "${distdir}/extras/contrib/src"
709   fi
710   cp "${srcdir}/extras/contrib/src/Makefile" "${distdir}/extras/contrib/src/Makefile"
711   cp "${srcdir}/extras/contrib/src/packages.mak" "${distdir}/extras/contrib/src/packages.mak"
712   if test ! -d "${distdir}/extras/contrib/src/Patches"
713   then
714     mkdir "${distdir}/extras/contrib/src/Patches"
715   fi
716   cp ${srcdir}/extras/contrib/src/Patches/* "${distdir}/extras/contrib/src/Patches/"
717 fi
718