]> git.sesse.net Git - vlc/blob - toolbox
* now search all srvtypes and add all srvs of all srvtypes to the
[vlc] / toolbox
1 #! /bin/sh
2
3 ##  toolbox for vlc, the VideoLAN Client
4 ##  $Id: toolbox,v 1.5 2003/01/16 12:49:28 sam Exp $
5 ##
6 ##  Authors: Samuel Hocevar <sam@zoy.org>
7
8 ###
9 ###  Get a sane environment, just in case
10 ###
11 LANG=C
12 export LANG
13 CYGWIN=binmode
14 export CYGWIN
15
16 ##
17 ##  Give help
18 ##
19 help()
20 {
21   cat << EOF
22 recognized flags are:
23   --update-vc     update Microsoft Visual Studio files
24   --update-po     update translation files
25 EOF
26   exit 1
27 }
28
29 ###
30 ###  argument check
31 ###
32 do_help=yes
33 do_po=no
34 do_vc=no
35 while test $# -gt 0; do
36   case "$1" in
37     --update-vc)
38       do_help=no
39       do_vc=yes
40       ;;
41     --update-po)
42       do_help=no
43       do_po=yes
44       ;;
45     *)
46       echo "$0: unknown option $1"
47       do_help=yes
48       help
49       ;;
50   esac
51   shift
52 done
53
54 ##
55 ##  Give help if needed
56 ##
57 if test "$do_help" = "yes"
58 then
59   help
60 fi
61
62 ##
63 ##  Update the MSVC project files
64 ##
65 if test "$do_vc" = "yes"
66 then
67   if test ! -f Makefile
68   then
69     echo "no Makefile found, did you run ./configure?"
70     exit 1
71   fi
72
73   echo "generating Visual Studio files..."
74
75   #  The evil ^M
76   M='\r'
77
78   #  Variables we get from configure.ac.in
79   LIBVLC_VERSION=`sed -ne '/AC_INIT/s/.*,\(.*\))/\1/p' < configure.ac.in`
80   LIBVLC_CODENAME=`sed -ne '/CODENAME=/s/.*"\(.*\)"/\1/p' < configure.ac.in`
81   LIBVLC_SYMBOL=`echo $LIBVLC_VERSION | sed -e 'y/.-/__/'`
82
83   #  Sources that get built under Win32 - FIXME: anyone wanna deuglify this? :)
84   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'`
85
86   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'`
87
88   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'`
89
90   # Clean up
91   rm -f evc/*.vcp msvc/*.dsp
92
93   # config files
94   for target in evc/config.h msvc/config.h
95   do
96     echo "${target}"
97     rm -f ${target}
98     sed -e "s/@CODENAME@/${LIBVLC_CODENAME}/" \
99         -e "s/@VERSION@/${LIBVLC_VERSION}/" \
100         -e "s/@SYMBOL@/${LIBVLC_SYMBOL}/" < ${target}.in > ${target}
101   done
102
103   # libvlc files
104   for target in evc/libvlc.vcp msvc/libvlc.dsp
105   do
106     echo "${target}"
107     #  Top of the project file
108     perl -pe 'if(/§SOURCES§/){last;}' < ${target}.in > ${target}
109     #  The source files
110     for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep -v "/.*/"`
111     do
112       cat >> ${target} << EOF
113 # Begin Source File${M}
114 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
115 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\"plugins\\" /D DATA_PATH=\\"share\\"${M}
116 # End Source File${M}
117 EOF
118     done
119     for subdir in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/.*/" | cut -f2 -d/ | sort | uniq`
120     do
121       cat >> ${target} << EOF
122 # Begin Group "${subdir}"${M}
123 EOF
124       for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/${subdir}/"`
125       do
126       if test "${target}" = "evc/libvlc.vcp"
127       then
128         cat >> ${target} << EOF
129 # Begin Source File${M}
130 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
131 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\"plugins\\" /D DATA_PATH=\\"share\\"${M}
132 !IF "\$(CFG)" == "libvlc - Win32 (WCE MIPS) Release"${M}
133 # PROP Output_Dir "MIPSRel\\${subdir}"${M}
134 # PROP Intermediate_Dir "MIPSRel\\${subdir}"${M}
135 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE MIPS) Debug"${M}
136 # PROP Output_Dir "MIPSDbg\\${subdir}"${M}
137 # PROP Intermediate_Dir "MIPSDbg\\${subdir}"${M}
138 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH4) Release"${M}
139 # PROP Output_Dir "SH4Rel\\${subdir}"${M}
140 # PROP Intermediate_Dir "SH4Rel\\${subdir}"${M}
141 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH4) Debug"${M}
142 # PROP Output_Dir "SH4Dbg\\${subdir}"${M}
143 # PROP Intermediate_Dir "SH4Dbg\\${subdir}"${M}
144 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH3) Release"${M}
145 # PROP Output_Dir "SH3Rel\\${subdir}"${M}
146 # PROP Intermediate_Dir "SH3Rel\\${subdir}"${M}
147 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE SH3) Debug"${M}
148 # PROP Output_Dir "SH3Dbg\\${subdir}"${M}
149 # PROP Intermediate_Dir "SH3Dbg\\${subdir}"${M}
150 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARM) Release"${M}
151 # PROP Output_Dir "ARMRel\\${subdir}"${M}
152 # PROP Intermediate_Dir "ARMRel\\${subdir}"${M}
153 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE ARM) Debug"${M}
154 # PROP Output_Dir "ARMDbg\\${subdir}"${M}
155 # PROP Intermediate_Dir "ARMDbg\\${subdir}"${M}
156 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE x86em) Release"${M}
157 # PROP Output_Dir "X86EMRel\\${subdir}"${M}
158 # PROP Intermediate_Dir "X86EMRel\\${subdir}"${M}
159 !ELSEIF "\$(CFG)" == "libvlc - Win32 (WCE x86em) Debug"${M}
160 # PROP Output_Dir "X86EMDbg\\${subdir}"${M}
161 # PROP Intermediate_Dir "X86EMDbg\\${subdir}"${M}
162 !ENDIF${M}
163 # End Source File${M}
164 EOF
165         else
166           cat >> ${target} << EOF
167 # Begin Source File${M}
168 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
169 # ADD CPP /D "__VLC__" /D PLUGIN_PATH=\\"plugins\\" /D DATA_PATH=\\"share\\"${M}
170 !IF "\$(CFG)" == "libvlc - Win32 Release"${M}
171 # PROP Output_Dir "Release\\${subdir}"${M}
172 # PROP Intermediate_Dir "Release\\${subdir}"${M}
173 !ELSEIF "\$(CFG)" == "libvlc - Win32 Debug"${M}
174 # PROP Output_Dir "Debug\\${subdir}"${M}
175 # PROP Intermediate_Dir "Debug\\${subdir}"${M}
176 !ENDIF${M}
177 # End Source File${M}
178 EOF
179         fi
180       done
181       cat >> ${target} << EOF
182 # End Group${M}
183 EOF
184     done
185     #  The headers
186     perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){if(/§HEADERS§/){last;}print $_}' < ${target}.in >> ${target}
187     for file in ${LIBVLC_HEADERS}
188     do
189       cat >> ${target} << EOF
190 # Begin Source File${M}
191 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
192 # End Source File${M}
193 EOF
194     done
195     cat >> ${target} << EOF
196 # Begin Group "vlc"${M}
197 EOF
198     for file in ${LIBVLC_PKG_HEADERS}
199     do
200       cat >> ${target} << EOF
201 # Begin Source File${M}
202 SOURCE="..\\`echo $file | sed -e 's%/%\\\\%g'`"${M}
203 # End Source File${M}
204 EOF
205     done
206     cat >> ${target} << EOF
207 # End Group${M}
208 EOF
209     perl -e 'while(<>){if(/§HEADERS§/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
210   done
211
212   # plugins files
213   grep '^L_[^ ]*_pic =' Modules.am | while read a b c
214   do
215     makefile="`echo $c | sed -e 's@/[^/]*$@/Modules.am@'`"
216     plugin="`echo $a | sed 's/L_\(.*\)_pic/\1/'`"
217     # this is an attempt at getting a list of plugin sources... we take the
218     # production and remove everything that does not contain "module", which
219     # means you miss $(NULL), but other variables too.
220     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'`
221     hfiles=`for i in ${cfiles} ; do echo $i ; done | grep '\.h$'`
222     cfiles=`for i in ${cfiles} ; do echo $i ; done | grep -v '\.h$'`
223     for dir in evc msvc
224     do
225       test "${dir}" = "evc" && suf="vcp" || suf="dsp"
226       source="${dir}/plugins.${suf}.in"
227       target="${dir}/plugin_${plugin}.${suf}"
228       echo "${target}"
229       perl -pe 'if(/§SOURCES§/){last;} s/§PLUGIN§/'${plugin}'/g' < ${source} > ${target}
230       for cfile in ${cfiles}
231       do
232         cat >> ${target} << EOF
233 # Begin Source File${M}
234 SOURCE="..\\${cfile}"${M}
235 # End Source File${M}
236 EOF
237       done
238       # sed is really nicer for this... unfortunately it's broken under cygwin
239       # sed -ne '1,/§SOURCES§/d; /§HEADERS§/,$d; p' < ${source} >> ${target}
240       perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){if(/§HEADERS§/){last;}print $_}' < ${source} >> ${target}
241       for hfile in ${hfiles}
242       do
243         cat >> ${target} << EOF
244 # Begin Source File${M}
245 SOURCE="..\\${hfile}"${M}
246 # End Source File${M}
247 EOF
248       done
249       # sed -ne '1,/§HEADERS§/d; p' < ${source} >> ${target}
250       perl -e 'while(<>){if(/§HEADERS§/){last;}}while(<>){print $_}' < ${source} >> ${target}
251     done
252   done
253
254   # vlc files
255   for target in evc/vlc.vcp msvc/vlc.dsp
256   do
257     echo "${target}"
258     #  Top of the project file
259     perl -pe 'if(/§SOURCES§/){last;}' < ${target}.in > ${target}
260     #  The source files
261     if test "${target}" = "evc/vlc.vcp"
262     then
263       cat >> ${target} << EOF
264 # Begin Source File${M}
265 SOURCE="..\\evc\\vlc.c"${M}
266 # End Source File${M}
267 EOF
268     else
269       cat >> ${target} << EOF
270 # Begin Source File${M}
271 SOURCE="..\\src\\vlc.c"${M}
272 # End Source File${M}
273 EOF
274     fi
275     #  Bottom of the project file - handles resource files too
276     perl -e 'while(<>){if(/§SOURCES§/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
277   done
278
279   echo "done."
280   exit 0
281 fi
282
283 ##
284 ##  Update the potfiles because no one ever does it
285 ##
286 if test "$do_po" = "yes"
287 then
288   # create a fake file containing win32 strings
289   rm -f modules/gui/win32/strings.cpp
290   printf "/* Automatically generated by 'toolbox --update-po', please don't compile */\n" > modules/gui/win32/strings.cpp
291   find modules/gui/win32 -name '*.dfm' | while read file
292   do
293     printf "\n/*\n * from $file:\n */\n\n" >> modules/gui/win32/strings.cpp
294     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 '"-*"' >> modules/gui/win32/strings.cpp || exit 1
295   done
296   # clean old potfiles
297   cd po
298   rm -f vlc.pot
299   # update
300   make vlc.pot || exit 1
301   make update-po || exit 1
302   cd ..
303
304   exit 0
305 fi
306