]> git.sesse.net Git - vlc/blob - toolbox
Removed unused variable f_arg
[vlc] / toolbox
1 #! /bin/sh
2
3 ##  toolbox for the VLC media player
4 ##  $Id$
5 ##
6 ##  Copyright (C) 2005  the VideoLAN team
7 ##
8 ##  Authors: Samuel Hocevar <sam@zoy.org>
9 ##           Rémi Denis-Courmont <rem # videolan.org>
10
11 ###
12 ###  Get a sane environment, just in case
13 ###
14 LC_ALL=C
15 export LC_ALL
16 LANG=C
17 export LANG
18 CYGWIN=binmode
19 export CYGWIN
20
21 ##
22 ##  Give help
23 ##
24 help()
25 {
26   cat << EOF
27 recognized flags are:
28   --update-vc             update Microsoft Visual Studio files
29   --update-vc7            update Microsoft Visual .NET files
30   --update-po             update translation files
31   --update-includes       generate various include files
32   --update-version        generate src/misc/version.c
33   --update-glade          generate and fix Glade code
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   --make-woody <dir>      change distdir <dir> to a woody distdir
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   --make-woody)
95     action=woody
96     ;;
97   --add-include)
98     action=include
99     ;;
100   --dist-contrib)
101     action=contrib
102     ;;
103   --help)
104     help
105     ;;
106   *)
107     echo "$0: unknown option $1"
108     help
109     ;;
110 esac
111 shift
112
113 ##
114 ##  Add includes to help doxygen
115 ##
116 if test "${action}" = "include"
117 then
118   case "$1" in
119     */vlc_common.h|*/include/vlc/*);;
120     */include/*.h) echo "#include <vlc_common.h>" ;;
121   esac
122   cat $1
123   exit 0
124 fi
125
126 ##
127 ##  Update the CVS changelog
128 ##
129 if test "${action}" = "changelog"
130 then
131   YEAR="`date +%Y`"
132   echo "toolbox --changelog no longer required. use this instead:"
133   echo " svn log -v -r '{$YEAR-12-31}:{$YEAR-01-01}' > ChangeLog"
134   exit 0
135 fi
136
137 ##
138 ##  Update the MSVC project files
139 ##
140 if test "${action}" = "vc"
141 then
142   echo "generating Visual Studio files"
143
144   if test -z "${srcdir}"; then
145     srcdir="`sed -ne 's/^srcdir *= *//p' < Makefile`"
146   fi
147
148   #  The evil ^M. printf '\r' does not work in Cygwin.
149   M='\r'
150
151   #  Variables we get from configure.ac
152   LIBVLC_VERSION=`sed -ne '/AC_INIT/s/.*,\(.*\))/\1/p' < configure.ac`
153   LIBVLC_CODENAME=`sed -ne '/CODENAME=/s/.*"\(.*\)"/\1/p' < configure.ac`
154   LIBVLC_SYMBOL=`echo $LIBVLC_VERSION | sed -e 'y/.-/__/'`
155
156   #  Sources that get built under Win32 - FIXME: anyone wanna deuglify this? :)
157   LIBVLC_SOURCES=`getfiles SOURCES_libvlc_common; getfiles SOURCES_libvlc_win32; getfiles SOURCES_libvlc_dirent; getfiles SOURCES_libvlc_getopt; getfiles SOURCES_libvlc_libc`
158
159   LIBVLC_HEADERS=`getfiles HEADERS_include; getfiles HEADERS_include_built`
160
161   LIBVLC_PKG_HEADERS=`getfiles dist_pkginclude_HEADERS`
162
163   # Clean up
164   rm -f evc/*.vcp msvc/*.dsp msvc/*.vcproj msvc/*.sln msvc/*.ncb
165
166   # config files
167   for target in evc/config.h msvc/config.h
168   do
169     printf "."
170     rm -f ${target}
171     sed -e "s/@CODENAME@/${LIBVLC_CODENAME}/" \
172         -e "s/@VERSION@/${LIBVLC_VERSION}/" \
173         -e "s/@SYMBOL@/${LIBVLC_SYMBOL}/" < ${target}.in > ${target}
174   done
175
176   # libvlc files
177   for target in evc/libvlc.vcp msvc/libvlc.dsp
178   do
179     printf "."
180     #  Top of the project file
181     perl -pe 'if(/§SOURCES§/){last;}' < ${target}.in > ${target}
182     #  The source files
183     for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep -v "/.*/"`
184     do
185       cat >> ${target} << EOF
186 # Begin Source File${M}
187 SOURCE="..\\`echo ${file} | sed -e 's%/%\\\\%g'`"${M}
188 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
189 # End Source File${M}
190 EOF
191     done
192     for subdir in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/.*/" | cut -f2 -d/ | sort | uniq`
193     do
194       cat >> ${target} << EOF
195 # Begin Group "${subdir}"${M}
196 EOF
197       for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/${subdir}/"`
198       do
199       subdir="`echo ${file} | sed -e 's%/[^/]*$%/%' | sed -e 's%/%\\\\%g'`"
200       if test "${target}" = "evc/libvlc.vcp"
201       then
202         cat >> ${target} << EOF
203 # Begin Source File${M}
204 SOURCE="..\\`echo ${file} | sed -e 's%/%\\\\%g'`"${M}
205 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
206 !IF "\$(CFG)" == "libvlc - Win32 (WCE MIPS) Release"${M}
207 # PROP Output_Dir "MIPSRel\\${subdir}"${M}
208 # PROP Intermediate_Dir "MIPSRel\\${subdir}"${M}
209 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE MIPS) Debug"${M}
210 # PROP Output_Dir "MIPSDbg\\${subdir}"${M}
211 # PROP Intermediate_Dir "MIPSDbg\\${subdir}"${M}
212 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH4) Release"${M}
213 # PROP Output_Dir "SH4Rel\\${subdir}"${M}
214 # PROP Intermediate_Dir "SH4Rel\\${subdir}"${M}
215 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH4) Debug"${M}
216 # PROP Output_Dir "SH4Dbg\\${subdir}"${M}
217 # PROP Intermediate_Dir "SH4Dbg\\${subdir}"${M}
218 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH3) Release"${M}
219 # PROP Output_Dir "SH3Rel\\${subdir}"${M}
220 # PROP Intermediate_Dir "SH3Rel\\${subdir}"${M}
221 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH3) Debug"${M}
222 # PROP Output_Dir "SH3Dbg\\${subdir}"${M}
223 # PROP Intermediate_Dir "SH3Dbg\\${subdir}"${M}
224 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARM) Release"${M}
225 # PROP Output_Dir "ARMRel\\${subdir}"${M}
226 # PROP Intermediate_Dir "ARMRel\\${subdir}"${M}
227 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARM) Debug"${M}
228 # PROP Output_Dir "ARMDbg\\${subdir}"${M}
229 # PROP Intermediate_Dir "ARMDbg\\${subdir}"${M}
230 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARMV4) Release"${M}
231 # PROP Output_Dir "ARMV4Rel\\${subdir}"${M}
232 # PROP Intermediate_Dir "ARMV4Rel\\${subdir}"${M}
233 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARMV4) Debug"${M}
234 # PROP Output_Dir "ARMV4Dbg\\${subdir}"${M}
235 # PROP Intermediate_Dir "ARMV4Dbg\\${subdir}"${M}
236 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE x86em) Release"${M}
237 # PROP Output_Dir "X86EMRel\\${subdir}"${M}
238 # PROP Intermediate_Dir "X86EMRel\\${subdir}"${M}
239 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE x86em) Debug"${M}
240 # PROP Output_Dir "X86EMDbg\\${subdir}"${M}
241 # PROP Intermediate_Dir "X86EMDbg\\${subdir}"${M}
242 !ELSEIF  "\$(CFG)" == "libvlc - Win32 (WCE emulator) Debug"${M}
243 # PROP Output_Dir "emulatorDbg\\${subdir}"${M}
244 # PROP Intermediate_Dir "emulatorDbg\\${subdir}"${M}
245 !ELSEIF  "\$(CFG)" == "libvlc - Win32 (WCE emulator) Release"${M}
246 # PROP Output_Dir "emulatorRel\\${subdir}"${M}
247 # PROP Intermediate_Dir "emulatorRel\\${subdir}"${M}
248 !ELSEIF  "\$(CFG)" == "libvlc - Win32 (WCE x86) Debug"${M}
249 # PROP Output_Dir "X86Dbg\\${subdir}"${M}
250 # PROP Intermediate_Dir "X86Dbg\\${subdir}"${M}
251 !ELSEIF  "\$(CFG)" == "libvlc - Win32 (WCE x86) Release"${M}
252 # PROP Output_Dir "X86Rel\\${subdir}"${M}
253 # PROP Intermediate_Dir "X86Rel\\${subdir}"${M}
254 !ENDIF${M}
255 # End Source File${M}
256 EOF
257         else
258           cat >> ${target} << EOF
259 # Begin Source File${M}
260 SOURCE="..\\`echo ${file} | sed -e 's%/%\\\\%g'`"${M}
261 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
262 !IF "\$(CFG)" == "libvlc - Win32 Release"${M}
263 # PROP Output_Dir "Release\\${subdir}"${M}
264 # PROP Intermediate_Dir "Release\\${subdir}"${M}
265 !ELSEIF "\$(CFG)" == "libvlc - Win32 Debug"${M}
266 # PROP Output_Dir "Debug\\${subdir}"${M}
267 # PROP Intermediate_Dir "Debug\\${subdir}"${M}
268 !ENDIF${M}
269 # End Source File${M}
270 EOF
271         fi
272       done
273       cat >> ${target} << EOF
274 # End Group${M}
275 EOF
276     done
277     #  The headers
278     perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){if(/§HEADERS§/){last;}print $_}' < ${target}.in >> ${target}
279     for file in ${LIBVLC_HEADERS}
280     do
281       cat >> ${target} << EOF
282 # Begin Source File${M}
283 SOURCE="..\\`echo ${file} | sed -e 's%/%\\\\%g'`"${M}
284 # End Source File${M}
285 EOF
286     done
287     cat >> ${target} << EOF
288 # Begin Group "vlc"${M}
289 EOF
290     for file in ${LIBVLC_PKG_HEADERS}
291     do
292       cat >> ${target} << EOF
293 # Begin Source File${M}
294 SOURCE="..\\`echo ${file} | sed -e 's%/%\\\\%g'`"${M}
295 # End Source File${M}
296 EOF
297     done
298     cat >> ${target} << EOF
299 # End Group${M}
300 EOF
301     perl -e 'while(<>){if(/§HEADERS§/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
302   done
303
304   # plugins files
305   for dir in `sed -ne 's,modules/\(.*\)/Makefile,\1,p' ${srcdir}/configure.ac`
306   do
307     mf="${srcdir}/modules/${dir}/Modules.am"
308     for mod in `sed -n -e 's/^ *SOURCES_\([^ ]*\).*/\1/p' < ${mf}`
309     do
310       # this is an attempt at getting a list of plugin sources... we take the
311       # production and remove everything that does not contain "module", which
312       # means you miss $(NULL), but other variables too.
313       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 '\.'`
314       hfiles=`for i in ${allfiles} ; do echo "$i" ; done | grep '\.h$'`
315       cfiles=`for i in ${allfiles} ; do echo "$i" ; done | grep -v '\.h$'`
316       for msdir in evc msvc
317       do
318         test "${msdir}" = "evc" && suf="vcp" || suf="dsp"
319         source="${msdir}/plugins.${suf}.in"
320         target="${msdir}/plugin_${mod}.${suf}"
321         printf "."
322         perl -pe 'if(/§SOURCES§/){last;} s/§PLUGIN§/'${mod}'/g' < ${source} > ${target}
323         for cfile in ${cfiles}
324         do
325           cat >> ${target} << EOF
326 # Begin Source File${M}
327 SOURCE="..\\modules\\`echo ${dir}/${cfile} | sed 's,/,\\\\,g'`"${M}
328 # ADD CPP /D "__VLC__" /D "__PLUGIN__"  /D "MODULE_NAME=${mod}" /D "MODULE_NAME_IS_${mod}" ${M}
329 !IF "\$(CFG)" == "plugin_${mod} - Win32 Release"${M}
330 # PROP Output_Dir "Release\\modules\\`echo ${dir} | sed 's,/,\\\\,g'`"${M}
331 # PROP Intermediate_Dir "Release\\modules\\`echo ${dir} | sed 's,/,\\\\,g'`"${M}
332 !ELSEIF "\$(CFG)" == "plugin_${mod} - Win32 Debug"${M}
333 # PROP Output_Dir "Debug\\modules\\`echo ${dir} | sed 's,/,\\\\,g'`"${M}
334 # PROP Intermediate_Dir "Debug\\modules\\`echo ${dir} | sed 's,/,\\\\,g'`"${M}
335 # End Source File${M}
336 EOF
337         done
338         # sed is really nicer for this... unfortunately it's broken under cygwin
339         # sed -ne '1,/§SOURCES§/d; /§HEADERS§/,$d; p' < ${source} >> ${target}
340         perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){if(/§HEADERS§/){last;}print $_}' < ${source} >> ${target}
341         for hfile in ${hfiles}
342         do
343           cat >> ${target} << EOF
344 # Begin Source File${M}
345 SOURCE="..\\modules\\`echo ${dir}/${hfile} | sed 's,/,\\\\,g'`"${M}
346 # End Source File${M}
347 EOF
348         done
349         # sed -ne '1,/§HEADERS§/d; p' < ${source} >> ${target}
350         perl -e 'while(<>){if(/§HEADERS§/){last;}}while(<>){print $_}' < ${source} >> ${target}
351       done
352     done
353   done
354
355   # vlc files
356   for target in evc/vlc.vcp msvc/vlc.dsp
357   do
358     printf "."
359     #  Top of the project file
360     perl -pe 'if(/§SOURCES§/){last;}' < ${target}.in > ${target}
361     #  The source files
362       cat >> ${target} << EOF
363 # Begin Source File${M}
364 SOURCE="..\\src\\vlc.c"${M}
365 # End Source File${M}
366 EOF
367     #  Bottom of the project file - handles resource files too
368     perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
369   done
370
371   echo " done."
372   exit 0
373 fi
374
375 ##
376 ##  Update the MSVC (.NET) project files
377 ##
378 if test "${action}" = "vc7"
379 then
380   echo "generating Visual .NET files"
381
382   srcdir=.
383
384   #  The evil ^M. printf '\r' does not work in Cygwin.
385   M='
386 '
387
388   #  Variables we get from configure.ac
389   LIBVLC_VERSION=`sed -ne '/AC_INIT/s/.*,\(.*\))/\1/p' < configure.ac`
390   LIBVLC_CODENAME=`sed -ne '/CODENAME=/s/.*"\(.*\)"/\1/p' < configure.ac`
391   LIBVLC_SYMBOL=`echo $LIBVLC_VERSION | sed -e 'y/.-/__/'`
392
393   #  Sources that get built under Win32 - FIXME: anyone wanna deuglify this? :)
394   LIBVLC_SOURCES=`getfiles SOURCES_libvlc_common; getfiles SOURCES_libvlc_win32; getfiles SOURCES_libvlc_dirent; getfiles SOURCES_libvlc_getopt; getfiles SOURCES_libvlc_libc`
395
396   LIBVLC_HEADERS=`getfiles HEADERS_include; getfiles HEADERS_include_built`
397
398   LIBVLC_PKG_HEADERS=`getfiles dist_pkginclude_HEADERS`
399
400   # Clean up
401   rm -f msvc/*.vcproj
402
403   # config files
404   for target in msvc/config.h
405   do
406     printf "."
407     rm -f ${target}
408     sed -e "s/@CODENAME@/${LIBVLC_CODENAME}/" \
409         -e "s/@VERSION@/${LIBVLC_VERSION}/" \
410         -e "s/@SYMBOL@/${LIBVLC_SYMBOL}/" < ${target}.in > ${target}
411   done
412
413  # vlc files
414   target="msvc/vlc.vcproj"
415   printf "."
416   #  Top of the project file
417   guid=`perl -e 'sub r {return sprintf("%X", int rand(65536))} print r.r."-".r."-".r."-".r."-".r.r.r'`
418   perl -pe 'if(/§SOURCES§/){last;} s/§GUID§/'${guid}'/g' < ${target}.in > ${target}
419   #  The source files
420   cat >> ${target} << EOF
421 <File RelativePath="..\\src\\vlc.c"></File>${M}
422 EOF
423   #  Bottom of the project file - handles resource files too
424   perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
425   
426   # libvlc files
427   target=msvc/libvlc.vcproj
428   printf "."
429   #  Top of the project file
430   guid=`perl -e 'sub r {return sprintf("%X", int rand(65536))} print r.r."-".r."-".r."-".r."-".r.r.r'`
431   perl -pe 'if(/§SOURCES§/){last;} s/§GUID§/'${guid}'/g' < ${target}.in > ${target}
432   #  The source files
433   for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep -v "/.*/"`
434   do
435     cat >> ${target} << EOF
436 <File RelativePath="..\\`echo ${dir}/${file} | sed 's,/,\\\\,g'`"></File>${M}
437 EOF
438   done
439   for subdir in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/.*/" | cut -f2 -d/ | sort | uniq`
440   do
441     cat >> ${target} << EOF
442 <Filter Name="`echo ${subdir} | sed s,/,_,g`" Filter="c;cpp">${M}
443 EOF
444     for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/${subdir}/"`
445     do
446       cat >> ${target} << EOF
447 <File RelativePath="..\\`echo ${file} | sed 's,/,\\\\,g'`">${M}
448 EOF
449       if echo ${file} | grep -q '.c$'
450       then
451         cat >> ${target} << EOF
452         <FileConfiguration Name="Debug|Win32">${M}
453                 <Tool Name="VCCLCompilerTool" ObjectFile="\$(IntDir)/\$(ProjectName)/`echo ${file} | sed -e s/\.c$/.obj/`"/>${M}
454         </FileConfiguration>${M}
455 EOF
456       fi
457       cat >> ${target} << EOF
458 </File>${M}
459 EOF
460     done
461     cat >> ${target} << EOF
462 </Filter>${M}
463 EOF
464   done
465   #  The headers
466   perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){if(/§HEADERS§/){last;}print $_}' < ${target}.in >> ${target}
467   for file in ${LIBVLC_HEADERS}
468   do
469     cat >> ${target} << EOF
470 <File RelativePath="..\\`echo ${file} | sed 's,/,\\\\,g'`"></File>${M}
471 EOF
472   done
473   cat >> ${target} << EOF
474 <Filter Name="vlc" Filter="h;hpp">${M}
475 EOF
476   for file in ${LIBVLC_PKG_HEADERS}
477   do
478     cat >> ${target} << EOF
479 <File RelativePath="..\\`echo ${file} | sed 's,/,\\\\,g'`"></File>${M}
480 EOF
481   done
482   cat >> ${target} << EOF
483 </Filter>${M}
484 EOF
485   perl -e 'while(<>){if(/§HEADERS§/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
486
487   # plugins files
488   for dir in `sed -ne 's,modules/\(.*\)/Makefile,\1,p' ${srcdir}/configure.ac`
489   do
490     mf="${srcdir}/modules/${dir}/Modules.am"
491     for mod in `sed -n -e 's/^ *SOURCES_\([^ ]*\).*/\1/p' < ${mf}`
492     do
493       # this is an attempt at getting a list of plugin sources... we take the
494       # production and remove everything that does not contain "module", which
495       # means you miss $(NULL), but other variables too.
496       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 '\.'`
497       hfiles=`for i in ${allfiles} ; do echo "$i" ; done | grep '\.h$'`
498       cfiles=`for i in ${allfiles} ; do echo "$i" ; done | grep -v '\.h$'`
499       for msdir in msvc
500       do
501         source="${msdir}/plugins.vcproj.in"
502         target="${msdir}/plugin_${mod}.vcproj"
503         printf "."
504         guid=`perl -e 'sub r {return sprintf("%X", int rand(65536))} print r.r."-".r."-".r."-".r."-".r.r.r'`
505         perl -pe 'if(/§SOURCES§/){last;} s/§PLUGIN§/'${mod}'/g' < ${source} | sed 's,§GUID§,'${guid}',' > ${target}
506         for cfile in ${cfiles}
507         do
508           cat >> ${target} << EOF
509 <File RelativePath="..\\modules\\`echo ${dir}/${cfile} | sed 's,/,\\\\,g'`"></File>${M}
510 EOF
511         done
512         # sed is really nicer for this... unfortunately it's broken under cygwin
513         # sed -ne '1,/§SOURCES§/d; /§HEADERS§/,$d; p' < ${source} >> ${target}
514         perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){if(/§HEADERS§/){last;}print $_}' < ${source} >> ${target}
515         for hfile in ${hfiles}
516         do
517           cat >> ${target} << EOF
518 <File RelativePath="..\\modules\\`echo ${dir}/${hfile} | sed 's,/,\\\\,g'`"></File>${M}
519 EOF
520         done
521         # sed -ne '1,/§HEADERS§/d; p' < ${source} >> ${target}
522         perl -e 'while(<>){if(/§HEADERS§/){last;}}while(<>){print $_}' < ${source} >> ${target}
523       done
524     done
525   done
526
527   echo " done."
528   exit 0
529 fi
530
531 ##
532 ##  Update the potfiles because no one ever does it
533 ##
534 if test "${action}" = "po"
535 then
536   # find out the source files
537   echo "WARNING: you should run \"make update-po\" instead!" >&2
538   make update-po
539   exit $?
540 fi
541
542 ##
543 ##  Create include files
544 ##
545 if test "${action}" = "includes"
546 then
547   #set -x
548
549   if test -z "${srcdir}"; then
550     srcdir="`sed -ne 's/^srcdir *= *//p' < Makefile`"
551   fi
552   if test -z "${builddir}"; then
553     builddir="`sed -ne 's/^top_builddir *= *//p' < Makefile`"
554   fi
555   BUILTINS=`sed -ne 's/.*builtins *= *" *\([^"]*\)".*/\1/p' vlc-config`
556
557   file="${builddir}/src/misc/modules_builtin.h"
558
559   rm -f ${file}.tmp && cp ${srcdir}/src/misc/modules_builtin.h.in ${file}.tmp
560   if test -n "${BUILTINS}"
561   then
562     for i in `echo ${BUILTINS}`
563     do
564       echo "int vlc_entry__`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`( module_t* );" >>${file}.tmp
565     done
566     echo "" >> ${file}.tmp
567   fi
568   echo "#define ALLOCATE_ALL_BUILTINS() \\" >> ${file}.tmp
569   echo "    do \\" >> ${file}.tmp
570   echo "    { \\" >> ${file}.tmp
571   if test -n "${BUILTINS}"
572   then
573     for i in `echo ${BUILTINS}`
574     do
575       echo "        ALLOCATE_BUILTIN(`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`); \\" >> ${file}.tmp
576     done
577   fi
578   echo "    } while( 0 );" >> ${file}.tmp
579   echo "" >> ${file}.tmp
580   if diff >/dev/null 2>&1 ${file} ${file}.tmp
581   then
582     rm -f ${file}.tmp
583   else
584     echo "creating new ${file}"
585     mv -f ${file}.tmp ${file}
586   fi
587
588   exit 0
589 fi
590
591 ##
592 ##  Create version file
593 ##
594 if test "${action}" = "version"
595 then
596   if test -z "${srcdir}"; then
597     srcdir="`sed -ne 's/^srcdir *= *//p' < Makefile`"
598   fi
599   if test -z "${builddir}"; then
600     builddir="`sed -ne 's/^top_builddir *= *//p' < Makefile`"
601   fi
602   if test -z "${CC}"; then
603     CC="`sed -ne 's/^CC *= *//p' < Makefile`"
604   fi
605
606   file="${builddir}/src/misc/version.c"
607   if which svnversion 2>&1 >/dev/null; then
608     VLC_CHANGESET=`svnversion $srcdir`
609   else
610     VLC_CHANGESET='exported'
611   fi
612
613   rm -f ${file}.tmp
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 debian/rules || 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   (cd debian && find . -type d '(' -name '[a-z]*' ! -name 'patches' ')' -maxdepth 1 -exec rm -Rf '{}' ';')
735   find msvc -type f -name '*.dsp' -exec rm -f '{}' ';'
736   find evc -type f -name '*.vcp' -exec rm -f '{}' ';'
737   find . -type d -name '.deps' -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
777 ##
778 ##  Build a woody-friendly package
779 ##
780 if test "${action}" = "woody"
781 then
782   set -ex
783   test -d "$1"
784
785   # changelog: replace (1.2.3-4) with (1.2.3-0woody.4)
786   sed -e 's/^vlc (\([^)]*\)-\([^-)]*\))/vlc-woody (\1-0woody.\2)/' \
787       -e 's/ unstable; / stable; /' \
788       < "$1/debian/changelog" > "$1/debian/changelog.woody"
789   mv "$1/debian/changelog.woody" "$1/debian/changelog"
790
791   # control: replace liba52-*-dev with a52dec-dev (>=0.7.3)
792   #                  libdv*-dev with libdv-dev
793   #                  kdelibs4-dev with kdelibs-dev
794   #                  libqt3-mt-dev libqt3-compat-headers with libqt-dev
795   #                  libarts1-dev with libarts-dev
796   #                  libdvdread3-dev with libdvdread2-dev
797   #                  libdvdplay0-dev (>=1.0.1-2) with libdvdplay0-dev
798   #                  libxosd-dev (>=2.2.4-1.3) with libxosd-dev
799   #                  ttf-freefont with ttf-thryomanes
800   #                  dvb-dev (>= 1.0.1-6) with dvb-dev
801   #          remove libwxgtk2.4-dev
802   #                 libidl0 (workaround for mozilla-dev's bad deps)
803   #                 libglib2.0-0 (workaround for mozilla-dev's bad deps)
804   #                 gcc-3.2 (workaround for an ICE in gcc-3.3)
805   #          change Section: gnome with Section: graphics
806   #                 Section: kde with Section: kde
807   #                 Section: libdevel with Section: devel
808   sed -e 's/liba52-[^-]*-dev/a52dec-dev (>=0.7.3)/' \
809       -e 's/libdv[0-9]*-dev/libdv-dev/' \
810       -e 's/kdelibs[0-9]*-dev/kdelibs-dev/' \
811       -e 's/libqt[0-9]*-mt-dev/libqt-dev/' \
812       -e 's/, libqt[0-9]*-compat-headers[^,]*//' \
813       -e 's/libarts[0-9]*-dev/libarts-dev/' \
814       -e 's/libdvdread[0-9]*-dev/libdvdread2-dev/' \
815       -e 's/, libdvdplay0-dev[^,]*/, libdvdplay0-dev/' \
816       -e 's/, libxosd-dev[^,]*/, libxosd-dev/' \
817       -e 's/, ttf-freefont[^,]*/, ttf-thryomanes/' \
818       -e 's/, dvb-dev[^,]*/, dvb-dev/' \
819       -e 's/, libwx[^,]*//' \
820       -e '/Package: wxvlc/,/^ *$/d' \
821       -e 's/, libidl0[^,]*//' \
822       -e 's/, libglib2.0-0[^,]*//' \
823       -e 's/, gcc-3.2[^,]*//' \
824       -e 's/Section: gnome/Section: graphics/' \
825       -e 's/Section: kde/Section: graphics/' \
826       -e 's/Section: libdevel/Section: devel/' \
827       < "$1/debian/control" > "$1/debian/control.woody"
828   mv "$1/debian/control.woody" "$1/debian/control"
829
830   # rules: remove wxwindows and skins stuff
831   sed -e '/# Package: wxvlc/,/^ *$/d' \
832       -e 's,--enable-wxwindows,--disable-wxwindows,' \
833       -e 's,--enable-skins,--disable-skins,' \
834       < "$1/debian/rules" > "$1/debian/rules.woody"
835   mv "$1/debian/rules.woody" "$1/debian/rules"
836   chmod 0755 "$1/debian/rules"
837
838   # modules/misc/freetype.c: replace the default font
839   sed -e 's,freefont/FreeSerifBold.ttf,thryomanes/thryb___.ttf,' \
840       < "$1/modules/misc/freetype.c" > "$1/modules/misc/freetype.c.woody"
841   mv "$1/modules/misc/freetype.c.woody" "$1/modules/misc/freetype.c"
842 fi
843