+ 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."
+ exit 0
+fi
+
+##
+## Update the potfiles because no one ever does it
+##
+if test "${action}" = "po"
+then
+ # find out the source files
+ echo "WARNING: you should run \"make update-po\" instead!" >&2
+ make update-po
+ exit $?
+fi
+
+##
+## Create include files
+##
+if test "${action}" = "includes"
+then
+ #set -x
+
+ if test -z "${srcdir}"; then
+ srcdir="`sed -ne 's/^srcdir *= *//p' < Makefile`"
+ fi
+ if test -z "${builddir}"; then
+ builddir="`sed -ne 's/^top_builddir *= *//p' < Makefile`"
+ fi
+ BUILTINS=`sed -ne 's/.*builtins *= *" *\([^"]*\)".*/\1/p' ${builddir}/vlc-config`
+
+ file="${builddir}/src/misc/modules_builtin.h"
+
+ rm -f "${file}.tmp"
+ mkdir -p -- "${builddir}/src/misc"
+ cat "${srcdir}/src/misc/modules_builtin.h.in" > "${file}.tmp" || exit 1
+ if test -n "${BUILTINS}"
+ then
+ for i in `echo ${BUILTINS}`
+ do
+ echo "int vlc_entry__`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`( module_t* );" >> "${file}.tmp"
+ done
+ echo "" >> "${file}.tmp"
+ fi
+ echo "#define ALLOCATE_ALL_BUILTINS() \\" >> ${file}.tmp
+ echo " do \\" >> "${file}.tmp"
+ echo " { \\" >> "${file}.tmp"
+ if test -n "${BUILTINS}"
+ then
+ for i in `echo ${BUILTINS}`
+ do
+ echo " ALLOCATE_BUILTIN(`echo $i | sed -e 'y@/@_@' -e 's@\..*@@'`); \\" >> "${file}.tmp"
+ done
+ fi
+ echo " } while( 0 );" >> "${file}.tmp"
+ echo "" >> "${file}.tmp" || exit 1
+ if diff >/dev/null 2>&1 "${file}" "${file}.tmp"
+ then
+ rm -f "${file}.tmp"
+ else
+ echo "creating new ${file}"
+ mv -f "${file}.tmp" "${file}"
+ fi
+
+ exit 0
+fi
+
+##
+## Create version file
+##
+if test "${action}" = "version"
+then
+ if test -z "${srcdir}"; then
+ srcdir="`sed -ne 's/^srcdir *= *//p' < Makefile`"
+ fi
+ if test -z "${builddir}"; then
+ builddir="`sed -ne 's/^top_builddir *= *//p' < Makefile`"
+ fi
+ if test -z "${CC}"; then
+ CC="`sed -ne 's/^CC *= *//p' < Makefile`"
+ fi
+
+ file="${builddir}/src/misc/version.c"
+ if which svnversion 2>&1 >/dev/null; then
+ VLC_CHANGESET=`svnversion $srcdir`
+ else
+ VLC_CHANGESET='exported'
+ fi
+
+ rm -f ${file}.tmp
+ mkdir -p -- "${builddir}/src/misc"
+ cat > ${file}.tmp << EOF
+/* DO NOT EDIT THIS FILE - IT IS REGENERATED AT EVERY COMPILE -
+ * IT GIVES BETTER TRACKING OF VLC STABLE AND DEVELOPMENT VERSIONS
+ * WHETHER THEY ARE BUILT BY OTHERS OR DURING DEVELOPMENT OR FOR THE
+ * OFFICIAL VLC STABLE RELEASES.
+ */
+const char psz_vlc_changeset[] = "${VLC_CHANGESET}";
+
+EOF
+ if diff >/dev/null 2>&1 ${file} ${file}.tmp
+ then
+ rm -f ${file}.tmp
+ else
+ echo "creating new ${file}"
+ mv -f ${file}.tmp ${file}
+ fi
+
+ exit 0
+fi
+
+##
+## Fix glade2-generated files
+##
+if test "${action}" = "glade2"
+then
+ file="modules/gui/pda/pda.glade"
+ echo "generating code from $file"
+ glade-2 -w "$file" || exit 1
+
+ file="modules/gui/pda/pda_interface.c"
+ echo "fixing $file"
+ if grep "DO NOT EDIT THIS FILE" "$file" >/dev/null 2>&1
+ then
+ rm -f -- "$file.$$.bak"
+ cat > "$file.$$.bak" << EOF
+/* This file was created automatically by glade2 and fixed by bootstrap */
+
+#include <vlc/vlc.h>
+EOF
+ sed -e 1,7d \
+ -e 's#_(\(".:..:.."\))#\1#' \
+ -e 's#_(\("[a-z0-9]*://[^"]*"\))#\1#' \
+ -e 's#_("---")#"---"#' \
+ -e 's#_("--")#"--"#' \
+ -e 's#_(\("/dev/[^"]*"\))#\1#' \
+ -e 's#_(\("./."\))#\1#' \
+ < "$file" >> "$file.$$.bak"
+ mv -f "$file.$$.bak" "$file"
+ fi