Refresh patch.
[vlc/vlc-skelet.git] / toolbox
blob01945e4f69a7efc91cd2103188730de255057494
1 #! /bin/sh
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>
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
23 ## Give help
25 help()
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-glade2 generate and fix Glade 2 code
34 --update-flexml generate and fix flexml and flex code
35 --distclean "make distclean" on steroids
36 --dist-contrib add the contrib dir to MAKE_DIST
37 EOF
38 exit 1
42 ## Extract stuff from Makefile.am
44 getfiles()
46 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" | \
47 tr '\\ ' '\n\n' | \
48 sed -ne 's/[^-$()_a-zA-Z0-9][^-$()_a-zA-Z0-9]*\([a-zA-Z]\)/\1/p' | \
49 sed -e "s,^,${srcdir}/,"
52 ###
53 ### argument check
54 ###
56 if test "$1" = ""
57 then
58 help
61 case "$1" in
62 --changelog|--update-changelog)
63 action=changelog
65 --update-vc)
66 action=vc
68 --update-vc7)
69 action=vc7
71 --update-po)
72 action=po
74 --update-includes)
75 action=includes
77 --update-flexml)
78 action=flexml
80 --update-glade2|--update-glade-2|--fix-glade2)
81 action=glade2
83 --distclean)
84 action=distclean
86 --add-include)
87 action=include
89 --dist-contrib)
90 action=contrib
92 --help)
93 help
96 echo "$0: unknown option $1"
97 help
99 esac
100 shift
103 ## Add includes to help doxygen
105 if test "${action}" = "include"
106 then
107 case "$1" in
108 */vlc_common.h|*/include/vlc/*);;
109 */include/*.h) echo "#include <vlc_common.h>" ;;
110 esac
111 cat $1
112 exit 0
116 ## Update the CVS changelog
118 if test "${action}" = "changelog"
119 then
120 YEAR="`date +%Y`"
121 echo "toolbox --changelog no longer required. use this instead:"
122 echo " LANG=C svn log -v -r '{$YEAR-12-31}:{$YEAR-01-01}' > ChangeLog"
123 exit 0
127 ## Update the MSVC project files
129 if test "${action}" = "vc"
130 then
131 echo "generating Visual Studio files"
133 if test -z "${srcdir}"; then
134 srcdir="`sed -ne 's/^srcdir *= *//p' < Makefile`"
137 # The evil ^M. printf '\r' does not work in Cygwin.
138 M=' '
140 # Variables we get from configure.ac
141 LIBVLC_VERSION=`sed -ne '/AC_INIT/s/.*,\(.*\))/\1/p' < configure.ac`
142 LIBVLC_CODENAME=`sed -ne '/CODENAME=/s/.*"\(.*\)"/\1/p' < configure.ac`
143 LIBVLC_SYMBOL=`echo $LIBVLC_VERSION | sed -e 'y/.-/__/'`
145 # Sources that get built under Win32 - FIXME: anyone wanna deuglify this? :)
146 LIBVLC_SOURCES=`getfiles SOURCES_libvlc_common; getfiles SOURCES_libvlc_win32; getfiles SOURCES_libvlc_dirent; getfiles SOURCES_libvlc_getopt; getfiles SOURCES_libvlc_libc`
148 LIBVLC_HEADERS=`getfiles HEADERS_include; getfiles HEADERS_include_built`
150 LIBVLC_PKG_HEADERS=`getfiles dist_pkginclude_HEADERS`
152 # Clean up
153 rm -f evc/*.vcp msvc/*.dsp msvc/*.vcproj msvc/*.sln msvc/*.ncb
155 # config files
156 for target in evc/config.h msvc/config.h
158 printf "."
159 rm -f ${target}
160 sed -e "s/@CODENAME@/${LIBVLC_CODENAME}/" \
161 -e "s/@VERSION@/${LIBVLC_VERSION}/" \
162 -e "s/@SYMBOL@/${LIBVLC_SYMBOL}/" < ${target}.in > ${target}
163 done
165 # libvlc files
166 for target in evc/libvlc.vcp msvc/libvlc.dsp
168 printf "."
169 # Top of the project file
170 perl -pe 'if(/ZSOURCESZ/){last;}' < ${target}.in > ${target}
171 # The source files
172 for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep -v "/.*/"`
174 cat >> ${target} << EOF
175 # Begin Source File${M}
176 SOURCE="..\\`echo ${file} | sed -e 's%/%\\\\%g'`"${M}
177 # ADD CPP /D "__LIBVLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
178 # End Source File${M}
180 done
181 for subdir in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/.*/" | cut -f2 -d/ | sort | uniq`
183 cat >> ${target} << EOF
184 # Begin Group "${subdir}"${M}
186 for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/${subdir}/"`
188 subdir="`echo ${file} | sed -e 's%/[^/]*$%/%' | sed -e 's%/%\\\\%g'`"
189 if test "${target}" = "evc/libvlc.vcp"
190 then
191 cat >> ${target} << EOF
192 # Begin Source File${M}
193 SOURCE="..\\`echo ${file} | sed -e 's%/%\\\\%g'`"${M}
194 # ADD CPP /D "__LIBVLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
195 !IF "\$(CFG)" == "libvlc - Win32 (WCE MIPS) Release"${M}
196 # PROP Output_Dir "MIPSRel\\${subdir}"${M}
197 # PROP Intermediate_Dir "MIPSRel\\${subdir}"${M}
198 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE MIPS) Debug"${M}
199 # PROP Output_Dir "MIPSDbg\\${subdir}"${M}
200 # PROP Intermediate_Dir "MIPSDbg\\${subdir}"${M}
201 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH4) Release"${M}
202 # PROP Output_Dir "SH4Rel\\${subdir}"${M}
203 # PROP Intermediate_Dir "SH4Rel\\${subdir}"${M}
204 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH4) Debug"${M}
205 # PROP Output_Dir "SH4Dbg\\${subdir}"${M}
206 # PROP Intermediate_Dir "SH4Dbg\\${subdir}"${M}
207 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH3) Release"${M}
208 # PROP Output_Dir "SH3Rel\\${subdir}"${M}
209 # PROP Intermediate_Dir "SH3Rel\\${subdir}"${M}
210 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH3) Debug"${M}
211 # PROP Output_Dir "SH3Dbg\\${subdir}"${M}
212 # PROP Intermediate_Dir "SH3Dbg\\${subdir}"${M}
213 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARM) Release"${M}
214 # PROP Output_Dir "ARMRel\\${subdir}"${M}
215 # PROP Intermediate_Dir "ARMRel\\${subdir}"${M}
216 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARM) Debug"${M}
217 # PROP Output_Dir "ARMDbg\\${subdir}"${M}
218 # PROP Intermediate_Dir "ARMDbg\\${subdir}"${M}
219 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARMV4) Release"${M}
220 # PROP Output_Dir "ARMV4Rel\\${subdir}"${M}
221 # PROP Intermediate_Dir "ARMV4Rel\\${subdir}"${M}
222 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARMV4) Debug"${M}
223 # PROP Output_Dir "ARMV4Dbg\\${subdir}"${M}
224 # PROP Intermediate_Dir "ARMV4Dbg\\${subdir}"${M}
225 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE x86em) Release"${M}
226 # PROP Output_Dir "X86EMRel\\${subdir}"${M}
227 # PROP Intermediate_Dir "X86EMRel\\${subdir}"${M}
228 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE x86em) Debug"${M}
229 # PROP Output_Dir "X86EMDbg\\${subdir}"${M}
230 # PROP Intermediate_Dir "X86EMDbg\\${subdir}"${M}
231 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE emulator) Debug"${M}
232 # PROP Output_Dir "emulatorDbg\\${subdir}"${M}
233 # PROP Intermediate_Dir "emulatorDbg\\${subdir}"${M}
234 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE emulator) Release"${M}
235 # PROP Output_Dir "emulatorRel\\${subdir}"${M}
236 # PROP Intermediate_Dir "emulatorRel\\${subdir}"${M}
237 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE x86) Debug"${M}
238 # PROP Output_Dir "X86Dbg\\${subdir}"${M}
239 # PROP Intermediate_Dir "X86Dbg\\${subdir}"${M}
240 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE x86) Release"${M}
241 # PROP Output_Dir "X86Rel\\${subdir}"${M}
242 # PROP Intermediate_Dir "X86Rel\\${subdir}"${M}
243 !ENDIF${M}
244 # End Source File${M}
246 else
247 cat >> ${target} << EOF
248 # Begin Source File${M}
249 SOURCE="..\\`echo ${file} | sed -e 's%/%\\\\%g'`"${M}
250 # ADD CPP /D "__LIBVLC__" /D PLUGIN_PATH=\\".\\" /D DATA_PATH=\\"share\\"${M}
251 !IF "\$(CFG)" == "libvlc - Win32 Release"${M}
252 # PROP Output_Dir "Release\\${subdir}"${M}
253 # PROP Intermediate_Dir "Release\\${subdir}"${M}
254 !ELSEIF "\$(CFG)" == "libvlc - Win32 Debug"${M}
255 # PROP Output_Dir "Debug\\${subdir}"${M}
256 # PROP Intermediate_Dir "Debug\\${subdir}"${M}
257 !ENDIF${M}
258 # End Source File${M}
261 done
262 cat >> ${target} << EOF
263 # End Group${M}
265 done
266 # The headers
267 perl -e 'while(<>){if(/ZSOURCESZ/){last;}}while(<>){if(/ZHEADERSZ/){last;}print $_}' < ${target}.in >> ${target}
268 for file in ${LIBVLC_HEADERS}
270 cat >> ${target} << EOF
271 # Begin Source File${M}
272 SOURCE="..\\`echo ${file} | sed -e 's%/%\\\\%g'`"${M}
273 # End Source File${M}
275 done
276 cat >> ${target} << EOF
277 # Begin Group "vlc"${M}
279 for file in ${LIBVLC_PKG_HEADERS}
281 cat >> ${target} << EOF
282 # Begin Source File${M}
283 SOURCE="..\\`echo ${file} | sed -e 's%/%\\\\%g'`"${M}
284 # End Source File${M}
286 done
287 cat >> ${target} << EOF
288 # End Group${M}
290 perl -e 'while(<>){if(/ZHEADERSZ/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
291 done
293 # plugins files
294 for dir in `sed -ne 's,modules/\(.*\)/Makefile,\1,p' ${srcdir}/configure.ac`
296 mf="${srcdir}/modules/${dir}/Modules.am"
297 for mod in `sed -n -e 's/^ *SOURCES_\([^ ]*\).*/\1/p' < ${mf}`
299 # this is an attempt at getting a list of plugin sources... we take the
300 # production and remove everything that does not contain "module", which
301 # means you miss $(NULL), but other variables too.
302 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 '\.'`
303 hfiles=`for i in ${allfiles} ; do echo "$i" ; done | grep '\.h$'`
304 cfiles=`for i in ${allfiles} ; do echo "$i" ; done | grep -v '\.h$'`
305 for msdir in evc msvc
307 test "${msdir}" = "evc" && suf="vcp" || suf="dsp"
308 source="${msdir}/plugins.${suf}.in"
309 target="${msdir}/plugin_${mod}.${suf}"
310 printf "."
311 perl -pe 'if(/ZSOURCESZ/){last;} s/ZPLUGINZ/'${mod}'/g' < ${source} > ${target}
312 for cfile in ${cfiles}
314 cat >> ${target} << EOF
315 # Begin Source File${M}
316 SOURCE="..\\modules\\`echo ${dir}/${cfile} | sed 's,/,\\\\,g'`"${M}
317 # ADD CPP /D "__LIBVLC__" /D "__PLUGIN__" /D "MODULE_NAME=${mod}" /D "MODULE_NAME_IS_${mod}" ${M}
318 !IF "\$(CFG)" == "plugin_${mod} - Win32 Release"${M}
319 # PROP Output_Dir "Release\\modules\\`echo ${dir} | sed 's,/,\\\\,g'`"${M}
320 # PROP Intermediate_Dir "Release\\modules\\`echo ${dir} | sed 's,/,\\\\,g'`"${M}
321 !ELSEIF "\$(CFG)" == "plugin_${mod} - Win32 Debug"${M}
322 # PROP Output_Dir "Debug\\modules\\`echo ${dir} | sed 's,/,\\\\,g'`"${M}
323 # PROP Intermediate_Dir "Debug\\modules\\`echo ${dir} | sed 's,/,\\\\,g'`"${M}
324 # End Source File${M}
326 done
327 # sed is really nicer for this... unfortunately it's broken under cygwin
328 # sed -ne '1,/ZSOURCESZ/d; /ZHEADERSZ/,$d; p' < ${source} >> ${target}
329 perl -e 'while(<>){if(/ZSOURCESZ/){last;}}while(<>){if(/ZHEADERSZ/){last;}print $_}' < ${source} >> ${target}
330 for hfile in ${hfiles}
332 cat >> ${target} << EOF
333 # Begin Source File${M}
334 SOURCE="..\\modules\\`echo ${dir}/${hfile} | sed 's,/,\\\\,g'`"${M}
335 # End Source File${M}
337 done
338 # sed -ne '1,/ZHEADERSZ/d; p' < ${source} >> ${target}
339 perl -e 'while(<>){if(/ZHEADERSZ/){last;}}while(<>){print $_}' < ${source} >> ${target}
340 done
341 done
342 done
344 # vlc files
345 for target in evc/vlc.vcp msvc/vlc.dsp
347 printf "."
348 # Top of the project file
349 perl -pe 'if(/ZSOURCESZ/){last;}' < ${target}.in > ${target}
350 # The source files
351 cat >> ${target} << EOF
352 # Begin Source File${M}
353 SOURCE="..\\src\\vlc.c"${M}
354 # End Source File${M}
356 # Bottom of the project file - handles resource files too
357 perl -e 'while(<>){if(/ZSOURCESZ/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
358 done
360 echo " done."
361 exit 0
365 ## Update the MSVC (.NET) project files
367 if test "${action}" = "vc7"
368 then
369 echo "generating Visual .NET files"
371 srcdir=.
373 # The evil ^M. printf '\r' does not work in Cygwin.
377 # Variables we get from configure.ac
378 LIBVLC_VERSION=`sed -ne '/AC_INIT/s/.*,\(.*\))/\1/p' < configure.ac`
379 LIBVLC_CODENAME=`sed -ne '/CODENAME=/s/.*"\(.*\)"/\1/p' < configure.ac`
380 LIBVLC_SYMBOL=`echo $LIBVLC_VERSION | sed -e 'y/.-/__/'`
382 # Sources that get built under Win32 - FIXME: anyone wanna deuglify this? :)
383 LIBVLC_SOURCES=`getfiles SOURCES_libvlc_common; getfiles SOURCES_libvlc_win32; getfiles SOURCES_libvlc_dirent; getfiles SOURCES_libvlc_getopt; getfiles SOURCES_libvlc_libc`
385 LIBVLC_HEADERS=`getfiles HEADERS_include; getfiles HEADERS_include_built`
387 LIBVLC_PKG_HEADERS=`getfiles dist_pkginclude_HEADERS`
389 # Clean up
390 rm -f msvc/*.vcproj
392 # config files
393 for target in msvc/config.h
395 printf "."
396 rm -f ${target}
397 sed -e "s/@CODENAME@/${LIBVLC_CODENAME}/" \
398 -e "s/@VERSION@/${LIBVLC_VERSION}/" \
399 -e "s/@SYMBOL@/${LIBVLC_SYMBOL}/" < ${target}.in > ${target}
400 done
402 # vlc files
403 target="msvc/vlc.vcproj"
404 printf "."
405 # Top of the project file
406 guid=`perl -e 'sub r {return sprintf("%X", int rand(65536))} print r.r."-".r."-".r."-".r."-".r.r.r'`
407 perl -pe 'if(/ZSOURCESZ/){last;} s/ZGUIDZ/'${guid}'/g' < ${target}.in > ${target}
408 # The source files
409 cat >> ${target} << EOF
410 <File RelativePath="..\\src\\vlc.c"></File>${M}
412 # Bottom of the project file - handles resource files too
413 perl -e 'while(<>){if(/ZSOURCESZ/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
415 # libvlc files
416 target=msvc/libvlc.vcproj
417 printf "."
418 # Top of the project file
419 guid=`perl -e 'sub r {return sprintf("%X", int rand(65536))} print r.r."-".r."-".r."-".r."-".r.r.r'`
420 perl -pe 'if(/ZSOURCESZ/){last;} s/ZGUIDZ/'${guid}'/g' < ${target}.in > ${target}
421 # The source files
422 for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep -v "/.*/"`
424 cat >> ${target} << EOF
425 <File RelativePath="..\\`echo ${dir}/${file} | sed 's,/,\\\\,g'`"></File>${M}
427 done
428 for subdir in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/.*/" | cut -f2 -d/ | sort | uniq`
430 cat >> ${target} << EOF
431 <Filter Name="`echo ${subdir} | sed s,/,_,g`" Filter="c;cpp">${M}
433 for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/${subdir}/"`
435 cat >> ${target} << EOF
436 <File RelativePath="..\\`echo ${file} | sed 's,/,\\\\,g'`">${M}
438 if echo ${file} | grep -q '.c$'
439 then
440 cat >> ${target} << EOF
441 <FileConfiguration Name="Debug|Win32">${M}
442 <Tool Name="VCCLCompilerTool" ObjectFile="\$(IntDir)/\$(ProjectName)/`echo ${file} | sed -e s/\.c$/.obj/`"/>${M}
443 </FileConfiguration>${M}
446 cat >> ${target} << EOF
447 </File>${M}
449 done
450 cat >> ${target} << EOF
451 </Filter>${M}
453 done
454 # The headers
455 perl -e 'while(<>){if(/ZSOURCESZ/){last;}}while(<>){if(/ZHEADERSZ/){last;}print $_}' < ${target}.in >> ${target}
456 for file in ${LIBVLC_HEADERS}
458 cat >> ${target} << EOF
459 <File RelativePath="..\\`echo ${file} | sed 's,/,\\\\,g'`"></File>${M}
461 done
462 cat >> ${target} << EOF
463 <Filter Name="vlc" Filter="h;hpp">${M}
465 for file in ${LIBVLC_PKG_HEADERS}
467 cat >> ${target} << EOF
468 <File RelativePath="..\\`echo ${file} | sed 's,/,\\\\,g'`"></File>${M}
470 done
471 cat >> ${target} << EOF
472 </Filter>${M}
474 perl -e 'while(<>){if(/ZHEADERSZ/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
476 # plugins files
477 for dir in `sed -ne 's,modules/\(.*\)/Makefile,\1,p' ${srcdir}/configure.ac`
479 mf="${srcdir}/modules/${dir}/Modules.am"
480 for mod in `sed -n -e 's/^ *SOURCES_\([^ ]*\).*/\1/p' < ${mf}`
482 # this is an attempt at getting a list of plugin sources... we take the
483 # production and remove everything that does not contain "module", which
484 # means you miss $(NULL), but other variables too.
485 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 '\.'`
486 hfiles=`for i in ${allfiles} ; do echo "$i" ; done | grep '\.h$'`
487 cfiles=`for i in ${allfiles} ; do echo "$i" ; done | grep -v '\.h$'`
488 for msdir in msvc
490 source="${msdir}/plugins.vcproj.in"
491 target="${msdir}/plugin_${mod}.vcproj"
492 printf "."
493 guid=`perl -e 'sub r {return sprintf("%X", int rand(65536))} print r.r."-".r."-".r."-".r."-".r.r.r'`
494 perl -pe 'if(/ZSOURCESZ/){last;} s/ZPLUGINZ/'${mod}'/g' < ${source} | sed 's,ZGUIDZ,'${guid}',' > ${target}
495 for cfile in ${cfiles}
497 cat >> ${target} << EOF
498 <File RelativePath="..\\modules\\`echo ${dir}/${cfile} | sed 's,/,\\\\,g'`"></File>${M}
500 done
501 # sed is really nicer for this... unfortunately it's broken under cygwin
502 # sed -ne '1,/ZSOURCESZ/d; /ZHEADERSZ/,$d; p' < ${source} >> ${target}
503 perl -e 'while(<>){if(/ZSOURCESZ/){last;}}while(<>){if(/ZHEADERSZ/){last;}print $_}' < ${source} >> ${target}
504 for hfile in ${hfiles}
506 cat >> ${target} << EOF
507 <File RelativePath="..\\modules\\`echo ${dir}/${hfile} | sed 's,/,\\\\,g'`"></File>${M}
509 done
510 # sed -ne '1,/ZHEADERSZ/d; p' < ${source} >> ${target}
511 perl -e 'while(<>){if(/ZHEADERSZ/){last;}}while(<>){print $_}' < ${source} >> ${target}
512 done
513 done
514 done
516 echo " done."
517 exit 0
521 ## Update the potfiles because no one ever does it
523 if test "${action}" = "po"
524 then
525 # find out the source files
526 echo "WARNING: you should run \"make update-po\" instead!" >&2
527 make update-po
528 exit $?
532 ## Create include files
534 if test "${action}" = "includes"
535 then
536 #set -x
538 if test -z "${srcdir}"; then
539 srcdir="`sed -ne 's/^srcdir *= *//p' < Makefile`"
541 if test -z "${builddir}"; then
542 builddir="`sed -ne 's/^top_builddir *= *//p' < Makefile`"
544 BUILTINS=`sed -ne 's/.*builtins *= *" *\([^"]*\)".*/\1/p' ${builddir}/vlc-config`
546 file="${builddir}/src/modules/builtin.h"
548 rm -f "${file}.tmp"
549 mkdir -p -- "${builddir}/src/modules"
550 cat "${srcdir}/src/modules/builtin.h.in" > "${file}.tmp" || exit 1
551 if test -n "${BUILTINS}"
552 then
553 for i in `echo ${BUILTINS}`
555 echo "int vlc_entry__`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`( module_t* );" >> "${file}.tmp"
556 done
557 echo "" >> "${file}.tmp"
559 echo "#define ALLOCATE_ALL_BUILTINS() \\" >> ${file}.tmp
560 echo " do \\" >> "${file}.tmp"
561 echo " { \\" >> "${file}.tmp"
562 if test -n "${BUILTINS}"
563 then
564 for i in `echo ${BUILTINS}`
566 echo " ALLOCATE_BUILTIN(`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`); \\" >> "${file}.tmp"
567 done
569 echo " } while( 0 );" >> "${file}.tmp"
570 echo "" >> "${file}.tmp" || exit 1
571 if diff >/dev/null 2>&1 "${file}" "${file}.tmp"
572 then
573 rm -f "${file}.tmp"
574 else
575 echo "creating new ${file}"
576 mv -f "${file}.tmp" "${file}"
579 exit 0
583 ## Fix glade2-generated files
585 if test "${action}" = "glade2"
586 then
587 file="modules/gui/pda/pda.glade"
588 echo "generating code from $file"
589 glade-2 -w "$file" || exit 1
591 file="modules/gui/pda/pda_interface.c"
592 echo "fixing $file"
593 if grep "DO NOT EDIT THIS FILE" "$file" >/dev/null 2>&1
594 then
595 rm -f -- "$file.$$.bak"
596 cat > "$file.$$.bak" << EOF
597 /* This file was created automatically by glade2 and fixed by bootstrap */
599 #include <vlc/vlc.h>
601 sed -e 1,7d \
602 -e 's#_(\(".:..:.."\))#\1#' \
603 -e 's#_(\("[a-z0-9]*://[^"]*"\))#\1#' \
604 -e 's#_("---")#"---"#' \
605 -e 's#_("--")#"--"#' \
606 -e 's#_(\("/dev/[^"]*"\))#\1#' \
607 -e 's#_(\("./."\))#\1#' \
608 < "$file" >> "$file.$$.bak"
609 mv -f "$file.$$.bak" "$file"
612 exit 0
616 ## Make distclean
618 if test "${action}" = "distclean"
619 then
620 set -x
621 # a naive sanity check to make sure we are in a VLC tree
622 test -f vlc.mandriva.spec -a -f vlc.win32.nsi.in || exit 1
623 # let's rock!
624 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 '{}' ';'
625 (cd autotools && find . -maxdepth 1 -name '[a-z]*' -exec rm -f '{}' ';')
626 find msvc -type f -name '*.dsp' -exec rm -f '{}' ';'
627 find evc -type f -name '*.vcp' -exec rm -f '{}' ';'
628 find . -type d -name '.deps' -exec rm -Rf '{}' ';'
629 find . -type d -name '.libs' -exec rm -Rf '{}' ';'
630 # there's some more cruft all around
631 rm -f config.h config.log config.status
632 rm -f vlc vlc-config Makefile Modules.am
633 rm -Rf autom4te.cache
634 echo "\`toolbox --distclean\' is known to be broken."
635 echo "Don't complain if it does not work, or better yet, don't use it."
636 echo "You were warned."
637 # FIXME: a lot of Makefiles are still there
641 ## Add the extras/contrib dir to the distribution
643 if test "${action}" = "contrib"
644 then
645 set -x
646 if test ! -d "${distdir}/extras"
647 then
648 mkdir "${distdir}/extras"
650 if test ! -d "${distdir}/extras/contrib"
651 then
652 mkdir "${distdir}/extras/contrib"
654 cp "${srcdir}/extras/contrib/Makefile" "${distdir}/extras/contrib/Makefile"
655 cp "${srcdir}/extras/contrib/README" "${distdir}/extras/contrib/README"
656 cp "${srcdir}/extras/contrib/bootstrap" "${distdir}/extras/contrib/bootstrap"
657 cp "${srcdir}/extras/contrib/change_prefix.sh" "${distdir}/extras/contrib/change_prefix.sh"
658 if test ! -d "${distdir}/extras/contrib/src"
659 then
660 mkdir "${distdir}/extras/contrib/src"
662 cp "${srcdir}/extras/contrib/src/Makefile" "${distdir}/extras/contrib/src/Makefile"
663 cp "${srcdir}/extras/contrib/src/packages.mak" "${distdir}/extras/contrib/src/packages.mak"
664 if test ! -d "${distdir}/extras/contrib/src/Patches"
665 then
666 mkdir "${distdir}/extras/contrib/src/Patches"
668 cp ${srcdir}/extras/contrib/src/Patches/* "${distdir}/extras/contrib/src/Patches/"