3 ## toolbox for the VLC media player
4 ## $Id: toolbox,v 1.9 2003/02/02 04:01:29 sam Exp $
6 ## Authors: Samuel Hocevar <sam@zoy.org>
9 ### Get a sane environment, just in case
23 --update-vc update Microsoft Visual Studio files
24 --update-po update translation files
25 --update-glade generate and fix Glade code
37 while test $# -gt 0; do
47 --update-glade|--fix-glade)
52 echo "$0: unknown option $1"
61 ## Give help if needed
63 if test "$do_help" = "yes"
69 ## Update the MSVC project files
71 if test "$do_vc" = "yes"
75 echo "no Makefile found, did you run ./configure?"
79 echo "generating Visual Studio files..."
84 # Variables we get from configure.ac.in
85 LIBVLC_VERSION=`sed -ne '/AC_INIT/s/.*,\(.*\))/\1/p' < configure.ac.in`
86 LIBVLC_CODENAME=`sed -ne '/CODENAME=/s/.*"\(.*\)"/\1/p' < configure.ac.in`
87 LIBVLC_SYMBOL=`echo $LIBVLC_VERSION | sed -e 'y/.-/__/'`
89 # Sources that get built under Win32 - FIXME: anyone wanna deuglify this? :)
90 LIBVLC_SOURCES=`awk 'BEGIN{a=0}{if(!a&&/^'SOURCES_libvlc_common'[^-_a-zA-Z0-9]*=/){a=1;print$0;next;}if(a){if(/^[a-zA-Z]/){exit;}print $0}}' < Makefile.am | tr '\\ ' '\n\n' | sed -ne 's/[^$-_a-zA-Z0-9][^$-_a-zA-Z0-9]*\([a-zA-Z]\)/\1/p'; awk 'BEGIN{a=0}{if(!a&&/^'SOURCES_libvlc_win32'[^-_a-zA-Z0-9]*=/){a=1;print$0;next;}if(a){if(/^[a-zA-Z]/){exit;}print $0}}' < Makefile.am | tr '\\ ' '\n\n' | sed -ne 's/[^$-_a-zA-Z0-9][^$-_a-zA-Z0-9]*\([a-zA-Z]\)/\1/p'; awk 'BEGIN{a=0}{if(!a&&/^'SOURCES_libvlc_dirent'[^-_a-zA-Z0-9]*=/){a=1;print$0;next;}if(a){if(/^[a-zA-Z]/){exit;}print $0}}' < Makefile.am | tr '\\ ' '\n\n' | sed -ne 's/[^$-_a-zA-Z0-9][^$-_a-zA-Z0-9]*\([a-zA-Z]\)/\1/p'; awk 'BEGIN{a=0}{if(!a&&/^'SOURCES_libvlc_getopt'[^-_a-zA-Z0-9]*=/){a=1;print$0;next;}if(a){if(/^[a-zA-Z]/){exit;}print $0}}' < Makefile.am | tr '\\ ' '\n\n' | sed -ne 's/[^$-_a-zA-Z0-9][^$-_a-zA-Z0-9]*\([a-zA-Z]\)/\1/p'; awk 'BEGIN{a=0}{if(!a&&/^'SOURCES_libvlc_libc'[^-_a-zA-Z0-9]*=/){a=1;print$0;next;}if(a){if(/^[a-zA-Z]/){exit;}print $0}}' < Makefile.am | tr '\\ ' '\n\n' | sed -ne 's/[^$-_a-zA-Z0-9][^$-_a-zA-Z0-9]*\([a-zA-Z]\)/\1/p'`
92 LIBVLC_HEADERS=`awk 'BEGIN{a=0}{if(!a&&/^'HEADERS_include'[^-_a-zA-Z0-9]*=/){a=1;print$0;next;}if(a){if(/^[a-zA-Z]/){exit;}print $0}}' < Makefile.am | tr '\\ ' '\n\n' | sed -ne 's/[^$-_a-zA-Z0-9][^$-_a-zA-Z0-9]*\([a-zA-Z]\)/\1/p'; awk 'BEGIN{a=0}{if(!a&&/^'HEADERS_include_built'[^-_a-zA-Z0-9]*=/){a=1;print$0;next;}if(a){if(/^[a-zA-Z]/){exit;}print $0}}' < Makefile.am | tr '\\ ' '\n\n' | sed -ne 's/[^$-_a-zA-Z0-9][^$-_a-zA-Z0-9]*\([a-zA-Z]\)/\1/p'`
94 LIBVLC_PKG_HEADERS=`awk 'BEGIN{a=0}{if(!a&&/^'dist_pkginclude_HEADERS'[^-_a-zA-Z0-9]*=/){a=1;print$0;next;}if(a){if(/^[a-zA-Z]/){exit;}print $0}}' < Makefile.am | tr '\\ ' '\n\n' | sed -ne 's/[^$-_a-zA-Z0-9][^$-_a-zA-Z0-9]*\([a-zA-Z]\)/\1/p'`
97 rm -f evc/*.vcp msvc/*.dsp
100 for target in evc/config.h msvc/config.h
104 sed -e "s/@CODENAME@/${LIBVLC_CODENAME}/" \
105 -e "s/@VERSION@/${LIBVLC_VERSION}/" \
106 -e "s/@SYMBOL@/${LIBVLC_SYMBOL}/" < ${target}.in > ${target}
110 for target in evc/libvlc.vcp msvc/libvlc.dsp
113 # Top of the project file
114 perl -pe 'if(/§SOURCES§/){last;}' < ${target}.in > ${target}
116 for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep -v "/.*/"`
118 cat >> ${target} << EOF
119 # Begin Source File${M}
120 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
121 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\"plugins\\" /D DATA_PATH=\\"share\\"${M}
122 # End Source File${M}
125 for subdir in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/.*/" | cut -f2 -d/ | sort | uniq`
127 cat >> ${target} << EOF
128 # Begin Group "${subdir}"${M}
130 for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/${subdir}/"`
132 if test "${target}" = "evc/libvlc.vcp"
134 cat >> ${target} << EOF
135 # Begin Source File${M}
136 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
137 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\"plugins\\" /D DATA_PATH=\\"share\\"${M}
138 !IF "\$(CFG)" == "libvlc - Win32 (WCE MIPS) Release"${M}
139 # PROP Output_Dir "MIPSRel\\${subdir}"${M}
140 # PROP Intermediate_Dir "MIPSRel\\${subdir}"${M}
141 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE MIPS) Debug"${M}
142 # PROP Output_Dir "MIPSDbg\\${subdir}"${M}
143 # PROP Intermediate_Dir "MIPSDbg\\${subdir}"${M}
144 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH4) Release"${M}
145 # PROP Output_Dir "SH4Rel\\${subdir}"${M}
146 # PROP Intermediate_Dir "SH4Rel\\${subdir}"${M}
147 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH4) Debug"${M}
148 # PROP Output_Dir "SH4Dbg\\${subdir}"${M}
149 # PROP Intermediate_Dir "SH4Dbg\\${subdir}"${M}
150 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH3) Release"${M}
151 # PROP Output_Dir "SH3Rel\\${subdir}"${M}
152 # PROP Intermediate_Dir "SH3Rel\\${subdir}"${M}
153 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH3) Debug"${M}
154 # PROP Output_Dir "SH3Dbg\\${subdir}"${M}
155 # PROP Intermediate_Dir "SH3Dbg\\${subdir}"${M}
156 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARM) Release"${M}
157 # PROP Output_Dir "ARMRel\\${subdir}"${M}
158 # PROP Intermediate_Dir "ARMRel\\${subdir}"${M}
159 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARM) Debug"${M}
160 # PROP Output_Dir "ARMDbg\\${subdir}"${M}
161 # PROP Intermediate_Dir "ARMDbg\\${subdir}"${M}
162 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE x86em) Release"${M}
163 # PROP Output_Dir "X86EMRel\\${subdir}"${M}
164 # PROP Intermediate_Dir "X86EMRel\\${subdir}"${M}
165 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE x86em) Debug"${M}
166 # PROP Output_Dir "X86EMDbg\\${subdir}"${M}
167 # PROP Intermediate_Dir "X86EMDbg\\${subdir}"${M}
169 # End Source File${M}
172 cat >> ${target} << EOF
173 # Begin Source File${M}
174 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
175 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\"plugins\\" /D DATA_PATH=\\"share\\"${M}
176 !IF "\$(CFG)" == "libvlc - Win32 Release"${M}
177 # PROP Output_Dir "Release\\${subdir}"${M}
178 # PROP Intermediate_Dir "Release\\${subdir}"${M}
179 !ELSEIF "\$(CFG)" == "libvlc - Win32 Debug"${M}
180 # PROP Output_Dir "Debug\\${subdir}"${M}
181 # PROP Intermediate_Dir "Debug\\${subdir}"${M}
183 # End Source File${M}
187 cat >> ${target} << EOF
192 perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){if(/§HEADERS§/){last;}print $_}' < ${target}.in >> ${target}
193 for file in ${LIBVLC_HEADERS}
195 cat >> ${target} << EOF
196 # Begin Source File${M}
197 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
198 # End Source File${M}
201 cat >> ${target} << EOF
202 # Begin Group "vlc"${M}
204 for file in ${LIBVLC_PKG_HEADERS}
206 cat >> ${target} << EOF
207 # Begin Source File${M}
208 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
209 # End Source File${M}
212 cat >> ${target} << EOF
215 perl -e 'while(<>){if(/§HEADERS§/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
219 grep '^L_[^ ]*_pic =' Modules.am | while read a b c
221 makefile="`echo $c | sed -e 's@/[^/]*$@/Modules.am@'`"
222 plugin="`echo $a | sed 's/L_\(.*\)_pic/\1/'`"
223 # this is an attempt at getting a list of plugin sources... we take the
224 # production and remove everything that does not contain "module", which
225 # means you miss $(NULL), but other variables too.
226 cfiles=`grep -v '[^-_a-zA-Z0-9]*#' ${makefile} | awk 'BEGIN{a=0}{if(!a&&/^SOURCES_'${plugin}'[^-_a-zA-Z0-9]*=/){a=1;print$0;next;}if(a){if(/^[a-zA-Z]/){exit;}print $0}}' | tr '\\ ' '\n\n' | sed -ne 's,/,\\\\,g; s/.*modules/modules/p'`
227 hfiles=`for i in ${cfiles} ; do echo $i ; done | grep '\.h$'`
228 cfiles=`for i in ${cfiles} ; do echo $i ; done | grep -v '\.h$'`
231 test "${dir}" = "evc" && suf="vcp" || suf="dsp"
232 source="${dir}/plugins.${suf}.in"
233 target="${dir}/plugin_${plugin}.${suf}"
235 perl -pe 'if(/§SOURCES§/){last;} s/§PLUGIN§/'${plugin}'/g' < ${source} > ${target}
236 for cfile in ${cfiles}
238 cat >> ${target} << EOF
239 # Begin Source File${M}
240 SOURCE="..\\${cfile}"${M}
241 # End Source File${M}
244 # sed is really nicer for this... unfortunately it's broken under cygwin
245 # sed -ne '1,/§SOURCES§/d; /§HEADERS§/,$d; p' < ${source} >> ${target}
246 perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){if(/§HEADERS§/){last;}print $_}' < ${source} >> ${target}
247 for hfile in ${hfiles}
249 cat >> ${target} << EOF
250 # Begin Source File${M}
251 SOURCE="..\\${hfile}"${M}
252 # End Source File${M}
255 # sed -ne '1,/§HEADERS§/d; p' < ${source} >> ${target}
256 perl -e 'while(<>){if(/§HEADERS§/){last;}}while(<>){print $_}' < ${source} >> ${target}
261 for target in evc/vlc.vcp msvc/vlc.dsp
264 # Top of the project file
265 perl -pe 'if(/§SOURCES§/){last;}' < ${target}.in > ${target}
267 if test "${target}" = "evc/vlc.vcp"
269 cat >> ${target} << EOF
270 # Begin Source File${M}
271 SOURCE="..\\evc\\vlc.c"${M}
272 # End Source File${M}
275 cat >> ${target} << EOF
276 # Begin Source File${M}
277 SOURCE="..\\src\\vlc.c"${M}
278 # End Source File${M}
281 # Bottom of the project file - handles resource files too
282 perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
290 ## Update the potfiles because no one ever does it
292 if test "$do_po" = "yes"
294 # create a fake file containing win32 strings
295 rm -f modules/gui/win32/strings.cpp
296 printf "/* Automatically generated by 'toolbox --update-po', please don't compile */\n" > modules/gui/win32/strings.cpp
297 find modules/gui/win32 -name '*.dfm' | while read file
299 printf "\n/*\n * from $file:\n */\n\n" >> modules/gui/win32/strings.cpp
300 perl -ne 'chop; chop; if( / (Caption|Text|Hint) / || $buffer =~ /[+=] *$/ ) { $buffer =~ s/\+ *$//; $buffer .= $_; } if( $buffer =~ /'"'"' *$/) { $buffer =~ s/'"'"'/"/g; $buffer =~ s/\\/\\\\/g; $buffer =~ s/=/= _(/; print $buffer." );\n"; $buffer = "";}' < $file | grep -v '"-*"' | grep -v '"http://' | grep -v '"vlcs"' >> modules/gui/win32/strings.cpp || exit 1
306 make vlc.pot || exit 1
307 make update-po || exit 1
314 ## Fix glade-generated files
316 if test "$do_glade" = "yes"
318 for file in modules/gui/gtk/gnome.glade modules/gui/gtk/gtk.glade modules/gui/familiar/familiar.glade
320 echo "generating code from $file"
321 glade -w $file || exit 1
324 for file in modules/gui/gtk/gnome_interface.c modules/gui/gtk/gtk_interface.c modules/gui/familiar/interface.c
327 if grep "DO NOT EDIT THIS FILE" $file 2>&1 > /dev/null
330 cat > $file.$$.bak << EOF
331 /* This file was created automatically by glade and fixed by bootstrap */
336 -e 's#_(\(".:..:.."\))#\1#' \
337 -e 's#_(\("[a-z0-9]*://[^"]*"\))#\1#' \
338 -e 's#_("---")#"---"#' \
339 -e 's#_("--")#"--"#' \
340 -e 's#_("/dev/dvd")#"/dev/dvd"#' \
341 -e 's#_(\("./."\))#\1#' \
342 < $file >> $file.$$.bak
343 mv -f $file.$$.bak $file
347 for file in modules/gui/gtk/gtk_support.h modules/gui/familiar/support.h
350 if grep "DO NOT EDIT THIS FILE" $file 2>&1 > /dev/null
353 sed -e 's/DO NOT EDIT.*/Created by glade, fixed by bootstrap/' \
354 -e 's,<config.h>,<vlc/vlc.h>,' \
355 -e 's,#if.*ENABLE_NLS.*,#if 0 /* Disabled by bootstrap */,' \
356 -e 's,#else,/* & */,' \
357 < $file > $file.$$.bak
358 mv -f $file.$$.bak $file