+ # vlc files
+ target="msvc/vlc.vcproj"
+ printf "."
+ # Top of the project file
+ guid=`perl -e 'sub r {return sprintf("%X", int rand(65536))} print r.r."-".r."-".r."-".r."-".r.r.r'`
+ perl -pe 'if(/ZSOURCESZ/){last;} s/ZGUIDZ/'${guid}'/g' < ${target}.in > ${target}
+ # The source files
+ cat >> ${target} << EOF
+<File RelativePath="..\\src\\vlc.c"></File>${M}
+EOF
+ # Bottom of the project file - handles resource files too
+ perl -e 'while(<>){if(/ZSOURCESZ/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
+
+ # libvlc files
+ target=msvc/libvlc.vcproj
+ printf "."
+ # Top of the project file
+ guid=`perl -e 'sub r {return sprintf("%X", int rand(65536))} print r.r."-".r."-".r."-".r."-".r.r.r'`
+ perl -pe 'if(/ZSOURCESZ/){last;} s/ZGUIDZ/'${guid}'/g' < ${target}.in > ${target}
+ # The source files
+ for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep -v "/.*/"`
+ do
+ cat >> ${target} << EOF
+<File RelativePath="..\\`echo ${dir}/${file} | sed 's,/,\\\\,g'`"></File>${M}
+EOF
+ done
+ for subdir in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/.*/" | cut -f2 -d/ | sort | uniq`
+ do
+ cat >> ${target} << EOF
+<Filter Name="`echo ${subdir} | sed s,/,_,g`" Filter="c;cpp">${M}
+EOF
+ for file in `for i in ${LIBVLC_SOURCES} ; do echo $i ; done | grep "/${subdir}/"`
+ do
+ cat >> ${target} << EOF
+<File RelativePath="..\\`echo ${file} | sed 's,/,\\\\,g'`">${M}
+EOF
+ if echo ${file} | grep -q '.c$'
+ then
+ cat >> ${target} << EOF
+ <FileConfiguration Name="Debug|Win32">${M}
+ <Tool Name="VCCLCompilerTool" ObjectFile="\$(IntDir)/\$(ProjectName)/`echo ${file} | sed -e s/\.c$/.obj/`"/>${M}
+ </FileConfiguration>${M}
+EOF
+ fi
+ cat >> ${target} << EOF
+</File>${M}
+EOF
+ done
+ cat >> ${target} << EOF
+</Filter>${M}
+EOF
+ done
+ # The headers
+ perl -e 'while(<>){if(/ZSOURCESZ/){last;}}while(<>){if(/ZHEADERSZ/){last;}print $_}' < ${target}.in >> ${target}
+ for file in ${LIBVLC_HEADERS}
+ do
+ cat >> ${target} << EOF
+<File RelativePath="..\\`echo ${file} | sed 's,/,\\\\,g'`"></File>${M}
+EOF
+ done
+ cat >> ${target} << EOF
+<Filter Name="vlc" Filter="h;hpp">${M}
+EOF
+ for file in ${LIBVLC_PKG_HEADERS}
+ do
+ cat >> ${target} << EOF
+<File RelativePath="..\\`echo ${file} | sed 's,/,\\\\,g'`"></File>${M}
+EOF
+ done
+ cat >> ${target} << EOF
+</Filter>${M}
+EOF
+ perl -e 'while(<>){if(/ZHEADERSZ/){last;}}while(<>){print $_}' < ${target}.in >> ${target}
+
+ # plugins files
+ for dir in `sed -ne 's,modules/\(.*\)/Makefile,\1,p' ${srcdir}/configure.ac`
+ do
+ mf="${srcdir}/modules/${dir}/Modules.am"
+ for mod in `sed -n -e 's/^ *SOURCES_\([^ ]*\).*/\1/p' < ${mf}`
+ do
+ # this is an attempt at getting a list of plugin sources... we take the
+ # production and remove everything that does not contain "module", which
+ # means you miss $(NULL), but other variables too.
+ 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 '\.'`
+ hfiles=`for i in ${allfiles} ; do echo "$i" ; done | grep '\.h$'`
+ cfiles=`for i in ${allfiles} ; do echo "$i" ; done | grep -v '\.h$'`
+ for msdir in msvc
+ do
+ source="${msdir}/plugins.vcproj.in"
+ target="${msdir}/plugin_${mod}.vcproj"
+ printf "."
+ guid=`perl -e 'sub r {return sprintf("%X", int rand(65536))} print r.r."-".r."-".r."-".r."-".r.r.r'`
+ perl -pe 'if(/ZSOURCESZ/){last;} s/ZPLUGINZ/'${mod}'/g' < ${source} | sed 's,ZGUIDZ,'${guid}',' > ${target}
+ for cfile in ${cfiles}
+ do
+ cat >> ${target} << EOF
+<File RelativePath="..\\modules\\`echo ${dir}/${cfile} | sed 's,/,\\\\,g'`"></File>${M}
+EOF
+ done
+ # sed is really nicer for this... unfortunately it's broken under cygwin
+ # sed -ne '1,/ZSOURCESZ/d; /ZHEADERSZ/,$d; p' < ${source} >> ${target}
+ perl -e 'while(<>){if(/ZSOURCESZ/){last;}}while(<>){if(/ZHEADERSZ/){last;}print $_}' < ${source} >> ${target}
+ for hfile in ${hfiles}
+ do
+ cat >> ${target} << EOF
+<File RelativePath="..\\modules\\`echo ${dir}/${hfile} | sed 's,/,\\\\,g'`"></File>${M}
+EOF
+ done
+ # sed -ne '1,/ZHEADERSZ/d; p' < ${source} >> ${target}
+ perl -e 'while(<>){if(/ZHEADERSZ/){last;}}while(<>){print $_}' < ${source} >> ${target}
+ done
+ done
+ done
+
+ echo " done."