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