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