+#################################################
+# Set up libwine.so
+#################################################
+if %REPLACE_WINE%; then
+ echo ""
+ echo "Searching libwine.so (Windows VST support)"
+ # we need to add libwine to ardour's LD_LIBRARY_PATH
+ # libwine itself includes paths to the various system-components
+ # which may be different on each platform.
+ #
+ # There's some chicken/egg here: ardour.exe.so is linked against libwine.so
+ # at build-time. wine/wineloader assumes a windows-application (which does not use libwine
+ # directly) and does not set up the LD path to libwine itself. the application terminates
+ # (missing libs) before it even starts..
+ #
+ # wine itself does not provide means to find the location of libwine.
+ # /usr/bin/wine is usually shell-script and libwine.so can be found in
+ # various places on different distros.
+ #
+ # if this check were quick and easy.. it should be done in the startup-script, but it's not
+ # so here we go... (updating wine may require re-installing ardour)
+ #
+ # on recent Ubuntu wine does load both:
+ # /usr/lib/i386-linux-gnu/libwine.so.1
+ # AND
+ # /usr/lib/x86_64-linux-gnu/libwine.so.1
+ # so we need to work around this (thanks).
+ # (this hack break 64bit LinuxVST builds, but we don't do those anyway)
+
+ LIBWINE=$(
+ LD_DEBUG=files wine `pwd`/${BUNDLE_DIR}/lib/ardour-vst-scanner.exe.so 2>&1 \
+ | grep -e "calling init:.*libwine" \
+ | sed 's/^.*calling init: //' \
+ | grep -v x86_64-linux-gnu \
+ | uniq \
+ )
+ if ! test -f "$LIBWINE"; then
+ echo ""
+ echo "!!! ERROR !!! - 'libwine.so*' was not found."
+ echo ""
+ read -p "Press ENTER to exit installer:" BLAH
+ exit 1
+ fi
+ echo "Using: $LIBWINE"
+ # this replaces/overwrites the bundled libwine
+ cp -L "$LIBWINE" `pwd`/${BUNDLE_DIR}/lib/libwine.so.1
+fi
+