[SCM] idjc packaging branch, master, updated. debian/0.7.14-2-12-g99caab2

quadrispro-guest at users.alioth.debian.org quadrispro-guest at users.alioth.debian.org
Tue Dec 1 02:07:04 UTC 2009


The following commit has been merged in the master branch:
commit 99caab2944f211be51d86131014790c99a6d07c0
Author: Alessio Treglia <quadrispro at ubuntu.com>
Date:   Tue Dec 1 03:06:50 2009 +0100

    New upstream release

diff --git a/ChangeLog b/ChangeLog
index 171b07c..12f8c50 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,167 @@
 	***   Changelog for Internet DJ Console.  Most recent changes first.   ***
 
+* Changes in version 0.8.1 *
+
+Added the ability to drag and drop tracks from a directory's subdirectory. Two levels deep.
+
+Added support for wma tagging and playlist metadata.
+
+Improved transitioning of old playlist data from the 0.7 series.
+
+Allows addition of mp3 files to the playlist when using old versions of mutagen.
+
+* Changes in version 0.8.0 *
+
+Altered some variable names in configure.in to produce better error messages.
+
+Removed a namespace collision in embedded libshout.
+
+Documentation updated.
+
+MP3 playback can now be dithered. Option in the preferences. Default = on.
+
+Added Replay Gain functionality. 
+
+Untagged tracks are now typically shown with the track number cleaned off (requires track number be on the left).
+
+Untagged tracks are now shown with black text and a No Tag message alongside in dark red.
+
+Code to restart the idjcsourceclient module when it crashes has been fixed.
+
+IDJC now runs in the default MALLOC_CHECK_ mode.
+
+Fixed a bug where idjcctrl could start an encoder with bad parameters and cause memory to be freed twice.
+
+Fixed a race condition during encoder shutdown.
+
+Fixed a file filter preselection bug in the 'Add music' file chooser dialog.
+
+Added a precautionary recursion limit to oggscan_eos.
+
+Fixed an Ogg parsing problem where failure to find a valid ogg page in the right hand side caused premature termination of the search.
+
+Fixed a problem seeking files that are in their last ten seconds of playback. Broken since 0.7.17.
+
+Fixed the metadata timing for mp3 recordings. A metadata segment of less than ten seconds could be skipped if it was at the end of a file. Broken since 0.7.17.
+
+Fixed the metadata timing for Ogg recordings. Broken since 0.7.17.
+
+Tracks with quiet endings are not ended early when a server disconnect is imminent or the playlist has nearly run its course. This is to assist server handovers.
+
+A cue file is saved for each mp3 recording. Amarok can make use of these.
+
+./configure stops if the mutagen dependency is not fulfilled.
+
+Recording of mp3 is now possible when the server list is empty.
+
+Players are restarted when the current song playing gets retagged (IDJC tagger only). This is to prevent playback failure.
+
+Dependency list updated.
+
+Added support for multiple metadata tags.
+
+Added APEv2 tagging capability. Includes support for monkeys audio and musepack formats.
+
+* Changes in version 0.7.19 *
+
+Version bump because the Sourceforge file release system is being a pain.
+
+* Changes in version 0.7.18a *
+
+Workaround for a regression in mutagen-1.17. The mutagen.easyid3 module can't be pulled in without first pulling in mutagen.id3 or mutagen.mp3.
+
+* Changes in version 0.7.18 *
+
+Added support for m4b and m4p file extensions. Synonymous with mp4.
+
+New media metadata tagger added, based on mutagen.
+
+Dependency removed: libmp4v2
+
+Dependency removed: eyeD3
+
+Dependency added: mutagen. This covers the functionality of the removed dependencies.
+
+ID3 chapter tags lacking null terminators on the TIT2 frame are handled properly.
+
+Added some Mac portability fixes.
+
+The advance button now works in accordance with the fade setting.
+
+The partially working fade in simple mixer mode is now disabled. This is reflected in the fade selector which greys out.
+
+* Changes in version 0.7.17 *
+
+Fixed minor layout bug in the connection box.
+
+Removed the forced inclusion of mp4.h in mp4tag.c.
+
+MP4 tags API updated in mp4tag.c to prevent deprecation warnings.
+
+The DJ alarm now triggers off a deeper inspection of playlist controls. This permits correct operation of the alarm when fading to an announcement.
+
+The DJ alarm now sounds prior to announcements.
+
+Added playlist controls for fading between tracks. These override the fade speed of the player and can be used to fade announcements.
+
+Added a new fading-between-tracks in-the-same-playlist feature.
+
+Fixed a bug where the player could freeze at the end of a track after a progress bar seek that left the bar at the far right hand size.
+
+Jingles keyboard shortcuts now work when the announcement dialog is active. The shortcut to cancel the dialog (not in editing mode) is BACKSPACE since ESC is used to stop jingles.
+
+Added record_start and record_stop commands to idcjctrl.
+
+Prokyon 3 database parse optimisations. Approx 15% speedup.
+
+Conditional inclusion of jack_set_info_function function call.
+
+Fixes to catch exceptions when there are problems connecting to a song title database.
+
+* Changes in version 0.7.16 *
+
+The application icon and menu entry are now installed according to the ${prefix} value, so it is possible to install to ${HOME}/.local without being root.
+
+When the prokyon 3 database is being indexed (for the tree view) a progress bar is shown. Also the GUI is not frozen during this time as was the case previously.
+
+The password for the prokyon 3 database is now non visible.
+
+When using the prokyon 3 database upon loading IDJC the correct database is now used rather than the default values.
+
+Added Fkeys control of the jingles player. Escape key is used to stop.
+
+The scrolled window in the connection pane now has a specified size
+
+Fixed a segfault that would occur when the main window had focus and the F8 key was pressed.
+
+* Changes in version 0.7.15 *
+
+Uses avcodec_decode_audio3 for libavcodec audio decoding when available.
+
+Fixed bug in avcodecdecode.c, the samples buffer is now aligned on 64 bytes which ensures best performance and the ability to decode formats for which libavcodec uses sse instructions.
+
+Fixed bug in avcodecdecode.c where freed memory could continue to be used.
+
+Added some minor fixes supplied by Andrew Suffield.
+
+Removed the option to not keep passwords over application restarts. Given the extra mouseclicks now requried in order to enter the password and no visible cue to password absence, this feature has been dropped.
+
+Added a new connection feature to the server window. This allows for listener stats to be gathered from a list of relays as well as the master server. Aslo, stats collection can be turned off on a per server basis.
+
+Removed directory checks and conditional inclusion for ffmpeg header files to aid compilation on certain distibutions.
+
+Version 0.7.15_pre1 released as 0.7.14a.
+
+* Changes in version 0.7.14a *
+
+Server stats are now obtained in a threaded manner to prevent the possibility of lockup.
+
+Added a new admin password entry to the server window so that in instances where the Shoutcast server has an admin password applied the stats can still be obtained.
+
+Added and option to turn off stats retrieval on a per server basis.
+
+Stats are additionally now displayed on a per server basis in the server window.
+
 * Changes in version 0.7.14 *
 
 Added 'Alternate' playlist mode.
@@ -8,7 +170,7 @@ Added listener stats retrieval. Stats are now displayed below the stream status
 
 Dynamic runtime linking supported for libmad. MP3 playback can no longer be completely disabled.
 
-Added prefs for how to handle faulty server connnections.
+Added prefs for how to handle faulty server connections.
 
 Dynamic runtime linking supported for libmp3lame. MP3 streaming can no longer be completely disabled.
 
diff --git a/Makefile.am b/Makefile.am
index 4cf9e78..ac1e3b2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -7,7 +7,7 @@ nodist_doc_DATA=AUTHORS.gz NEWS.gz README.gz ChangeLog.gz
 docdir=${prefix}/share/doc/${PACKAGE_NAME}-${PACKAGE_VERSION}
 dist_noinst_DATA=idjc.desktop_
 nodist_appmenu_DATA=idjc.desktop
-appmenudir=/usr/share/applications
+appmenudir=${prefix}/share/applications
 
 idjc: idjc_
 	@sed -e 's|^pyexecdir=|&${pyexecdir}|' -e 's|^export pkgpyexecdir=|&${pkgpyexecdir}|' -e 's|^python=|&${PYTHON}|' $? >$@
@@ -18,7 +18,7 @@ idjcctrl: idjcctrl_.py
 	@chmod u+x $@
 
 idjc.desktop: idjc.desktop_
-	@sed -e 's|EXECPATHNAME|${bindir}/${PACKAGE_NAME}|' -e 's|___||' $? >$@
+	@sed -e 's|EXECPATHNAME|${prefix}/bin/${PACKAGE_NAME}|' -e 's|___||' -e 's|ICONPATHNAME|${prefix}/share/pixmaps/idjc.png|' $? >$@
 
 AUTHORS.gz: AUTHORS
 	@ gzip -c $? >$@
@@ -32,7 +32,7 @@ README.gz: README
 ChangeLog.gz: ChangeLog
 	@ gzip -c $? >$@
 
-# produce a locally runnable version for testing and development (and paranoid users)
+# build idjc for running directly from the source tree
 local:
 	@make all
 	@sed -e "s|^pyexecdir=|&`pwd`/idjcpython|" -e "s|^export pkgpyexecdir=|&`pwd`/idjcpython|" -e "s|^python=|&${PYTHON}|" idjc_ >idjc
@@ -43,7 +43,6 @@ local:
 	@echo "pkgdatadir = \"`pwd`/artwork/\"" >> idjcpython/idjc_config.py
 	@echo "avformat = ${HAVE_AVFORMAT}" >> idjcpython/idjc_config.py
 	@echo "avcodec = ${HAVE_AVCODEC}" >> idjcpython/idjc_config.py
-	@echo "mp4enabled = ${HAVE_MP4V2}" >> idjcpython/idjc_config.py
 	@echo "flacenabled = ${HAVE_FLAC}" >> idjcpython/idjc_config.py
 	@echo "oggflacenabled = ${HAVE_OGGFLAC}" >> idjcpython/idjc_config.py
 	@echo "speexenabled = ${HAVE_SPEEX}" >> idjcpython/idjc_config.py
@@ -55,13 +54,6 @@ local:
 	@echo "num_recorders = "@RECORDERS_S@ >> idjcpython/idjc_config.py
 	@echo "enh_libshout = "${ENH_SHOUT} >> idjcpython/idjc_config.py
 
-# unlike dist this target builds a tarball which includes the libshout sources
-#dist2: distdir
-#	cd libshout ; make distdir
-#	mv libshout/libshout-2.2.2/ $(distdir)/libshout
-#	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
-#	$(am__remove_distdir)
-
 # publish in full the new version including web pages updates
 publish:
 	@if test -f ../WebPage/Makefile ; then make htmldoc ; make dist ; echo ${PACKAGE_VERSION} > ../WebPage/currentversion ; echo "${PACKAGE_TARNAME}-${PACKAGE_VERSION}.tar.gz" > ../WebPage/currentpackage ; cp ${PACKAGE_TARNAME}-${PACKAGE_VERSION}.tar.gz ../WebPage/download/ ; cp ChangeLog ../WebPage/ChangeLog.txt ; cd ../WebPage ; make publish ; else echo "Web Page Makefile not found" ; /bin/false ; fi
@@ -82,4 +74,4 @@ ebuild:
 	emerge "${PACKAGE_TARNAME}"
 	cp idjc-ver.ebuild "${PACKAGE_TARNAME}-${PACKAGE_VERSION}.ebuild"
 
-.PHONY: idjc
\ No newline at end of file
+.PHONY: idjc
diff --git a/Makefile.in b/Makefile.in
index e4f9738..d6b83cd 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -40,7 +40,7 @@ DIST_COMMON = README $(am__configure_deps) $(dist_noinst_DATA) \
 	$(dist_noinst_SCRIPTS) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in $(srcdir)/config.h.in \
 	$(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \
-	compile depcomp install-sh missing py-compile
+	compile depcomp install-sh ltmain.sh missing py-compile
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@@ -92,10 +92,6 @@ AMTAR = @AMTAR@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
 AUTOMAKE = @AUTOMAKE@
-AVCODEC_CFLAGS = @AVCODEC_CFLAGS@
-AVCODEC_LIBS = @AVCODEC_LIBS@
-AVFORMAT_CFLAGS = @AVFORMAT_CFLAGS@
-AVFORMAT_LIBS = @AVFORMAT_LIBS@
 AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
@@ -114,32 +110,46 @@ EGREP = @EGREP@
 ENH_SHOUT = @ENH_SHOUT@
 EXEEXT = @EXEEXT@
 EXT = @EXT@
-FLAC_CFLAGS = @FLAC_CFLAGS@
-FLAC_LIBS = @FLAC_LIBS@
 GREP = @GREP@
 HAVE_AVCODEC = @HAVE_AVCODEC@
 HAVE_AVFORMAT = @HAVE_AVFORMAT@
 HAVE_FLAC = @HAVE_FLAC@
-HAVE_MP4V2 = @HAVE_MP4V2@
 HAVE_OGGFLAC = @HAVE_OGGFLAC@
 HAVE_SPEEX = @HAVE_SPEEX@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-JACK_CFLAGS = @JACK_CFLAGS@
-JACK_LIBS = @JACK_LIBS@
 LDFLAGS = @LDFLAGS@
+LIBAVCODEC_CFLAGS = @LIBAVCODEC_CFLAGS@
+LIBAVCODEC_LIBS = @LIBAVCODEC_LIBS@
+LIBAVFORMAT_CFLAGS = @LIBAVFORMAT_CFLAGS@
+LIBAVFORMAT_LIBS = @LIBAVFORMAT_LIBS@
+LIBFLAC_CFLAGS = @LIBFLAC_CFLAGS@
+LIBFLAC_LIBS = @LIBFLAC_LIBS@
+LIBJACK_CFLAGS = @LIBJACK_CFLAGS@
+LIBJACK_LIBS = @LIBJACK_LIBS@
 LIBM = @LIBM@
+LIBMAD_CFLAGS = @LIBMAD_CFLAGS@
+LIBMAD_LIBS = @LIBMAD_LIBS@
+LIBMP3LAME = @LIBMP3LAME@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LIBSAMPLERATE_CFLAGS = @LIBSAMPLERATE_CFLAGS@
+LIBSAMPLERATE_LIBS = @LIBSAMPLERATE_LIBS@
+LIBSHOUT_CFLAGS = @LIBSHOUT_CFLAGS@
+LIBSHOUT_LIBS = @LIBSHOUT_LIBS@
+LIBSNDFILE_CFLAGS = @LIBSNDFILE_CFLAGS@
+LIBSNDFILE_LIBS = @LIBSNDFILE_LIBS@
+LIBSPEEX_CFLAGS = @LIBSPEEX_CFLAGS@
+LIBSPEEX_LIBS = @LIBSPEEX_LIBS@
+LIBVORBISENC_CFLAGS = @LIBVORBISENC_CFLAGS@
+LIBVORBISENC_LIBS = @LIBVORBISENC_LIBS@
+LIBVORBIS_CFLAGS = @LIBVORBIS_CFLAGS@
+LIBVORBIS_LIBS = @LIBVORBIS_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
-MAD_CFLAGS = @MAD_CFLAGS@
-MAD_LIBS = @MAD_LIBS@
 MAKEINFO = @MAKEINFO@
 MAYBE_LIBSHOUT = @MAYBE_LIBSHOUT@
-MP3LAME = @MP3LAME@
-MP4V2_LIBS = @MP4V2_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -158,27 +168,13 @@ PYTHON_PREFIX = @PYTHON_PREFIX@
 PYTHON_VERSION = @PYTHON_VERSION@
 RECORDERS = @RECORDERS@
 RECORDERS_S = @RECORDERS_S@
-SAMPLERATE_CFLAGS = @SAMPLERATE_CFLAGS@
-SAMPLERATE_LIBS = @SAMPLERATE_LIBS@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
-SHOUT_CFLAGS = @SHOUT_CFLAGS@
-SHOUT_LIBS = @SHOUT_LIBS@
-SNDFILE_CFLAGS = @SNDFILE_CFLAGS@
-SNDFILE_LIBS = @SNDFILE_LIBS@
-SPEEX_CFLAGS = @SPEEX_CFLAGS@
-SPEEX_LIBS = @SPEEX_LIBS@
 STREAMERS = @STREAMERS@
 STREAMERS_S = @STREAMERS_S@
 STRIP = @STRIP@
 TOOLTIPS = @TOOLTIPS@
 VERSION = @VERSION@
-VORBISENC_CFLAGS = @VORBISENC_CFLAGS@
-VORBISENC_LIBS = @VORBISENC_LIBS@
-VORBISFILE_CFLAGS = @VORBISFILE_CFLAGS@
-VORBISFILE_LIBS = @VORBISFILE_LIBS@
-VORBIS_CFLAGS = @VORBIS_CFLAGS@
-VORBIS_LIBS = @VORBIS_LIBS@
 ac_ct_CC = @ac_ct_CC@
 am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
 am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
@@ -226,7 +222,7 @@ dist_noinst_SCRIPTS = idjc_ idjcctrl_.py $(wildcard doc/*.html) $(wildcard doc/*
 nodist_doc_DATA = AUTHORS.gz NEWS.gz README.gz ChangeLog.gz
 dist_noinst_DATA = idjc.desktop_
 nodist_appmenu_DATA = idjc.desktop
-appmenudir = /usr/share/applications
+appmenudir = ${prefix}/share/applications
 all: config.h
 	$(MAKE) $(AM_MAKEFLAGS) all-recursive
 
@@ -722,7 +718,7 @@ idjcctrl: idjcctrl_.py
 	@chmod u+x $@
 
 idjc.desktop: idjc.desktop_
-	@sed -e 's|EXECPATHNAME|${bindir}/${PACKAGE_NAME}|' -e 's|___||' $? >$@
+	@sed -e 's|EXECPATHNAME|${prefix}/bin/${PACKAGE_NAME}|' -e 's|___||' -e 's|ICONPATHNAME|${prefix}/share/pixmaps/idjc.png|' $? >$@
 
 AUTHORS.gz: AUTHORS
 	@ gzip -c $? >$@
@@ -736,7 +732,7 @@ README.gz: README
 ChangeLog.gz: ChangeLog
 	@ gzip -c $? >$@
 
-# produce a locally runnable version for testing and development (and paranoid users)
+# build idjc for running directly from the source tree
 local:
 	@make all
 	@sed -e "s|^pyexecdir=|&`pwd`/idjcpython|" -e "s|^export pkgpyexecdir=|&`pwd`/idjcpython|" -e "s|^python=|&${PYTHON}|" idjc_ >idjc
@@ -747,7 +743,6 @@ local:
 	@echo "pkgdatadir = \"`pwd`/artwork/\"" >> idjcpython/idjc_config.py
 	@echo "avformat = ${HAVE_AVFORMAT}" >> idjcpython/idjc_config.py
 	@echo "avcodec = ${HAVE_AVCODEC}" >> idjcpython/idjc_config.py
-	@echo "mp4enabled = ${HAVE_MP4V2}" >> idjcpython/idjc_config.py
 	@echo "flacenabled = ${HAVE_FLAC}" >> idjcpython/idjc_config.py
 	@echo "oggflacenabled = ${HAVE_OGGFLAC}" >> idjcpython/idjc_config.py
 	@echo "speexenabled = ${HAVE_SPEEX}" >> idjcpython/idjc_config.py
@@ -759,13 +754,6 @@ local:
 	@echo "num_recorders = "@RECORDERS_S@ >> idjcpython/idjc_config.py
 	@echo "enh_libshout = "${ENH_SHOUT} >> idjcpython/idjc_config.py
 
-# unlike dist this target builds a tarball which includes the libshout sources
-#dist2: distdir
-#	cd libshout ; make distdir
-#	mv libshout/libshout-2.2.2/ $(distdir)/libshout
-#	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
-#	$(am__remove_distdir)
-
 # publish in full the new version including web pages updates
 publish:
 	@if test -f ../WebPage/Makefile ; then make htmldoc ; make dist ; echo ${PACKAGE_VERSION} > ../WebPage/currentversion ; echo "${PACKAGE_TARNAME}-${PACKAGE_VERSION}.tar.gz" > ../WebPage/currentpackage ; cp ${PACKAGE_TARNAME}-${PACKAGE_VERSION}.tar.gz ../WebPage/download/ ; cp ChangeLog ../WebPage/ChangeLog.txt ; cd ../WebPage ; make publish ; else echo "Web Page Makefile not found" ; /bin/false ; fi
diff --git a/Man/Makefile.in b/Man/Makefile.in
index 63966a8..d073ec3 100644
--- a/Man/Makefile.in
+++ b/Man/Makefile.in
@@ -59,10 +59,6 @@ AMTAR = @AMTAR@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
 AUTOMAKE = @AUTOMAKE@
-AVCODEC_CFLAGS = @AVCODEC_CFLAGS@
-AVCODEC_LIBS = @AVCODEC_LIBS@
-AVFORMAT_CFLAGS = @AVFORMAT_CFLAGS@
-AVFORMAT_LIBS = @AVFORMAT_LIBS@
 AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
@@ -81,32 +77,46 @@ EGREP = @EGREP@
 ENH_SHOUT = @ENH_SHOUT@
 EXEEXT = @EXEEXT@
 EXT = @EXT@
-FLAC_CFLAGS = @FLAC_CFLAGS@
-FLAC_LIBS = @FLAC_LIBS@
 GREP = @GREP@
 HAVE_AVCODEC = @HAVE_AVCODEC@
 HAVE_AVFORMAT = @HAVE_AVFORMAT@
 HAVE_FLAC = @HAVE_FLAC@
-HAVE_MP4V2 = @HAVE_MP4V2@
 HAVE_OGGFLAC = @HAVE_OGGFLAC@
 HAVE_SPEEX = @HAVE_SPEEX@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-JACK_CFLAGS = @JACK_CFLAGS@
-JACK_LIBS = @JACK_LIBS@
 LDFLAGS = @LDFLAGS@
+LIBAVCODEC_CFLAGS = @LIBAVCODEC_CFLAGS@
+LIBAVCODEC_LIBS = @LIBAVCODEC_LIBS@
+LIBAVFORMAT_CFLAGS = @LIBAVFORMAT_CFLAGS@
+LIBAVFORMAT_LIBS = @LIBAVFORMAT_LIBS@
+LIBFLAC_CFLAGS = @LIBFLAC_CFLAGS@
+LIBFLAC_LIBS = @LIBFLAC_LIBS@
+LIBJACK_CFLAGS = @LIBJACK_CFLAGS@
+LIBJACK_LIBS = @LIBJACK_LIBS@
 LIBM = @LIBM@
+LIBMAD_CFLAGS = @LIBMAD_CFLAGS@
+LIBMAD_LIBS = @LIBMAD_LIBS@
+LIBMP3LAME = @LIBMP3LAME@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LIBSAMPLERATE_CFLAGS = @LIBSAMPLERATE_CFLAGS@
+LIBSAMPLERATE_LIBS = @LIBSAMPLERATE_LIBS@
+LIBSHOUT_CFLAGS = @LIBSHOUT_CFLAGS@
+LIBSHOUT_LIBS = @LIBSHOUT_LIBS@
+LIBSNDFILE_CFLAGS = @LIBSNDFILE_CFLAGS@
+LIBSNDFILE_LIBS = @LIBSNDFILE_LIBS@
+LIBSPEEX_CFLAGS = @LIBSPEEX_CFLAGS@
+LIBSPEEX_LIBS = @LIBSPEEX_LIBS@
+LIBVORBISENC_CFLAGS = @LIBVORBISENC_CFLAGS@
+LIBVORBISENC_LIBS = @LIBVORBISENC_LIBS@
+LIBVORBIS_CFLAGS = @LIBVORBIS_CFLAGS@
+LIBVORBIS_LIBS = @LIBVORBIS_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
-MAD_CFLAGS = @MAD_CFLAGS@
-MAD_LIBS = @MAD_LIBS@
 MAKEINFO = @MAKEINFO@
 MAYBE_LIBSHOUT = @MAYBE_LIBSHOUT@
-MP3LAME = @MP3LAME@
-MP4V2_LIBS = @MP4V2_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -125,27 +135,13 @@ PYTHON_PREFIX = @PYTHON_PREFIX@
 PYTHON_VERSION = @PYTHON_VERSION@
 RECORDERS = @RECORDERS@
 RECORDERS_S = @RECORDERS_S@
-SAMPLERATE_CFLAGS = @SAMPLERATE_CFLAGS@
-SAMPLERATE_LIBS = @SAMPLERATE_LIBS@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
-SHOUT_CFLAGS = @SHOUT_CFLAGS@
-SHOUT_LIBS = @SHOUT_LIBS@
-SNDFILE_CFLAGS = @SNDFILE_CFLAGS@
-SNDFILE_LIBS = @SNDFILE_LIBS@
-SPEEX_CFLAGS = @SPEEX_CFLAGS@
-SPEEX_LIBS = @SPEEX_LIBS@
 STREAMERS = @STREAMERS@
 STREAMERS_S = @STREAMERS_S@
 STRIP = @STRIP@
 TOOLTIPS = @TOOLTIPS@
 VERSION = @VERSION@
-VORBISENC_CFLAGS = @VORBISENC_CFLAGS@
-VORBISENC_LIBS = @VORBISENC_LIBS@
-VORBISFILE_CFLAGS = @VORBISFILE_CFLAGS@
-VORBISFILE_LIBS = @VORBISFILE_LIBS@
-VORBIS_CFLAGS = @VORBIS_CFLAGS@
-VORBIS_LIBS = @VORBIS_LIBS@
 ac_ct_CC = @ac_ct_CC@
 am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
 am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
diff --git a/README b/README
index ff92fb0..06db90e 100644
--- a/README
+++ b/README
@@ -1,3 +1,6 @@
 Internet DJ Console README.
 
 A full set of documentation can be found in the doc directory of the source tree in html format and on the homepage http://idjc.sourceforge.net.
+
+The documentation contains the build instructions.
+
diff --git a/artwork/Makefile.am b/artwork/Makefile.am
index d90048f..0772d8d 100644
--- a/artwork/Makefile.am
+++ b/artwork/Makefile.am
@@ -8,7 +8,7 @@ dist_noinst_DATA = ${xpms} ${pngs}
 nodist_pkgdata_DATA = ${used}
 
 nodist_pixmaps_DATA = idjc.png
-pixmapsdir = /usr/share/pixmaps
+pixmapsdir = ${prefix}/share/pixmaps
 
 idjc.png: icon.png
 	@cp $? $@
diff --git a/artwork/Makefile.in b/artwork/Makefile.in
index 3e49b10..2625fa7 100644
--- a/artwork/Makefile.in
+++ b/artwork/Makefile.in
@@ -65,10 +65,6 @@ AMTAR = @AMTAR@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
 AUTOMAKE = @AUTOMAKE@
-AVCODEC_CFLAGS = @AVCODEC_CFLAGS@
-AVCODEC_LIBS = @AVCODEC_LIBS@
-AVFORMAT_CFLAGS = @AVFORMAT_CFLAGS@
-AVFORMAT_LIBS = @AVFORMAT_LIBS@
 AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
@@ -87,32 +83,46 @@ EGREP = @EGREP@
 ENH_SHOUT = @ENH_SHOUT@
 EXEEXT = @EXEEXT@
 EXT = @EXT@
-FLAC_CFLAGS = @FLAC_CFLAGS@
-FLAC_LIBS = @FLAC_LIBS@
 GREP = @GREP@
 HAVE_AVCODEC = @HAVE_AVCODEC@
 HAVE_AVFORMAT = @HAVE_AVFORMAT@
 HAVE_FLAC = @HAVE_FLAC@
-HAVE_MP4V2 = @HAVE_MP4V2@
 HAVE_OGGFLAC = @HAVE_OGGFLAC@
 HAVE_SPEEX = @HAVE_SPEEX@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-JACK_CFLAGS = @JACK_CFLAGS@
-JACK_LIBS = @JACK_LIBS@
 LDFLAGS = @LDFLAGS@
+LIBAVCODEC_CFLAGS = @LIBAVCODEC_CFLAGS@
+LIBAVCODEC_LIBS = @LIBAVCODEC_LIBS@
+LIBAVFORMAT_CFLAGS = @LIBAVFORMAT_CFLAGS@
+LIBAVFORMAT_LIBS = @LIBAVFORMAT_LIBS@
+LIBFLAC_CFLAGS = @LIBFLAC_CFLAGS@
+LIBFLAC_LIBS = @LIBFLAC_LIBS@
+LIBJACK_CFLAGS = @LIBJACK_CFLAGS@
+LIBJACK_LIBS = @LIBJACK_LIBS@
 LIBM = @LIBM@
+LIBMAD_CFLAGS = @LIBMAD_CFLAGS@
+LIBMAD_LIBS = @LIBMAD_LIBS@
+LIBMP3LAME = @LIBMP3LAME@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LIBSAMPLERATE_CFLAGS = @LIBSAMPLERATE_CFLAGS@
+LIBSAMPLERATE_LIBS = @LIBSAMPLERATE_LIBS@
+LIBSHOUT_CFLAGS = @LIBSHOUT_CFLAGS@
+LIBSHOUT_LIBS = @LIBSHOUT_LIBS@
+LIBSNDFILE_CFLAGS = @LIBSNDFILE_CFLAGS@
+LIBSNDFILE_LIBS = @LIBSNDFILE_LIBS@
+LIBSPEEX_CFLAGS = @LIBSPEEX_CFLAGS@
+LIBSPEEX_LIBS = @LIBSPEEX_LIBS@
+LIBVORBISENC_CFLAGS = @LIBVORBISENC_CFLAGS@
+LIBVORBISENC_LIBS = @LIBVORBISENC_LIBS@
+LIBVORBIS_CFLAGS = @LIBVORBIS_CFLAGS@
+LIBVORBIS_LIBS = @LIBVORBIS_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
-MAD_CFLAGS = @MAD_CFLAGS@
-MAD_LIBS = @MAD_LIBS@
 MAKEINFO = @MAKEINFO@
 MAYBE_LIBSHOUT = @MAYBE_LIBSHOUT@
-MP3LAME = @MP3LAME@
-MP4V2_LIBS = @MP4V2_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -131,27 +141,13 @@ PYTHON_PREFIX = @PYTHON_PREFIX@
 PYTHON_VERSION = @PYTHON_VERSION@
 RECORDERS = @RECORDERS@
 RECORDERS_S = @RECORDERS_S@
-SAMPLERATE_CFLAGS = @SAMPLERATE_CFLAGS@
-SAMPLERATE_LIBS = @SAMPLERATE_LIBS@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
-SHOUT_CFLAGS = @SHOUT_CFLAGS@
-SHOUT_LIBS = @SHOUT_LIBS@
-SNDFILE_CFLAGS = @SNDFILE_CFLAGS@
-SNDFILE_LIBS = @SNDFILE_LIBS@
-SPEEX_CFLAGS = @SPEEX_CFLAGS@
-SPEEX_LIBS = @SPEEX_LIBS@
 STREAMERS = @STREAMERS@
 STREAMERS_S = @STREAMERS_S@
 STRIP = @STRIP@
 TOOLTIPS = @TOOLTIPS@
 VERSION = @VERSION@
-VORBISENC_CFLAGS = @VORBISENC_CFLAGS@
-VORBISENC_LIBS = @VORBISENC_LIBS@
-VORBISFILE_CFLAGS = @VORBISFILE_CFLAGS@
-VORBISFILE_LIBS = @VORBISFILE_LIBS@
-VORBIS_CFLAGS = @VORBIS_CFLAGS@
-VORBIS_LIBS = @VORBIS_LIBS@
 ac_ct_CC = @ac_ct_CC@
 am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
 am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
@@ -198,7 +194,7 @@ used = add3. at EXT@ advance. at EXT@ del. at EXT@ greenphone. at EXT@ interlude. at EXT@ jack2
 dist_noinst_DATA = ${xpms} ${pngs}
 nodist_pkgdata_DATA = ${used}
 nodist_pixmaps_DATA = idjc.png
-pixmapsdir = /usr/share/pixmaps
+pixmapsdir = ${prefix}/share/pixmaps
 all: all-am
 
 .SUFFIXES:
diff --git a/c/Makefile.am b/c/Makefile.am
index 047ec34..58eb819 100644
--- a/c/Makefile.am
+++ b/c/Makefile.am
@@ -1,11 +1,11 @@
 libexec_PROGRAMS=idjcmixer idjcsourceclient
 
 idjcsourceclient_SOURCES=sourceclient.c sourceclient.h kvpdict.c kvpdict.h kvpparse.c kvpparse.h encoder.c encoder.h streamer.c streamer.h recorder.c recorder.h audio_feed.c audio_feed.h live_ogg_encoder.c live_ogg_encoder.h watchdog.c watchdog.h  live_mp3_encoder.c live_mp3_encoder.h id3.c id3.h bsdcompat.c bsdcompat.h gnusource.h live_oggflac_encoder.c live_oggflac_encoder.h live_oggspeex_encoder.c live_oggspeex_encoder.h dyn_lame.c dyn_lame.h lame.h
-idjcsourceclient_CFLAGS=-Wall -std=gnu99 -O2 ${JACK_CFLAGS} ${VORBIS_CFLAGS} ${VORBISENC_CFLAGS} ${SAMPLERATE_CFLAGS} ${FLAC_CFLAGS} ${SPEEX_CFLAGS} ${SHOUT_CFLAGS}
-idjcsourceclient_LDADD=-lpthread ${DYN_LIBS} ${MP3LAME} ${LIBM} ${JACK_LIBS} ${VORBIS_LIBS} ${VORBISENC_LIBS} ${SAMPLERATE_LIBS} ${FLAC_LIBS} ${SPEEX_LIBS} ${SHOUT_LIBS}
+idjcsourceclient_CFLAGS=-Wall -std=gnu99 -O2 ${LIBJACK_CFLAGS} ${LIBVORBIS_CFLAGS} ${LIBVORBISENC_CFLAGS} ${LIBSAMPLERATE_CFLAGS} ${LIBFLAC_CFLAGS} ${LIBSPEEX_CFLAGS} ${LIBSHOUT_CFLAGS}
+idjcsourceclient_LDADD=-lpthread ${DYN_LIBS} ${LIBMP3LAME} ${LIBM} ${LIBJACK_LIBS} ${LIBVORBIS_LIBS} ${LIBVORBISENC_LIBS} ${LIBSAMPLERATE_LIBS} ${LIBFLAC_LIBS} ${LIBSPEEX_LIBS} ${LIBSHOUT_LIBS}
 idjcsourceclient_LDFLAGS=${DYN_LDFLAGS}
 
-idjcmixer_SOURCES=idjcmixer.c kvpdict.c kvpparse.c kvpdict.h kvpparse.h dbconvert.c dbconvert.h ialloc.c ialloc.h xlplayer.c xlplayer.h mp4tag.c mp4tag.h compressor.c compressor.h sndfileinfo.c sndfileinfo.h flacdecode.c flacdecode.h mp3dec.c mp3dec.h sndfiledecode.c sndfiledecode.h avcodecdecode.c avcodecdecode.h mp3tagread.c mp3tagread.h oggdec.c oggdec.h ogg_vorbis_dec.c ogg_vorbis_dec.h ogg_flac_dec.c ogg_flac_dec.h ogg_speex_dec.c ogg_speex_dec.h speextag.c speextag.h bsdcompat.c bsdcompat.h gnusource.h agc.c agc.h dyn_mad.c dyn_mad.h mad.h
-idjcmixer_CFLAGS=-Wall -std=gnu99 -O2 ${JACK_CFLAGS} ${VORBISFILE_CFLAGS} ${SAMPLERATE_CFLAGS} ${FLAC_CFLAGS} ${SNDFILE_CFLAGS} ${MAD_CFLAGS} ${AVCODEC_CFLAGS} ${AVFORMAT_CFLAGS} ${SPEEX_CFLAGS}
-idjcmixer_LDADD=-lpthread ${DYN_LIBS} ${LIBM} ${JACK_LIBS} ${VORBISFILE_LIBS} ${SAMPLERATE_LIBS} ${FLAC_LIBS} ${MP4FF_LIBS} ${SNDFILE_LIBS} ${FAAD_LIBS} ${MAD_LIBS} ${AVCODEC_LIBS} ${AVFORMAT_LIBS} ${SPEEX_LIBS} ${MP4V2_LIBS}
+idjcmixer_SOURCES=idjcmixer.c kvpdict.c kvpparse.c kvpdict.h kvpparse.h dbconvert.c dbconvert.h ialloc.c ialloc.h xlplayer.c xlplayer.h compressor.c compressor.h sndfileinfo.c sndfileinfo.h flacdecode.c flacdecode.h mp3dec.c mp3dec.h sndfiledecode.c sndfiledecode.h avcodecdecode.c avcodecdecode.h mp3tagread.c mp3tagread.h oggdec.c oggdec.h ogg_vorbis_dec.c ogg_vorbis_dec.h ogg_flac_dec.c ogg_flac_dec.h ogg_speex_dec.c ogg_speex_dec.h speextag.c speextag.h bsdcompat.c bsdcompat.h gnusource.h agc.c agc.h dyn_mad.c dyn_mad.h mad.h
+idjcmixer_CFLAGS=-Wall -std=gnu99 -O2 ${LIBVORBIS_CFLAGS} ${LIBJACK_CFLAGS} ${LIBSAMPLERATE_CFLAGS} ${LIBFLAC_CFLAGS} ${LIBSNDFILE_CFLAGS} ${LIBMAD_CFLAGS} ${LIBAVCODEC_CFLAGS} ${LIBAVFORMAT_CFLAGS} ${LIBSPEEX_CFLAGS}
+idjcmixer_LDADD=-lpthread ${DYN_LIBS} ${LIBM} ${LIBVORBIS_LIBS} ${LIBJACK_LIBS} ${LIBSAMPLERATE_LIBS} ${LIBFLAC_LIBS} ${LIBSNDFILE_LIBS} ${LIBMAD_LIBS} ${LIBAVCODEC_LIBS} ${LIBAVFORMAT_LIBS} ${LIBSPEEX_LIBS}
 idjcmixer_LDFLAGS=${DYN_LDFLAGS}
diff --git a/c/Makefile.in b/c/Makefile.in
index 5371641..bb316cd 100644
--- a/c/Makefile.in
+++ b/c/Makefile.in
@@ -50,10 +50,9 @@ PROGRAMS = $(libexec_PROGRAMS)
 am_idjcmixer_OBJECTS = idjcmixer-idjcmixer.$(OBJEXT) \
 	idjcmixer-kvpdict.$(OBJEXT) idjcmixer-kvpparse.$(OBJEXT) \
 	idjcmixer-dbconvert.$(OBJEXT) idjcmixer-ialloc.$(OBJEXT) \
-	idjcmixer-xlplayer.$(OBJEXT) idjcmixer-mp4tag.$(OBJEXT) \
-	idjcmixer-compressor.$(OBJEXT) idjcmixer-sndfileinfo.$(OBJEXT) \
-	idjcmixer-flacdecode.$(OBJEXT) idjcmixer-mp3dec.$(OBJEXT) \
-	idjcmixer-sndfiledecode.$(OBJEXT) \
+	idjcmixer-xlplayer.$(OBJEXT) idjcmixer-compressor.$(OBJEXT) \
+	idjcmixer-sndfileinfo.$(OBJEXT) idjcmixer-flacdecode.$(OBJEXT) \
+	idjcmixer-mp3dec.$(OBJEXT) idjcmixer-sndfiledecode.$(OBJEXT) \
 	idjcmixer-avcodecdecode.$(OBJEXT) \
 	idjcmixer-mp3tagread.$(OBJEXT) idjcmixer-oggdec.$(OBJEXT) \
 	idjcmixer-ogg_vorbis_dec.$(OBJEXT) \
@@ -68,7 +67,7 @@ idjcmixer_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
 	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
 	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
 	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+	$(am__DEPENDENCIES_1)
 am_idjcsourceclient_OBJECTS = idjcsourceclient-sourceclient.$(OBJEXT) \
 	idjcsourceclient-kvpdict.$(OBJEXT) \
 	idjcsourceclient-kvpparse.$(OBJEXT) \
@@ -110,10 +109,6 @@ AMTAR = @AMTAR@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
 AUTOMAKE = @AUTOMAKE@
-AVCODEC_CFLAGS = @AVCODEC_CFLAGS@
-AVCODEC_LIBS = @AVCODEC_LIBS@
-AVFORMAT_CFLAGS = @AVFORMAT_CFLAGS@
-AVFORMAT_LIBS = @AVFORMAT_LIBS@
 AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
@@ -132,32 +127,46 @@ EGREP = @EGREP@
 ENH_SHOUT = @ENH_SHOUT@
 EXEEXT = @EXEEXT@
 EXT = @EXT@
-FLAC_CFLAGS = @FLAC_CFLAGS@
-FLAC_LIBS = @FLAC_LIBS@
 GREP = @GREP@
 HAVE_AVCODEC = @HAVE_AVCODEC@
 HAVE_AVFORMAT = @HAVE_AVFORMAT@
 HAVE_FLAC = @HAVE_FLAC@
-HAVE_MP4V2 = @HAVE_MP4V2@
 HAVE_OGGFLAC = @HAVE_OGGFLAC@
 HAVE_SPEEX = @HAVE_SPEEX@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-JACK_CFLAGS = @JACK_CFLAGS@
-JACK_LIBS = @JACK_LIBS@
 LDFLAGS = @LDFLAGS@
+LIBAVCODEC_CFLAGS = @LIBAVCODEC_CFLAGS@
+LIBAVCODEC_LIBS = @LIBAVCODEC_LIBS@
+LIBAVFORMAT_CFLAGS = @LIBAVFORMAT_CFLAGS@
+LIBAVFORMAT_LIBS = @LIBAVFORMAT_LIBS@
+LIBFLAC_CFLAGS = @LIBFLAC_CFLAGS@
+LIBFLAC_LIBS = @LIBFLAC_LIBS@
+LIBJACK_CFLAGS = @LIBJACK_CFLAGS@
+LIBJACK_LIBS = @LIBJACK_LIBS@
 LIBM = @LIBM@
+LIBMAD_CFLAGS = @LIBMAD_CFLAGS@
+LIBMAD_LIBS = @LIBMAD_LIBS@
+LIBMP3LAME = @LIBMP3LAME@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LIBSAMPLERATE_CFLAGS = @LIBSAMPLERATE_CFLAGS@
+LIBSAMPLERATE_LIBS = @LIBSAMPLERATE_LIBS@
+LIBSHOUT_CFLAGS = @LIBSHOUT_CFLAGS@
+LIBSHOUT_LIBS = @LIBSHOUT_LIBS@
+LIBSNDFILE_CFLAGS = @LIBSNDFILE_CFLAGS@
+LIBSNDFILE_LIBS = @LIBSNDFILE_LIBS@
+LIBSPEEX_CFLAGS = @LIBSPEEX_CFLAGS@
+LIBSPEEX_LIBS = @LIBSPEEX_LIBS@
+LIBVORBISENC_CFLAGS = @LIBVORBISENC_CFLAGS@
+LIBVORBISENC_LIBS = @LIBVORBISENC_LIBS@
+LIBVORBIS_CFLAGS = @LIBVORBIS_CFLAGS@
+LIBVORBIS_LIBS = @LIBVORBIS_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
-MAD_CFLAGS = @MAD_CFLAGS@
-MAD_LIBS = @MAD_LIBS@
 MAKEINFO = @MAKEINFO@
 MAYBE_LIBSHOUT = @MAYBE_LIBSHOUT@
-MP3LAME = @MP3LAME@
-MP4V2_LIBS = @MP4V2_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -176,27 +185,13 @@ PYTHON_PREFIX = @PYTHON_PREFIX@
 PYTHON_VERSION = @PYTHON_VERSION@
 RECORDERS = @RECORDERS@
 RECORDERS_S = @RECORDERS_S@
-SAMPLERATE_CFLAGS = @SAMPLERATE_CFLAGS@
-SAMPLERATE_LIBS = @SAMPLERATE_LIBS@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
-SHOUT_CFLAGS = @SHOUT_CFLAGS@
-SHOUT_LIBS = @SHOUT_LIBS@
-SNDFILE_CFLAGS = @SNDFILE_CFLAGS@
-SNDFILE_LIBS = @SNDFILE_LIBS@
-SPEEX_CFLAGS = @SPEEX_CFLAGS@
-SPEEX_LIBS = @SPEEX_LIBS@
 STREAMERS = @STREAMERS@
 STREAMERS_S = @STREAMERS_S@
 STRIP = @STRIP@
 TOOLTIPS = @TOOLTIPS@
 VERSION = @VERSION@
-VORBISENC_CFLAGS = @VORBISENC_CFLAGS@
-VORBISENC_LIBS = @VORBISENC_LIBS@
-VORBISFILE_CFLAGS = @VORBISFILE_CFLAGS@
-VORBISFILE_LIBS = @VORBISFILE_LIBS@
-VORBIS_CFLAGS = @VORBIS_CFLAGS@
-VORBIS_LIBS = @VORBIS_LIBS@
 ac_ct_CC = @ac_ct_CC@
 am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
 am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
@@ -238,12 +233,12 @@ subdirs = @subdirs@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
 idjcsourceclient_SOURCES = sourceclient.c sourceclient.h kvpdict.c kvpdict.h kvpparse.c kvpparse.h encoder.c encoder.h streamer.c streamer.h recorder.c recorder.h audio_feed.c audio_feed.h live_ogg_encoder.c live_ogg_encoder.h watchdog.c watchdog.h  live_mp3_encoder.c live_mp3_encoder.h id3.c id3.h bsdcompat.c bsdcompat.h gnusource.h live_oggflac_encoder.c live_oggflac_encoder.h live_oggspeex_encoder.c live_oggspeex_encoder.h dyn_lame.c dyn_lame.h lame.h
-idjcsourceclient_CFLAGS = -Wall -std=gnu99 -O2 ${JACK_CFLAGS} ${VORBIS_CFLAGS} ${VORBISENC_CFLAGS} ${SAMPLERATE_CFLAGS} ${FLAC_CFLAGS} ${SPEEX_CFLAGS} ${SHOUT_CFLAGS}
-idjcsourceclient_LDADD = -lpthread ${DYN_LIBS} ${MP3LAME} ${LIBM} ${JACK_LIBS} ${VORBIS_LIBS} ${VORBISENC_LIBS} ${SAMPLERATE_LIBS} ${FLAC_LIBS} ${SPEEX_LIBS} ${SHOUT_LIBS}
+idjcsourceclient_CFLAGS = -Wall -std=gnu99 -O2 ${LIBJACK_CFLAGS} ${LIBVORBIS_CFLAGS} ${LIBVORBISENC_CFLAGS} ${LIBSAMPLERATE_CFLAGS} ${LIBFLAC_CFLAGS} ${LIBSPEEX_CFLAGS} ${LIBSHOUT_CFLAGS}
+idjcsourceclient_LDADD = -lpthread ${DYN_LIBS} ${LIBMP3LAME} ${LIBM} ${LIBJACK_LIBS} ${LIBVORBIS_LIBS} ${LIBVORBISENC_LIBS} ${LIBSAMPLERATE_LIBS} ${LIBFLAC_LIBS} ${LIBSPEEX_LIBS} ${LIBSHOUT_LIBS}
 idjcsourceclient_LDFLAGS = ${DYN_LDFLAGS}
-idjcmixer_SOURCES = idjcmixer.c kvpdict.c kvpparse.c kvpdict.h kvpparse.h dbconvert.c dbconvert.h ialloc.c ialloc.h xlplayer.c xlplayer.h mp4tag.c mp4tag.h compressor.c compressor.h sndfileinfo.c sndfileinfo.h flacdecode.c flacdecode.h mp3dec.c mp3dec.h sndfiledecode.c sndfiledecode.h avcodecdecode.c avcodecdecode.h mp3tagread.c mp3tagread.h oggdec.c oggdec.h ogg_vorbis_dec.c ogg_vorbis_dec.h ogg_flac_dec.c ogg_flac_dec.h ogg_speex_dec.c ogg_speex_dec.h speextag.c speextag.h bsdcompat.c bsdcompat.h gnusource.h agc.c agc.h dyn_mad.c dyn_mad.h mad.h
-idjcmixer_CFLAGS = -Wall -std=gnu99 -O2 ${JACK_CFLAGS} ${VORBISFILE_CFLAGS} ${SAMPLERATE_CFLAGS} ${FLAC_CFLAGS} ${SNDFILE_CFLAGS} ${MAD_CFLAGS} ${AVCODEC_CFLAGS} ${AVFORMAT_CFLAGS} ${SPEEX_CFLAGS}
-idjcmixer_LDADD = -lpthread ${DYN_LIBS} ${LIBM} ${JACK_LIBS} ${VORBISFILE_LIBS} ${SAMPLERATE_LIBS} ${FLAC_LIBS} ${MP4FF_LIBS} ${SNDFILE_LIBS} ${FAAD_LIBS} ${MAD_LIBS} ${AVCODEC_LIBS} ${AVFORMAT_LIBS} ${SPEEX_LIBS} ${MP4V2_LIBS}
+idjcmixer_SOURCES = idjcmixer.c kvpdict.c kvpparse.c kvpdict.h kvpparse.h dbconvert.c dbconvert.h ialloc.c ialloc.h xlplayer.c xlplayer.h compressor.c compressor.h sndfileinfo.c sndfileinfo.h flacdecode.c flacdecode.h mp3dec.c mp3dec.h sndfiledecode.c sndfiledecode.h avcodecdecode.c avcodecdecode.h mp3tagread.c mp3tagread.h oggdec.c oggdec.h ogg_vorbis_dec.c ogg_vorbis_dec.h ogg_flac_dec.c ogg_flac_dec.h ogg_speex_dec.c ogg_speex_dec.h speextag.c speextag.h bsdcompat.c bsdcompat.h gnusource.h agc.c agc.h dyn_mad.c dyn_mad.h mad.h
+idjcmixer_CFLAGS = -Wall -std=gnu99 -O2 ${LIBVORBIS_CFLAGS} ${LIBJACK_CFLAGS} ${LIBSAMPLERATE_CFLAGS} ${LIBFLAC_CFLAGS} ${LIBSNDFILE_CFLAGS} ${LIBMAD_CFLAGS} ${LIBAVCODEC_CFLAGS} ${LIBAVFORMAT_CFLAGS} ${LIBSPEEX_CFLAGS}
+idjcmixer_LDADD = -lpthread ${DYN_LIBS} ${LIBM} ${LIBVORBIS_LIBS} ${LIBJACK_LIBS} ${LIBSAMPLERATE_LIBS} ${LIBFLAC_LIBS} ${LIBSNDFILE_LIBS} ${LIBMAD_LIBS} ${LIBAVCODEC_LIBS} ${LIBAVFORMAT_LIBS} ${LIBSPEEX_LIBS}
 idjcmixer_LDFLAGS = ${DYN_LDFLAGS}
 all: all-am
 
@@ -327,7 +322,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/idjcmixer-kvpparse.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/idjcmixer-mp3dec.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/idjcmixer-mp3tagread.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/idjcmixer-mp4tag.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/idjcmixer-ogg_flac_dec.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/idjcmixer-ogg_speex_dec.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/idjcmixer-ogg_vorbis_dec.Po at am__quote@
@@ -450,20 +444,6 @@ idjcmixer-xlplayer.obj: xlplayer.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(idjcmixer_CFLAGS) $(CFLAGS) -c -o idjcmixer-xlplayer.obj `if test -f 'xlplayer.c'; then $(CYGPATH_W) 'xlplayer.c'; else $(CYGPATH_W) '$(srcdir)/xlplayer.c'; fi`
 
-idjcmixer-mp4tag.o: mp4tag.c
- at am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(idjcmixer_CFLAGS) $(CFLAGS) -MT idjcmixer-mp4tag.o -MD -MP -MF "$(DEPDIR)/idjcmixer-mp4tag.Tpo" -c -o idjcmixer-mp4tag.o `test -f 'mp4tag.c' || echo '$(srcdir)/'`mp4tag.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/idjcmixer-mp4tag.Tpo" "$(DEPDIR)/idjcmixer-mp4tag.Po"; else rm -f "$(DEPDIR)/idjcmixer-mp4tag.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='mp4tag.c' object='idjcmixer-mp4tag.o' libtool=no @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(idjcmixer_CFLAGS) $(CFLAGS) -c -o idjcmixer-mp4tag.o `test -f 'mp4tag.c' || echo '$(srcdir)/'`mp4tag.c
-
-idjcmixer-mp4tag.obj: mp4tag.c
- at am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(idjcmixer_CFLAGS) $(CFLAGS) -MT idjcmixer-mp4tag.obj -MD -MP -MF "$(DEPDIR)/idjcmixer-mp4tag.Tpo" -c -o idjcmixer-mp4tag.obj `if test -f 'mp4tag.c'; then $(CYGPATH_W) 'mp4tag.c'; else $(CYGPATH_W) '$(srcdir)/mp4tag.c'; fi`; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/idjcmixer-mp4tag.Tpo" "$(DEPDIR)/idjcmixer-mp4tag.Po"; else rm -f "$(DEPDIR)/idjcmixer-mp4tag.Tpo"; exit 1; fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='mp4tag.c' object='idjcmixer-mp4tag.obj' libtool=no @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(idjcmixer_CFLAGS) $(CFLAGS) -c -o idjcmixer-mp4tag.obj `if test -f 'mp4tag.c'; then $(CYGPATH_W) 'mp4tag.c'; else $(CYGPATH_W) '$(srcdir)/mp4tag.c'; fi`
-
 idjcmixer-compressor.o: compressor.c
 @am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(idjcmixer_CFLAGS) $(CFLAGS) -MT idjcmixer-compressor.o -MD -MP -MF "$(DEPDIR)/idjcmixer-compressor.Tpo" -c -o idjcmixer-compressor.o `test -f 'compressor.c' || echo '$(srcdir)/'`compressor.c; \
 @am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/idjcmixer-compressor.Tpo" "$(DEPDIR)/idjcmixer-compressor.Po"; else rm -f "$(DEPDIR)/idjcmixer-compressor.Tpo"; exit 1; fi
diff --git a/c/agc.c b/c/agc.c
index 2c1e970..1988e36 100644
--- a/c/agc.c
+++ b/c/agc.c
@@ -470,7 +470,7 @@ void agc_free(struct agc *s)
 
 void agc_valueparse(struct agc *s, char *param)
    {
-   char *save, *key, *value;
+   char *save = NULL, *key, *value;
 
    key = strtok_r(param, "=", &save);
    value = strtok_r(NULL, "=", &save);
diff --git a/c/audio_feed.c b/c/audio_feed.c
index 14f0c6a..2ac1c37 100644
--- a/c/audio_feed.c
+++ b/c/audio_feed.c
@@ -17,6 +17,7 @@
 #   If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "../config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -69,7 +70,12 @@ static int jack_process_callback(jack_nframes_t n_frames, void *arg)
 
 static void custom_jack_error_callback(const char *message)
    {
-   fprintf(stderr, "jack: %s\n", message);
+   fprintf(stderr, "jack error: %s\n", message);
+   }
+
+static void custom_jack_info_callback(const char *message)
+   {
+   fprintf(stderr, "jack info: %s\n", message);
    }
 
 static void jack_shutdown_callback()
@@ -102,6 +108,9 @@ struct audio_feed *audio_feed_init(struct threads_info *ti)
       }
    self->threads_info = ti;
    jack_set_error_function(custom_jack_error_callback);
+#ifdef HAVE_JACK_SET_INFO_FUNCTION
+   jack_set_info_function(custom_jack_info_callback);
+#endif
 
    if (!(self->jack_h = jack_client_open(self->jack_client_name, JackUseExactName | JackServerName, NULL, getenv("IDJC_JACK_SERVER"))))
       {
diff --git a/c/avcodecdecode.c b/c/avcodecdecode.c
index bd11c44..a9cbbfe 100644
--- a/c/avcodecdecode.c
+++ b/c/avcodecdecode.c
@@ -97,6 +97,7 @@ static void avcodecdecode_init(struct xlplayer *xlplayer)
          avcodecdecode_eject(xlplayer);
          xlplayer->playmode = PM_STOPPED;
          xlplayer->command = CMD_COMPLETE;
+         return;
          }
       if ((xlplayer->src_state = src_new(xlplayer->rsqual, self->c->channels, &src_error)), src_error)
          {
@@ -109,18 +110,22 @@ static void avcodecdecode_init(struct xlplayer *xlplayer)
          return;
          }
       }
+fprintf(stderr, "avcodecdecode_init: completed\n");
    }
    
 static void avcodecdecode_play(struct xlplayer *xlplayer)
    {
    struct avcodecdecode_vars *self = xlplayer->dec_data;
-   AVPacket pkt;
-   int size, out_size, len, frames, channels = self->c->channels;
+   AVPacket pkt, pktcopy;
+   int size, out_size, len, frames, channels = self->c->channels, ret;
    uint8_t *inbuf_ptr;
    SRC_DATA *src_data = &xlplayer->src_data;
    
-   if (av_read_frame(self->ic, &pkt) < 0 || (size = pkt.size) == 0)
+   if ((ret = av_read_frame(self->ic, &pkt)) < 0 || (size = pkt.size) == 0)
       {
+      if (pkt.data)
+         av_free_packet(&pkt);
+
       if (self->resample)	/* flush the resampler */
          {
          src_data->end_of_input = TRUE;
@@ -138,33 +143,44 @@ static void avcodecdecode_play(struct xlplayer *xlplayer)
       return;
       }
    inbuf_ptr = pkt.data;
-   
-   if (pkt.stream_index != self->stream)	/* discard video and audio not from the first audio stream */
+   pktcopy = pkt;
+
+   if (pkt.stream_index != self->stream)
       {
       if (pkt.data)
          av_free_packet(&pkt);
       return;
       }
-   
+
    while(size > 0 && xlplayer->command != CMD_EJECT)
       {
       out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
       pthread_mutex_lock(&mutex);
-#ifdef DECODE_AUDIO_2
-      len = avcodec_decode_audio2(self->c, (short *)self->outbuf, &out_size, inbuf_ptr, size);
+#ifdef DECODE_AUDIO_3
+      len = avcodec_decode_audio3(self->c, (short *)self->outbuf, &out_size, &pktcopy);
 #else
-      len = avcodec_decode_audio(self->c, (short *)self->outbuf, &out_size, inbuf_ptr, size);
+      len = avcodec_decode_audio2(self->c, (short *)self->outbuf, &out_size, inbuf_ptr, size);
 #endif
       pthread_mutex_unlock(&mutex);
       frames = (out_size >> 1) / channels;
 
       if (len < 0)
+         {
+         fprintf(stderr, "avcodecdecode_play: error during decode\n");
          break;
+         }
+
+      pktcopy.data += len;
+      pktcopy.size -= len;
+      inbuf_ptr += len;
+      size -= len;
+
       if (out_size <= 0)
+         {
          continue;
+         }
 
       xlplayer_make_audio_to_float(xlplayer, self->floatsamples, self->outbuf, frames, 16, channels); 
-      
       if (self->resample)
          {
          src_data->input_frames = frames;
@@ -178,7 +194,6 @@ static void avcodecdecode_play(struct xlplayer *xlplayer)
          }
       else
          xlplayer_demux_channel_data(xlplayer, self->floatsamples, frames, channels, 1.f);
-      
       if (self->drop > 0)
          self->drop -= frames / (float)xlplayer->samplerate;
       else
@@ -187,17 +202,16 @@ static void avcodecdecode_play(struct xlplayer *xlplayer)
             xlplayer_write_channel_data(xlplayer);
             } while(xlplayer->write_deferred && xlplayer->command != CMD_EJECT);
          }
-
-      size -= len;
-      inbuf_ptr += len;
-      if (pkt.data)
-         av_free_packet(&pkt);
       }
+
+   if (pkt.data)
+      av_free_packet(&pkt);
    }
    
 int avcodecdecode_reg(struct xlplayer *xlplayer)
    {
    struct avcodecdecode_vars *self;
+   int error;
    
    pthread_once(&once_control, once_init);
    if (!(xlplayer->dec_data = self = calloc(1, sizeof (struct avcodecdecode_vars))))
@@ -254,9 +268,9 @@ int avcodecdecode_reg(struct xlplayer *xlplayer)
       }
    pthread_mutex_unlock(&mutex);
     
-   self->outbuf = malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE);
+   error = posix_memalign((void *)&self->outbuf, 64, AVCODEC_MAX_AUDIO_FRAME_SIZE);
    self->floatsamples = malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE * 2);
-   if (!self->outbuf || !self->floatsamples)
+   if (error || !self->floatsamples)
       {
       fprintf(stderr, "avcodecdecode_reg: malloc failure\n");
       avcodecdecode_eject(xlplayer);
@@ -267,6 +281,8 @@ int avcodecdecode_reg(struct xlplayer *xlplayer)
    xlplayer->dec_play = avcodecdecode_play;
    xlplayer->dec_eject = avcodecdecode_eject;
    
+fprintf(stderr, "avcodecdecode_reg: registered\n");
+
    return ACCEPTED;
    }
 
diff --git a/c/avcodecdecode.h b/c/avcodecdecode.h
index b65c1fe..7f96f0c 100644
--- a/c/avcodecdecode.h
+++ b/c/avcodecdecode.h
@@ -22,20 +22,8 @@
 #ifdef HAVE_AVCODEC
 #ifdef HAVE_AVFORMAT
 
-#ifdef HAVE_LIBAVCODEC_AVCODEC_H
 #include <libavcodec/avcodec.h>
-#else
-#ifdef HAVE_FFMPEG_AVCODEC_H
-#include <ffmpeg/avcodec.h>
-#endif /* FFMPEG_AVCODEC_H */
-#endif /* LIBAVCODEC_AVCODEC_H */
-#ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
 #include <libavformat/avformat.h>
-#else
-#ifdef HAVE_FFMPEG_AVFORMAT_H
-#include <ffmpeg/avformat.h>
-#endif /* FFMPEG_AVFORMAT_H */
-#endif /* LIBAVFORMAT_AVFORMAT_H */
 
 #include "xlplayer.h"
 
diff --git a/c/dyn_lame.c b/c/dyn_lame.c
index 7d7f0fe..e29c9c0 100644
--- a/c/dyn_lame.c
+++ b/c/dyn_lame.c
@@ -57,27 +57,31 @@ int dyn_lame_init()
    {
    char *error;
 
-   handle = dlopen("libmp3lame.so", RTLD_LAZY);
+   (handle = dlopen("libmp3lame.so", RTLD_LAZY)) ||
+   (handle = dlopen("libmp3lame.dylib", RTLD_LAZY)) ||
+   (handle = dlopen("liblame.so", RTLD_LAZY)) ||
+   (handle = dlopen("liblame.dylib", RTLD_LAZY));
+
    if (!handle)
       {
-      fprintf(stderr, "failed to locate libmp3lame.so\n");
+      fprintf(stderr, "failed to locate lib[mp3]lame dynamic library\n");
       return 0;
       }
    dlerror();
 
-   init = dlsym(handle, "lame_init");
-   encode_flush_nogap = dlsym(handle, "lame_encode_flush_nogap");
-   set_num_channels = dlsym(handle, "lame_set_num_channels");
-   set_brate = dlsym(handle, "lame_set_brate");
-   set_in_samplerate = dlsym(handle, "lame_set_in_samplerate");
-   set_out_samplerate = dlsym(handle, "lame_set_out_samplerate");
-   set_mode = dlsym(handle, "lame_set_mode");
-   set_quality = dlsym(handle, "lame_set_quality");
-   set_free_format = dlsym(handle, "lame_set_free_format");
-   set_bWriteVbrTag = dlsym(handle, "lame_set_bWriteVbrTag");
-   init_params = dlsym(handle, "lame_init_params");
-   close = dlsym(handle, "lame_close");
-   encode_buffer_float = dlsym(handle, "lame_encode_buffer_float");
+   (init = dlsym(handle, "lame_init")) &&
+   (encode_flush_nogap = dlsym(handle, "lame_encode_flush_nogap")) &&
+   (set_num_channels = dlsym(handle, "lame_set_num_channels")) &&
+   (set_brate = dlsym(handle, "lame_set_brate")) &&
+   (set_in_samplerate = dlsym(handle, "lame_set_in_samplerate")) &&
+   (set_out_samplerate = dlsym(handle, "lame_set_out_samplerate")) &&
+   (set_mode = dlsym(handle, "lame_set_mode")) &&
+   (set_quality = dlsym(handle, "lame_set_quality")) &&
+   (set_free_format = dlsym(handle, "lame_set_free_format")) &&
+   (set_bWriteVbrTag = dlsym(handle, "lame_set_bWriteVbrTag")) &&
+   (init_params = dlsym(handle, "lame_init_params")) &&
+   (close = dlsym(handle, "lame_close")) &&
+   (encode_buffer_float = dlsym(handle, "lame_encode_buffer_float"));
 
    if ((error = dlerror()))
       {
diff --git a/c/dyn_mad.c b/c/dyn_mad.c
index 261cef4..1aec3d6 100644
--- a/c/dyn_mad.c
+++ b/c/dyn_mad.c
@@ -47,22 +47,24 @@ int dyn_mad_init()
    {
    char *error;
 
-   handle = dlopen("libmad.so", RTLD_LAZY);
+   (handle = dlopen("libmad.so", RTLD_LAZY)) ||
+   (handle = dlopen("libmad.dylib", RTLD_LAZY));
+
    if (!handle)
       {
-      fprintf(stderr, "failed to locate libmad.so\n");
+      fprintf(stderr, "failed to locate libmad dynamic libraryn");
       return 0;
       }
    dlerror();
 
-   frame_decode = dlsym(handle, "mad_frame_decode");
-   stream_buffer = dlsym(handle, "mad_stream_buffer");
-   stream_finish = dlsym(handle, "mad_stream_finish");
-   frame_finish = dlsym(handle, "mad_frame_finish");
-   synth_init = dlsym(handle, "mad_synth_init");
-   stream_init = dlsym(handle, "mad_stream_init");
-   frame_init = dlsym(handle, "mad_frame_init");
-   synth_frame = dlsym(handle, "mad_synth_frame");
+   (frame_decode = dlsym(handle, "mad_frame_decode")) &&
+   (stream_buffer = dlsym(handle, "mad_stream_buffer")) &&
+   (stream_finish = dlsym(handle, "mad_stream_finish")) &&
+   (frame_finish = dlsym(handle, "mad_frame_finish")) &&
+   (synth_init = dlsym(handle, "mad_synth_init")) &&
+   (stream_init = dlsym(handle, "mad_stream_init")) &&
+   (frame_init = dlsym(handle, "mad_frame_init")) &&
+   (synth_frame = dlsym(handle, "mad_synth_frame"));
 
    if ((error = dlerror()))
       {
diff --git a/c/encoder.c b/c/encoder.c
index 34cb64e..7b53c97 100644
--- a/c/encoder.c
+++ b/c/encoder.c
@@ -1,6 +1,6 @@
 /*
 #   encoder.c: the encoder framework for the streaming module of idjc
-#   Copyright (C) 2007 Stephen Fairchild (s-fairchild at users.sourceforge.net)
+#   Copyright (C) 2007-2009 Stephen Fairchild (s-fairchild at users.sourceforge.net)
 #
 #   This program is free software: you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
@@ -92,6 +92,13 @@ static int encoder_get_resample_mode(char *rm_string)
 
 static void encoder_free_input_ringbuffers(struct encoder *self)
    {
+   struct timespec ms10 = { 0, 10000000 };
+   
+   if (self->jack_dataflow_control == JD_ON)
+      self->jack_dataflow_control = JD_FLUSH;
+   while (self->jack_dataflow_control != JD_OFF)
+      nanosleep(&ms10, NULL);
+   
    if (self->input_rb[0])
       jack_ringbuffer_free(self->input_rb[0]);
    if (self->input_rb[1])
@@ -99,31 +106,34 @@ static void encoder_free_input_ringbuffers(struct encoder *self)
    self->input_rb[0] = self->input_rb[1] = NULL;
    }
 
-static int encoder_unlink(struct encoder *self)
+static void encoder_free_resampler(struct encoder *self)
    {
-   struct timespec ms10 = { 0, 10000000 };
    int i;
+   
+   for (i = 0; i < 2; i++)
+      if (self->src_state[i])
+         {
+         src_delete(self->src_state[i]);
+         self->src_state[i] = NULL;
+         }
+   }
 
-   if (!self->run_request_f)
-      {
-      fprintf(stderr, "encoder_unlink: run_request_f was unset when this function was called\n");
-      return FAILED;
-      }
-   self->run_request_f = FALSE;		/* tell the encoder to make an orderly exit */
-   fprintf(stderr, "encoder_unlink: waiting for encoder to finish\n");
+static void encoder_plugin_terminate(struct encoder *self)
+   {
+   struct timespec ms10 = { 0, 10000000 };
+      
+   self->run_request_f = FALSE;
+   if (self->encoder_state != ES_STOPPED)
+      fprintf(stderr, "encoder_plugin_terminate: waiting for encoder to finish\n");
    while (self->encoder_state != ES_STOPPED)
       nanosleep(&ms10, NULL);
-   if (self->jack_dataflow_control != JD_OFF)
-      {
-      self->jack_dataflow_control = JD_FLUSH;
-      while(self->jack_dataflow_control == JD_FLUSH)
-         nanosleep(&ms10, NULL);
-      }
+   }
+
+static void encoder_unlink(struct encoder *self)
+   {
+   encoder_plugin_terminate(self);
    encoder_free_input_ringbuffers(self);
-   if (self->resample_f)
-      for (i = 0; i < self->n_channels; i++)
-         src_delete(self->src_state[i]);
-   return SUCCEEDED;
+   encoder_free_resampler(self);
    }
 
 static long encoder_input_rb_mono_downmix(jack_ringbuffer_t **rb, float *bptr, int max_samples)
@@ -567,19 +577,7 @@ int encoder_start(struct threads_info *ti, struct universal_vars *uv, void *othe
       return SUCCEEDED;
       }
    failed:
-   self->run_request_f = FALSE;
-   while (self->encoder_state != ES_STOPPED)
-      nanosleep(&ms10, NULL);
-   if (self->jack_dataflow_control != JD_OFF)
-      {
-      self->jack_dataflow_control = JD_FLUSH;
-      while (self->jack_dataflow_control != JD_OFF)
-         nanosleep(&ms10, NULL);
-      }
-   encoder_free_input_ringbuffers(self);
-   if (self->resample_f)
-      for (i = 0; i < self->n_channels; i++)
-         src_delete(self->src_state[i]);
+   encoder_unlink(self);
    fprintf(stderr, "encoder_start: failed to start the encoder\n");
    return FAILED;
    }
@@ -588,11 +586,7 @@ int encoder_stop(struct threads_info *ti, struct universal_vars *uv, void *other
    {
    struct encoder *self = ti->encoder[uv->tab];
    
-   if (!encoder_unlink(self))
-      {
-      fprintf(stderr, "encoder_stop: failed to stop encoder\n");
-      return FAILED;
-      }
+   encoder_unlink(self);
    if (self->output_chain)
       fprintf(stderr, "encoder_stop: function has been called with encoder_op objects still attached\n");
    fprintf(stderr, "encoder_stop: encoder is stopped\n");
@@ -603,10 +597,8 @@ int encoder_update(struct threads_info *ti, struct universal_vars *uv, void *oth
    {
    struct encoder *self = ti->encoder[uv->tab];
    
-   if (!encoder_unlink(self))
-      return FAILED;
+   encoder_unlink(self);
    return encoder_start(ti, uv, other);
-   return SUCCEEDED;
    }
  
 int encoder_new_metadata(struct threads_info *ti, struct universal_vars *uv, void *other)
@@ -739,9 +731,5 @@ void encoder_destroy(struct encoder *self)
       free(self->metaformat);
    if (self->metaformat_mp3)
       free(self->metaformat_mp3);
-   if (self->input_rb[0])
-      jack_ringbuffer_free(self->input_rb[0]);
-   if (self->input_rb[1])
-      jack_ringbuffer_free(self->input_rb[1]);
    free(self);
    }
diff --git a/c/encoder.h b/c/encoder.h
index 4bf8197..75823fe 100644
--- a/c/encoder.h
+++ b/c/encoder.h
@@ -1,6 +1,6 @@
 /*
 #   encoder.h: the encoder for the streaming module of idjc
-#   Copyright (C) 2007 Stephen Fairchild (s-fairchild at users.sourceforge.net)
+#   Copyright (C) 2007-2009 Stephen Fairchild (s-fairchild at users.sourceforge.net)
 #
 #   This program is free software: you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
diff --git a/c/id3.c b/c/id3.c
index 1ec0c07..186963e 100644
--- a/c/id3.c
+++ b/c/id3.c
@@ -1,5 +1,5 @@
 /*
-#   id3.c: the id3 tag reading/writing part of idjc
+#   id3.c: generater of id3 tags for the recorder - emphasis on chapter tags
 #   Copyright (C) 2007 Stephen Fairchild (s-fairchild at users.sourceforge.net)
 #
 #   This program is free software: you can redistribute it and/or modify
@@ -111,7 +111,7 @@ static int id3_compile_text_frame(struct id3_frame *ptr, int embedded_size)
    dptr = ptr->data;
    body = calloc(1, body_size = strlen(dptr->text) + 1 + dptr->null_terminator);
    body[0] = dptr->text_encoding;
-   memcpy(body + 1, dptr->text, body_size - dptr->null_terminator);
+   memcpy(body + 1, dptr->text, body_size - 1 - dptr->null_terminator);
    if (!(ptr->compiled_data = malloc(body_size + 10)))
       {
       fprintf(stderr, "id3_compile_text_frame: malloc failure\n");
diff --git a/c/idjcmixer.c b/c/idjcmixer.c
index 6871ce1..fd4bb10 100644
--- a/c/idjcmixer.c
+++ b/c/idjcmixer.c
@@ -40,7 +40,6 @@
 #include "compressor.h"
 #include "xlplayer.h"
 #include "ialloc.h"
-#include "mp4tag.h"
 #include "speextag.h"
 #include "sndfileinfo.h"
 #include "avcodecdecode.h"
@@ -53,7 +52,7 @@
 #define FALSE 0
 
 /* playlength of ring buffer contents */
-#define RB_SIZE 1.0
+#define RB_SIZE 10.0
 /* number of samples in the fade (ring) buffer */
 #define FB_SIZE (RB_SIZE * sr)
 
@@ -88,6 +87,8 @@ int mic_filter;
 /* value of the stream mon. button */
 int stream_monitor = 0;
 /* when this is set the end of track alarm is started */
+int eot_alarm_set = 0;
+/* set when end of track alarm is active */
 int eot_alarm_f = 0;
 /* threshold values for a premature indicator that a player is about to finish */
 int jingles_samples_cutoff;
@@ -122,6 +123,8 @@ int mic_agc;
 struct agc *agc_left, *agc_right;
 /* flag for mp3 decode capability */
 int have_mad;
+/* size of the fade buffer */
+int fb_size;
 
 /* part of CTRL+C handling */
 sigset_t mixersigset;
@@ -221,19 +224,21 @@ char *mixer_string, *compressor_string, *gate_string, *microphone_string;
 char *normalizer_string, *new_mic_string;
 char *micl, *micr, *auxl, *auxr, *audl, *audr, *strl, *strr, *action;
 char *dol, *dor, *dil, *dir;
-char *oggpathname, *sndfilepathname, *mp4pathname, *mp4taglist, *avformatpathname, *speexpathname, *speextaglist, *speexcreatedby;
+char *oggpathname, *sndfilepathname, *avformatpathname, *speexpathname, *speextaglist, *speexcreatedby;
 char *playerpathname, *seek_s, *size, *playerplaylist, *loop, *resamplequality;
-char *agc_param;
+char *agc_param, *fade_mode;
+char *rg_db;
 
 /* dictionary look-up type thing used by the parse routine */
 struct kvpdict kvpdict[] = {
-	 { "PLRP", &playerpathname },		/* The media-file pathname for playback */
-         { "SEEK", &seek_s },			/* Playback initial seek time in seconds */
-         { "SIZE", &size },			/* Size of the file in seconds */
-         { "PLPL", &playerplaylist },		/* A playlist for the media players */
-         { "LOOP", &loop },			/* play in a loop */
-         { "MIXR", &mixer_string },		/* Control strings */
-         { "COMP", &compressor_string },	/* packed full of data */
+         { "PLRP", &playerpathname },   /* The media-file pathname for playback */
+         { "RGDB", &rg_db },            /* Replay Gain volume level controlled at the player end */
+         { "SEEK", &seek_s },           /* Playback initial seek time in seconds */
+         { "SIZE", &size },             /* Size of the file in seconds */
+         { "PLPL", &playerplaylist },   /* A playlist for the media players */
+         { "LOOP", &loop },             /* play in a loop */
+         { "MIXR", &mixer_string },     /* Control strings */
+         { "COMP", &compressor_string },/* packed full of data */
          { "GATE", &gate_string },
          { "MICS", &microphone_string },
          { "NORM", &normalizer_string },
@@ -250,12 +255,11 @@ struct kvpdict kvpdict[] = {
          { "DOR", &dor   },
          { "DIL", &dil   },
          { "DIR", &dir   },
+         { "FADE", &fade_mode },
          { "OGGP", &oggpathname },
-         { "MP4P", &mp4pathname },
          { "SPXP", &speexpathname },
          { "SNDP", &sndfilepathname },
          { "AVFP", &avformatpathname },
-         { "MP4T", &mp4taglist },
          { "SPXT", &speextaglist },
          { "SPXC", &speexcreatedby },
          { "RSQT", &resamplequality },
@@ -263,48 +267,6 @@ struct kvpdict kvpdict[] = {
          { "ACTN", &action },			/* Action to take */
          { "", NULL }};
 
-/* These two point to either sharp, mild, or NULL - optional mic hi-pass filter */   
-#if 0
-struct digital_filter *left_mic_filter;
-struct digital_filter *right_mic_filter;   
-
-/* variables for the various microphone filters */
-struct digital_filter *sharp_left_mic_filter;
-struct digital_filter *sharp_right_mic_filter;
-dfilter_t a_cheby100[] = { 1 , -4 , 6, -4, 1 };
-size_t a_cheby100_count = 5;
-dfilter_t b_cheby100[] = { 3.9418017792,-5.8274608161, 3.8294852689 ,-0.9438267667};
-size_t b_cheby100_count = 4;
-dfilter_t cheby100_filter_gain =1.029430476;
-
-struct digital_filter *mild_left_mic_filter;
-struct digital_filter *mild_right_mic_filter;
-dfilter_t a_butterworth90[] = { 1, -1 };
-size_t a_butterworth90_count = 2;
-dfilter_t b_butterworth90[] = { 0.9872586881 };
-size_t b_butterworth90_count = 1;
-dfilter_t butterworth90_filter_gain = 1.006411501;
-
-/* used for de-essing */
-struct digital_filter *ess_left_filter;
-struct digital_filter *ess_right_filter;
-dfilter_t a_ess8k12k[] = { 1, 0, -4, 0, 6, 0, -4, 0, 1 };
-size_t a_ess8k12k_count = 9;
-dfilter_t b_ess8k12k[] = { 1.0672882610,-3.4723263985,2.5984638141,-4.4589555851, 2.1983120838,-2.4940727230, 0.6389926185,-0.5067329547};
-size_t b_ess8k12k_count = 8;
-dfilter_t ess8k12k_gain = 5.472512765e+02;
- 
-/* used to produce a clean feed for the noisegate */
-struct digital_filter *ng_left_filter;
-struct digital_filter *ng_right_filter;
-dfilter_t a_ngbandpass[] = { 1, 0, -4, 0, 6, 0, -4, 0, 1 };
-size_t a_ngbandpasscount = 9;
-dfilter_t b_ngbandpass[] = { 7.0389284721, -21.9220056594, 39.5069302814, -45.1037888240, 33.4221059835, -15.7003351003, 4.2743904241, -0.5162255821 };
-size_t b_ngbandpasscount = 8;
-dfilter_t ngbandpassgain = 6.381624743e+02;
-#endif
-
-
 /* the rms filter currently in use */
 struct rms_calc *lm_rms_filter, *rm_rms_filter;
 
@@ -840,38 +802,38 @@ void process_audio(jack_nframes_t nframes)
          }
          /* end microphone mix */
 
-         if (plr_l->fadeindex != FB_SIZE)
+         if (plr_l->fadeindex < FB_SIZE)
             {
             lp_lc_fade = fade_table[plr_l->fadeindex] * *lplcpf++; 
             lp_rc_fade = fade_table[plr_l->fadeindex] * *lprcpf++;
-            plr_l->fadeindex++;
+            plr_l->fadeindex += plr_l->fadeoutstep;
             }
          else
             lp_lc_fade = lp_rc_fade = 0.0;
             
-         if (plr_r->fadeindex != FB_SIZE)
+         if (plr_r->fadeindex < FB_SIZE)
             {
             rp_lc_fade = fade_table[plr_r->fadeindex] * *rplcpf++; 
             rp_rc_fade = fade_table[plr_r->fadeindex] * *rprcpf++;
-            plr_r->fadeindex++;
+            plr_r->fadeindex += plr_r->fadeoutstep;
             }
          else
             rp_lc_fade = rp_rc_fade = 0.0;
          
-         if (plr_j->fadeindex != FB_SIZE)
+         if (plr_j->fadeindex < FB_SIZE)
             {
             jp_lc_fade = fade_table[plr_j->fadeindex] * *jplcpf++; 
             jp_rc_fade = fade_table[plr_j->fadeindex] * *jprcpf++;
-            plr_j->fadeindex++;
+            plr_j->fadeindex += plr_j->fadeoutstep;
             }
          else
             jp_lc_fade = jp_rc_fade = 0.0;
             
-         if (plr_i->fadeindex != FB_SIZE)
+         if (plr_i->fadeindex < FB_SIZE)
             {
             ip_lc_fade = fade_table[plr_i->fadeindex] * *iplcpf++; 
             ip_rc_fade = fade_table[plr_i->fadeindex] * *iprcpf++;
-            plr_i->fadeindex++;
+            plr_i->fadeindex += plr_i->fadeoutstep;
             }
          else
             ip_lc_fade = ip_rc_fade = 0.0;
@@ -1073,38 +1035,38 @@ void process_audio(jack_nframes_t nframes)
             /* No ducking */
             df = 1.0;
             
-            if (plr_l->fadeindex != FB_SIZE)
+            if (plr_l->fadeindex < FB_SIZE)
                {
                lp_lc_fade = fade_table[plr_l->fadeindex] * *lplcpf++; 
                lp_rc_fade = fade_table[plr_l->fadeindex] * *lprcpf++;
-               plr_l->fadeindex++;
+               plr_l->fadeindex += plr_l->fadeoutstep;
                }
             else
                lp_lc_fade = lp_rc_fade = 0.0;
                
-            if (plr_r->fadeindex != FB_SIZE)
+            if (plr_r->fadeindex < FB_SIZE)
                {
                rp_lc_fade = fade_table[plr_r->fadeindex] * *rplcpf++; 
                rp_rc_fade = fade_table[plr_r->fadeindex] * *rprcpf++;
-               plr_r->fadeindex++;
+               plr_r->fadeindex += plr_r->fadeoutstep;
                }
             else
                rp_lc_fade = rp_rc_fade = 0.0;
             
-            if (plr_j->fadeindex != FB_SIZE)
+            if (plr_j->fadeindex < FB_SIZE)
                {
                jp_lc_fade = fade_table[plr_j->fadeindex] * *jplcpf++; 
                jp_rc_fade = fade_table[plr_j->fadeindex] * *jprcpf++;
-               plr_j->fadeindex++;
+               plr_j->fadeindex += plr_j->fadeoutstep;
                }
             else
                jp_lc_fade = jp_rc_fade = 0.0;
-            
-            if (plr_i->fadeindex != FB_SIZE)
+               
+            if (plr_i->fadeindex < FB_SIZE)
                {
                ip_lc_fade = fade_table[plr_i->fadeindex] * *iplcpf++; 
                ip_rc_fade = fade_table[plr_i->fadeindex] * *iprcpf++;
-               plr_i->fadeindex++;
+               plr_i->fadeindex += plr_i->fadeoutstep;
                }
             else
                ip_lc_fade = ip_rc_fade = 0.0;
@@ -1311,42 +1273,42 @@ void process_audio(jack_nframes_t nframes)
                /* No ducking */
                df = 1.0;
                
-               if (plr_l->fadeindex != FB_SIZE)
+               if (plr_l->fadeindex < FB_SIZE)
                   {
                   lp_lc_fade = fade_table[plr_l->fadeindex] * *lplcpf++; 
                   lp_rc_fade = fade_table[plr_l->fadeindex] * *lprcpf++;
-                  plr_l->fadeindex++;
+                  plr_l->fadeindex += plr_l->fadeoutstep;
                   }
                else
                   lp_lc_fade = lp_rc_fade = 0.0;
                   
-               if (plr_r->fadeindex != FB_SIZE)
+               if (plr_r->fadeindex < FB_SIZE)
                   {
                   rp_lc_fade = fade_table[plr_r->fadeindex] * *rplcpf++; 
                   rp_rc_fade = fade_table[plr_r->fadeindex] * *rprcpf++;
-                  plr_r->fadeindex++;
+                  plr_r->fadeindex += plr_r->fadeoutstep;
                   }
                else
                   rp_lc_fade = rp_rc_fade = 0.0;
                
-               if (plr_j->fadeindex!= FB_SIZE)
+               if (plr_j->fadeindex < FB_SIZE)
                   {
                   jp_lc_fade = fade_table[plr_j->fadeindex] * *jplcpf++; 
                   jp_rc_fade = fade_table[plr_j->fadeindex] * *jprcpf++;
-                  plr_j->fadeindex++;
+                  plr_j->fadeindex += plr_j->fadeoutstep;
                   }
                else
                   jp_lc_fade = jp_rc_fade = 0.0;
-               
-               if (plr_i->fadeindex != FB_SIZE)
+                  
+               if (plr_i->fadeindex < FB_SIZE)
                   {
                   ip_lc_fade = fade_table[plr_i->fadeindex] * *iplcpf++; 
                   ip_rc_fade = fade_table[plr_i->fadeindex] * *iprcpf++;
-                  plr_i->fadeindex++;
+                  plr_i->fadeindex += plr_i->fadeoutstep;
                   }
                else
                   ip_lc_fade = ip_rc_fade = 0.0;
-               
+
                if (lmic_flux || rmic_flux || aux_flux)
                   update_mic_and_aux();		/* smooth mic rise and fall mute/unmute */
                
@@ -1558,42 +1520,42 @@ void process_audio(jack_nframes_t nframes)
                   }
                   /* end microphone mix */
                      
-                  if (plr_l->fadeindex != FB_SIZE)
+                  if (plr_l->fadeindex < FB_SIZE)
                      {
                      lp_lc_fade = fade_table[plr_l->fadeindex] * *lplcpf++; 
                      lp_rc_fade = fade_table[plr_l->fadeindex] * *lprcpf++;
-                     plr_l->fadeindex++;
+                     plr_l->fadeindex += plr_l->fadeoutstep;
                      }
                   else
                      lp_lc_fade = lp_rc_fade = 0.0;
                      
-                  if (plr_r->fadeindex != FB_SIZE)
+                  if (plr_r->fadeindex < FB_SIZE)
                      {
                      rp_lc_fade = fade_table[plr_r->fadeindex] * *rplcpf++; 
                      rp_rc_fade = fade_table[plr_r->fadeindex] * *rprcpf++;
-                     plr_r->fadeindex++;
+                     plr_r->fadeindex += plr_r->fadeoutstep;
                      }
                   else
                      rp_lc_fade = rp_rc_fade = 0.0;
                   
-                  if (plr_j->fadeindex!= FB_SIZE)
+                  if (plr_j->fadeindex < FB_SIZE)
                      {
                      jp_lc_fade = fade_table[plr_j->fadeindex] * *jplcpf++; 
                      jp_rc_fade = fade_table[plr_j->fadeindex] * *jprcpf++;
-                     plr_j->fadeindex++;
+                     plr_j->fadeindex += plr_j->fadeoutstep;
                      }
                   else
                      jp_lc_fade = jp_rc_fade = 0.0;
-
-                  if (plr_i->fadeindex != FB_SIZE)
+                     
+                  if (plr_i->fadeindex < FB_SIZE)
                      {
                      ip_lc_fade = fade_table[plr_i->fadeindex] * *iplcpf++; 
                      ip_rc_fade = fade_table[plr_i->fadeindex] * *iprcpf++;
-                     plr_i->fadeindex++;
+                     plr_i->fadeindex += plr_i->fadeoutstep;
                      }
                   else
                      ip_lc_fade = ip_rc_fade = 0.0;
-                  
+
                   if (lmic_flux || rmic_flux || aux_flux)
   	             update_mic_and_aux();	/* smooth mic rise and fall mute/unmute */
 
@@ -1863,7 +1825,7 @@ int main(int argc, char **argv)
    int i, new_left_pause, new_right_pause;
    static int old_lmic_on = 0, old_rmic_on = 0, old_aux_on = 0;
    jack_nframes_t nframes;
-   char *artist = NULL, *title = NULL;
+   char *artist = NULL, *title = NULL, *replaygain = NULL;
    double length;
    int sync = FALSE;
    int use_dsp;
@@ -1934,14 +1896,9 @@ int main(int argc, char **argv)
       					JackPortIsInput, 0);
 
    sr = jack_get_sample_rate(client);
+   fb_size = FB_SIZE;
    jingles_samples_cutoff = sr / 12;		/* A twelfth of a second early */
    player_samples_cutoff = sr * 0.25;		/* for gapless playback */
-      
-   if(!(xlplayer_create_fadein_lookup(0.07F, sr)))
-      {
-      printf("failed to create the fadein lookup table for xlplayer\n");
-      return 1;
-      }
 
    if(! ((plr_l = xlplayer_create(sr, RB_SIZE, "leftplayer", &jack_closed_f)) &&
          (plr_r = xlplayer_create(sr, RB_SIZE, "rightplayer", &jack_closed_f))))
@@ -2004,6 +1961,7 @@ int main(int argc, char **argv)
       plr_i->fadeindex = FB_SIZE;
       for (i = 0; i < FB_SIZE; i ++)
          fade_table[i] = pow10f(i / -20000.0 * 44100.0 / FB_SIZE);
+         fade_table[i] = powf(fade_table[i], 0.1f);
       }
 
    if (!((agc_left = agc_init(sr, 0.01161f)) && (agc_right = agc_init(sr, 0.01161f))))
@@ -2094,27 +2052,33 @@ int main(int argc, char **argv)
          agc_valueparse(agc_right, agc_param);
          }
 
+      if (!strcmp(action, "fademode_left"))
+         plr_l->fade_mode = atoi(fade_mode);
+         
+      if (!strcmp(action, "fademode_right"))
+         plr_r->fade_mode = atoi(fade_mode);
+
       if (!strcmp(action, "playleft"))
          {
-         fprintf(stdout, "context_id=%d\n", xlplayer_play(plr_l, playerpathname, atoi(seek_s), atoi(size)));
+         fprintf(stdout, "context_id=%d\n", xlplayer_play(plr_l, playerpathname, atoi(seek_s), atoi(size), atof(rg_db)));
          fflush(stdout);
          }
       if (!strcmp(action, "playright"))
          {
-         fprintf(stdout, "context_id=%d\n", xlplayer_play(plr_r, playerpathname, atoi(seek_s), atoi(size)));
+         fprintf(stdout, "context_id=%d\n", xlplayer_play(plr_r, playerpathname, atoi(seek_s), atoi(size), atof(rg_db)));
          fflush(stdout);
          }
       if (!strcmp(action, "playnoflushleft"))
          {
-         fprintf(stdout, "context_id=%d\n", xlplayer_play_noflush(plr_l, playerpathname, atoi(seek_s), atoi(size)));
+         fprintf(stdout, "context_id=%d\n", xlplayer_play_noflush(plr_l, playerpathname, atoi(seek_s), atoi(size), atof(rg_db)));
          fflush(stdout);
          }
       if (!strcmp(action, "playnoflushright"))
          {
-         fprintf(stdout, "context_id=%d\n", xlplayer_play_noflush(plr_r, playerpathname, atoi(seek_s), atoi(size)));
+         fprintf(stdout, "context_id=%d\n", xlplayer_play_noflush(plr_r, playerpathname, atoi(seek_s), atoi(size), atof(rg_db)));
          fflush(stdout);
          }
-      
+    
       if (!strcmp(action, "playmanyjingles"))
          {
          fprintf(stdout, "context_id=%d\n", xlplayer_playmany(plr_j, playerplaylist, loop[0]=='1'));
@@ -2158,9 +2122,9 @@ int main(int argc, char **argv)
       
       if (!strcmp(action, "ogginforequest"))
          {
-         if (oggdecode_get_metainfo(oggpathname, &artist, &title, &length))
+         if (oggdecode_get_metainfo(oggpathname, &artist, &title, &length, &replaygain))
             {
-            fprintf(stdout, "OIR:ARTIST=%s\nOIR:TITLE=%s\nOIR:LENGTH=%f\nOIR:end\n", artist, title, length);
+            fprintf(stdout, "OIR:ARTIST=%s\nOIR:TITLE=%s\nOIR:LENGTH=%f\nOIR:REPLAYGAIN_TRACK_GAIN=%s\nOIR:end\n", artist, title, length, replaygain);
             fflush(stdout);
             }
          else
@@ -2173,15 +2137,6 @@ int main(int argc, char **argv)
       if (!strcmp(action, "sndfileinforequest"))
          sndfileinfo(sndfilepathname);
 
-#ifdef HAVE_MP4V2
-      if (!strcmp(action, "mp4inforequest"))
-         mp4_file_info(mp4pathname);
-      if (!strcmp(action, "mp4readtagrequest"))
-         mp4_tag_read(mp4pathname);
-      if (!strcmp(action, "mp4writetagrequest"))
-         mp4_tag_write(mp4pathname, mp4taglist);
-#endif
-
 #ifdef HAVE_AVCODEC
 #ifdef HAVE_AVFORMAT
       if (!strcmp(action, "avformatinforequest"))
@@ -2253,12 +2208,14 @@ int main(int argc, char **argv)
                 ":%03d:%03d:%03d:%03d:%03d:%d:%1d%1d%1d%1d%1d:%1d%1d:%1d%1d%1d:%1d%1d%1d%1d:%1d:%1d:%1d:%1d:%1d:%f:%f:%1d:%f:%d:%d:%d:",
       		&volume, &crossfade, &jinglesvolume, &interludevol, &mixbackvol, &jingles_playing,
                 &left_stream, &left_audio, &right_stream, &right_audio, &stream_monitor,
-		&new_left_pause, &new_right_pause, &lmic_on, &rmic_on, &aux_on, &flush_left, &flush_right, &flush_jingles, &flush_interlude, &simple_mixer, &eot_alarm_f, &mixermode, &fadeout_f, &main_play, &(plr_l->newpbspeed), &(plr_r->newpbspeed), &speed_variance, &dj_audio_level, &crosspattern, &use_dsp, &twodblimit) !=32)
+		&new_left_pause, &new_right_pause, &lmic_on, &rmic_on, &aux_on, &flush_left, &flush_right, &flush_jingles, &flush_interlude, &simple_mixer, &eot_alarm_set, &mixermode, &fadeout_f, &main_play, &(plr_l->newpbspeed), &(plr_r->newpbspeed), &speed_variance, &dj_audio_level, &crosspattern, &use_dsp, &twodblimit) !=32)
 	    {
 	    fprintf(stderr, "mixer got bad mixer string\n");
 	    break;
 	    }
 
+         eot_alarm_f |= eot_alarm_set;
+
          plr_l->fadeout_f = plr_r->fadeout_f = plr_j->fadeout_f = plr_i->fadeout_f = fadeout_f;
 
          if (use_dsp != using_dsp)
@@ -2497,6 +2454,7 @@ int main(int argc, char **argv)
 	 fflush(stdout);
          }
       }
+   alarm(0);
    jack_client_close(client);
    client = NULL;
    agc_free(agc_left);
@@ -2523,7 +2481,6 @@ int main(int argc, char **argv)
    xlplayer_destroy(plr_r);
    xlplayer_destroy(plr_j);
    xlplayer_destroy(plr_i);
-   xlplayer_destroy_fadein_lookup();
    fprintf(stderr, "Mixer module has closed\n");
    return 0;
    }
diff --git a/c/mp3dec.c b/c/mp3dec.c
index c1baf96..4984279 100644
--- a/c/mp3dec.c
+++ b/c/mp3dec.c
@@ -22,6 +22,7 @@
 #include "gnusource.h"
 #include <stdio.h>
 #include <string.h>
+#include <math.h>
 #include <jack/jack.h>
 #ifdef DYN_MAD
 #include "mad.h"
@@ -38,14 +39,27 @@
 #define REJECTED 0
 
 #define BSIZ 16384
-#define MAD_SCALE ((float)(1L << MAD_F_SCALEBITS))
+#define MAD_SCALE ((float)(1L << (MAD_F_SCALEBITS - 18)))
 
 static int metadata_form[4] = { DM_JOINED_L1, DM_JOINED_UC, DM_JOINED_UCBE, DM_JOINED_U8 };
 
-static inline float scale(mad_fixed_t sample)
+static inline float scale(struct xlplayer *xlplayer, mad_fixed_t sample)
    {
-   return (float)sample / MAD_SCALE;
-   }
+   float ret;
+   
+   if (xlplayer->dither)
+      {
+      ret = floorf((float)sample / (float)(1L << (MAD_F_SCALEBITS - 18)));
+   
+      if (rand_r(&xlplayer->seed) < (RAND_MAX >> 1))
+         ret -= 1.0f;
+      if (rand_r(&xlplayer->seed) > (RAND_MAX >> 1))
+         ret += 1.0f;
+      return ret / 262144.0f;
+      }
+   else
+      return sample / (float)(1L << MAD_F_SCALEBITS);
+   }   
 
 static int mp3decode_get_frame(struct xlplayer *xlplayer)
    {
@@ -243,7 +257,7 @@ static void mp3decode_play(struct xlplayer *xlplayer)
    struct mad_pcm *pcm;
    jack_default_audio_sample_t *lp, *rp, *dp, gain;
    mad_fixed_t *left_ch, *right_ch, *lc, *rc;
-   int nchannels, nsamples, frame_code, pcmlength, toskip;
+   int nchannels, nsamples, frame_code, pcmlength, toskip, delay;
    SRC_DATA *src_data = &(xlplayer->src_data);
    struct chapter *chapter;
 
@@ -315,9 +329,9 @@ static void mp3decode_play(struct xlplayer *xlplayer)
          src_data->data_out = realloc(src_data->data_out, src_data->output_frames * nchannels * sizeof (float));
          for (nsamples = pcmlength; nsamples; nsamples--)
             {
-            *dp++ = scale(*(lc++));
+            *dp++ = scale(xlplayer, *(lc++));
             if (nchannels == 2)
-               *dp++ = scale(*(rc++));
+               *dp++ = scale(xlplayer, *(rc++));
             }
          if (src_process(xlplayer->src_state, src_data))
             {
@@ -348,9 +362,9 @@ static void mp3decode_play(struct xlplayer *xlplayer)
          while (nsamples--)
             {
             gain = xlplayer_get_next_gain(xlplayer);
-            *lp++ = gain * scale(*(lc++));
+            *lp++ = gain * scale(xlplayer, *(lc++));
             if (nchannels == 2)
-               *rp++ = gain * scale(*(rc++));
+               *rp++ = gain * scale(xlplayer, *(rc++));
             }
          if (nchannels == 1)
             memcpy(xlplayer->rightbuffer, xlplayer->leftbuffer, xlplayer->op_buffersize);
@@ -370,11 +384,12 @@ static void mp3decode_play(struct xlplayer *xlplayer)
    else
       xlplayer->playmode = PM_EJECTING;
 
-   chapter = mp3_tag_chapter_scan(&self->taginfo, xlplayer->play_progress_ms);
+   delay = xlplayer_calc_rbdelay(xlplayer);
+   chapter = mp3_tag_chapter_scan(&self->taginfo, xlplayer->play_progress_ms + delay);
    if (chapter && chapter != self->current_chapter)
       {
       self->current_chapter = chapter;
-      xlplayer_set_dynamic_metadata(xlplayer, metadata_form[chapter->encoding], "", "", chapter->text, 0);
+      xlplayer_set_dynamic_metadata(xlplayer, metadata_form[chapter->encoding], "", "", chapter->text, delay);
       }
    }
 
diff --git a/c/mp3tagread.c b/c/mp3tagread.c
index b89f09c..48ccae5 100644
--- a/c/mp3tagread.c
+++ b/c/mp3tagread.c
@@ -151,7 +151,17 @@ static int decode_tit2(struct mp3taginfo *ti, unsigned char *start, struct chapt
       fprintf(stderr, "decode_tit2: unsupported character encoding\n");
       goto bailout;
       }
-   if (!(chap->text = malloc(chap->length = us.size - 1)))
+   if (us.data[us.size - 1])  /* handle potential null termination */
+      {
+      chap->length = us.size - 1;
+      fprintf(stderr, "not null terminated\n");
+      }
+   else
+      {
+      chap->length = us.size - 2;
+      fprintf(stderr, "null terminated\n");
+      }
+   if (!(chap->text = calloc(1, chap->length + 1)))
       goto bailout;
    memcpy(chap->text, us.data + 1, chap->length);
    free(us.data);
diff --git a/c/mp4tag.c b/c/mp4tag.c
deleted file mode 100644
index 6847ddd..0000000
--- a/c/mp4tag.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
-#   mp4tag.c: reads/writes mp4 metadata and gets playback time
-#   Copyright (C) 2006 Stephen Fairchild (s-fairchild at users.sourceforge.net)
-#
-#   This program is free software: you can redistribute it and/or modify
-#   it under the terms of the GNU General Public License as published by
-#   the Free Software Foundation, either version 3 of the License, or
-#   (at your option) any later version.
-#
-#   This program is distributed in the hope that it will be useful,
-#   but WITHOUT ANY WARRANTY; without even the implied warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#   GNU General Public License for more details.
-#
-#   You should have received a copy of the GNU General Public License
-#   along with this program in the file entitled COPYING.
-#   If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "../config.h"
-#ifdef HAVE_MP4V2
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <mp4.h>
-#include "mp4tag.h"
-
-int mp4_file_info(char *pathname)
-   {
-   MP4FileHandle h;
-   char *artist;
-   char *name;
-   int duration;
-   
-   if (!(h = MP4Read(pathname, 0)))
-      {
-      fprintf(stderr, "failed to open file %s\n", pathname);
-      printf("idjcmixer: mp4fileinfo Not Valid\n");
-      fflush(stdout);
-      return 0;
-      }
-
-   if (MP4GetMetadataArtist(h, &artist) && artist != NULL)
-      {
-      fprintf(stderr, "artist=%s\n", artist);
-      printf("idjcmixer: mp4fileinfo artist=%s\n", artist);
-      free(artist);
-      }
-
-   if (MP4GetMetadataName(h, &name) && name != NULL)
-      {
-      fprintf(stderr, "title=%s\n", name);
-      printf("idjcmixer: mp4fileinfo title=%s\n", name);
-      free(name);
-      }
-
-   duration = MP4GetDuration(h) / MP4GetTimeScale(h);
-   fprintf(stderr, "duration = %d\n", duration);
-   printf("idjcmixer: mp4fileinfo length=%d\n"
-          "idjcmixer: mp4fileinfo end\n", duration);
-   fflush(stdout);
-   MP4Close(h);
-   return 1;
-   }
-
-int mp4_tag_read(char *pathname)
-   {
-   MP4FileHandle h;
-   char *s;
-   u_int16_t i1, i2;
-   char *header = "idjcmixer: mp4tagread ";
-
-   if (!(h = MP4Read(pathname, 0)))
-      {
-      fprintf(stderr, "failed to open file %s\n", pathname);
-      printf("idjcmixer: mp4fileinfo Not Valid\n");
-      fflush(stdout);
-      return 0;
-      }
-
-   if (MP4GetMetadataArtist(h, &s))
-      {
-      printf("%sartist=%s\n", header, s);
-      free(s);
-      }
-
-   if (MP4GetMetadataName(h, &s))
-      {
-      printf("%sname=%s\n", header, s);
-      free(s);
-      }
-
-   if (MP4GetMetadataAlbum(h, &s))
-      {
-      printf("%salbum=%s\n", header, s);
-      free(s);
-      }
-
-   if (MP4GetMetadataYear(h, &s))
-      {
-      printf("%syear=%s\n", header, s);
-      free(s);
-      }
-
-   if (MP4GetMetadataTrack(h, &i1, &i2))
-      {
-      if (i1)
-         printf("%stracknum=%u\n", header, i1);
-      if (i2)
-         printf("%stracktotal=%u\n", header, i2);
-      }
-
-   if (MP4GetMetadataGenre(h, &s))
-      {
-      printf("%sgenre=%s\n", header,s);
-      free(s);
-      }
-
-   if (MP4GetMetadataComment(h, &s))
-      {
-      printf("%scomment=%s\n", header, s);
-      free(s);
-      }
-
-   printf("idjcmixer: mp4tagread end\n");
-   fflush(stdout);
-   MP4Close(h);
-   return 1;
-   }
-
-int mp4_tag_write(char *pathname, char *taglist)
-   {
-   MP4FileHandle h;
-   char *saveptr, *k, *v;
-   int i, tracknum = 0, tracktotal = 0;
-
-   if (!(h = MP4Modify(pathname, 0, 0)))
-      {
-      fprintf(stderr, "failed to open file %s\n", pathname);
-      printf("idjcmixer: mp4fileinfo Not Valid\n");
-      fflush(stdout);
-      return 0;
-      }
-
-   for (i = 0; (k = strtok_r(i ? NULL : taglist, "=", &saveptr)) != '\0'; i++)
-      {
-      v = strtok_r(NULL, "\n", &saveptr);
-      if (!strcmp(k, "artist"))
-         {
-         if (*v)
-            MP4SetMetadataArtist(h, v);
-         else
-            MP4DeleteMetadataArtist(h);
-         }
-  
-      if (!strcmp(k, "name"))
-         {
-         if (*v)
-            MP4SetMetadataName(h, v);
-         else
-            MP4DeleteMetadataName(h);
-         }
-
-      if (!strcmp(k, "album"))
-         {
-         if (*v)
-            MP4SetMetadataAlbum(h, v);
-         else
-            MP4DeleteMetadataAlbum(h);
-         }
-
-      if (!strcmp(k, "year"))
-         {
-         if (*v)
-            MP4SetMetadataYear(h, v);
-         else
-            MP4DeleteMetadataYear(h);
-         }
-
-      if (!strcmp(k, "tracknum"))
-         tracknum = atoi(v);
-
-      if (!strcmp(k, "tracktotal"))
-         tracktotal = atoi(v);
-
-      if (!strcmp(k, "genre"))
-         {
-         if (*v)
-            MP4SetMetadataGenre(h, v);
-         else
-            MP4DeleteMetadataGenre(h);
-         }
-
-      if (!strcmp(k, "comment"))
-         {
-         if (*v)
-            MP4SetMetadataComment(h, v);
-         else
-            MP4DeleteMetadataComment(h);
-         }
-      }
-
-   if (tracknum < 0)
-      tracknum = 0;
-   if (tracktotal < 0)
-      tracktotal = 0;
-
-   if (tracknum > 0 || tracktotal > 0)
-      MP4SetMetadataTrack(h, tracknum, tracktotal);
-   else
-      MP4DeleteMetadataTrack(h);
-
-   MP4Close(h);
-   return 1;
-   }
-
-#endif
-
diff --git a/c/mp4tag.h b/c/mp4tag.h
deleted file mode 100644
index 3cb6fa6..0000000
--- a/c/mp4tag.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-#   mp4tag.h: reads/writes mp4 metadata and gets playback time
-#   Copyright (C) 2006 Stephen Fairchild (s-fairchild at users.sourceforge.net)
-#
-#   This program is free software: you can redistribute it and/or modify
-#   it under the terms of the GNU General Public License as published by
-#   the Free Software Foundation, either version 3 of the License, or
-#   (at your option) any later version.
-#
-#   This program is distributed in the hope that it will be useful,
-#   but WITHOUT ANY WARRANTY; without even the implied warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#   GNU General Public License for more details.
-#
-#   You should have received a copy of the GNU General Public License
-#   along with this program in the file entitled COPYING.
-#   If not, see <http://www.gnu.org/licenses/>.
-*/
-
-int mp4_file_info(char *pathname);
-int mp4_tag_read(char *pathname);
-int mp4_tag_write(char *pathname, char *taglist);
diff --git a/c/oggdec.c b/c/oggdec.c
index eecc57b..de54de3 100644
--- a/c/oggdec.c
+++ b/c/oggdec.c
@@ -1,6 +1,6 @@
 /*
 #   oggdec.c: ogg file parser for xlplayer
-#   Copyright (C) 2008 Stephen Fairchild (s-fairchild at users.sourceforge.net)
+#   Copyright (C) 2008-2009 Stephen Fairchild (s-fairchild at users.sourceforge.net)
 #
 #   This program is free software: you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
@@ -81,11 +81,57 @@ static int vorbis_get_samplerate(struct oggdec_vars *self)  /* attempt to get AR
    vorbis_info vi;
    vorbis_comment vc;
    int samplerate;
-   char *tmp;
 
    vorbis_info_init(&vi);
    vorbis_comment_init(&vc);
 
+   void obtain_tag_info(char *name, char **target, int multiple)
+      {
+      int tags = vorbis_comment_query_count(&vc, name);
+      int size, i;
+
+      if (tags == 0)
+         {
+         *target = strdup("");
+         return;
+         }
+
+      if (tags == 1)
+         {
+         *target = strdup(vorbis_comment_query(&vc, name, 0));
+         return;
+         }
+
+      if (multiple)
+         {
+         /* calculate the space needed */
+         size = tags;
+         for (i = 0; i < tags; i++)
+            size += strlen(vorbis_comment_query(&vc, name, i));
+
+         if (!(*target = malloc(size)))
+            {
+            *target = strdup("");
+            fprintf(stderr, "vorbis_get_samplerate: malloc failure\n");
+            return;
+            }
+         *target[0] = '\0';
+
+         /* collect a slash separated list of tags */
+         for (i = 0; i < tags; i++)
+            {
+            strcat(*target, vorbis_comment_query(&vc, name, i));
+            if (i < tags - 1)
+               strcat(*target, "/");
+            }
+         }
+      else
+         {
+         /* grab the last comment when only a single will do */
+         *target = strdup(vorbis_comment_query(&vc, name, tags - 1));
+         }
+      }
+
    /* enforce that first header yields the sample rate, that granule pos for the header is zero and */
    /* that the third and final header finishes on a page boundary */
    if (oggdec_get_next_packet(self) && vorbis_synthesis_headerin(&vi, &vc, &self->op) >= 0 && vi.rate &&
@@ -97,16 +143,9 @@ static int vorbis_get_samplerate(struct oggdec_vars *self)  /* attempt to get AR
       samplerate = self->samplerate[self->ix] = vi.rate;
       self->channels[self->ix] = vi.channels;
       
-      /* Upper case tag names are the standard form but lower case tags also exist in the wild */
-      if ((tmp = vorbis_comment_query(&vc, "ARTIST", 0)) || (tmp = vorbis_comment_query(&vc, "artist", 0)))
-         self->artist[self->ix] = strdup(tmp);
-      if ((tmp = vorbis_comment_query(&vc, "TITLE", 0))  || (tmp = vorbis_comment_query(&vc, "title", 0)))
-         self->title[self->ix] = strdup(tmp);
-      
-      if (self->artist[self->ix] == NULL)
-         self->artist[self->ix] = strdup("");
-      if (self->title[self->ix] == NULL)
-         self->title[self->ix] = strdup("");
+      obtain_tag_info("artist", &self->artist[self->ix], TRUE);
+      obtain_tag_info("title", &self->title[self->ix], TRUE);
+      obtain_tag_info("replaygain_track_gain", &self->replaygain[self->ix], FALSE);
       }
    else
       {
@@ -236,7 +275,7 @@ static void oggflac_metadata_callback(const FLAC__StreamDecoder *decoder, const
    
    int match(char *t, char *comment)
       {
-      return !strncmp(t, comment, strlen(t));
+      return !strncasecmp(t, comment, strlen(t));
       }
    
    char *end(char *t)
@@ -247,17 +286,23 @@ static void oggflac_metadata_callback(const FLAC__StreamDecoder *decoder, const
       return t;
       }
 
-   void copy_tag(char *t, char **target)
+   void copy_tag(char *t, char **target, int multiple)
       {
       int j;
+      char *old, *new;
       
       for (j = 0; j < vc->num_comments; j++)
          {
          if (match(t, (char *)vc->comments[j].entry))
             {
-            if (*target)
-               free(*target);
-            *target = strdup(end((char *)vc->comments[j].entry));
+            old = strdup(*target);
+            new = end((char *)vc->comments[j].entry);
+            *target = realloc(*target, strlen(old) + strlen(new) + 2);
+            if (old[0] && multiple)
+               sprintf(*target, "%s/%s", old, new);
+            else
+               strcpy(*target, new);
+            free(old);
             }
          }
       if (*target == NULL)
@@ -282,10 +327,9 @@ static void oggflac_metadata_callback(const FLAC__StreamDecoder *decoder, const
          for (i = 0; i < vc->num_comments; i++)
             fprintf(stderr, "%s\n", vc->comments[i].entry);
 
-         copy_tag("ARTIST=", &self->artist[self->ix]);
-         copy_tag("artist=", &self->artist[self->ix]);
-         copy_tag("TITLE=", &self->title[self->ix]);
-         copy_tag("title=", &self->title[self->ix]);
+         copy_tag("artist=", &self->artist[self->ix], TRUE);
+         copy_tag("title=", &self->title[self->ix], TRUE);
+         copy_tag("replaygain_track_gain=", &self->replaygain[self->ix], FALSE);
          }
       else
          fprintf(stderr, "oggflac_metadata_callback: unhandled FLAC metadata type\n");
@@ -359,24 +403,50 @@ static void speex_get_comments(struct oggdec_vars *self, char *comments, int len
    char *c=comments;
    int len, i, nb_fields;
    char *end;
-   
-   void handle_comment(char *comment, int comment_length)
+
+   void handle_keyval(char *key, char *val, char **target, char *match, int multiple)
       {
-      if (comment_length > 7 && !strncmp("author=", comment, 7))
+      char *old;
+
+      if (!strcasecmp(key, match))
          {
-         self->artist[self->ix] = realloc(self->artist[self->ix], comment_length - 6);
-         memcpy(self->artist[self->ix], comment + 7, comment_length - 7);
-         self->artist[self->ix][comment_length - 7] = '\0';
-         return;
+         if (*target && *target[0] && multiple)
+            {
+            old = strdup(*target);
+            *target = realloc(*target, strlen(old) + strlen(val) + 2);
+            sprintf(*target, "%s/%s", old, val);
+            free(old);
+            }
+         else
+            {
+            *target = realloc(*target, strlen(val) + 1);
+            strcpy(*target, val);
+            }
          }
-
-      if (comment_length > 6 && !strncmp("title=", comment, 6))
+      }
+  
+   void handle_comment(char *comment, int comment_length)
+      {
+      
+      char *key = malloc(comment_length + 1);
+      char *val;
+      
+      memcpy(key, comment, comment_length);
+      key[comment_length] = '\0';
+      val = strchr(key, '=');
+      if (!val)
          {
-         self->title[self->ix] = realloc(self->title[self->ix], comment_length - 5);
-         memcpy(self->title[self->ix], comment + 6, comment_length - 6);
-         self->title[self->ix][comment_length - 6] = '\0';
+         fprintf(stderr, "Invalid/corrupted comments\n");
+         free(key);
          return;
          }
+      *val++ = '\0';
+
+      handle_keyval(key, val, &self->artist[self->ix], "author", TRUE);
+      handle_keyval(key, val, &self->artist[self->ix], "artist", TRUE);
+      handle_keyval(key, val, &self->title[self->ix], "title", TRUE);
+      handle_keyval(key, val, &self->replaygain[self->ix], "replaygain_track_gain", FALSE);
+      free(key);
       }
    
    self->artist[self->ix] = NULL;
@@ -470,7 +540,7 @@ static int speex_get_samplerate(struct oggdec_vars *self)
 
 /* oggscan_eos: perform a binary search on the ogg file for the e_o_s page
  * and log details of the current logical stream when it is found */
-static off_t oggscan_eos(struct oggdec_vars *self, off_t offset, off_t offset_end, int serial)
+static off_t oggscan_eos(struct oggdec_vars *self, off_t offset, off_t offset_end, int serial, int depth)
    {
    char  *buffer;
    size_t bytes;
@@ -478,16 +548,23 @@ static off_t oggscan_eos(struct oggdec_vars *self, off_t offset, off_t offset_en
    off_t  midpoint = (offset_end - offset) / 2 + offset;
    off_t  stored_mid = midpoint;
    int eos = FALSE, terminate = FALSE;
+   
+   if (++depth >= 40)
+      {
+      fprintf(stderr, "maximum recursion depth %d reached on oggscan_eos\n", depth);
+      return -1;
+      } 
 
    fseeko(self->fp, midpoint, SEEK_SET);
    ogg_sync_reset(&self->oy);
+
    while ((retval = ogg_sync_pageseek(&self->oy, &self->og)) <= 0)
       {
       if (retval < 0)
          {
          midpoint -= retval;
          if (midpoint >= offset_end)
-            return oggscan_eos(self, offset, stored_mid, serial);
+            return oggscan_eos(self, offset, stored_mid, serial, depth);
          }
       else
          {
@@ -496,6 +573,8 @@ static off_t oggscan_eos(struct oggdec_vars *self, off_t offset, off_t offset_en
          ogg_sync_wrote(&self->oy, bytes);
          if (bytes == 0)
             {
+            if (offset_end > midpoint)
+               return oggscan_eos(self, offset, midpoint, serial, depth);
             fprintf(stderr, "oggscan_eos: unexpected file io error, the file is probably truncated\n");
             terminate = TRUE;
             midpoint = offset_end;
@@ -521,6 +600,8 @@ static off_t oggscan_eos(struct oggdec_vars *self, off_t offset, off_t offset_en
          self->artist[self->n_streams - 1] = strdup("");
          self->title  = realloc(self->title,  self->n_streams * sizeof (char *));
          self->title[self->n_streams - 1] = strdup("");
+         self->replaygain = realloc(self->replaygain, self->n_streams * sizeof (char *));
+         self->replaygain[self->n_streams - 1] = strdup("");
          self->streamtype = realloc(self->streamtype, self->n_streams * sizeof (enum streamtype_t));
          self->start_time = realloc(self->start_time, self->n_streams * sizeof (double));
          self->duration = realloc(self->duration, self->n_streams * sizeof (double));
@@ -539,7 +620,7 @@ static off_t oggscan_eos(struct oggdec_vars *self, off_t offset, off_t offset_en
          }
       
       /* seek to the right next time */
-      return oggscan_eos(self, midpoint, offset_end, serial);
+      return oggscan_eos(self, midpoint, offset_end, serial, depth);
       }
    else
       {
@@ -549,7 +630,7 @@ static off_t oggscan_eos(struct oggdec_vars *self, off_t offset, off_t offset_en
          return -1;
          }
       /* seek to the left next time */
-      return oggscan_eos(self, offset, midpoint, serial);
+      return oggscan_eos(self, offset, midpoint, serial, depth);
       }
    }
 
@@ -582,7 +663,7 @@ static off_t oggscan(struct oggdec_vars *self, off_t *offset, off_t offset_end)
       }
 
    serial = ogg_page_serialno(&self->og);
-   return oggscan_eos(self, *offset, offset_end, serial);
+   return oggscan_eos(self, *offset, offset_end, serial, 0);
    }
 
 static struct oggdec_vars *oggdecode_get_metadata(char *pathname)
@@ -834,7 +915,7 @@ void oggdecode_seek_to_packet(struct oggdec_vars *self)
 void oggdecode_dynamic_dispatcher(struct xlplayer *xlplayer)
    {
    struct oggdec_vars *s = xlplayer->dec_data;
-   int success = 0;
+   int success = 0, delay;
    
    while (s->ix < s->n_streams)
       {
@@ -866,15 +947,20 @@ void oggdecode_dynamic_dispatcher(struct xlplayer *xlplayer)
 
       if (success)
          {
+         if (xlplayer->usedelay)
+            delay = xlplayer_calc_rbdelay(xlplayer);
+         else
+            delay = 0;
+         
          if (s->artist[s->ix][0] && s->title[s->ix][0])
-            xlplayer_set_dynamic_metadata(xlplayer, DM_SPLIT_U8, s->artist[s->ix], s->title[s->ix], "", xlplayer->usedelay);
+            xlplayer_set_dynamic_metadata(xlplayer, DM_SPLIT_U8, s->artist[s->ix], s->title[s->ix], "", delay);
          else
             if (s->title[s->ix][0])
-               xlplayer_set_dynamic_metadata(xlplayer, DM_JOINED_U8, "", "", s->title[s->ix], xlplayer->usedelay);
+               xlplayer_set_dynamic_metadata(xlplayer, DM_JOINED_U8, "", "", s->title[s->ix], delay);
             else
                {
                fprintf(stderr, "oggdecode_dynamic_dispatcher: insufficient metadata\n");
-               xlplayer_set_dynamic_metadata(xlplayer, DM_NOTAG, "", "", "", xlplayer->usedelay);
+               xlplayer_set_dynamic_metadata(xlplayer, DM_NOTAG, "", "", "", delay);
                }
          
          xlplayer->usedelay = TRUE;
@@ -963,7 +1049,7 @@ int oggdecode_reg(struct xlplayer *xlplayer)
       }
    }
 
-int oggdecode_get_metainfo(char *pathname, char **artist, char **title, double *length)
+int oggdecode_get_metainfo(char *pathname, char **artist, char **title, double *length, char **replaygain)
    {
    struct oggdec_vars *self;
    int has_pbtime;
@@ -1009,6 +1095,18 @@ int oggdecode_get_metainfo(char *pathname, char **artist, char **title, double *
             *title = realloc(*title, 1);
             *title[0] = '\0';
             }
+
+         if (self->replaygain[0])
+            {
+            if (*replaygain)
+               free(*replaygain);
+            *replaygain = strdup(self->replaygain[0]);
+            }
+         else
+            {
+            *replaygain = realloc(*replaygain, 1);
+            *replaygain[0] = '\0';
+            }
          }
       }
 
diff --git a/c/oggdec.h b/c/oggdec.h
index 6827e0a..c425254 100644
--- a/c/oggdec.h
+++ b/c/oggdec.h
@@ -1,6 +1,6 @@
 /*
 #   oggdec.h: ogg file parser/decoder for xlplayer
-#   Copyright (C) 2008 Stephen Fairchild (s-fairchild at users.sourceforge.net)
+#   Copyright (C) 2008-2009 Stephen Fairchild (s-fairchild at users.sourceforge.net)
 #
 #   This program is free software: you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
@@ -50,6 +50,7 @@ struct oggdec_vars
    int    *channels;        /* number of audio channels */
    char  **artist;          /* artist and title metadata */
    char  **title;
+   char  **replaygain;      /* specifically replaygain_track_gain */
    enum streamtype_t *streamtype;    /* indicate which type ie vorbis, flac */
    double *start_time;      /* the time when each stream starts */
    double *duration;        /* playback time */
@@ -60,7 +61,7 @@ struct oggdec_vars
    };
 
 int oggdecode_reg(struct xlplayer *xlplayer);
-int oggdecode_get_metainfo(char *pathname, char **artist, char **title, double *length);
+int oggdecode_get_metainfo(char *pathname, char **artist, char **title, double *length, char **replaygain);
 int oggdec_get_next_packet(struct oggdec_vars *self);
 void oggdecode_dynamic_dispatcher(struct xlplayer *xlplayer);
 void oggdecode_playnext(struct xlplayer *xlplayer);
diff --git a/c/recorder.c b/c/recorder.c
index b174ece..bfe61f4 100644
--- a/c/recorder.c
+++ b/c/recorder.c
@@ -1,6 +1,6 @@
 /*
 #   recorder.c: the recording part of the streaming module of idjc
-#   Copyright (C) 2007 Stephen Fairchild (s-fairchild at users.sourceforge.net)
+#   Copyright (C) 2007-2009 Stephen Fairchild (s-fairchild at users.sourceforge.net)
 #
 #   This program is free software: you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
@@ -143,6 +143,56 @@ static int recorder_write_id3_tag(struct recorder *self, FILE *fp)
    return SUCCEEDED;
    }
    
+static int recorder_create_mp3_cuesheet(struct recorder *self)
+   {
+   struct metadata_item *mi;
+   char *cuepathname, *bp;
+   FILE *fp;
+   int i;
+   
+   i = strrchr(self->pathname, '.') - self->pathname + 1;
+   if (!(cuepathname = malloc(i + 4)))
+      {
+      fprintf(stderr, "recorder_write_mp3_cue_sheet: malloc failure\n");
+      return FAILED;
+      }
+   else
+      strcpy(strncpy(cuepathname, self->pathname, i) + i, "cue");
+   
+   if (!(fp = fopen(cuepathname, "wb")))
+      {
+      fprintf(stderr, "recorder_write_mp3_cue_sheet: failed to open cue sheet file for writing\n");
+      free(cuepathname);
+      return FAILED;
+      }
+
+   fprintf(fp, "TITLE \"%s\"\r\n", self->title);
+   fprintf(fp, "PERFORMER \"Recorded with IDJC\"\r\n");
+   fprintf(fp, "FILE \"%s\" MP3\r\n", strrchr(self->pathname, '/') + 1);
+   
+   for (i = 1, mi = self->mi_first; mi; i++, mi = mi->next)
+      {
+      fprintf(fp, "  TRACK %02d AUDIO\r\n", i);
+      if ((bp = strstr(mi->artist_title, " - ")))
+         {
+         fprintf(fp, "    TITLE \"%s\"\r\n", bp + 3);
+         fprintf(fp, "    PERFORMER \"");
+         if (!(fwrite(mi->artist_title, bp - mi->artist_title, 1, fp)))
+            fprintf(stderr, "error writing cuesheet\n");
+         fputc('"', fp);
+         fputc('\r', fp);
+         fputc('\n', fp);
+         }
+      else
+         fprintf(fp, "    TITLE \"%s\"\r\n", mi->artist_title);
+      fprintf(fp, "    INDEX 01 %02d:%02d:00\r\n", mi->time_offset / 60000, mi->time_offset / 1000 % 60);
+      }
+   
+   fclose(fp);
+   free(cuepathname);
+   return SUCCEEDED;
+   }
+      
 static int recorder_write_vbr_tag(struct recorder *self, FILE *fp)
    {
    int mpeg1_f, mono_f;
@@ -166,13 +216,22 @@ static int recorder_write_vbr_tag(struct recorder *self, FILE *fp)
    mono_f = ((self->first_mp3_header[3] & 0xC0) == 0xC0) ? 1 : 0;
    samples_per_frame = mpeg1_f ? 1152 : 576;
    xing_offset = side_info_table[mpeg1_f][mono_f];
-   fwrite(self->first_mp3_header, 4, 1, fp);
+   if (!fwrite(self->first_mp3_header, 4, 1, fp))
+      return FAILED;
    for (i = 0; i < xing_offset; i++)
+      {
       fputc(0x00, fp);
+      if (ferror(fp))
+         return FAILED;
+      }
    if (self->is_vbr)
-      fwrite("Xing\x00\x00\x00\x07", 8, 1, fp);
+      {
+      if (!(fwrite("Xing\x00\x00\x00\x07", 8, 1, fp)))
+         return FAILED;
+      }
    else
-      fwrite("Info\x00\x00\x00\x03", 8, 1, fp);
+      if (!(fwrite("Info\x00\x00\x00\x03", 8, 1, fp)))
+         return FAILED;
    /* the following calculation is fake for files with varying sample rates
     * however the players which use this value will probably only use it 
     * for calclulating the play duration which will yield the intended result */
@@ -204,13 +263,16 @@ static int recorder_write_vbr_tag(struct recorder *self, FILE *fp)
          seg_prop = (look_ms - mi2->start_offset_ms) / (double)(mi2->finish_offset_ms - mi2->start_offset_ms);
          *ptr = (((seg_prop * mi2->size_bytes) + mi2->byte_offset) / self->bytes_written * 255);
          }
-      fwrite(seek_table, 100, 1, fp);
+      if (!(fwrite(seek_table, 100, 1, fp)))
+         return FAILED;
       if (seek_table[99] == 0xFF)
          fputc('\0', fp);
       }
    frame_fill = framelength - ftell(fp) + initial_offset;
    while (frame_fill-- > 0)	/* this frame is allowed to overrun its bounds */
       fputc('\0', fp);		/* and can do so with very low bitrate, high sample rate */
+   if (ferror(fp))
+      return FAILED;
    return SUCCEEDED;
    }
 
@@ -522,10 +584,12 @@ static void *recorder_main(void *args)
                recorder_display_logged_metadata(self->mi_first);
                recorder_display_logged_metadata2(self->mi2_first);
                recorder_apply_mp3_tags(self);
+               recorder_create_mp3_cuesheet(self);
                recorder_free_metadata(self);
                recorder_free_metadata2(self);
-	       }
+    	       }
             free(self->pathname);
+            free(self->title);
             encoder_unregister_client(self->encoder_op);
             memset(self->first_mp3_header, 0x00, 4);
             self->oldbitrate = 0;
@@ -605,12 +669,14 @@ int recorder_start(struct threads_info *ti, struct universal_vars *uv, void *oth
    /* generate a timestamp filename */
    t = time(NULL);
    tm = localtime(&t);
-   strftime(timestamp, TIMESTAMP_SIZ, "[%Y-%m-%d][%H:%M:%S]", tm); 
+   strftime(timestamp, TIMESTAMP_SIZ, "[%Y-%m-%d][%H:%M:%S]", tm);
+   self->title = strdup(timestamp);
    snprintf(self->pathname, pathname_size, "%s/idjc.%s.%02d%s", rv->record_folder, timestamp, uv->tab+1, file_extension);
    if (!(self->fp = fopen(self->pathname, "w")))
       {
       fprintf(stderr, "recorder_start: failed to open file %s\nuser should check file permissions on the particular directory\n", rv->record_folder);
       free(self->pathname);
+      free(self->title);
       encoder_unregister_client(self->encoder_op);
       return FAILED;
       }
diff --git a/c/recorder.h b/c/recorder.h
index fe5bfc6..2f3bace 100644
--- a/c/recorder.h
+++ b/c/recorder.h
@@ -1,6 +1,6 @@
 /*
 #   recorder.h: the recording part of the streaming module of idjc
-#   Copyright (C) 2007 Stephen Fairchild (s-fairchild at users.sourceforge.net)
+#   Copyright (C) 2007-2009 Stephen Fairchild (s-fairchild at users.sourceforge.net)
 #
 #   This program is free software: you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
@@ -79,6 +79,7 @@ struct recorder
    struct encoder_op *encoder_op;	/* handle for getting input data */
    FILE *fp;
    char *pathname;		/* /path/to/filebeingsaved.[ogg/mp3] */
+   char *title;         /* just the timestamp from the filename */
    enum record_mode record_mode;
    struct metadata_item *mi_first;	/* log mp3 song title changes */
    struct metadata_item *mi_last;
diff --git a/c/speextag.c b/c/speextag.c
index 3ab8f0e..5e72180 100644
--- a/c/speextag.c
+++ b/c/speextag.c
@@ -245,7 +245,8 @@ void speex_tag_read(char *pathname)
             else
                {
                printf("idjcmixer: speexcreatedread ");
-               fwrite(s + offset, size, 1, stdout);
+               if (!(fwrite(s + offset, size, 1, stdout)))
+                  goto fail3;
                putchar('\n');
                offset += size;
                }
@@ -271,7 +272,8 @@ void speex_tag_read(char *pathname)
                else
                   {
                   printf("idjcmixer: speextagread ");
-                  fwrite(s + offset, size, 1, stdout);
+                  if (!(fwrite(s + offset, size, 1, stdout)))
+                     goto fail3;
                   putchar('\n');
                   offset += size;
                   }
@@ -328,8 +330,9 @@ void speex_tag_write(char *suppliedpathname, char *createdby, char *taglist)
       {
       while (ogg_stream_flush(&osw, &ogw))
          {
-         fwrite(ogw.header, ogw.header_len, 1, fpw);
-         fwrite(ogw.body, ogw.body_len, 1, fpw);
+         if (fwrite(ogw.header, ogw.header_len, 1, fpw) == 0 ||
+             fwrite(ogw.body, ogw.body_len, 1, fpw) == 0)
+            break;
          }
       }
 
@@ -485,7 +488,8 @@ void speex_tag_write(char *suppliedpathname, char *createdby, char *taglist)
          do
             {
             bytes = fread(copybuf, 1, 4096, fpr);
-            fwrite(copybuf, 1, bytes, fpw);
+            if (fwrite(copybuf, 1, bytes, fpw) != bytes)
+               break;
             } while (bytes == 4096);
 
          free(copybuf);
diff --git a/c/xlplayer.c b/c/xlplayer.c
index ad91996..0571df6 100644
--- a/c/xlplayer.c
+++ b/c/xlplayer.c
@@ -1,6 +1,6 @@
 /*
 #   xlplayer.c: player decoder module for idjc
-#   Copyright (C) 2006-2007 Stephen Fairchild (s-fairchild at users.sourceforge.net)
+#   Copyright (C) 2006-2009 Stephen Fairchild (s-fairchild at users.sourceforge.net)
 #
 #   This program is free software: you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
@@ -44,10 +44,7 @@
 
 typedef jack_default_audio_sample_t sample_t;
 
-static sample_t *fadeinlookuptable;
-static size_t fadeinlookuptable_numsamples;
-
-extern int have_mad;
+extern int have_mad, fb_size;
 
 /* make_audio_to_float: convert the audio to the format used by jack and libsamplerate */
 float *xlplayer_make_audio_to_float(struct xlplayer *self, float *buffer, uint8_t *data, int num_samples, int bits_per_sample, int num_channels)
@@ -101,17 +98,17 @@ float *xlplayer_make_audio_to_float(struct xlplayer *self, float *buffer, uint8_
 /* used to fade in the audio when not starting from the beginning */
 sample_t xlplayer_get_next_gain(struct xlplayer *self)
    {
+   float val;
+   extern float *fade_table;
+
    if (self->fadein_index >= 0)
       {
-      if (self->fadein_index == fadeinlookuptable_numsamples)
-         {
-         self->fadein_index = -1;
-         return 1.0F;
-         }
-      return fadeinlookuptable[self->fadein_index++];
+      val = fade_table[self->fadein_index];
+      self->fadein_index -= self->fadeinstep;
+      return val * self->gain;
       }
    else
-      return 1.0F;
+      return self->gain;
    }
 
 /* xlplayer_demux_channel_data: this is where down/upmixing is performed - audio split to 2 channels */
@@ -225,8 +222,9 @@ static u_int32_t xlplayer_update_progress_time_ms(struct xlplayer *self)
    int32_t rb_time_ms;  /* the amount of time it would take to play all the samples in the buffer */
    int32_t progress;
    
-   rb_time_ms = jack_ringbuffer_read_space(self->right_ch) / sizeof (sample_t) * 1000 / self->samplerate;
-   progress = self->samples_written * 1000 / self->samplerate - rb_time_ms + self->seek_s * 1000;
+   rb_time_ms = (float)jack_ringbuffer_read_space(self->right_ch) / sizeof (sample_t) * 1000.0f / self->samplerate;
+   progress = self->samples_written * 1000.0f / self->samplerate - rb_time_ms + self->seek_s * 1000.0f;
+
    if (progress >= 0)
       return self->play_progress_ms = progress;
    else
@@ -244,7 +242,10 @@ static char *get_extension(char *pathname)
       }
    extension = p = strdup(p + 1);
    while (*p)
-      *p++ = tolower(*p);
+      {
+      char c = tolower(*p);
+      *p++ = c;
+      }
    return extension;
    }
 
@@ -270,6 +271,7 @@ static void *xlplayer_main(struct xlplayer *self)
                self->playmode = PM_EJECTING;
             else
                {
+               xlplayer_set_fadesteps(self, self->fade_mode);
                self->jack_flush = TRUE;
                while (self->jack_is_flushed == 0 && *(self->jack_shutdown_f) == FALSE)
                   usleep(10000);
@@ -291,6 +293,7 @@ static void *xlplayer_main(struct xlplayer *self)
             continue;
          case PM_INITIATE:
             self->initial_audio_context = -1;	/* pre-select failure return code */
+            xlplayer_set_fadesteps(self, self->fade_mode);
             extension = get_extension(self->pathname);
             if (
 	            ((!strcmp(extension, "ogg") || !strcmp(extension, "oga")) && oggdecode_reg(self))
@@ -301,12 +304,9 @@ static void *xlplayer_main(struct xlplayer *self)
 		    || (!strcmp(extension, "flac") && flacdecode_reg(self))
 #endif
 		    || ((!strcmp(extension, "wav") || !strcmp(extension, "au") || !strcmp(extension, "aiff")) && sndfiledecode_reg(self))
-#ifdef HAVE_FAAD
-           	    || ((!strcmp(extension, "m4a") || !strcmp(extension, "mp4")) && mp4decode_reg(self))
-#endif
 #ifdef HAVE_AVCODEC
 #ifdef HAVE_AVFORMAT
-                    || ((!strcmp(extension, "m4a") || !strcmp(extension, "mp4") || !strcmp(extension, "wma") || !strcmp(extension, "avi") || !strcmp(extension, "mpc") || !strcmp(extension, "ape")) && avcodecdecode_reg(self))
+                    || ((!strcmp(extension, "m4a") || !strcmp(extension, "mp4") || !strcmp(extension, "m4b") || !strcmp(extension, "m4p") || !strcmp(extension, "wma") || !strcmp(extension, "avi") || !strcmp(extension, "mpc") || !strcmp(extension, "ape")) && avcodecdecode_reg(self))
 #endif /* HAVE_AVFORMAT */
 #endif /* HAVE_AVCODEC */
        		    || (!strcmp(extension, "mp3") && have_mad && mp3decode_reg(self))
@@ -318,7 +318,7 @@ static void *xlplayer_main(struct xlplayer *self)
                self->pause = 0;
                self->samples_written = 0;
                self->sleep_samples = 0;
-               self->fadein_index = self->seek_s ? 0 : -1;
+               self->fadein_index = (self->seek_s || self->fade_mode) ? fb_size - 1 : -1;
                self->dec_init(self);
                if (self->command != CMD_COMPLETE)
                   ++self->current_audio_context;
@@ -336,6 +336,7 @@ static void *xlplayer_main(struct xlplayer *self)
                self->dec_play(self);
             break;
          case PM_EJECTING:
+            xlplayer_set_fadesteps(self, self->fade_mode);
             self->dec_eject(self);
             if (self->playlistmode)
                {
@@ -525,6 +526,7 @@ struct xlplayer *xlplayer_create(int samplerate, double duration, char *playerna
    self->pause = 0;
    self->jack_flush = self->jack_is_flushed = 0;
    self->fadeindex = -1;
+   self->fade_mode = 0;
    self->fadeout_f = 0;
    self->fadein_index = -1;
    self->dither = 0;
@@ -540,6 +542,9 @@ struct xlplayer *xlplayer_create(int samplerate, double duration, char *playerna
    self->up = FALSE;
    self->pbspeed = 1.0F;
    self->pbs_exchange = 0;
+   self->samples_written = 0;
+   self->seek_s = 0;
+   self->play_progress_ms = 0;
    self->dynamic_metadata.data_type = DM_NONE_NEW;
    self->dynamic_metadata.artist = NULL;
    self->dynamic_metadata.title = NULL;
@@ -575,11 +580,11 @@ void xlplayer_destroy(struct xlplayer *self)
       }
    }
 
-int xlplayer_play(struct xlplayer *self, char *pathname, int seek_s, int size)
+int xlplayer_play(struct xlplayer *self, char *pathname, int seek_s, int size, float gain_db)
    {
-   if (self->playmode == PM_PLAYING)
-      xlplayer_eject(self);
+   xlplayer_eject(self);
    self->pathname = pathname;
+   self->gain = pow(10.0, gain_db / 20.0);
    self->seek_s = seek_s;
    self->size = size;
    self->loop = FALSE;
@@ -596,8 +601,7 @@ int xlplayer_playmany(struct xlplayer *self, char *playlist, int loop_f)
    char *start = playlist, *end;
    int payloadlen, i;
 
-   if (self->playmode == PM_PLAYING)
-      xlplayer_eject(self);
+   xlplayer_eject(self);
    /* this is where we parse the playlist starting with getting the number of entries */
    while (*start++ != '#');
    start[-1] = '\0';
@@ -628,6 +632,7 @@ int xlplayer_playmany(struct xlplayer *self, char *playlist, int loop_f)
          }
       start = end;
       }
+   self->gain = 1.0;
    self->seek_s = 0;
    self->loop = loop_f;
    self->playlistmode = TRUE;
@@ -637,12 +642,12 @@ int xlplayer_playmany(struct xlplayer *self, char *playlist, int loop_f)
    return self->initial_audio_context;
    }
 
-int xlplayer_play_noflush(struct xlplayer *self, char *pathname, int seek_s, int size)
+int xlplayer_play_noflush(struct xlplayer *self, char *pathname, int seek_s, int size, float gain_db)
    {
    self->noflush = TRUE;
-   if (self->playmode == PM_PLAYING)
-      xlplayer_eject(self);
+   xlplayer_eject(self);
    self->pathname = pathname;
+   self->gain = pow(10.0, gain_db / 20.0);
    self->seek_s = seek_s;
    self->size = size;
    self->loop = FALSE;
@@ -671,14 +676,20 @@ void xlplayer_dither(struct xlplayer *self, int dither_f)
  
 void xlplayer_eject(struct xlplayer *self)
    {
-   if (self->playmode == PM_PLAYING)
-      {
-      if (!self->fadeout_f)
-         xlplayer_pause(self);
-      self->command = CMD_EJECT;
-      while (self->command)
-         usleep(10000);
-      }
+   if (!self->fadeout_f)
+      xlplayer_pause(self);
+   self->command = CMD_EJECT;
+   while (self->command)
+      usleep(10000);
+   }
+
+void xlplayer_set_fadesteps(struct xlplayer *self, int fade_mode)
+   {
+   static int a[] = { 10, 2, 1 };
+   static int b[] = { 200, 2, 1 };
+
+   self->fadeoutstep = a[fade_mode];
+   self->fadeinstep = b[fade_mode];
    }
 
 /* version supporting playback speed variance */
@@ -840,36 +851,15 @@ size_t read_from_player(struct xlplayer *self, sample_t *left_buf, sample_t *rig
    xlplayer_update_progress_time_ms(self);
    return todo;
    }
-   
-int xlplayer_create_fadein_lookup(float size_seconds, int samplerate)
-   {
-   uint32_t i;
-   sample_t ratio;
-   
-   fadeinlookuptable_numsamples = (size_t)(size_seconds * (float)samplerate);
-   
-   if (!(fadeinlookuptable = malloc(fadeinlookuptable_numsamples * sizeof (sample_t))))
-      return FALSE;
 
-   for (i = 0; i < fadeinlookuptable_numsamples; i++)
-      {
-      ratio = ((sample_t)i) / ((sample_t)fadeinlookuptable_numsamples); /* ranges 0 -> 1 */
-      fadeinlookuptable[i] = powf(10.0F, ((ratio - 1.0F) * 99.0F) / 20.0F);	/* ranges -99 to 0db */
-      }
-   return TRUE;
-   }
-   
-/* xlplayer_destroy_fadein_lookup: frees the lookup table used for fading */
-void xlplayer_destroy_fadein_lookup()
+int xlplayer_calc_rbdelay(struct xlplayer *xlplayer)
    {
-   if (fadeinlookuptable)
-      free(fadeinlookuptable);
+   return jack_ringbuffer_read_space(xlplayer->left_ch) * 1000 / (sizeof (sample_t) * xlplayer->samplerate);
    }
 
-void xlplayer_set_dynamic_metadata(struct xlplayer *xlplayer, enum metadata_t type, char *artist, char *title, char *artist_title, int usedelay)
+void xlplayer_set_dynamic_metadata(struct xlplayer *xlplayer, enum metadata_t type, char *artist, char *title, char *artist_title, int delay)
    {
    struct xlp_dynamic_metadata *dm = &(xlplayer->dynamic_metadata);
-   int min;
    
    pthread_mutex_lock(&(dm->meta_mutex));
    dm->data_type = type;
@@ -883,7 +873,6 @@ void xlplayer_set_dynamic_metadata(struct xlplayer *xlplayer, enum metadata_t ty
    dm->title = strdup(title);
    dm->artist_title = strdup(artist_title);
    dm->current_audio_context = xlplayer->current_audio_context;
-   min = (xlplayer->rbdelay < xlplayer->play_progress_ms) ? xlplayer->rbdelay : xlplayer->play_progress_ms;
-   dm->rbdelay = min * usedelay * 9 / 10;
+   dm->rbdelay = delay;
    pthread_mutex_unlock(&(dm->meta_mutex));
    }
diff --git a/c/xlplayer.h b/c/xlplayer.h
index dd8a122..a5a58f1 100644
--- a/c/xlplayer.h
+++ b/c/xlplayer.h
@@ -1,6 +1,6 @@
 /*
 #   xlplayer.h: player decoder module for idjc
-#   Copyright (C) 2006-2007 Stephen Fairchild (s-fairchild at users.sourceforge.net)
+#   Copyright (C) 2006-2009 Stephen Fairchild (s-fairchild at users.sourceforge.net)
 #
 #   This program is free software: you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
@@ -71,6 +71,7 @@ struct xlplayer
    size_t op_buffersize;		/* the current size of the player output buffers */
    char *pathname;			/* the pathname of the music file being played */
    char **playlist;			/* the playlist as an array of pointers */
+   float gain;              /* amount of gain to apply to the playback */
    int loop;				/* flag indicating if we loop or come to a stop */
    int seek_s;				/* the initial seek time of the song in seconds */
    int size;				/* size of the file in seconds */
@@ -79,7 +80,10 @@ struct xlplayer
    int playlistsize;			/* the number of tracks in the playlist */
    jack_default_audio_sample_t *leftbuffer;	/* the output buffers */
    jack_default_audio_sample_t *rightbuffer;
+   int fade_mode;                       /* deferred fade mode */
    int fadeout_f;			/* flag indicated if fade is applied upon stopping */
+   int fadeoutstep;                     /* affects the fade out speed */
+   int fadeinstep;                      /* affects the fade in speed */
    int jack_flush;			/* tells the jack callback to flush the ringbuffers */
    int jack_is_flushed;			/* indicates true when jack callback has done the flush */
    int samplerate;			/* the audio sample rate in use by the jack transport */
@@ -137,7 +141,7 @@ void xlplayer_destroy(struct xlplayer *);
 /* xlplayer_play: starts the player on a particular track immediately
 * if a track is currently playing eject is called
 * return value: a context-id for this track */
-int xlplayer_play(struct xlplayer *self, char *pathname, int seek_s, int size);
+int xlplayer_play(struct xlplayer *self, char *pathname, int seek_s, int size, float gain_db);
 
 /* xlplayer_playmany: starts the player on a playlist
 * if a track is currently playing eject is called, also can set looping with this function
@@ -145,7 +149,7 @@ int xlplayer_play(struct xlplayer *self, char *pathname, int seek_s, int size);
 int xlplayer_playmany(struct xlplayer *self, char *playlist, int loop_f);
 
 /* xlplayer_play_noflush: starts the player without flushing out old data from the ringbuffer */
-int xlplayer_play_noflush(struct xlplayer *self, char *pathname, int seek_s, int size);
+int xlplayer_play_noflush(struct xlplayer *self, char *pathname, int seek_s, int size, float gain_db);
 
 /* xlplayer_cancelplaynext: cancels the automatic playing of the next track 
 * the current track is allowed to continue playing */
@@ -170,13 +174,6 @@ size_t read_from_player(struct xlplayer *self, jack_default_audio_sample_t *left
 /* this is meant to be run inside the jack callback */
 size_t read_from_player_sv(struct xlplayer *self, jack_default_audio_sample_t *left_buf, jack_default_audio_sample_t *right_buf, jack_default_audio_sample_t *left_fbuf, jack_default_audio_sample_t *right_fbuf, jack_nframes_t nframes);
 
-/* xlplayer_create_fadein_lookup: creates the lookup table used for song fadein */
-/* must be called before starting any of the players */
-int xlplayer_create_fadein_lookup(float size_seconds, int samplerate);
-
-/* xlplayer_destroy_fadein_lookup: frees the lookup table used for fading */
-void xlplayer_destroy_fadein_lookup(void);
-
 /* calculate the gain for fading in - used when seeking to prevent clicks */
 jack_default_audio_sample_t xlplayer_get_next_gain(struct xlplayer *self);
 
@@ -190,6 +187,12 @@ void xlplayer_demux_channel_data(struct xlplayer *self, jack_default_audio_sampl
 void xlplayer_write_channel_data(struct xlplayer *self);
 
 /* provide data for sending back to the user interface */
-void xlplayer_set_dynamic_metadata(struct xlplayer *xlplayer, enum metadata_t type, char *artist, char *title, char *artist_title, int usedelay);
+void xlplayer_set_dynamic_metadata(struct xlplayer *xlplayer, enum metadata_t type, char *artist, char *title, char *artist_title, int delay);
+
+/* return the delay caused by the ringbuffer */
+int xlplayer_calc_rbdelay(struct xlplayer *xlplayer);
+
+/* this sets the speed of fading for a particular mode */
+void xlplayer_set_fadesteps(struct xlplayer *self, int fade_step);
 
 #endif /* XLPLAYER_H */
diff --git a/config.h.in b/config.h.in
index acc5e0e..4f81b02 100644
--- a/config.h.in
+++ b/config.h.in
@@ -1,7 +1,7 @@
 /* config.h.in.  Generated from configure.in by autoheader.  */
 
-/* Used in avcodecdecode */
-#undef DECODE_AUDIO_2
+/* Used in avcodecdecode.c */
+#undef DECODE_AUDIO_3
 
 /* LAME to be linked dynamically */
 #undef DYN_LAME
@@ -27,12 +27,6 @@
 /* Define to 1 if you have the <fcntl.h> header file. */
 #undef HAVE_FCNTL_H
 
-/* Define to 1 if you have the <ffmpeg/avcodec.h> header file. */
-#undef HAVE_FFMPEG_AVCODEC_H
-
-/* Define to 1 if you have the <ffmpeg/avformat.h> header file. */
-#undef HAVE_FFMPEG_AVFORMAT_H
-
 /* Set if libflac >= 1.1.3 was found */
 #undef HAVE_FLAC
 
@@ -45,15 +39,12 @@
 /* Define to 1 if you have the <jack/jack.h> header file. */
 #undef HAVE_JACK_JACK_H
 
+/* set for presence of */
+#undef HAVE_JACK_SET_INFO_FUNCTION
+
 /* Define to 1 if you have the <jack/transport.h> header file. */
 #undef HAVE_JACK_TRANSPORT_H
 
-/* Define to 1 if you have the <libavcodec/avcodec.h> header file. */
-#undef HAVE_LIBAVCODEC_AVCODEC_H
-
-/* Define to 1 if you have the <libavformat/avformat.h> header file. */
-#undef HAVE_LIBAVFORMAT_AVFORMAT_H
-
 /* Define to 1 if your system has a GNU libc compatible `malloc' function, and
    to 0 otherwise. */
 #undef HAVE_MALLOC
@@ -64,9 +55,6 @@
 /* Define to 1 if you have the `memset' function. */
 #undef HAVE_MEMSET
 
-/* Set if library libmp4v2 was found */
-#undef HAVE_MP4V2
-
 /* Set if libFLAC has oggflac support */
 #undef HAVE_OGGFLAC
 
diff --git a/configure b/configure
index 08e415e..09c6839 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.63 for idjc 0.7.14.
+# Generated by GNU Autoconf 2.63 for idjc 0.8.1.
 #
 # Report bugs to <s-fairchild at users.sourceforge.net>.
 #
@@ -596,8 +596,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
 # Identity of this package.
 PACKAGE_NAME='idjc'
 PACKAGE_TARNAME='idjc'
-PACKAGE_VERSION='0.7.14'
-PACKAGE_STRING='idjc 0.7.14'
+PACKAGE_VERSION='0.8.1'
+PACKAGE_STRING='idjc 0.8.1'
 PACKAGE_BUGREPORT='s-fairchild at users.sourceforge.net'
 
 ac_unique_file="config.h.in"
@@ -643,8 +643,8 @@ DYN_LDFLAGS
 DYN_LIBS
 ENH_SHOUT
 MAYBE_LIBSHOUT
-SHOUT_LIBS
-SHOUT_CFLAGS
+LIBSHOUT_LIBS
+LIBSHOUT_CFLAGS
 subdirs
 RECORDERS_S
 STREAMERS_S
@@ -653,42 +653,38 @@ STREAMERS
 TOOLTIPS
 EXT
 LIBOBJS
+EGREP
+GREP
+CPP
 LIBM
-MP3LAME
+LIBMP3LAME
 HAVE_OGGFLAC
 HAVE_FLAC
-FLAC_LIBS
-FLAC_CFLAGS
+LIBFLAC_LIBS
+LIBFLAC_CFLAGS
 PYGTK_LIBS
 PYGTK_CFLAGS
 HAVE_SPEEX
-SPEEX_LIBS
-SPEEX_CFLAGS
-MP4V2_LIBS
-HAVE_MP4V2
-EGREP
-GREP
-CPP
-AVFORMAT_LIBS
-AVFORMAT_CFLAGS
+LIBSPEEX_LIBS
+LIBSPEEX_CFLAGS
+LIBAVFORMAT_LIBS
+LIBAVFORMAT_CFLAGS
 HAVE_AVFORMAT
-AVCODEC_LIBS
-AVCODEC_CFLAGS
+LIBAVCODEC_LIBS
+LIBAVCODEC_CFLAGS
 HAVE_AVCODEC
-SNDFILE_LIBS
-SNDFILE_CFLAGS
-SAMPLERATE_LIBS
-SAMPLERATE_CFLAGS
-MAD_LIBS
-MAD_CFLAGS
-VORBISFILE_LIBS
-VORBISFILE_CFLAGS
-VORBISENC_LIBS
-VORBISENC_CFLAGS
-VORBIS_LIBS
-VORBIS_CFLAGS
-JACK_LIBS
-JACK_CFLAGS
+LIBSNDFILE_LIBS
+LIBSNDFILE_CFLAGS
+LIBSAMPLERATE_LIBS
+LIBSAMPLERATE_CFLAGS
+LIBMAD_LIBS
+LIBMAD_CFLAGS
+LIBVORBISENC_LIBS
+LIBVORBISENC_CFLAGS
+LIBVORBIS_LIBS
+LIBVORBIS_CFLAGS
+LIBJACK_LIBS
+LIBJACK_CFLAGS
 PKG_CONFIG
 am__fastdepCC_FALSE
 am__fastdepCC_TRUE
@@ -779,7 +775,6 @@ enable_option_checking
 enable_dependency_tracking
 enable_mad
 enable_ffmpeg
-enable_mp4
 enable_speex
 enable_flac
 enable_lame
@@ -795,35 +790,33 @@ LDFLAGS
 LIBS
 CPPFLAGS
 PKG_CONFIG
-JACK_CFLAGS
-JACK_LIBS
-VORBIS_CFLAGS
-VORBIS_LIBS
-VORBISENC_CFLAGS
-VORBISENC_LIBS
-VORBISFILE_CFLAGS
-VORBISFILE_LIBS
-MAD_CFLAGS
-MAD_LIBS
-SAMPLERATE_CFLAGS
-SAMPLERATE_LIBS
-SNDFILE_CFLAGS
-SNDFILE_LIBS
-AVCODEC_CFLAGS
-AVCODEC_LIBS
-AVFORMAT_CFLAGS
-AVFORMAT_LIBS
-CPP
-SPEEX_CFLAGS
-SPEEX_LIBS
+LIBJACK_CFLAGS
+LIBJACK_LIBS
+LIBVORBIS_CFLAGS
+LIBVORBIS_LIBS
+LIBVORBISENC_CFLAGS
+LIBVORBISENC_LIBS
+LIBMAD_CFLAGS
+LIBMAD_LIBS
+LIBSAMPLERATE_CFLAGS
+LIBSAMPLERATE_LIBS
+LIBSNDFILE_CFLAGS
+LIBSNDFILE_LIBS
+LIBAVCODEC_CFLAGS
+LIBAVCODEC_LIBS
+LIBAVFORMAT_CFLAGS
+LIBAVFORMAT_LIBS
+LIBSPEEX_CFLAGS
+LIBSPEEX_LIBS
 PYGTK_CFLAGS
 PYGTK_LIBS
-FLAC_CFLAGS
-FLAC_LIBS
+LIBFLAC_CFLAGS
+LIBFLAC_LIBS
+CPP
 STREAMERS
 RECORDERS
-SHOUT_CFLAGS
-SHOUT_LIBS'
+LIBSHOUT_CFLAGS
+LIBSHOUT_LIBS'
 ac_subdirs_all='libshout'
 
 # Initialize some variables set by options.
@@ -1376,7 +1369,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures idjc 0.7.14 to adapt to many kinds of systems.
+\`configure' configures idjc 0.8.1 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1442,7 +1435,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of idjc 0.7.14:";;
+     short | recursive ) echo "Configuration of idjc 0.8.1:";;
    esac
   cat <<\_ACEOF
 
@@ -1454,7 +1447,6 @@ Optional Features:
   --enable-dependency-tracking   do not reject slow dependency extractors
   --disable-mad           remove capability to decode mp3 files
   --disable-ffmpeg        remove capability to decode m4a/wma/avi files
-  --disable-mp4           remove capability to decode mp4/m4a files
   --disable-speex         remove the capability to play/stream speex
   --disable-flac          remove the capability to play/stream in FLAC
   --disable-lame          remove capability to stream/record mp3 format
@@ -1470,51 +1462,55 @@ Some influential environment variables:
   CPPFLAGS    C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
               you have headers in a nonstandard directory <include dir>
   PKG_CONFIG  path to pkg-config utility
-  JACK_CFLAGS C compiler flags for JACK, overriding pkg-config
-  JACK_LIBS   linker flags for JACK, overriding pkg-config
-  VORBIS_CFLAGS
-              C compiler flags for VORBIS, overriding pkg-config
-  VORBIS_LIBS linker flags for VORBIS, overriding pkg-config
-  VORBISENC_CFLAGS
-              C compiler flags for VORBISENC, overriding pkg-config
-  VORBISENC_LIBS
-              linker flags for VORBISENC, overriding pkg-config
-  VORBISFILE_CFLAGS
-              C compiler flags for VORBISFILE, overriding pkg-config
-  VORBISFILE_LIBS
-              linker flags for VORBISFILE, overriding pkg-config
-  MAD_CFLAGS  C compiler flags for MAD, overriding pkg-config
-  MAD_LIBS    linker flags for MAD, overriding pkg-config
-  SAMPLERATE_CFLAGS
-              C compiler flags for SAMPLERATE, overriding pkg-config
-  SAMPLERATE_LIBS
-              linker flags for SAMPLERATE, overriding pkg-config
-  SNDFILE_CFLAGS
-              C compiler flags for SNDFILE, overriding pkg-config
-  SNDFILE_LIBS
-              linker flags for SNDFILE, overriding pkg-config
-  AVCODEC_CFLAGS
-              C compiler flags for AVCODEC, overriding pkg-config
-  AVCODEC_LIBS
-              linker flags for AVCODEC, overriding pkg-config
-  AVFORMAT_CFLAGS
-              C compiler flags for AVFORMAT, overriding pkg-config
-  AVFORMAT_LIBS
-              linker flags for AVFORMAT, overriding pkg-config
-  CPP         C preprocessor
-  SPEEX_CFLAGS
-              C compiler flags for SPEEX, overriding pkg-config
-  SPEEX_LIBS  linker flags for SPEEX, overriding pkg-config
+  LIBJACK_CFLAGS
+              C compiler flags for LIBJACK, overriding pkg-config
+  LIBJACK_LIBS
+              linker flags for LIBJACK, overriding pkg-config
+  LIBVORBIS_CFLAGS
+              C compiler flags for LIBVORBIS, overriding pkg-config
+  LIBVORBIS_LIBS
+              linker flags for LIBVORBIS, overriding pkg-config
+  LIBVORBISENC_CFLAGS
+              C compiler flags for LIBVORBISENC, overriding pkg-config
+  LIBVORBISENC_LIBS
+              linker flags for LIBVORBISENC, overriding pkg-config
+  LIBMAD_CFLAGS
+              C compiler flags for LIBMAD, overriding pkg-config
+  LIBMAD_LIBS linker flags for LIBMAD, overriding pkg-config
+  LIBSAMPLERATE_CFLAGS
+              C compiler flags for LIBSAMPLERATE, overriding pkg-config
+  LIBSAMPLERATE_LIBS
+              linker flags for LIBSAMPLERATE, overriding pkg-config
+  LIBSNDFILE_CFLAGS
+              C compiler flags for LIBSNDFILE, overriding pkg-config
+  LIBSNDFILE_LIBS
+              linker flags for LIBSNDFILE, overriding pkg-config
+  LIBAVCODEC_CFLAGS
+              C compiler flags for LIBAVCODEC, overriding pkg-config
+  LIBAVCODEC_LIBS
+              linker flags for LIBAVCODEC, overriding pkg-config
+  LIBAVFORMAT_CFLAGS
+              C compiler flags for LIBAVFORMAT, overriding pkg-config
+  LIBAVFORMAT_LIBS
+              linker flags for LIBAVFORMAT, overriding pkg-config
+  LIBSPEEX_CFLAGS
+              C compiler flags for LIBSPEEX, overriding pkg-config
+  LIBSPEEX_LIBS
+              linker flags for LIBSPEEX, overriding pkg-config
   PYGTK_CFLAGS
               C compiler flags for PYGTK, overriding pkg-config
   PYGTK_LIBS  linker flags for PYGTK, overriding pkg-config
-  FLAC_CFLAGS C compiler flags for FLAC, overriding pkg-config
-  FLAC_LIBS   linker flags for FLAC, overriding pkg-config
+  LIBFLAC_CFLAGS
+              C compiler flags for LIBFLAC, overriding pkg-config
+  LIBFLAC_LIBS
+              linker flags for LIBFLAC, overriding pkg-config
+  CPP         C preprocessor
   STREAMERS   The number of streamers that will be available
   RECORDERS   The number of recorders that will be available
-  SHOUT_CFLAGS
-              C compiler flags for SHOUT, overriding pkg-config
-  SHOUT_LIBS  linker flags for SHOUT, overriding pkg-config
+  LIBSHOUT_CFLAGS
+              C compiler flags for LIBSHOUT, overriding pkg-config
+  LIBSHOUT_LIBS
+              linker flags for LIBSHOUT, overriding pkg-config
 
 Use these variables to override the choices made by `configure' or to help
 it to find libraries and programs with nonstandard names/locations.
@@ -1582,7 +1578,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-idjc configure 0.7.14
+idjc configure 0.8.1
 generated by GNU Autoconf 2.63
 
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1596,7 +1592,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by idjc $as_me 0.7.14, which was
+It was created by idjc $as_me 0.8.1, which was
 generated by GNU Autoconf 2.63.  Invocation command line was
 
   $ $0 $@
@@ -2293,7 +2289,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='idjc'
- VERSION='0.7.14'
+ VERSION='0.8.1'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -3984,11 +3980,11 @@ $as_echo "no" >&6; }
 fi
 
 pkg_failed=no
-{ $as_echo "$as_me:$LINENO: checking for JACK" >&5
-$as_echo_n "checking for JACK... " >&6; }
+{ $as_echo "$as_me:$LINENO: checking for LIBJACK" >&5
+$as_echo_n "checking for LIBJACK... " >&6; }
 
-if test -n "$JACK_CFLAGS"; then
-    pkg_cv_JACK_CFLAGS="$JACK_CFLAGS"
+if test -n "$LIBJACK_CFLAGS"; then
+    pkg_cv_LIBJACK_CFLAGS="$LIBJACK_CFLAGS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
     { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"jack >= 0.98.0\"") >&5
@@ -3996,15 +3992,15 @@ if test -n "$JACK_CFLAGS"; then
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  pkg_cv_JACK_CFLAGS=`$PKG_CONFIG --cflags "jack >= 0.98.0" 2>/dev/null`
+  pkg_cv_LIBJACK_CFLAGS=`$PKG_CONFIG --cflags "jack >= 0.98.0" 2>/dev/null`
 else
   pkg_failed=yes
 fi
  else
     pkg_failed=untried
 fi
-if test -n "$JACK_LIBS"; then
-    pkg_cv_JACK_LIBS="$JACK_LIBS"
+if test -n "$LIBJACK_LIBS"; then
+    pkg_cv_LIBJACK_LIBS="$LIBJACK_LIBS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
     { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"jack >= 0.98.0\"") >&5
@@ -4012,7 +4008,7 @@ if test -n "$JACK_LIBS"; then
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  pkg_cv_JACK_LIBS=`$PKG_CONFIG --libs "jack >= 0.98.0" 2>/dev/null`
+  pkg_cv_LIBJACK_LIBS=`$PKG_CONFIG --libs "jack >= 0.98.0" 2>/dev/null`
 else
   pkg_failed=yes
 fi
@@ -4030,33 +4026,33 @@ else
         _pkg_short_errors_supported=no
 fi
         if test $_pkg_short_errors_supported = yes; then
-	        JACK_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "jack >= 0.98.0" 2>&1`
+	        LIBJACK_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "jack >= 0.98.0" 2>&1`
         else
-	        JACK_PKG_ERRORS=`$PKG_CONFIG --print-errors "jack >= 0.98.0" 2>&1`
+	        LIBJACK_PKG_ERRORS=`$PKG_CONFIG --print-errors "jack >= 0.98.0" 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
-	echo "$JACK_PKG_ERRORS" >&5
+	echo "$LIBJACK_PKG_ERRORS" >&5
 
 	{ { $as_echo "$as_me:$LINENO: error: Package requirements (jack >= 0.98.0) were not met:
 
-$JACK_PKG_ERRORS
+$LIBJACK_PKG_ERRORS
 
 Consider adjusting the PKG_CONFIG_PATH environment variable if you
 installed software in a non-standard prefix.
 
-Alternatively, you may set the environment variables JACK_CFLAGS
-and JACK_LIBS to avoid the need to call pkg-config.
+Alternatively, you may set the environment variables LIBJACK_CFLAGS
+and LIBJACK_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.
 " >&5
 $as_echo "$as_me: error: Package requirements (jack >= 0.98.0) were not met:
 
-$JACK_PKG_ERRORS
+$LIBJACK_PKG_ERRORS
 
 Consider adjusting the PKG_CONFIG_PATH environment variable if you
 installed software in a non-standard prefix.
 
-Alternatively, you may set the environment variables JACK_CFLAGS
-and JACK_LIBS to avoid the need to call pkg-config.
+Alternatively, you may set the environment variables LIBJACK_CFLAGS
+and LIBJACK_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.
 " >&2;}
    { (exit 1); exit 1; }; }
@@ -4067,8 +4063,8 @@ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 is in your PATH or set the PKG_CONFIG environment variable to the full
 path to pkg-config.
 
-Alternatively, you may set the environment variables JACK_CFLAGS
-and JACK_LIBS to avoid the need to call pkg-config.
+Alternatively, you may set the environment variables LIBJACK_CFLAGS
+and LIBJACK_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.
 
 To get pkg-config, see <http://pkg-config.freedesktop.org/>.
@@ -4077,29 +4073,103 @@ $as_echo "$as_me: error: The pkg-config script could not be found or is too old.
 is in your PATH or set the PKG_CONFIG environment variable to the full
 path to pkg-config.
 
-Alternatively, you may set the environment variables JACK_CFLAGS
-and JACK_LIBS to avoid the need to call pkg-config.
+Alternatively, you may set the environment variables LIBJACK_CFLAGS
+and LIBJACK_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.
 
 To get pkg-config, see <http://pkg-config.freedesktop.org/>.
 See \`config.log' for more details." >&2;}
    { (exit 1); exit 1; }; }; }
 else
-	JACK_CFLAGS=$pkg_cv_JACK_CFLAGS
-	JACK_LIBS=$pkg_cv_JACK_LIBS
+	LIBJACK_CFLAGS=$pkg_cv_LIBJACK_CFLAGS
+	LIBJACK_LIBS=$pkg_cv_LIBJACK_LIBS
         { $as_echo "$as_me:$LINENO: result: yes" >&5
 $as_echo "yes" >&6; }
 	:
 fi
 
+{ $as_echo "$as_me:$LINENO: checking for jack_set_info_function in -ljack" >&5
+$as_echo_n "checking for jack_set_info_function in -ljack... " >&6; }
+if test "${ac_cv_lib_jack_jack_set_info_function+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ljack  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char jack_set_info_function ();
+int
+main ()
+{
+return jack_set_info_function ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 $as_test_x conftest$ac_exeext
+       }; then
+  ac_cv_lib_jack_jack_set_info_function=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_jack_jack_set_info_function=no
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_jack_jack_set_info_function" >&5
+$as_echo "$ac_cv_lib_jack_jack_set_info_function" >&6; }
+if test "x$ac_cv_lib_jack_jack_set_info_function" = x""yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_JACK_SET_INFO_FUNCTION 1
+_ACEOF
+
+fi
+
+
 # Also check for libvorbis and libvorbisenc
 
 pkg_failed=no
-{ $as_echo "$as_me:$LINENO: checking for VORBIS" >&5
-$as_echo_n "checking for VORBIS... " >&6; }
+{ $as_echo "$as_me:$LINENO: checking for LIBVORBIS" >&5
+$as_echo_n "checking for LIBVORBIS... " >&6; }
 
-if test -n "$VORBIS_CFLAGS"; then
-    pkg_cv_VORBIS_CFLAGS="$VORBIS_CFLAGS"
+if test -n "$LIBVORBIS_CFLAGS"; then
+    pkg_cv_LIBVORBIS_CFLAGS="$LIBVORBIS_CFLAGS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
     { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"vorbis >= 1.0.0\"") >&5
@@ -4107,15 +4177,15 @@ if test -n "$VORBIS_CFLAGS"; then
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  pkg_cv_VORBIS_CFLAGS=`$PKG_CONFIG --cflags "vorbis >= 1.0.0" 2>/dev/null`
+  pkg_cv_LIBVORBIS_CFLAGS=`$PKG_CONFIG --cflags "vorbis >= 1.0.0" 2>/dev/null`
 else
   pkg_failed=yes
 fi
  else
     pkg_failed=untried
 fi
-if test -n "$VORBIS_LIBS"; then
-    pkg_cv_VORBIS_LIBS="$VORBIS_LIBS"
+if test -n "$LIBVORBIS_LIBS"; then
+    pkg_cv_LIBVORBIS_LIBS="$LIBVORBIS_LIBS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
     { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"vorbis >= 1.0.0\"") >&5
@@ -4123,7 +4193,7 @@ if test -n "$VORBIS_LIBS"; then
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  pkg_cv_VORBIS_LIBS=`$PKG_CONFIG --libs "vorbis >= 1.0.0" 2>/dev/null`
+  pkg_cv_LIBVORBIS_LIBS=`$PKG_CONFIG --libs "vorbis >= 1.0.0" 2>/dev/null`
 else
   pkg_failed=yes
 fi
@@ -4141,33 +4211,33 @@ else
         _pkg_short_errors_supported=no
 fi
         if test $_pkg_short_errors_supported = yes; then
-	        VORBIS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "vorbis >= 1.0.0" 2>&1`
+	        LIBVORBIS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "vorbis >= 1.0.0" 2>&1`
         else
-	        VORBIS_PKG_ERRORS=`$PKG_CONFIG --print-errors "vorbis >= 1.0.0" 2>&1`
+	        LIBVORBIS_PKG_ERRORS=`$PKG_CONFIG --print-errors "vorbis >= 1.0.0" 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
-	echo "$VORBIS_PKG_ERRORS" >&5
+	echo "$LIBVORBIS_PKG_ERRORS" >&5
 
 	{ { $as_echo "$as_me:$LINENO: error: Package requirements (vorbis >= 1.0.0) were not met:
 
-$VORBIS_PKG_ERRORS
+$LIBVORBIS_PKG_ERRORS
 
 Consider adjusting the PKG_CONFIG_PATH environment variable if you
 installed software in a non-standard prefix.
 
-Alternatively, you may set the environment variables VORBIS_CFLAGS
-and VORBIS_LIBS to avoid the need to call pkg-config.
+Alternatively, you may set the environment variables LIBVORBIS_CFLAGS
+and LIBVORBIS_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.
 " >&5
 $as_echo "$as_me: error: Package requirements (vorbis >= 1.0.0) were not met:
 
-$VORBIS_PKG_ERRORS
+$LIBVORBIS_PKG_ERRORS
 
 Consider adjusting the PKG_CONFIG_PATH environment variable if you
 installed software in a non-standard prefix.
 
-Alternatively, you may set the environment variables VORBIS_CFLAGS
-and VORBIS_LIBS to avoid the need to call pkg-config.
+Alternatively, you may set the environment variables LIBVORBIS_CFLAGS
+and LIBVORBIS_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.
 " >&2;}
    { (exit 1); exit 1; }; }
@@ -4178,8 +4248,8 @@ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 is in your PATH or set the PKG_CONFIG environment variable to the full
 path to pkg-config.
 
-Alternatively, you may set the environment variables VORBIS_CFLAGS
-and VORBIS_LIBS to avoid the need to call pkg-config.
+Alternatively, you may set the environment variables LIBVORBIS_CFLAGS
+and LIBVORBIS_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.
 
 To get pkg-config, see <http://pkg-config.freedesktop.org/>.
@@ -4188,27 +4258,27 @@ $as_echo "$as_me: error: The pkg-config script could not be found or is too old.
 is in your PATH or set the PKG_CONFIG environment variable to the full
 path to pkg-config.
 
-Alternatively, you may set the environment variables VORBIS_CFLAGS
-and VORBIS_LIBS to avoid the need to call pkg-config.
+Alternatively, you may set the environment variables LIBVORBIS_CFLAGS
+and LIBVORBIS_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.
 
 To get pkg-config, see <http://pkg-config.freedesktop.org/>.
 See \`config.log' for more details." >&2;}
    { (exit 1); exit 1; }; }; }
 else
-	VORBIS_CFLAGS=$pkg_cv_VORBIS_CFLAGS
-	VORBIS_LIBS=$pkg_cv_VORBIS_LIBS
+	LIBVORBIS_CFLAGS=$pkg_cv_LIBVORBIS_CFLAGS
+	LIBVORBIS_LIBS=$pkg_cv_LIBVORBIS_LIBS
         { $as_echo "$as_me:$LINENO: result: yes" >&5
 $as_echo "yes" >&6; }
 	:
 fi
 
 pkg_failed=no
-{ $as_echo "$as_me:$LINENO: checking for VORBISENC" >&5
-$as_echo_n "checking for VORBISENC... " >&6; }
+{ $as_echo "$as_me:$LINENO: checking for LIBVORBISENC" >&5
+$as_echo_n "checking for LIBVORBISENC... " >&6; }
 
-if test -n "$VORBISENC_CFLAGS"; then
-    pkg_cv_VORBISENC_CFLAGS="$VORBISENC_CFLAGS"
+if test -n "$LIBVORBISENC_CFLAGS"; then
+    pkg_cv_LIBVORBISENC_CFLAGS="$LIBVORBISENC_CFLAGS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
     { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"vorbisenc >= 1.0.0\"") >&5
@@ -4216,15 +4286,15 @@ if test -n "$VORBISENC_CFLAGS"; then
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  pkg_cv_VORBISENC_CFLAGS=`$PKG_CONFIG --cflags "vorbisenc >= 1.0.0" 2>/dev/null`
+  pkg_cv_LIBVORBISENC_CFLAGS=`$PKG_CONFIG --cflags "vorbisenc >= 1.0.0" 2>/dev/null`
 else
   pkg_failed=yes
 fi
  else
     pkg_failed=untried
 fi
-if test -n "$VORBISENC_LIBS"; then
-    pkg_cv_VORBISENC_LIBS="$VORBISENC_LIBS"
+if test -n "$LIBVORBISENC_LIBS"; then
+    pkg_cv_LIBVORBISENC_LIBS="$LIBVORBISENC_LIBS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
     { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"vorbisenc >= 1.0.0\"") >&5
@@ -4232,7 +4302,7 @@ if test -n "$VORBISENC_LIBS"; then
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  pkg_cv_VORBISENC_LIBS=`$PKG_CONFIG --libs "vorbisenc >= 1.0.0" 2>/dev/null`
+  pkg_cv_LIBVORBISENC_LIBS=`$PKG_CONFIG --libs "vorbisenc >= 1.0.0" 2>/dev/null`
 else
   pkg_failed=yes
 fi
@@ -4250,142 +4320,33 @@ else
         _pkg_short_errors_supported=no
 fi
         if test $_pkg_short_errors_supported = yes; then
-	        VORBISENC_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "vorbisenc >= 1.0.0" 2>&1`
+	        LIBVORBISENC_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "vorbisenc >= 1.0.0" 2>&1`
         else
-	        VORBISENC_PKG_ERRORS=`$PKG_CONFIG --print-errors "vorbisenc >= 1.0.0" 2>&1`
+	        LIBVORBISENC_PKG_ERRORS=`$PKG_CONFIG --print-errors "vorbisenc >= 1.0.0" 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
-	echo "$VORBISENC_PKG_ERRORS" >&5
+	echo "$LIBVORBISENC_PKG_ERRORS" >&5
 
 	{ { $as_echo "$as_me:$LINENO: error: Package requirements (vorbisenc >= 1.0.0) were not met:
 
-$VORBISENC_PKG_ERRORS
+$LIBVORBISENC_PKG_ERRORS
 
 Consider adjusting the PKG_CONFIG_PATH environment variable if you
 installed software in a non-standard prefix.
 
-Alternatively, you may set the environment variables VORBISENC_CFLAGS
-and VORBISENC_LIBS to avoid the need to call pkg-config.
+Alternatively, you may set the environment variables LIBVORBISENC_CFLAGS
+and LIBVORBISENC_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.
 " >&5
 $as_echo "$as_me: error: Package requirements (vorbisenc >= 1.0.0) were not met:
 
-$VORBISENC_PKG_ERRORS
-
-Consider adjusting the PKG_CONFIG_PATH environment variable if you
-installed software in a non-standard prefix.
-
-Alternatively, you may set the environment variables VORBISENC_CFLAGS
-and VORBISENC_LIBS to avoid the need to call pkg-config.
-See the pkg-config man page for more details.
-" >&2;}
-   { (exit 1); exit 1; }; }
-elif test $pkg_failed = untried; then
-	{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ { $as_echo "$as_me:$LINENO: error: The pkg-config script could not be found or is too old.  Make sure it
-is in your PATH or set the PKG_CONFIG environment variable to the full
-path to pkg-config.
-
-Alternatively, you may set the environment variables VORBISENC_CFLAGS
-and VORBISENC_LIBS to avoid the need to call pkg-config.
-See the pkg-config man page for more details.
-
-To get pkg-config, see <http://pkg-config.freedesktop.org/>.
-See \`config.log' for more details." >&5
-$as_echo "$as_me: error: The pkg-config script could not be found or is too old.  Make sure it
-is in your PATH or set the PKG_CONFIG environment variable to the full
-path to pkg-config.
-
-Alternatively, you may set the environment variables VORBISENC_CFLAGS
-and VORBISENC_LIBS to avoid the need to call pkg-config.
-See the pkg-config man page for more details.
-
-To get pkg-config, see <http://pkg-config.freedesktop.org/>.
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }; }
-else
-	VORBISENC_CFLAGS=$pkg_cv_VORBISENC_CFLAGS
-	VORBISENC_LIBS=$pkg_cv_VORBISENC_LIBS
-        { $as_echo "$as_me:$LINENO: result: yes" >&5
-$as_echo "yes" >&6; }
-	:
-fi
-
-pkg_failed=no
-{ $as_echo "$as_me:$LINENO: checking for VORBISFILE" >&5
-$as_echo_n "checking for VORBISFILE... " >&6; }
-
-if test -n "$VORBISFILE_CFLAGS"; then
-    pkg_cv_VORBISFILE_CFLAGS="$VORBISFILE_CFLAGS"
- elif test -n "$PKG_CONFIG"; then
-    if test -n "$PKG_CONFIG" && \
-    { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"vorbisfile >= 1.0.0\"") >&5
-  ($PKG_CONFIG --exists --print-errors "vorbisfile >= 1.0.0") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-  pkg_cv_VORBISFILE_CFLAGS=`$PKG_CONFIG --cflags "vorbisfile >= 1.0.0" 2>/dev/null`
-else
-  pkg_failed=yes
-fi
- else
-    pkg_failed=untried
-fi
-if test -n "$VORBISFILE_LIBS"; then
-    pkg_cv_VORBISFILE_LIBS="$VORBISFILE_LIBS"
- elif test -n "$PKG_CONFIG"; then
-    if test -n "$PKG_CONFIG" && \
-    { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"vorbisfile >= 1.0.0\"") >&5
-  ($PKG_CONFIG --exists --print-errors "vorbisfile >= 1.0.0") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-  pkg_cv_VORBISFILE_LIBS=`$PKG_CONFIG --libs "vorbisfile >= 1.0.0" 2>/dev/null`
-else
-  pkg_failed=yes
-fi
- else
-    pkg_failed=untried
-fi
-
-
-
-if test $pkg_failed = yes; then
-
-if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
-        _pkg_short_errors_supported=yes
-else
-        _pkg_short_errors_supported=no
-fi
-        if test $_pkg_short_errors_supported = yes; then
-	        VORBISFILE_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "vorbisfile >= 1.0.0" 2>&1`
-        else
-	        VORBISFILE_PKG_ERRORS=`$PKG_CONFIG --print-errors "vorbisfile >= 1.0.0" 2>&1`
-        fi
-	# Put the nasty error message in config.log where it belongs
-	echo "$VORBISFILE_PKG_ERRORS" >&5
-
-	{ { $as_echo "$as_me:$LINENO: error: Package requirements (vorbisfile >= 1.0.0) were not met:
-
-$VORBISFILE_PKG_ERRORS
+$LIBVORBISENC_PKG_ERRORS
 
 Consider adjusting the PKG_CONFIG_PATH environment variable if you
 installed software in a non-standard prefix.
 
-Alternatively, you may set the environment variables VORBISFILE_CFLAGS
-and VORBISFILE_LIBS to avoid the need to call pkg-config.
-See the pkg-config man page for more details.
-" >&5
-$as_echo "$as_me: error: Package requirements (vorbisfile >= 1.0.0) were not met:
-
-$VORBISFILE_PKG_ERRORS
-
-Consider adjusting the PKG_CONFIG_PATH environment variable if you
-installed software in a non-standard prefix.
-
-Alternatively, you may set the environment variables VORBISFILE_CFLAGS
-and VORBISFILE_LIBS to avoid the need to call pkg-config.
+Alternatively, you may set the environment variables LIBVORBISENC_CFLAGS
+and LIBVORBISENC_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.
 " >&2;}
    { (exit 1); exit 1; }; }
@@ -4396,8 +4357,8 @@ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 is in your PATH or set the PKG_CONFIG environment variable to the full
 path to pkg-config.
 
-Alternatively, you may set the environment variables VORBISFILE_CFLAGS
-and VORBISFILE_LIBS to avoid the need to call pkg-config.
+Alternatively, you may set the environment variables LIBVORBISENC_CFLAGS
+and LIBVORBISENC_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.
 
 To get pkg-config, see <http://pkg-config.freedesktop.org/>.
@@ -4406,16 +4367,16 @@ $as_echo "$as_me: error: The pkg-config script could not be found or is too old.
 is in your PATH or set the PKG_CONFIG environment variable to the full
 path to pkg-config.
 
-Alternatively, you may set the environment variables VORBISFILE_CFLAGS
-and VORBISFILE_LIBS to avoid the need to call pkg-config.
+Alternatively, you may set the environment variables LIBVORBISENC_CFLAGS
+and LIBVORBISENC_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.
 
 To get pkg-config, see <http://pkg-config.freedesktop.org/>.
 See \`config.log' for more details." >&2;}
    { (exit 1); exit 1; }; }; }
 else
-	VORBISFILE_CFLAGS=$pkg_cv_VORBISFILE_CFLAGS
-	VORBISFILE_LIBS=$pkg_cv_VORBISFILE_LIBS
+	LIBVORBISENC_CFLAGS=$pkg_cv_LIBVORBISENC_CFLAGS
+	LIBVORBISENC_LIBS=$pkg_cv_LIBVORBISENC_LIBS
         { $as_echo "$as_me:$LINENO: result: yes" >&5
 $as_echo "yes" >&6; }
 	:
@@ -4432,11 +4393,11 @@ fi
 if test $makemad != "no" ; then
 
 pkg_failed=no
-{ $as_echo "$as_me:$LINENO: checking for MAD" >&5
-$as_echo_n "checking for MAD... " >&6; }
+{ $as_echo "$as_me:$LINENO: checking for LIBMAD" >&5
+$as_echo_n "checking for LIBMAD... " >&6; }
 
-if test -n "$MAD_CFLAGS"; then
-    pkg_cv_MAD_CFLAGS="$MAD_CFLAGS"
+if test -n "$LIBMAD_CFLAGS"; then
+    pkg_cv_LIBMAD_CFLAGS="$LIBMAD_CFLAGS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
     { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"mad\"") >&5
@@ -4444,15 +4405,15 @@ if test -n "$MAD_CFLAGS"; then
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  pkg_cv_MAD_CFLAGS=`$PKG_CONFIG --cflags "mad" 2>/dev/null`
+  pkg_cv_LIBMAD_CFLAGS=`$PKG_CONFIG --cflags "mad" 2>/dev/null`
 else
   pkg_failed=yes
 fi
  else
     pkg_failed=untried
 fi
-if test -n "$MAD_LIBS"; then
-    pkg_cv_MAD_LIBS="$MAD_LIBS"
+if test -n "$LIBMAD_LIBS"; then
+    pkg_cv_LIBMAD_LIBS="$LIBMAD_LIBS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
     { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"mad\"") >&5
@@ -4460,7 +4421,7 @@ if test -n "$MAD_LIBS"; then
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  pkg_cv_MAD_LIBS=`$PKG_CONFIG --libs "mad" 2>/dev/null`
+  pkg_cv_LIBMAD_LIBS=`$PKG_CONFIG --libs "mad" 2>/dev/null`
 else
   pkg_failed=yes
 fi
@@ -4478,12 +4439,12 @@ else
         _pkg_short_errors_supported=no
 fi
         if test $_pkg_short_errors_supported = yes; then
-	        MAD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "mad" 2>&1`
+	        LIBMAD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "mad" 2>&1`
         else
-	        MAD_PKG_ERRORS=`$PKG_CONFIG --print-errors "mad" 2>&1`
+	        LIBMAD_PKG_ERRORS=`$PKG_CONFIG --print-errors "mad" 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
-	echo "$MAD_PKG_ERRORS" >&5
+	echo "$LIBMAD_PKG_ERRORS" >&5
 
 	{ $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
@@ -4511,8 +4472,8 @@ $as_echo "$as_me: error: libmad not detected but specifically requested in confi
    { (exit 1); exit 1; }; }
          fi
 else
-	MAD_CFLAGS=$pkg_cv_MAD_CFLAGS
-	MAD_LIBS=$pkg_cv_MAD_LIBS
+	LIBMAD_CFLAGS=$pkg_cv_LIBMAD_CFLAGS
+	LIBMAD_LIBS=$pkg_cv_LIBMAD_LIBS
         { $as_echo "$as_me:$LINENO: result: yes" >&5
 $as_echo "yes" >&6; }
 	:
@@ -4528,11 +4489,11 @@ fi
 
 
 pkg_failed=no
-{ $as_echo "$as_me:$LINENO: checking for SAMPLERATE" >&5
-$as_echo_n "checking for SAMPLERATE... " >&6; }
+{ $as_echo "$as_me:$LINENO: checking for LIBSAMPLERATE" >&5
+$as_echo_n "checking for LIBSAMPLERATE... " >&6; }
 
-if test -n "$SAMPLERATE_CFLAGS"; then
-    pkg_cv_SAMPLERATE_CFLAGS="$SAMPLERATE_CFLAGS"
+if test -n "$LIBSAMPLERATE_CFLAGS"; then
+    pkg_cv_LIBSAMPLERATE_CFLAGS="$LIBSAMPLERATE_CFLAGS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
     { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"samplerate\"") >&5
@@ -4540,15 +4501,15 @@ if test -n "$SAMPLERATE_CFLAGS"; then
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  pkg_cv_SAMPLERATE_CFLAGS=`$PKG_CONFIG --cflags "samplerate" 2>/dev/null`
+  pkg_cv_LIBSAMPLERATE_CFLAGS=`$PKG_CONFIG --cflags "samplerate" 2>/dev/null`
 else
   pkg_failed=yes
 fi
  else
     pkg_failed=untried
 fi
-if test -n "$SAMPLERATE_LIBS"; then
-    pkg_cv_SAMPLERATE_LIBS="$SAMPLERATE_LIBS"
+if test -n "$LIBSAMPLERATE_LIBS"; then
+    pkg_cv_LIBSAMPLERATE_LIBS="$LIBSAMPLERATE_LIBS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
     { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"samplerate\"") >&5
@@ -4556,7 +4517,7 @@ if test -n "$SAMPLERATE_LIBS"; then
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  pkg_cv_SAMPLERATE_LIBS=`$PKG_CONFIG --libs "samplerate" 2>/dev/null`
+  pkg_cv_LIBSAMPLERATE_LIBS=`$PKG_CONFIG --libs "samplerate" 2>/dev/null`
 else
   pkg_failed=yes
 fi
@@ -4574,33 +4535,33 @@ else
         _pkg_short_errors_supported=no
 fi
         if test $_pkg_short_errors_supported = yes; then
-	        SAMPLERATE_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "samplerate" 2>&1`
+	        LIBSAMPLERATE_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "samplerate" 2>&1`
         else
-	        SAMPLERATE_PKG_ERRORS=`$PKG_CONFIG --print-errors "samplerate" 2>&1`
+	        LIBSAMPLERATE_PKG_ERRORS=`$PKG_CONFIG --print-errors "samplerate" 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
-	echo "$SAMPLERATE_PKG_ERRORS" >&5
+	echo "$LIBSAMPLERATE_PKG_ERRORS" >&5
 
 	{ { $as_echo "$as_me:$LINENO: error: Package requirements (samplerate) were not met:
 
-$SAMPLERATE_PKG_ERRORS
+$LIBSAMPLERATE_PKG_ERRORS
 
 Consider adjusting the PKG_CONFIG_PATH environment variable if you
 installed software in a non-standard prefix.
 
-Alternatively, you may set the environment variables SAMPLERATE_CFLAGS
-and SAMPLERATE_LIBS to avoid the need to call pkg-config.
+Alternatively, you may set the environment variables LIBSAMPLERATE_CFLAGS
+and LIBSAMPLERATE_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.
 " >&5
 $as_echo "$as_me: error: Package requirements (samplerate) were not met:
 
-$SAMPLERATE_PKG_ERRORS
+$LIBSAMPLERATE_PKG_ERRORS
 
 Consider adjusting the PKG_CONFIG_PATH environment variable if you
 installed software in a non-standard prefix.
 
-Alternatively, you may set the environment variables SAMPLERATE_CFLAGS
-and SAMPLERATE_LIBS to avoid the need to call pkg-config.
+Alternatively, you may set the environment variables LIBSAMPLERATE_CFLAGS
+and LIBSAMPLERATE_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.
 " >&2;}
    { (exit 1); exit 1; }; }
@@ -4611,8 +4572,8 @@ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 is in your PATH or set the PKG_CONFIG environment variable to the full
 path to pkg-config.
 
-Alternatively, you may set the environment variables SAMPLERATE_CFLAGS
-and SAMPLERATE_LIBS to avoid the need to call pkg-config.
+Alternatively, you may set the environment variables LIBSAMPLERATE_CFLAGS
+and LIBSAMPLERATE_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.
 
 To get pkg-config, see <http://pkg-config.freedesktop.org/>.
@@ -4621,16 +4582,16 @@ $as_echo "$as_me: error: The pkg-config script could not be found or is too old.
 is in your PATH or set the PKG_CONFIG environment variable to the full
 path to pkg-config.
 
-Alternatively, you may set the environment variables SAMPLERATE_CFLAGS
-and SAMPLERATE_LIBS to avoid the need to call pkg-config.
+Alternatively, you may set the environment variables LIBSAMPLERATE_CFLAGS
+and LIBSAMPLERATE_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.
 
 To get pkg-config, see <http://pkg-config.freedesktop.org/>.
 See \`config.log' for more details." >&2;}
    { (exit 1); exit 1; }; }; }
 else
-	SAMPLERATE_CFLAGS=$pkg_cv_SAMPLERATE_CFLAGS
-	SAMPLERATE_LIBS=$pkg_cv_SAMPLERATE_LIBS
+	LIBSAMPLERATE_CFLAGS=$pkg_cv_LIBSAMPLERATE_CFLAGS
+	LIBSAMPLERATE_LIBS=$pkg_cv_LIBSAMPLERATE_LIBS
         { $as_echo "$as_me:$LINENO: result: yes" >&5
 $as_echo "yes" >&6; }
 	:
@@ -4638,11 +4599,11 @@ fi
 
 
 pkg_failed=no
-{ $as_echo "$as_me:$LINENO: checking for SNDFILE" >&5
-$as_echo_n "checking for SNDFILE... " >&6; }
+{ $as_echo "$as_me:$LINENO: checking for LIBSNDFILE" >&5
+$as_echo_n "checking for LIBSNDFILE... " >&6; }
 
-if test -n "$SNDFILE_CFLAGS"; then
-    pkg_cv_SNDFILE_CFLAGS="$SNDFILE_CFLAGS"
+if test -n "$LIBSNDFILE_CFLAGS"; then
+    pkg_cv_LIBSNDFILE_CFLAGS="$LIBSNDFILE_CFLAGS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
     { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"sndfile\"") >&5
@@ -4650,15 +4611,15 @@ if test -n "$SNDFILE_CFLAGS"; then
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  pkg_cv_SNDFILE_CFLAGS=`$PKG_CONFIG --cflags "sndfile" 2>/dev/null`
+  pkg_cv_LIBSNDFILE_CFLAGS=`$PKG_CONFIG --cflags "sndfile" 2>/dev/null`
 else
   pkg_failed=yes
 fi
  else
     pkg_failed=untried
 fi
-if test -n "$SNDFILE_LIBS"; then
-    pkg_cv_SNDFILE_LIBS="$SNDFILE_LIBS"
+if test -n "$LIBSNDFILE_LIBS"; then
+    pkg_cv_LIBSNDFILE_LIBS="$LIBSNDFILE_LIBS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
     { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"sndfile\"") >&5
@@ -4666,7 +4627,7 @@ if test -n "$SNDFILE_LIBS"; then
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  pkg_cv_SNDFILE_LIBS=`$PKG_CONFIG --libs "sndfile" 2>/dev/null`
+  pkg_cv_LIBSNDFILE_LIBS=`$PKG_CONFIG --libs "sndfile" 2>/dev/null`
 else
   pkg_failed=yes
 fi
@@ -4684,33 +4645,33 @@ else
         _pkg_short_errors_supported=no
 fi
         if test $_pkg_short_errors_supported = yes; then
-	        SNDFILE_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "sndfile" 2>&1`
+	        LIBSNDFILE_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "sndfile" 2>&1`
         else
-	        SNDFILE_PKG_ERRORS=`$PKG_CONFIG --print-errors "sndfile" 2>&1`
+	        LIBSNDFILE_PKG_ERRORS=`$PKG_CONFIG --print-errors "sndfile" 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
-	echo "$SNDFILE_PKG_ERRORS" >&5
+	echo "$LIBSNDFILE_PKG_ERRORS" >&5
 
 	{ { $as_echo "$as_me:$LINENO: error: Package requirements (sndfile) were not met:
 
-$SNDFILE_PKG_ERRORS
+$LIBSNDFILE_PKG_ERRORS
 
 Consider adjusting the PKG_CONFIG_PATH environment variable if you
 installed software in a non-standard prefix.
 
-Alternatively, you may set the environment variables SNDFILE_CFLAGS
-and SNDFILE_LIBS to avoid the need to call pkg-config.
+Alternatively, you may set the environment variables LIBSNDFILE_CFLAGS
+and LIBSNDFILE_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.
 " >&5
 $as_echo "$as_me: error: Package requirements (sndfile) were not met:
 
-$SNDFILE_PKG_ERRORS
+$LIBSNDFILE_PKG_ERRORS
 
 Consider adjusting the PKG_CONFIG_PATH environment variable if you
 installed software in a non-standard prefix.
 
-Alternatively, you may set the environment variables SNDFILE_CFLAGS
-and SNDFILE_LIBS to avoid the need to call pkg-config.
+Alternatively, you may set the environment variables LIBSNDFILE_CFLAGS
+and LIBSNDFILE_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.
 " >&2;}
    { (exit 1); exit 1; }; }
@@ -4721,8 +4682,8 @@ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 is in your PATH or set the PKG_CONFIG environment variable to the full
 path to pkg-config.
 
-Alternatively, you may set the environment variables SNDFILE_CFLAGS
-and SNDFILE_LIBS to avoid the need to call pkg-config.
+Alternatively, you may set the environment variables LIBSNDFILE_CFLAGS
+and LIBSNDFILE_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.
 
 To get pkg-config, see <http://pkg-config.freedesktop.org/>.
@@ -4731,16 +4692,16 @@ $as_echo "$as_me: error: The pkg-config script could not be found or is too old.
 is in your PATH or set the PKG_CONFIG environment variable to the full
 path to pkg-config.
 
-Alternatively, you may set the environment variables SNDFILE_CFLAGS
-and SNDFILE_LIBS to avoid the need to call pkg-config.
+Alternatively, you may set the environment variables LIBSNDFILE_CFLAGS
+and LIBSNDFILE_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.
 
 To get pkg-config, see <http://pkg-config.freedesktop.org/>.
 See \`config.log' for more details." >&2;}
    { (exit 1); exit 1; }; }; }
 else
-	SNDFILE_CFLAGS=$pkg_cv_SNDFILE_CFLAGS
-	SNDFILE_LIBS=$pkg_cv_SNDFILE_LIBS
+	LIBSNDFILE_CFLAGS=$pkg_cv_LIBSNDFILE_CFLAGS
+	LIBSNDFILE_LIBS=$pkg_cv_LIBSNDFILE_LIBS
         { $as_echo "$as_me:$LINENO: result: yes" >&5
 $as_echo "yes" >&6; }
 	:
@@ -4757,11 +4718,11 @@ fi
 if test $makeffmpeg != "no" ; then
 
 pkg_failed=no
-{ $as_echo "$as_me:$LINENO: checking for AVCODEC" >&5
-$as_echo_n "checking for AVCODEC... " >&6; }
+{ $as_echo "$as_me:$LINENO: checking for LIBAVCODEC" >&5
+$as_echo_n "checking for LIBAVCODEC... " >&6; }
 
-if test -n "$AVCODEC_CFLAGS"; then
-    pkg_cv_AVCODEC_CFLAGS="$AVCODEC_CFLAGS"
+if test -n "$LIBAVCODEC_CFLAGS"; then
+    pkg_cv_LIBAVCODEC_CFLAGS="$LIBAVCODEC_CFLAGS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
     { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"libavcodec\"") >&5
@@ -4769,15 +4730,15 @@ if test -n "$AVCODEC_CFLAGS"; then
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  pkg_cv_AVCODEC_CFLAGS=`$PKG_CONFIG --cflags "libavcodec" 2>/dev/null`
+  pkg_cv_LIBAVCODEC_CFLAGS=`$PKG_CONFIG --cflags "libavcodec" 2>/dev/null`
 else
   pkg_failed=yes
 fi
  else
     pkg_failed=untried
 fi
-if test -n "$AVCODEC_LIBS"; then
-    pkg_cv_AVCODEC_LIBS="$AVCODEC_LIBS"
+if test -n "$LIBAVCODEC_LIBS"; then
+    pkg_cv_LIBAVCODEC_LIBS="$LIBAVCODEC_LIBS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
     { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"libavcodec\"") >&5
@@ -4785,7 +4746,7 @@ if test -n "$AVCODEC_LIBS"; then
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  pkg_cv_AVCODEC_LIBS=`$PKG_CONFIG --libs "libavcodec" 2>/dev/null`
+  pkg_cv_LIBAVCODEC_LIBS=`$PKG_CONFIG --libs "libavcodec" 2>/dev/null`
 else
   pkg_failed=yes
 fi
@@ -4803,12 +4764,12 @@ else
         _pkg_short_errors_supported=no
 fi
         if test $_pkg_short_errors_supported = yes; then
-	        AVCODEC_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libavcodec" 2>&1`
+	        LIBAVCODEC_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libavcodec" 2>&1`
         else
-	        AVCODEC_PKG_ERRORS=`$PKG_CONFIG --print-errors "libavcodec" 2>&1`
+	        LIBAVCODEC_PKG_ERRORS=`$PKG_CONFIG --print-errors "libavcodec" 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
-	echo "$AVCODEC_PKG_ERRORS" >&5
+	echo "$LIBAVCODEC_PKG_ERRORS" >&5
 
 	{ $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
@@ -4836,8 +4797,8 @@ $as_echo "$as_me: error: libavcodec not detected but specifically requested in c
 $as_echo "$as_me: WARNING: IDJC will be built without wma support" >&2;}
             fi
 else
-	AVCODEC_CFLAGS=$pkg_cv_AVCODEC_CFLAGS
-	AVCODEC_LIBS=$pkg_cv_AVCODEC_LIBS
+	LIBAVCODEC_CFLAGS=$pkg_cv_LIBAVCODEC_CFLAGS
+	LIBAVCODEC_LIBS=$pkg_cv_LIBAVCODEC_LIBS
         { $as_echo "$as_me:$LINENO: result: yes" >&5
 $as_echo "yes" >&6; }
 
@@ -4847,15 +4808,88 @@ _ACEOF
 
             HAVE_AVCODEC=1
 
+            { $as_echo "$as_me:$LINENO: checking for avcodec_decode_audio3 in -lavcodec" >&5
+$as_echo_n "checking for avcodec_decode_audio3 in -lavcodec... " >&6; }
+if test "${ac_cv_lib_avcodec_avcodec_decode_audio3+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lavcodec  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char avcodec_decode_audio3 ();
+int
+main ()
+{
+return avcodec_decode_audio3 ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 $as_test_x conftest$ac_exeext
+       }; then
+  ac_cv_lib_avcodec_avcodec_decode_audio3=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_avcodec_avcodec_decode_audio3=no
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_avcodec_avcodec_decode_audio3" >&5
+$as_echo "$ac_cv_lib_avcodec_avcodec_decode_audio3" >&6; }
+if test "x$ac_cv_lib_avcodec_avcodec_decode_audio3" = x""yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define DECODE_AUDIO_3 1
+_ACEOF
+
+fi
+
 fi
 
 
 pkg_failed=no
-{ $as_echo "$as_me:$LINENO: checking for AVFORMAT" >&5
-$as_echo_n "checking for AVFORMAT... " >&6; }
+{ $as_echo "$as_me:$LINENO: checking for LIBAVFORMAT" >&5
+$as_echo_n "checking for LIBAVFORMAT... " >&6; }
 
-if test -n "$AVFORMAT_CFLAGS"; then
-    pkg_cv_AVFORMAT_CFLAGS="$AVFORMAT_CFLAGS"
+if test -n "$LIBAVFORMAT_CFLAGS"; then
+    pkg_cv_LIBAVFORMAT_CFLAGS="$LIBAVFORMAT_CFLAGS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
     { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"libavformat\"") >&5
@@ -4863,15 +4897,15 @@ if test -n "$AVFORMAT_CFLAGS"; then
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  pkg_cv_AVFORMAT_CFLAGS=`$PKG_CONFIG --cflags "libavformat" 2>/dev/null`
+  pkg_cv_LIBAVFORMAT_CFLAGS=`$PKG_CONFIG --cflags "libavformat" 2>/dev/null`
 else
   pkg_failed=yes
 fi
  else
     pkg_failed=untried
 fi
-if test -n "$AVFORMAT_LIBS"; then
-    pkg_cv_AVFORMAT_LIBS="$AVFORMAT_LIBS"
+if test -n "$LIBAVFORMAT_LIBS"; then
+    pkg_cv_LIBAVFORMAT_LIBS="$LIBAVFORMAT_LIBS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
     { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"libavformat\"") >&5
@@ -4879,7 +4913,7 @@ if test -n "$AVFORMAT_LIBS"; then
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  pkg_cv_AVFORMAT_LIBS=`$PKG_CONFIG --libs "libavformat" 2>/dev/null`
+  pkg_cv_LIBAVFORMAT_LIBS=`$PKG_CONFIG --libs "libavformat" 2>/dev/null`
 else
   pkg_failed=yes
 fi
@@ -4897,12 +4931,12 @@ else
         _pkg_short_errors_supported=no
 fi
         if test $_pkg_short_errors_supported = yes; then
-	        AVFORMAT_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libavformat" 2>&1`
+	        LIBAVFORMAT_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libavformat" 2>&1`
         else
-	        AVFORMAT_PKG_ERRORS=`$PKG_CONFIG --print-errors "libavformat" 2>&1`
+	        LIBAVFORMAT_PKG_ERRORS=`$PKG_CONFIG --print-errors "libavformat" 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
-	echo "$AVFORMAT_PKG_ERRORS" >&5
+	echo "$LIBAVFORMAT_PKG_ERRORS" >&5
 
 	{ $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
@@ -4930,8 +4964,8 @@ $as_echo "$as_me: error: libavformat not detected but specifically requested in
 $as_echo "$as_me: WARNING: IDJC will be built without wma support" >&2;}
             fi
 else
-	AVFORMAT_CFLAGS=$pkg_cv_AVFORMAT_CFLAGS
-	AVFORMAT_LIBS=$pkg_cv_AVFORMAT_LIBS
+	LIBAVFORMAT_CFLAGS=$pkg_cv_LIBAVFORMAT_CFLAGS
+	LIBAVFORMAT_LIBS=$pkg_cv_LIBAVFORMAT_LIBS
         { $as_echo "$as_me:$LINENO: result: yes" >&5
 $as_echo "yes" >&6; }
 
@@ -4950,888 +4984,6 @@ else
 
 fi
 
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-{ $as_echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
-$as_echo_n "checking how to run the C preprocessor... " >&6; }
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
-  CPP=
-fi
-if test -z "$CPP"; then
-  if test "${ac_cv_prog_CPP+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-      # Double quotes because CPP needs to be expanded
-    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
-    do
-      ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> exists even on freestanding compilers.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-		     Syntax error
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null && {
-	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       }; then
-  :
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-  # Broken: fails on valid input.
-continue
-fi
-
-rm -f conftest.err conftest.$ac_ext
-
-  # OK, works on sane cases.  Now check whether nonexistent headers
-  # can be detected and how.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <ac_nonexistent.h>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null && {
-	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       }; then
-  # Broken: success on invalid input.
-continue
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-  # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
-  break
-fi
-
-    done
-    ac_cv_prog_CPP=$CPP
-
-fi
-  CPP=$ac_cv_prog_CPP
-else
-  ac_cv_prog_CPP=$CPP
-fi
-{ $as_echo "$as_me:$LINENO: result: $CPP" >&5
-$as_echo "$CPP" >&6; }
-ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> exists even on freestanding compilers.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-		     Syntax error
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null && {
-	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       }; then
-  :
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-  # Broken: fails on valid input.
-continue
-fi
-
-rm -f conftest.err conftest.$ac_ext
-
-  # OK, works on sane cases.  Now check whether nonexistent headers
-  # can be detected and how.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <ac_nonexistent.h>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null && {
-	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       }; then
-  # Broken: success on invalid input.
-continue
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-  # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
-  :
-else
-  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details." >&5
-$as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }; }
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-{ $as_echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5
-$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
-if test "${ac_cv_path_GREP+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  if test -z "$GREP"; then
-  ac_path_GREP_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_prog in grep ggrep; do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
-# Check for GNU ac_path_GREP and select it if it is found.
-  # Check for GNU $ac_path_GREP
-case `"$ac_path_GREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
-*)
-  ac_count=0
-  $as_echo_n 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    $as_echo 'GREP' >> "conftest.nl"
-    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    ac_count=`expr $ac_count + 1`
-    if test $ac_count -gt ${ac_path_GREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_GREP="$ac_path_GREP"
-      ac_path_GREP_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-      $ac_path_GREP_found && break 3
-    done
-  done
-done
-IFS=$as_save_IFS
-  if test -z "$ac_cv_path_GREP"; then
-    { { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
-$as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
-   { (exit 1); exit 1; }; }
-  fi
-else
-  ac_cv_path_GREP=$GREP
-fi
-
-fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5
-$as_echo "$ac_cv_path_GREP" >&6; }
- GREP="$ac_cv_path_GREP"
-
-
-{ $as_echo "$as_me:$LINENO: checking for egrep" >&5
-$as_echo_n "checking for egrep... " >&6; }
-if test "${ac_cv_path_EGREP+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
-   then ac_cv_path_EGREP="$GREP -E"
-   else
-     if test -z "$EGREP"; then
-  ac_path_EGREP_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_prog in egrep; do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
-# Check for GNU ac_path_EGREP and select it if it is found.
-  # Check for GNU $ac_path_EGREP
-case `"$ac_path_EGREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
-*)
-  ac_count=0
-  $as_echo_n 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    $as_echo 'EGREP' >> "conftest.nl"
-    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    ac_count=`expr $ac_count + 1`
-    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_EGREP="$ac_path_EGREP"
-      ac_path_EGREP_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-      $ac_path_EGREP_found && break 3
-    done
-  done
-done
-IFS=$as_save_IFS
-  if test -z "$ac_cv_path_EGREP"; then
-    { { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
-$as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
-   { (exit 1); exit 1; }; }
-  fi
-else
-  ac_cv_path_EGREP=$EGREP
-fi
-
-   fi
-fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5
-$as_echo "$ac_cv_path_EGREP" >&6; }
- EGREP="$ac_cv_path_EGREP"
-
-
-{ $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5
-$as_echo_n "checking for ANSI C header files... " >&6; }
-if test "${ac_cv_header_stdc+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_header_stdc=yes
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_header_stdc=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-if test $ac_cv_header_stdc = yes; then
-  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "memchr" >/dev/null 2>&1; then
-  :
-else
-  ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
-  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "free" >/dev/null 2>&1; then
-  :
-else
-  ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
-  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-  if test "$cross_compiling" = yes; then
-  :
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <ctype.h>
-#include <stdlib.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) \
-		   (('a' <= (c) && (c) <= 'i') \
-		     || ('j' <= (c) && (c) <= 'r') \
-		     || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
-  int i;
-  for (i = 0; i < 256; i++)
-    if (XOR (islower (i), ISLOWER (i))
-	|| toupper (i) != TOUPPER (i))
-      return 2;
-  return 0;
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  :
-else
-  $as_echo "$as_me: program exited with status $ac_status" >&5
-$as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-ac_cv_header_stdc=no
-fi
-rm -rf conftest.dSYM
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-
-
-fi
-fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
-$as_echo "$ac_cv_header_stdc" >&6; }
-if test $ac_cv_header_stdc = yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define STDC_HEADERS 1
-_ACEOF
-
-fi
-
-# On IRIX 5.3, sys/types and inttypes.h are conflicting.
-
-
-
-
-
-
-
-
-
-for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
-		  inttypes.h stdint.h unistd.h
-do
-as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
-$as_echo_n "checking for $ac_header... " >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  $as_echo_n "(cached) " >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  eval "$as_ac_Header=yes"
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	eval "$as_ac_Header=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-ac_res=`eval 'as_val=${'$as_ac_Header'}
-		 $as_echo "$as_val"'`
-	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-as_val=`eval 'as_val=${'$as_ac_Header'}
-		 $as_echo "$as_val"'`
-   if test "x$as_val" = x""yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
-
-
-
-
-for ac_header in libavcodec/avcodec.h ffmpeg/avcodec.h libavformat/avformat.h ffmpeg/avformat.h
-do
-as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
-$as_echo_n "checking for $ac_header... " >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  $as_echo_n "(cached) " >&6
-fi
-ac_res=`eval 'as_val=${'$as_ac_Header'}
-		 $as_echo "$as_val"'`
-	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-else
-  # Is the header compilable?
-{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
-$as_echo_n "checking $ac_header usability... " >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_header_compiler=yes
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_header_compiler=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-$as_echo "$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
-$as_echo_n "checking $ac_header presence... " >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <$ac_header>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null && {
-	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       }; then
-  ac_header_preproc=yes
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-  ac_header_preproc=no
-fi
-
-rm -f conftest.err conftest.$ac_ext
-{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-$as_echo "$ac_header_preproc" >&6; }
-
-# So?  What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
-  yes:no: )
-    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
-$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
-    ac_header_preproc=yes
-    ;;
-  no:yes:* )
-    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
-    { $as_echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
-$as_echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
-    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
-$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
-    { $as_echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
-$as_echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
-    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
-    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
-$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
-    ( cat <<\_ASBOX
-## ------------------------------------------------ ##
-## Report this to s-fairchild at users.sourceforge.net ##
-## ------------------------------------------------ ##
-_ASBOX
-     ) | sed "s/^/$as_me: WARNING:     /" >&2
-    ;;
-esac
-{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
-$as_echo_n "checking for $ac_header... " >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  $as_echo_n "(cached) " >&6
-else
-  eval "$as_ac_Header=\$ac_header_preproc"
-fi
-ac_res=`eval 'as_val=${'$as_ac_Header'}
-		 $as_echo "$as_val"'`
-	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-
-fi
-as_val=`eval 'as_val=${'$as_ac_Header'}
-		 $as_echo "$as_val"'`
-   if test "x$as_val" = x""yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
-# Check whether --enable-mp4 was given.
-if test "${enable_mp4+set}" = set; then
-  enableval=$enable_mp4; makemp4=$enableval
-else
-  makemp4="maybe"
-fi
-
-
-if test $makemp4 != "no" ; then
-   { $as_echo "$as_me:$LINENO: checking for MP4Read in -lmp4v2" >&5
-$as_echo_n "checking for MP4Read in -lmp4v2... " >&6; }
-if test "${ac_cv_lib_mp4v2_MP4Read+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lmp4v2  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char MP4Read ();
-int
-main ()
-{
-return MP4Read ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext && {
-	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
-       }; then
-  ac_cv_lib_mp4v2_MP4Read=yes
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_lib_mp4v2_MP4Read=no
-fi
-
-rm -rf conftest.dSYM
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_mp4v2_MP4Read" >&5
-$as_echo "$ac_cv_lib_mp4v2_MP4Read" >&6; }
-if test "x$ac_cv_lib_mp4v2_MP4Read" = x""yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_MP4V2 1
-_ACEOF
-
-            HAVE_MP4V2=1
-
-            MP4V2_LIBS=-lmp4v2
-
-else
-  HAVE_MP4V2=0
-
-
-            if test $makemp4 = "yes" ; then
-               { { $as_echo "$as_me:$LINENO: error: libmp4v2 not detected but specifically requested in configure options" >&5
-$as_echo "$as_me: error: libmp4v2 not detected but specifically requested in configure options" >&2;}
-   { (exit 1); exit 1; }; }
-            else
-               { $as_echo "$as_me:$LINENO: WARNING: IDJC will be built without mp4/m4a support" >&5
-$as_echo "$as_me: WARNING: IDJC will be built without mp4/m4a support" >&2;}
-            fi
-fi
-
-
-else
-   HAVE_MP4V2=0
-
-fi
-
 # Check whether --enable-speex was given.
 if test "${enable_speex+set}" = set; then
   enableval=$enable_speex; makespeex=$enableval
@@ -5843,11 +4995,11 @@ fi
 if test $makespeex != "no" ; then
 
 pkg_failed=no
-{ $as_echo "$as_me:$LINENO: checking for SPEEX" >&5
-$as_echo_n "checking for SPEEX... " >&6; }
+{ $as_echo "$as_me:$LINENO: checking for LIBSPEEX" >&5
+$as_echo_n "checking for LIBSPEEX... " >&6; }
 
-if test -n "$SPEEX_CFLAGS"; then
-    pkg_cv_SPEEX_CFLAGS="$SPEEX_CFLAGS"
+if test -n "$LIBSPEEX_CFLAGS"; then
+    pkg_cv_LIBSPEEX_CFLAGS="$LIBSPEEX_CFLAGS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
     { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"speex\"") >&5
@@ -5855,15 +5007,15 @@ if test -n "$SPEEX_CFLAGS"; then
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  pkg_cv_SPEEX_CFLAGS=`$PKG_CONFIG --cflags "speex" 2>/dev/null`
+  pkg_cv_LIBSPEEX_CFLAGS=`$PKG_CONFIG --cflags "speex" 2>/dev/null`
 else
   pkg_failed=yes
 fi
  else
     pkg_failed=untried
 fi
-if test -n "$SPEEX_LIBS"; then
-    pkg_cv_SPEEX_LIBS="$SPEEX_LIBS"
+if test -n "$LIBSPEEX_LIBS"; then
+    pkg_cv_LIBSPEEX_LIBS="$LIBSPEEX_LIBS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
     { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"speex\"") >&5
@@ -5871,7 +5023,7 @@ if test -n "$SPEEX_LIBS"; then
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  pkg_cv_SPEEX_LIBS=`$PKG_CONFIG --libs "speex" 2>/dev/null`
+  pkg_cv_LIBSPEEX_LIBS=`$PKG_CONFIG --libs "speex" 2>/dev/null`
 else
   pkg_failed=yes
 fi
@@ -5889,12 +5041,12 @@ else
         _pkg_short_errors_supported=no
 fi
         if test $_pkg_short_errors_supported = yes; then
-	        SPEEX_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "speex" 2>&1`
+	        LIBSPEEX_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "speex" 2>&1`
         else
-	        SPEEX_PKG_ERRORS=`$PKG_CONFIG --print-errors "speex" 2>&1`
+	        LIBSPEEX_PKG_ERRORS=`$PKG_CONFIG --print-errors "speex" 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
-	echo "$SPEEX_PKG_ERRORS" >&5
+	echo "$LIBSPEEX_PKG_ERRORS" >&5
 
 	{ $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
@@ -5922,8 +5074,8 @@ $as_echo "$as_me: error: libspeex not detected but specifically requested in con
 $as_echo "$as_me: WARNING: IDJC will be built without speex support" >&2;}
             fi
 else
-	SPEEX_CFLAGS=$pkg_cv_SPEEX_CFLAGS
-	SPEEX_LIBS=$pkg_cv_SPEEX_LIBS
+	LIBSPEEX_CFLAGS=$pkg_cv_LIBSPEEX_CFLAGS
+	LIBSPEEX_LIBS=$pkg_cv_LIBSPEEX_LIBS
         { $as_echo "$as_me:$LINENO: result: yes" >&5
 $as_echo "yes" >&6; }
 
@@ -6124,6 +5276,20 @@ $as_echo "yes" >&6; }
 	:
 fi
 
+{ $as_echo "$as_me:$LINENO: checking for mutagen" >&5
+$as_echo_n "checking for mutagen... " >&6; }
+python -c "import mutagen" &>/dev/null
+if test $? -ne 0 ; then
+    { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+    { { $as_echo "$as_me:$LINENO: error: required dependency (mutagen / python-mutagen) is missing" >&5
+$as_echo "$as_me: error: required dependency (mutagen / python-mutagen) is missing" >&2;}
+   { (exit 1); exit 1; }; }
+else
+    { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
+
 # Check whether --enable-flac was given.
 if test "${enable_flac+set}" = set; then
   enableval=$enable_flac; makeflac=$enableval
@@ -6135,11 +5301,11 @@ fi
 if test $makeflac != "no" ; then
 
 pkg_failed=no
-{ $as_echo "$as_me:$LINENO: checking for FLAC" >&5
-$as_echo_n "checking for FLAC... " >&6; }
+{ $as_echo "$as_me:$LINENO: checking for LIBFLAC" >&5
+$as_echo_n "checking for LIBFLAC... " >&6; }
 
-if test -n "$FLAC_CFLAGS"; then
-    pkg_cv_FLAC_CFLAGS="$FLAC_CFLAGS"
+if test -n "$LIBFLAC_CFLAGS"; then
+    pkg_cv_LIBFLAC_CFLAGS="$LIBFLAC_CFLAGS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
     { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"flac >= 1.1.3\"") >&5
@@ -6147,15 +5313,15 @@ if test -n "$FLAC_CFLAGS"; then
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  pkg_cv_FLAC_CFLAGS=`$PKG_CONFIG --cflags "flac >= 1.1.3" 2>/dev/null`
+  pkg_cv_LIBFLAC_CFLAGS=`$PKG_CONFIG --cflags "flac >= 1.1.3" 2>/dev/null`
 else
   pkg_failed=yes
 fi
  else
     pkg_failed=untried
 fi
-if test -n "$FLAC_LIBS"; then
-    pkg_cv_FLAC_LIBS="$FLAC_LIBS"
+if test -n "$LIBFLAC_LIBS"; then
+    pkg_cv_LIBFLAC_LIBS="$LIBFLAC_LIBS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
     { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"flac >= 1.1.3\"") >&5
@@ -6163,7 +5329,7 @@ if test -n "$FLAC_LIBS"; then
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  pkg_cv_FLAC_LIBS=`$PKG_CONFIG --libs "flac >= 1.1.3" 2>/dev/null`
+  pkg_cv_LIBFLAC_LIBS=`$PKG_CONFIG --libs "flac >= 1.1.3" 2>/dev/null`
 else
   pkg_failed=yes
 fi
@@ -6181,12 +5347,12 @@ else
         _pkg_short_errors_supported=no
 fi
         if test $_pkg_short_errors_supported = yes; then
-	        FLAC_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "flac >= 1.1.3" 2>&1`
+	        LIBFLAC_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "flac >= 1.1.3" 2>&1`
         else
-	        FLAC_PKG_ERRORS=`$PKG_CONFIG --print-errors "flac >= 1.1.3" 2>&1`
+	        LIBFLAC_PKG_ERRORS=`$PKG_CONFIG --print-errors "flac >= 1.1.3" 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
-	echo "$FLAC_PKG_ERRORS" >&5
+	echo "$LIBFLAC_PKG_ERRORS" >&5
 
 	{ $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
@@ -6214,8 +5380,8 @@ $as_echo "$as_me: error: libFLAC not detected but specifically requested in conf
 $as_echo "$as_me: WARNING: IDJC will be built without flac support" >&2;}
             fi
 else
-	FLAC_CFLAGS=$pkg_cv_FLAC_CFLAGS
-	FLAC_LIBS=$pkg_cv_FLAC_LIBS
+	LIBFLAC_CFLAGS=$pkg_cv_LIBFLAC_CFLAGS
+	LIBFLAC_LIBS=$pkg_cv_LIBFLAC_LIBS
         { $as_echo "$as_me:$LINENO: result: yes" >&5
 $as_echo "yes" >&6; }
 
@@ -6394,7 +5560,7 @@ fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_mp3lame__lm_lame_init" >&5
 $as_echo "$ac_cv_lib_mp3lame__lm_lame_init" >&6; }
 if test "x$ac_cv_lib_mp3lame__lm_lame_init" = x""yes; then
-  MP3LAME=-lmp3lame
+  LIBMP3LAME=-lmp3lame
 
 else
 
@@ -6487,86 +5653,12 @@ $as_echo "$ac_cv_lib_pthread_pthread_create" >&6; }
 if test "x$ac_cv_lib_pthread_pthread_create" = x""yes; then
   :
 else
-  { { $as_echo "$as_me:$LINENO: error: \"libpthread needed to compile\"" >&5
-$as_echo "$as_me: error: \"libpthread needed to compile\"" >&2;}
+  { { $as_echo "$as_me:$LINENO: error: \"libpthread not detected\"" >&5
+$as_echo "$as_me: error: \"libpthread not detected\"" >&2;}
    { (exit 1); exit 1; }; }
 fi
 
 
-{ $as_echo "$as_me:$LINENO: checking for avcodec_decode_audio2 in -lavcodec" >&5
-$as_echo_n "checking for avcodec_decode_audio2 in -lavcodec... " >&6; }
-if test "${ac_cv_lib_avcodec_avcodec_decode_audio2+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lavcodec  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char avcodec_decode_audio2 ();
-int
-main ()
-{
-return avcodec_decode_audio2 ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext && {
-	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
-       }; then
-  ac_cv_lib_avcodec_avcodec_decode_audio2=yes
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_lib_avcodec_avcodec_decode_audio2=no
-fi
-
-rm -rf conftest.dSYM
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_avcodec_avcodec_decode_audio2" >&5
-$as_echo "$ac_cv_lib_avcodec_avcodec_decode_audio2" >&6; }
-if test "x$ac_cv_lib_avcodec_avcodec_decode_audio2" = x""yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define DECODE_AUDIO_2 1
-_ACEOF
-
-fi
-
-
 # Conditionally include libm.  Some standard libraries could have inbuilt math stuff.
 
 
@@ -6747,6 +5839,377 @@ done
 
 
 # Checks for header files.
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
+$as_echo_n "checking how to run the C preprocessor... " >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+  if test "${ac_cv_prog_CPP+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+      # Double quotes because CPP needs to be expanded
+    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+    do
+      ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+		     Syntax error
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  :
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Broken: fails on valid input.
+continue
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  # Broken: success on invalid input.
+continue
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+  break
+fi
+
+    done
+    ac_cv_prog_CPP=$CPP
+
+fi
+  CPP=$ac_cv_prog_CPP
+else
+  ac_cv_prog_CPP=$CPP
+fi
+{ $as_echo "$as_me:$LINENO: result: $CPP" >&5
+$as_echo "$CPP" >&6; }
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+		     Syntax error
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  :
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Broken: fails on valid input.
+continue
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  # Broken: success on invalid input.
+continue
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+  :
+else
+  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+{ $as_echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if test "${ac_cv_path_GREP+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$GREP"; then
+  ac_path_GREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_prog in grep ggrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+  # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'GREP' >> "conftest.nl"
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    ac_count=`expr $ac_count + 1`
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_GREP="$ac_path_GREP"
+      ac_path_GREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_GREP_found && break 3
+    done
+  done
+done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_GREP"; then
+    { { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
+$as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
+   { (exit 1); exit 1; }; }
+  fi
+else
+  ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5
+$as_echo "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ $as_echo "$as_me:$LINENO: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if test "${ac_cv_path_EGREP+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     if test -z "$EGREP"; then
+  ac_path_EGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_prog in egrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    ac_count=`expr $ac_count + 1`
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_EGREP_found && break 3
+    done
+  done
+done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_EGREP"; then
+    { { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
+$as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
+   { (exit 1); exit 1; }; }
+  fi
+else
+  ac_cv_path_EGREP=$EGREP
+fi
+
+   fi
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
 { $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5
 $as_echo_n "checking for ANSI C header files... " >&6; }
 if test "${ac_cv_header_stdc+set}" = set; then
@@ -6925,6 +6388,79 @@ _ACEOF
 
 fi
 
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+
+
+
+
+
+
+
+
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+		  inttypes.h stdint.h unistd.h
+do
+as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  eval "$as_ac_Header=yes"
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_Header=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+ac_res=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+as_val=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
 
 
 
@@ -8051,9 +7587,9 @@ if test x$static = "xyes" ; then
 
 subdirs="$subdirs libshout"
 
-   SHOUT_CFLAGS='-I$(top_srcdir)/libshout/include/shout'
+   LIBSHOUT_CFLAGS='-I$(top_srcdir)/libshout/include/shout'
 
-   SHOUT_LIBS='$(top_srcdir)/libshout/src/.libs/libshout.a'
+   LIBSHOUT_LIBS='$(top_srcdir)/libshout/src/.libs/libshout.a'
 
    MAYBE_LIBSHOUT=libshout
 
@@ -8067,11 +7603,11 @@ _ACEOF
 else
 
 pkg_failed=no
-{ $as_echo "$as_me:$LINENO: checking for SHOUT" >&5
-$as_echo_n "checking for SHOUT... " >&6; }
+{ $as_echo "$as_me:$LINENO: checking for LIBSHOUT" >&5
+$as_echo_n "checking for LIBSHOUT... " >&6; }
 
-if test -n "$SHOUT_CFLAGS"; then
-    pkg_cv_SHOUT_CFLAGS="$SHOUT_CFLAGS"
+if test -n "$LIBSHOUT_CFLAGS"; then
+    pkg_cv_LIBSHOUT_CFLAGS="$LIBSHOUT_CFLAGS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
     { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"shout\"") >&5
@@ -8079,15 +7615,15 @@ if test -n "$SHOUT_CFLAGS"; then
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  pkg_cv_SHOUT_CFLAGS=`$PKG_CONFIG --cflags "shout" 2>/dev/null`
+  pkg_cv_LIBSHOUT_CFLAGS=`$PKG_CONFIG --cflags "shout" 2>/dev/null`
 else
   pkg_failed=yes
 fi
  else
     pkg_failed=untried
 fi
-if test -n "$SHOUT_LIBS"; then
-    pkg_cv_SHOUT_LIBS="$SHOUT_LIBS"
+if test -n "$LIBSHOUT_LIBS"; then
+    pkg_cv_LIBSHOUT_LIBS="$LIBSHOUT_LIBS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
     { ($as_echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"shout\"") >&5
@@ -8095,7 +7631,7 @@ if test -n "$SHOUT_LIBS"; then
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  pkg_cv_SHOUT_LIBS=`$PKG_CONFIG --libs "shout" 2>/dev/null`
+  pkg_cv_LIBSHOUT_LIBS=`$PKG_CONFIG --libs "shout" 2>/dev/null`
 else
   pkg_failed=yes
 fi
@@ -8113,33 +7649,33 @@ else
         _pkg_short_errors_supported=no
 fi
         if test $_pkg_short_errors_supported = yes; then
-	        SHOUT_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "shout" 2>&1`
+	        LIBSHOUT_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "shout" 2>&1`
         else
-	        SHOUT_PKG_ERRORS=`$PKG_CONFIG --print-errors "shout" 2>&1`
+	        LIBSHOUT_PKG_ERRORS=`$PKG_CONFIG --print-errors "shout" 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
-	echo "$SHOUT_PKG_ERRORS" >&5
+	echo "$LIBSHOUT_PKG_ERRORS" >&5
 
 	{ { $as_echo "$as_me:$LINENO: error: Package requirements (shout) were not met:
 
-$SHOUT_PKG_ERRORS
+$LIBSHOUT_PKG_ERRORS
 
 Consider adjusting the PKG_CONFIG_PATH environment variable if you
 installed software in a non-standard prefix.
 
-Alternatively, you may set the environment variables SHOUT_CFLAGS
-and SHOUT_LIBS to avoid the need to call pkg-config.
+Alternatively, you may set the environment variables LIBSHOUT_CFLAGS
+and LIBSHOUT_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.
 " >&5
 $as_echo "$as_me: error: Package requirements (shout) were not met:
 
-$SHOUT_PKG_ERRORS
+$LIBSHOUT_PKG_ERRORS
 
 Consider adjusting the PKG_CONFIG_PATH environment variable if you
 installed software in a non-standard prefix.
 
-Alternatively, you may set the environment variables SHOUT_CFLAGS
-and SHOUT_LIBS to avoid the need to call pkg-config.
+Alternatively, you may set the environment variables LIBSHOUT_CFLAGS
+and LIBSHOUT_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.
 " >&2;}
    { (exit 1); exit 1; }; }
@@ -8150,8 +7686,8 @@ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 is in your PATH or set the PKG_CONFIG environment variable to the full
 path to pkg-config.
 
-Alternatively, you may set the environment variables SHOUT_CFLAGS
-and SHOUT_LIBS to avoid the need to call pkg-config.
+Alternatively, you may set the environment variables LIBSHOUT_CFLAGS
+and LIBSHOUT_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.
 
 To get pkg-config, see <http://pkg-config.freedesktop.org/>.
@@ -8160,16 +7696,16 @@ $as_echo "$as_me: error: The pkg-config script could not be found or is too old.
 is in your PATH or set the PKG_CONFIG environment variable to the full
 path to pkg-config.
 
-Alternatively, you may set the environment variables SHOUT_CFLAGS
-and SHOUT_LIBS to avoid the need to call pkg-config.
+Alternatively, you may set the environment variables LIBSHOUT_CFLAGS
+and LIBSHOUT_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.
 
 To get pkg-config, see <http://pkg-config.freedesktop.org/>.
 See \`config.log' for more details." >&2;}
    { (exit 1); exit 1; }; }; }
 else
-	SHOUT_CFLAGS=$pkg_cv_SHOUT_CFLAGS
-	SHOUT_LIBS=$pkg_cv_SHOUT_LIBS
+	LIBSHOUT_CFLAGS=$pkg_cv_LIBSHOUT_CFLAGS
+	LIBSHOUT_LIBS=$pkg_cv_LIBSHOUT_LIBS
         { $as_echo "$as_me:$LINENO: result: yes" >&5
 $as_echo "yes" >&6; }
 	:
@@ -8772,7 +8308,7 @@ exec 6>&1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by idjc $as_me 0.7.14, which was
+This file was extended by idjc $as_me 0.8.1, which was
 generated by GNU Autoconf 2.63.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -8835,7 +8371,7 @@ Report bugs to <bug-autoconf at gnu.org>."
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_version="\\
-idjc config.status 0.7.14
+idjc config.status 0.8.1
 configured by $0, generated by GNU Autoconf 2.63,
   with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
 
diff --git a/configure.in b/configure.in
index ff4159d..588a452 100644
--- a/configure.in
+++ b/configure.in
@@ -2,7 +2,7 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ(2.59)
-AC_INIT(idjc, 0.7.14, s-fairchild at users.sourceforge.net)
+AC_INIT(idjc, 0.8.1, s-fairchild at users.sourceforge.net)
 AC_CONFIG_SRCDIR([config.h.in])
 AM_INIT_AUTOMAKE
 AM_CONFIG_HEADER([config.h])
@@ -14,18 +14,18 @@ AM_PATH_PYTHON(2.4)
 AM_PROG_CC_C_O
 
 # We need libjack in order to compile.
-PKG_CHECK_MODULES(JACK, [jack >= 0.98.0])
+PKG_CHECK_MODULES(LIBJACK, [jack >= 0.98.0])
+AC_CHECK_LIB([jack],[jack_set_info_function],[AC_DEFINE(HAVE_JACK_SET_INFO_FUNCTION, 1, [set for presence of])], [])
 
 # Also check for libvorbis and libvorbisenc
-PKG_CHECK_MODULES([VORBIS], [vorbis >= 1.0.0])
-PKG_CHECK_MODULES([VORBISENC], [vorbisenc >= 1.0.0])
-PKG_CHECK_MODULES([VORBISFILE], [vorbisfile >= 1.0.0])
+PKG_CHECK_MODULES([LIBVORBIS], [vorbis >= 1.0.0])
+PKG_CHECK_MODULES([LIBVORBISENC], [vorbisenc >= 1.0.0])
 
 AC_ARG_ENABLE(mad,
    AC_HELP_STRING([--disable-mad],[remove capability to decode mp3 files]),[makemad=$enableval],[makemad="maybe"])
 
 if test $makemad != "no" ; then
-   PKG_CHECK_MODULES([MAD], [mad],,
+   PKG_CHECK_MODULES([LIBMAD], [mad],,
          AC_DEFINE(DYN_MAD, 1, [libmad to be linked dynamically])
          DYNAMIC="1"
          if test $makemad = "yes" ; then 
@@ -36,16 +36,17 @@ else
    DYNAMIC="1"
 fi
 
-PKG_CHECK_MODULES([SAMPLERATE], [samplerate])
+PKG_CHECK_MODULES([LIBSAMPLERATE], [samplerate])
 
-PKG_CHECK_MODULES([SNDFILE], [sndfile])
+PKG_CHECK_MODULES([LIBSNDFILE], [sndfile])
 
 AC_ARG_ENABLE([ffmpeg],
    AC_HELP_STRING([--disable-ffmpeg],[remove capability to decode m4a/wma/avi files]),[makeffmpeg=$enableval],[makeffmpeg="maybe"])
 
 if test $makeffmpeg != "no" ; then
-   PKG_CHECK_MODULES([AVCODEC], [libavcodec], [AC_DEFINE(HAVE_AVCODEC, 1, [Set if libavcodec was found])
-            AC_SUBST(HAVE_AVCODEC, 1)],
+   PKG_CHECK_MODULES([LIBAVCODEC], [libavcodec], [AC_DEFINE(HAVE_AVCODEC, 1, [Set if libavcodec was found])
+            AC_SUBST(HAVE_AVCODEC, 1)
+            AC_CHECK_LIB([avcodec],[avcodec_decode_audio3], AC_DEFINE(DECODE_AUDIO_3, 1,[Used in avcodecdecode.c]))],
             AC_SUBST(HAVE_AVCODEC, 0)
 
             if test $makeffmpeg = "yes" ; then
@@ -54,7 +55,7 @@ if test $makeffmpeg != "no" ; then
                AC_MSG_WARN([IDJC will be built without wma support])
             fi)
 
-   PKG_CHECK_MODULES([AVFORMAT], [libavformat], AC_DEFINE(HAVE_AVFORMAT, 1, [Set if libavformat was found])
+   PKG_CHECK_MODULES([LIBAVFORMAT], [libavformat], AC_DEFINE(HAVE_AVFORMAT, 1, [Set if libavformat was found])
             AC_SUBST(HAVE_AVFORMAT, 1),
             AC_SUBST(HAVE_AVFORMAT, 0)
 
@@ -69,35 +70,12 @@ else
    AC_SUBST(HAVE_AVFORMAT, 0)
 fi
 
-AC_CHECK_HEADERS([libavcodec/avcodec.h ffmpeg/avcodec.h libavformat/avformat.h ffmpeg/avformat.h])
-
-AC_ARG_ENABLE([mp4],
-   AC_HELP_STRING([--disable-mp4],[remove capability to decode mp4/m4a files]),
-   [makemp4=$enableval],[makemp4="maybe"])
-
-if test $makemp4 != "no" ; then
-   AC_CHECK_LIB([mp4v2], [MP4Read],
-            [AC_DEFINE(HAVE_MP4V2, 1, [Set if library libmp4v2 was found])
-            AC_SUBST(HAVE_MP4V2, 1)
-            AC_SUBST(MP4V2_LIBS, [-lmp4v2])],
-            [AC_SUBST(HAVE_MP4V2, 0)
-
-            if test $makemp4 = "yes" ; then
-               AC_MSG_ERROR([libmp4v2 not detected but specifically requested in configure options])
-            else
-               AC_MSG_WARN([IDJC will be built without mp4/m4a support])
-            fi])
-
-else
-   AC_SUBST(HAVE_MP4V2, 0)
-fi
-
 AC_ARG_ENABLE([speex],
    AC_HELP_STRING([--disable-speex],[remove the capability to play/stream speex]),
    [makespeex=$enableval],[makespeex="maybe"])
 
 if test $makespeex != "no" ; then
-   PKG_CHECK_MODULES([SPEEX], [speex],
+   PKG_CHECK_MODULES([LIBSPEEX], [speex],
             [
             AC_CHECK_LIB([speex], [speex_header_free],
                      [AC_DEFINE(HAVE_SPEEX_HEADER_FREE, 1, [Set if speex_header_free was found])])
@@ -117,12 +95,21 @@ fi
 # Used only to check the correct version is installed
 PKG_CHECK_MODULES([PYGTK], [pygtk-2.0 >= 2.6.0])
 
+AC_MSG_CHECKING([for mutagen])
+python -c "import mutagen" &>/dev/null
+if test $? -ne 0 ; then
+    AC_MSG_RESULT([no])
+    AC_MSG_ERROR([required dependency (mutagen / python-mutagen) is missing])
+else
+    AC_MSG_RESULT([yes])
+fi
+
 AC_ARG_ENABLE([flac],
    AC_HELP_STRING([--disable-flac],[remove the capability to play/stream in FLAC]),
    [makeflac=$enableval],[makeflac="maybe"])
 
 if test $makeflac != "no" ; then
-   PKG_CHECK_MODULES([FLAC],[flac >= 1.1.3],
+   PKG_CHECK_MODULES([LIBFLAC],[flac >= 1.1.3],
             [AC_DEFINE([HAVE_FLAC],[1],[Set if libflac >= 1.1.3 was found])
             AC_DEFINE([FLAC_POST1_1_3],[2],[Set for new(er) flac API])
             AC_SUBST([HAVE_FLAC],[1])
@@ -150,7 +137,7 @@ AC_ARG_ENABLE(lame,
 
 if test $makelame != "no" ; then
 AC_CHECK_LIB([mp3lame -lm], [lame_init],
-	  AC_SUBST(MP3LAME, [-lmp3lame]),
+	  AC_SUBST(LIBMP3LAME, [-lmp3lame]),
           AC_DEFINE(DYN_LAME, 1, [LAME to be linked dynamically])
           DYNAMIC="1"
           if test $makelame = "yes" ; then
@@ -161,9 +148,7 @@ else
    DYNAMIC="1"
 fi
 
-AC_CHECK_LIB([pthread], [pthread_create], :, AC_MSG_ERROR("libpthread needed to compile"))
-
-AC_CHECK_LIB([avcodec],[avcodec_decode_audio2], AC_DEFINE(DECODE_AUDIO_2, 1,[Used in avcodecdecode]))
+AC_CHECK_LIB([pthread], [pthread_create], :, AC_MSG_ERROR("libpthread not detected"))
 
 # Conditionally include libm.  Some standard libraries could have inbuilt math stuff.
 AC_CHECK_FUNCS([sqrt pow], :, [AC_CHECK_LIB([m], [sqrt, pow], AC_SUBST(LIBM, "-lm"),
@@ -226,13 +211,13 @@ AC_ARG_ENABLE([static],AC_HELP_STRING([--disable-static],[build with shared libs
 
 if test x$static = "xyes" ; then
    AC_CONFIG_SUBDIRS([libshout])
-   AC_SUBST([SHOUT_CFLAGS],['-I$(top_srcdir)/libshout/include/shout'])
-   AC_SUBST([SHOUT_LIBS],['$(top_srcdir)/libshout/src/.libs/libshout.a'])
+   AC_SUBST([LIBSHOUT_CFLAGS],['-I$(top_srcdir)/libshout/include/shout'])
+   AC_SUBST([LIBSHOUT_LIBS],['$(top_srcdir)/libshout/src/.libs/libshout.a'])
    AC_SUBST([MAYBE_LIBSHOUT],[libshout])
    AC_SUBST([ENH_SHOUT],[1])
    AC_DEFINE([ENH_SHOUT],[1],[Set if using an enhanced libshout])
 else
-   PKG_CHECK_MODULES([SHOUT], [shout])
+   PKG_CHECK_MODULES([LIBSHOUT], [shout])
    AC_CHECK_HEADERS([shout/shout.h])
    AC_SUBST([ENH_SHOUT],[0])
 fi
diff --git a/doc/ChangeLog.html b/doc/ChangeLog.html
index 6389688..a339020 100644
--- a/doc/ChangeLog.html
+++ b/doc/ChangeLog.html
@@ -12,10 +12,92 @@
 </head>
 <body>
 <h3><center>Changelog for Internet DJ Console</center></h3>
+<p><br /><strong>Changes in version 0.8.1</strong></p>
+<p>Added the ability to drag and drop tracks from a directory's subdirectory.</p>
+<p>Added support for wma tagging and playlist metadata.</p>
+<p>Improved transitioning of old playlist data from the 0.7 series.</p>
+<p>Allows addition of mp3 files to the playlist when using old versions of mutagen.</p>
+<p><br /><strong>Changes in version 0.8.0</strong></p>
+<p>Altered some variable names in configure.in to produce better error messages.</p>
+<p>Removed a namespace collision in embedded libshout.</p>
+<p>Documentation updated.</p>
+<p>MP3 playback can now be dithered. Option in the preferences. Default = on.</p>
+<p>Added Replay Gain functionality. </p>
+<p>Untagged tracks are now typically shown with the track number cleaned off (requires track number be on the left).</p>
+<p>Untagged tracks are now shown with black text and a No Tag message alongside in dark red.</p>
+<p>Code to restart the idjcsourceclient module when it crashes has been fixed.</p>
+<p>IDJC now runs in the default MALLOC_CHECK_ mode.</p>
+<p>Fixed a bug where idjcctrl could start an encoder with bad parameters and cause memory to be freed twice.</p>
+<p>Fixed a race condition during encoder shutdown.</p>
+<p>Fixed a file filter preselection bug in the 'Add music' file chooser dialog.</p>
+<p>Added a precautionary recursion limit to oggscan_eos.</p>
+<p>Fixed an Ogg parsing problem where failure to find a valid ogg page in the right hand side caused premature termination of the search.</p>
+<p>Fixed a problem seeking files that are in their last ten seconds of playback. Broken since 0.7.17.</p>
+<p>Fixed the metadata timing for mp3 recordings. A metadata segment of less than ten seconds could be skipped if it was at the end of a file. Broken since 0.7.17.</p>
+<p>Fixed the metadata timing for Ogg recordings. Broken since 0.7.17.</p>
+<p>Tracks with quiet endings are not ended early when a server disconnect is imminent or the playlist has nearly run its course. This is to assist server handovers.</p>
+<p>A cue file is saved for each mp3 recording. Amarok can make use of these.</p>
+<p>./configure stops if the mutagen dependency is not fulfilled.</p>
+<p>Recording of mp3 is now possible when the server list is empty.</p>
+<p>Players are restarted when the current song playing gets retagged (IDJC tagger only). This is to prevent playback failure.</p>
+<p>Dependency list updated.</p>
+<p>Added support for multiple metadata tags.</p>
+<p>Added APEv2 tagging capability. Includes support for monkeys audio and musepack formats.</p>
+<p><br /><strong>Changes in version 0.7.19</strong></p>
+<p>Version bump because the Sourceforge file release system is being a pain.</p>
+<p><br /><strong>Changes in version 0.7.18a</strong></p>
+<p>Workaround for a regression in mutagen-1.17. The mutagen.easyid3 module can't be pulled in without first pulling in mutagen.id3 or mutagen.mp3.</p>
+<p><br /><strong>Changes in version 0.7.18</strong></p>
+<p>Added support for m4b and m4p file extensions. Synonymous with mp4.</p>
+<p>New media metadata tagger added, based on mutagen.</p>
+<p>Dependency removed: libmp4v2</p>
+<p>Dependency removed: eyeD3</p>
+<p>Dependency added: mutagen. This covers the functionality of the removed dependencies.</p>
+<p>ID3 chapter tags lacking null terminators on the TIT2 frame are handled properly.</p>
+<p>Added some Mac portability fixes.</p>
+<p>The advance button now works in accordance with the fade setting.</p>
+<p>The partially working fade in simple mixer mode is now disabled. This is reflected in the fade selector which greys out.</p>
+<p><br /><strong>Changes in version 0.7.17</strong></p>
+<p>Fixed minor layout bug in the connection box.</p>
+<p>Removed the forced inclusion of mp4.h in mp4tag.c.</p>
+<p>MP4 tags API updated in mp4tag.c to prevent deprecation warnings.</p>
+<p>The DJ alarm now triggers off a deeper inspection of playlist controls. This permits correct operation of the alarm when fading to an announcement.</p>
+<p>The DJ alarm now sounds prior to announcements.</p>
+<p>Added playlist controls for fading between tracks. These override the fade speed of the player and can be used to fade announcements.</p>
+<p>Added a new fading-between-tracks in-the-same-playlist feature.</p>
+<p>Fixed a bug where the player could freeze at the end of a track after a progress bar seek that left the bar at the far right hand size.</p>
+<p>Jingles keyboard shortcuts now work when the announcement dialog is active. The shortcut to cancel the dialog (not in editing mode) is BACKSPACE since ESC is used to stop jingles.</p>
+<p>Added record_start and record_stop commands to idcjctrl.</p>
+<p>Prokyon 3 database parse optimisations. Approx 15% speedup.</p>
+<p>Conditional inclusion of jack_set_info_function function call.</p>
+<p>Fixes to catch exceptions when there are problems connecting to a song title database.</p>
+<p><br /><strong>Changes in version 0.7.16</strong></p>
+<p>The application icon and menu entry are now installed according to the ${prefix} value, so it is possible to install to ${HOME}/.local without being root.</p>
+<p>When the prokyon 3 database is being indexed (for the tree view) a progress bar is shown. Also the GUI is not frozen during this time as was the case previously.</p>
+<p>The password for the prokyon 3 database is now non visible.</p>
+<p>When using the prokyon 3 database upon loading IDJC the correct database is now used rather than the default values.</p>
+<p>Added Fkeys control of the jingles player. Escape key is used to stop.</p>
+<p>The scrolled window in the connection pane now has a specified size</p>
+<p>Fixed a segfault that would occur when the main window had focus and the F8 key was pressed.</p>
+<p><br /><strong>Changes in version 0.7.15</strong></p>
+<p>Uses avcodec_decode_audio3 for libavcodec audio decoding when available.</p>
+<p>Fixed bug in avcodecdecode.c, the samples buffer is now aligned on 64 bytes which ensures best performance and the ability to decode formats for which libavcodec uses sse instructions.</p>
+<p>Fixed bug in avcodecdecode.c where freed memory could continue to be used.</p>
+<p>Added some minor fixes supplied by Andrew Suffield.</p>
+<p>Removed the option to not keep passwords over application restarts. Given the extra mouseclicks now requried in order to enter the password and no visible cue to password absence, this feature has been dropped.</p>
+<p>Added a new connection feature to the server window. This allows for listener stats to be gathered from a list of relays as well as the master server. Aslo, stats collection can be turned off on a per server basis.</p>
+<p>Removed directory checks and conditional inclusion for ffmpeg header files to aid compilation on certain distibutions.</p>
+<p>Version 0.7.15_pre1 released as 0.7.14a.</p>
+<p><br /><strong>Changes in version 0.7.14a</strong></p>
+<p>Server stats are now obtained in a threaded manner to prevent the possibility of lockup.</p>
+<p>Added a new admin password entry to the server window so that in instances where the Shoutcast server has an admin password applied the stats can still be obtained.</p>
+<p>Added and option to turn off stats retrieval on a per server basis.</p>
+<p>Stats are additionally now displayed on a per server basis in the server window.</p>
 <p><br /><strong>Changes in version 0.7.14</strong></p>
+<p>Added 'Alternate' playlist mode.</p>
 <p>Added listener stats retrieval. Stats are now displayed below the stream status indicator.</p>
 <p>Dynamic runtime linking supported for libmad. MP3 playback can no longer be completely disabled.</p>
-<p>Added prefs for how to handle faulty server connnections.</p>
+<p>Added prefs for how to handle faulty server connections.</p>
 <p>Dynamic runtime linking supported for libmp3lame. MP3 streaming can no longer be completely disabled.</p>
 <p>Added audio dumping facility to avcodecdecode.c for removing seek noise.</p>
 <p>Fixed a bug in avcodecdecode.c which was causing delayed stopping of ape tracks.</p>
diff --git a/doc/download.html b/doc/download.html
index 401b884..bec47cf 100644
--- a/doc/download.html
+++ b/doc/download.html
@@ -20,6 +20,8 @@
 <tbody>
 <tr><td align="left">Python</td>
 	<td>Required</td></tr>
+<tr><td align="left">mutagen</td>
+	<td>Required</td></tr>
 <tr><td align="left">Jack Audio Connection Kit</td>
 	<td>Required</td></tr>
 <tr><td align="left">PyGTK</td>
@@ -32,30 +34,26 @@
 	<td>Required</td></tr>
 <tr><td align="left">LAME</td>
 	<td>Recommended - for streaming/recording in the mp3 format</td></tr>
-<tr><td align="left">eyeD3</td>
-	<td>Recommended - for metadata tagging and mp3 support</td></tr>
 <tr><td align="left">libmad</td>
-	<td>Recommended - provides support for mp3 files</td></tr>
+	<td>Recommended - provides support for playing mp3s</td></tr>
 <tr><td align="left">ffmpeg</td>
-	<td>Recommended - provides support for wma, mp4/m4a files</td></tr>
-<tr><td align="left">libmp4v2</td>
-	<td>Recommended - additional requirement for mp4/m4a files</td></tr>
+	<td>Recommended - provides support for wma, mp4/m4a</td></tr>
 <tr><td align="left">FLAC</td>
-	<td>Recommended - provides support for flac files and streaming</td></tr>
+	<td>Recommended - provides support for flac playback and streaming</td></tr>
 <tr><td align="left">speex</td>
-	<td>Recommended - provides support for speex files and streaming</td></tr>
+	<td>Recommended - provides support for speex playback and streaming</td></tr>
 <tr><td align="left">libshout</td>
 	<td>Optional - not a requirement for streaming</td></tr>
 </tbody>
 </table>
 
 <p>Although some dependencies are marked as optional or recommended they should be installed before compiling IDJC if you intend on using them later.</p>
-<p>Some of these dependencies will probably already be installed on your system and the rest can typically be found as part of most linux distributions.  Don't forget to install the development packages for these dependencies where applicable.</p>
+<p>Some of these dependencies will probably already be installed on your system and the rest can typically be found as part of most linux distributions.  Don't forget to install the development packages for these dependencies where applicable. (example: for LAME you'll need libmp3lame-dev. Package names vary depending on the Linux distribution you are using.</p>
 <hr />
 <h3>Getting IDJC</h3>
 <p><strong>Official download link <a href="http://sourceforge.net/projects/idjc">http://sourceforge.net/projects/idjc</a> </strong></p>
 <p>The latest ChangeLog can be found <a href="ChangeLog.html"><em>Here</em></a></p>
-<p>The latest upload (may not be stable, may contain half implemented features). <a href="http://web.bethere.co.uk/idjc/download/idjc-0.7.14_pre14.tar.gz"><em>Download link</em></a>.</p>
+<p>The latest upload (may not be stable, may contain half implemented features). <a href="http://web.bethere.co.uk/idjc/download/idjc-0.8.1_pre3.tar.gz"><em>Download link</em></a>.</p>
 <p>
 IDJC is available in RPM format for SuSE Linux via Packman. <a href="http://packman.links2linux.de/package/idjc">Download links &amp; details</a>.</p>
 <p>
@@ -67,8 +65,8 @@ A PISI package for Pardus Linux is available
 <p>
 Unpack the source tarball and cd into the source tree. (please note that if you are reading these instructions direct from the web to substitute your version number for the ones shown below).
 </p>
-<p><pre><kbd>	$ tar xzvf idjc-0.7.14_pre14.tar.gz
-	$ cd idjc-0.7.14_pre14
+<p><pre><kbd>	$ tar xzvf idjc-0.8.1_pre3.tar.gz
+	$ cd idjc-0.8.1_pre3
 </kbd></pre></p>
 <p>
 The following line may be familiar to you.  It is used to generate the Makefile.  To use my suggested configuration you would type.
diff --git a/doc/icon.jpg b/doc/icon.jpg
index 0cf3d30..c67732d 100644
Binary files a/doc/icon.jpg and b/doc/icon.jpg differ
diff --git a/doc/idjc-event.png.jpg b/doc/idjc-event.png.jpg
index 8b48692..6e867a9 100644
Binary files a/doc/idjc-event.png.jpg and b/doc/idjc-event.png.jpg differ
diff --git a/doc/idjc-jack.png.jpg b/doc/idjc-jack.png.jpg
index bdd9d58..4492640 100644
Binary files a/doc/idjc-jack.png.jpg and b/doc/idjc-jack.png.jpg differ
diff --git a/doc/idjc-jingleswindow.png.jpg b/doc/idjc-jingleswindow.png.jpg
index 1f3d3b9..269ad82 100644
Binary files a/doc/idjc-jingleswindow.png.jpg and b/doc/idjc-jingleswindow.png.jpg differ
diff --git a/doc/idjc-mainwindow.png.jpg b/doc/idjc-mainwindow.png.jpg
index a31a5c3..8d327d5 100644
Binary files a/doc/idjc-mainwindow.png.jpg and b/doc/idjc-mainwindow.png.jpg differ
diff --git a/doc/idjc-mainwindow1.png.jpg b/doc/idjc-mainwindow1.png.jpg
index 7533fe2..03a7fb8 100644
Binary files a/doc/idjc-mainwindow1.png.jpg and b/doc/idjc-mainwindow1.png.jpg differ
diff --git a/doc/idjc-prefsgeneral.png.jpg b/doc/idjc-prefsgeneral.png.jpg
index 0917b6b..cf5a1be 100644
Binary files a/doc/idjc-prefsgeneral.png.jpg and b/doc/idjc-prefsgeneral.png.jpg differ
diff --git a/doc/idjc-prefsgeneral1.png.jpg b/doc/idjc-prefsgeneral1.png.jpg
index 2442524..9e43671 100644
Binary files a/doc/idjc-prefsgeneral1.png.jpg and b/doc/idjc-prefsgeneral1.png.jpg differ
diff --git a/doc/idjc-prefsmicrophone1.png.jpg b/doc/idjc-prefsmicrophone1.png.jpg
index ab121d8..9aceaeb 100644
Binary files a/doc/idjc-prefsmicrophone1.png.jpg and b/doc/idjc-prefsmicrophone1.png.jpg differ
diff --git a/doc/idjc-serverwindow.png.jpg b/doc/idjc-serverwindow.png.jpg
index 9cfc7fe..7d056af 100644
Binary files a/doc/idjc-serverwindow.png.jpg and b/doc/idjc-serverwindow.png.jpg differ
diff --git a/doc/idjc-xchat.png.jpg b/doc/idjc-xchat.png.jpg
index f16c803..c78fc21 100644
Binary files a/doc/idjc-xchat.png.jpg and b/doc/idjc-xchat.png.jpg differ
diff --git a/doc/index.html b/doc/index.html
index d950f59..baea813 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -19,7 +19,7 @@
 <h3>Foreward</h3>
 <p>Internet DJ Console is a program that I started writing in March of 2005 after discovering the lack of DJ software on Linux that suited me.  The programs that I did find were either feature poor, full of bugs, suited more towards the live side of things, or sadly did not even compile.  It dawned on me that something needed to be done and that having some coding skills of my own that I may as well have a go myself.  The basics of the different components of the project and how they would fit together came to me almost with ease so after pondering the sketch I drew a few days later I started coding.  The result is Internet DJ Console.  I hope you like it, and if you want to make any suggestions for features or have a gripe or bug report, you can contact me at <u>putidjc<notag />inthesubjectline at bethere.co.uk</u>.</p>
 <h3 style="clear:left">Overview</h3>
-<img align="left" hspace="20" width="1005" height="694" src="idjc-mainwindow.png.jpg" alt="Screenshot of Internet DJ Console: main window" title="Screenshot of Internet DJ Console: main window" /><p><b>The Internet DJ Console main application window.</b></p><p>Note the twin media players, the common volume control, the crossfader, the audio level meters, and the microphone button</p>
+<img align="left" hspace="20" width="1252" height="715" src="idjc-mainwindow.png.jpg" alt="Screenshot of Internet DJ Console: main window" title="Screenshot of Internet DJ Console: main window" /><p><b>The Internet DJ Console main application window.</b></p><p>Note the twin media players, the common volume control, the crossfader, the audio level meters, and the microphone button</p>
 <p>The Prefs, Server, and Jingles buttons in the bottom left corner open their own respective windows.</p><p>The <b>Tracks Played</b> pane (shown closed) contains a list of tracks that have been played recently.  <em>Playlist embeddable controls</em> enable a show to be pre-programmed to a certain extent and are accessible from the playlist popup menu.</p>
 <br />
 <p>The playlist windows support drag and drop of individal or folders containing music files, they also support m3u playlists.  Below the playlist is a row of buttons that are for as follows:</p>
@@ -34,7 +34,10 @@
 	<li type="circle"><strong>Loop All</strong> - Keep playing and restart at the beginning.</li>
 	<li type="circle"><strong>Random</strong> - Tracks are chosen at random.</li>
 	<li type="circle"><strong>Manual</strong> - No tracks are chosen and the player stops at the end of the track.</li>
-	<li type="circle"><strong>Cue Up</strong> - Player stops at the end of the track and the next playlist item is selected.</li></ul><br />
+	<li type="circle"><strong>Cue Up</strong> - Player stops at the end of the track and the next playlist item is selected.</li>
+        <li type="circle"><strong>External</strong> - Sequence through a playlist without incorporating the entire thing.</li>
+        <li type="circle"><strong>Alternate</strong> - Switch to the other player when the track has finished.
+</ul><br />
 <dt><li>Item <strong>Up</strong></li></dt>
 	<ul>Moves the selected playlist item up the playlist order</ul><br />
 <dt><li>Item <strong>Down</strong></li></dt>
diff --git a/doc/killerlogo.jpg b/doc/killerlogo.jpg
index c125ee4..be4834a 100644
Binary files a/doc/killerlogo.jpg and b/doc/killerlogo.jpg differ
diff --git a/doc/prefs.html b/doc/prefs.html
index 65704ca..9e5de2e 100644
--- a/doc/prefs.html
+++ b/doc/prefs.html
@@ -16,10 +16,11 @@
 
 <p>The preferences window is easily the window most in need of documentation, so here it is:</p>
 <h3>The General Tab:</h3>
-<img align="left" hspace="20" width="495" height="617" title="General Pane" src="idjc-prefsgeneral.png.jpg" />
+<img align="left" hspace="20" width="487" height="594" title="General Pane" src="idjc-prefsgeneral.png.jpg" />
 <p>The <strong>Feature Set</strong> frame allows you to set the amount of window space to a minimum.  It also minimises CPU usage by doing practically no audio mixing.  You get just one player, no crossfader or microphone when you choose the <strong>Basic Streamer</strong> option. Choosing <strong>Start Mini</strong> will cause IDJC to be in that state automatically when the application is started.</p>
-<p>The <strong>Audio Meters</strong> frame contains options for saving screen space by allowing you to remove sound level meters from the main application window.</p>
+<p>The <strong>Meters</strong> frame contains options for saving screen space by allowing you to remove sound level meters from the main application window.</p>
 <p>The <strong>Miscellaneous Features</strong> frame is where you can turn on or off some of the optional features of IDJC of which I will mention, the <strong>DJ Alarm</strong> which causes an audible beep to the DJ but not the listeners whenever the music is about to come to an end.</p>
+<p>The <strong>Replay Gain</strong> section deals with how <a href="http://www.replaygain.org">Replay Gain</a> is handled.</p>
 <p>A <strong>Stream Normalizer</strong> is provided to help even out the sound level between differing audio sources.</p>
 <p>There is an adjustment for the DJ audio level which affects sound to the headphones only and to the right of that a setting for the <strong>Player Resample Quality</strong>. What this does is allow you to set a sound resampling audio quality which does not overload your CPU.</p>
 <p>IDJC provides the ability to connect to a Prokyon 3 song title database. When connected a pane appears in the left hand side of the main application window and tracks can be dragged from there into either of the playlists.</p>
@@ -61,4 +62,4 @@
 <center><p><strong>Other Windows In IDJC</strong></p></center>
 <pre><center><strong><a href="index.html">Main Window</a>   <a href="server.html">Server</a>   <a href="jingles.html">Jingles</a></strong></center></pre>
 
-</body></html>
\ No newline at end of file
+</body></html>
diff --git a/doc/server.html b/doc/server.html
index 9f513d5..f32b98f 100644
--- a/doc/server.html
+++ b/doc/server.html
@@ -15,11 +15,12 @@
 <h1>Internet DJ Console: The Server Window</h1><br />
 
 <p>Here is the server window which is how Internet DJ Console (IDJC from now on) connects to the internet.  It is also where the off-line recorder lives.  This feature allows you to make podcasts.  Anyway the bulk of the window is taken up with the Server side of things, and if you have access to a SHOUTcast&#xAE; or Icecast server you should know what to type into these boxes.</p>
-<img align="left" hspace="20" width="593" height="944" src="idjc-serverwindow.png.jpg" title="Screenshot of Internet DJ Console: server window" /><p>The <strong>Connection</strong> frame is concerned with the actual connection details, and everything you type in this box needs to be correct if the connection attempt is going to succeed.  Firstly the connection <strong>Type</strong> refers to the type of server you are attempting to connect with.  I suggest that if you are not sure that you try each one in turn as there are only three.  The <strong>Hostname</strong> and <strong>Port</strong> number should be familiar to you, but for Icecast servers there is also the <strong>Mount</strong> point and <strong>Login</strong> username.  If you don't know the <strong>Login</strong> name, try <em>source</em> (it is the default login name of an Icecast server).  Finally <strong>Pass</strong> is an abbreviation of password.
+<img align="left" hspace="20" width="601" height="941" src="idjc-serverwindow.png.jpg" title="Screenshot of Internet DJ Console: server window" /><p>The <strong>Connection</strong> frame is concerned with the details necessary for establishing a connection with an Icecast or Shoutcast server. To make an entry, fill in the necessary details in the boxes and click the <strong>Add</strong> button.  The connection <strong>Type</strong> refers to the type of server you are attempting to connect with. The Stats/Relay types are for gathering listener stats only so if you wish to stream you will need to add one and only one master server.  The <strong>Hostname</strong> and <strong>Port</strong> number should be familiar to you, but for Icecast servers there is also the <strong>Mount</strong> point and <strong>Login</strong> username.  If you don't know the <strong>Login</strong> name, try <em>source</em> (it is considered the default login name for an Icecast server source).  Finally <strong>Pass</strong> is an abbreviation of password. If you wish to turn off stats retrieval for a particular server you can do so by unchecking the box in the asterisk column after having added your server to the list.</p>
 <p>The <strong>Format</strong> frame is for setting the samplerate, bitrate, and format of the stream of which you can choose between Ogg and mp3 and a wide selection of bitrates and samplerates, however not all of them are going to be valid, for instance all the valid mp3 samplerates are those listed in the drop down box. Additionally there is a status bar to indicate the state of the <em>stream encoder</em> and an <strong>Update</strong> button for changing the encoder parameters while the stream is running.</p>
-<p>The <strong>Stream Info</strong> pane is for entering information about your stream which is irrelevant to the connection. Be descriptive here if you want the information to be displayed on a listings site. See <strong>Make Public</strong>.</p>
+<p>The <strong>Stream Info</strong> pane (not shown) is for entering information about your stream which is irrelevant to the connection. Be descriptive here if you want the information to be displayed on a listings site. See <strong>Make Public</strong>.</p>
 <p><strong>Make Public</strong> causes your radio station to be catalogued on whichever listings site the server is configured for (as an example: <a href="http://www.shoutcast.com" target="_blank">www.shoutcast.com</a>) however it may not show up immediately and the server may be configured not to use a listings site at all. If you use this option make sure to fill all the fields in the Stream Info pane.</p>
-<p><strong>Server Connect</strong> triggers a connection attempt to the server. Notice the state of the status LED in the <em>stream tab</em>. When it goes solid green you are connected. To disconnect, click the <strong>Server Connect</strong> button once more. Notice that an automatic server connection is scheduled for 21:00 and a disconnection at 22:00. When the connection is made player 1 is to be started, and also recorder 1. The recording will be saved in the Recordings directory.</p>
+<p>The <strong>Shoutcast Contact Info</strong> pane (also not shown) allows for the setting of contact information for the IRC, AIM, and ICQ networks, ostensibly to allow listeners to make contact with the DJ. This feature does nothing when the connection is to an Icecast server and may also be disabled, if that is the case this particular pane will not be shown.</p>
+<p><strong>Server Connect</strong> triggers a connection attempt to the server. Notice the state of the status LED in the <em>stream tab</em>. When it goes solid green you are connected. To disconnect, click the <strong>Server Connect</strong> button once more. Alongside are controls to allow automatic server connection and disconnection based on a 24 hour clock, which can also be set to coincide with the starting of a media player and a recorder.</p>
 <p>The <strong>Metadata</strong> line is for entering custom text to be sent along with the stream. Typically just the song title is sent which can be achieved by entering "%s" in the box and pressing the <strong>Update</strong> button. The checkboxes are for specifying which streams are to be affected by the change.</p>
 <p>Regarding the recorder, left to right we have the <strong>Stream Selector</strong>, the <strong>Save Directory Chooser</strong>, the recording time elapsed counter, the <strong>Stop Button</strong>, the <strong>Record Button</strong>, and finally the <strong>Pause Button</strong>. It is not necessary to be streaming in order to make a recording.</p>
 <br />
diff --git a/idjc.desktop_ b/idjc.desktop_
index 0e757ee..eb85637 100644
--- a/idjc.desktop_
+++ b/idjc.desktop_
@@ -9,7 +9,7 @@ GenericName=Graphical shoutcast/icecast client
 GenericName[en_GB]=Graphical shoutcast/icecast client
 GenericName[de]=Grafischer Shoutcast/Icecast Client
 GenericName[fr]=Client graphique shoutcast/icecast
-Icon=/usr/share/pixmaps/idjc.png
+Icon=ICONPATHNAME
 MimeType=
 Name=Internet DJ Console
 Path=
diff --git a/idjc_ b/idjc_
index e05284e..e207d85 100644
--- a/idjc_
+++ b/idjc_
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 #   idjc(_): The program launcher shell script for IDJC
-#   Copyright (C) 2005-2008 Stephen Fairchild
+#   Copyright (C) 2005-2009 Stephen Fairchild
 #
 #   This program is free software; you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
@@ -26,20 +26,9 @@ export JACK_START_SERVER="1"
 # Make vorbiscomment and ogginfo use the UTF-8 character set
 export CHARSET="UTF-8"
 
-export metaflac=`which metaflac`
-export lame=`which lame`
-export oggenc=`which oggenc`
-export ogginfo=`which ogginfo`
 export jackd=`which jackd`
 export vorbiscomment=`which vorbiscomment`
 
-# Duplicate processes not allowed: check for a current IDJC process and signal it before exiting
-#if test `pgrep -lf -U $(id -u) idjcgui.py | wc -l` -gt 0 ; then
-#   echo "Only one instance of idjc can be run at any one time per user."
-#   pkill -USR2 -f -U $(id -u) idjcgui.py
-#   exit 5
-#fi
-
 # Process the command line arguments turning them into environment variables
 VERSION_ONLY="0"
 SHOW_HELP="0"
@@ -95,7 +84,7 @@ python=
 export python
 which $python > /dev/null
 if [ $? == "0" ] ; then
-   MALLOC_CHECK_=2 ${python} ${pyexecdir}/idjcgui.py
+   ${python} ${pyexecdir}/idjcgui.py
 else
    echo "Python interpreter not found.  IDJC can not be run without it"
 fi
diff --git a/idjcctrl_.py b/idjcctrl_.py
index 87434df..0448267 100644
--- a/idjcctrl_.py
+++ b/idjcctrl_.py
@@ -32,12 +32,14 @@ allowed_commands = ( "--play",
                      "--request_right",
                      "--testmonitor_on",
                      "--testmonitor_off",
+                     "--record_start",
+                     "--record_stop",
                      "--update" )
 
 def usage():
    print "commands are:", allowed_commands
    print "usage: idjcctrl [--play] [--enqueue] file1.mp3 file2.m3u"
-   print "or     idjcctrl [--connect] 1 2 3"
+   print "or     idjcctrl [--connect] [--record_start] 1 2"
    sys.exit(5)
 
 def write_out_file(command, listoffiles):
diff --git a/idjcpython/IDJCfree.py b/idjcpython/IDJCfree.py
index f9faeea..2ca8ea9 100644
--- a/idjcpython/IDJCfree.py
+++ b/idjcpython/IDJCfree.py
@@ -1,4 +1,4 @@
-#   IDJCfreefuncs.py: Free functions used by IDJC
+#   IDJCfree.py: Free functions used by IDJC
 #   Copyright (C) 2005-2007 Stephen Fairchild (s-fairchild at users.sourceforge.net)
 #
 #   This program is free software: you can redistribute it and/or modify
@@ -15,6 +15,10 @@
 #   along with this program in the file entitled COPYING.
 #   If not, see <http://www.gnu.org/licenses/>.
 
+import pygtk
+pygtk.require("2.0")
+import gtk
+
 import os, encodings.hex_codec
 
 # Convert characters that have special meaning in pango markup language to their safe equivalents
@@ -84,3 +88,11 @@ class int_object:		# Putting an int in a class allows its use in a dictionary
       return self.value
    def set_text(self, value):
       self.value = value
+
+def threadslock(f):
+   def newf(*args, **kwargs):
+      gtk.gdk.threads_enter()
+      r = f(*args, **kwargs)
+      gtk.gdk.threads_leave()
+      return r
+   return newf
diff --git a/idjcpython/IDJCjingles.py b/idjcpython/IDJCjingles.py
index 4823e8b..b7504b9 100644
--- a/idjcpython/IDJCjingles.py
+++ b/idjcpython/IDJCjingles.py
@@ -173,8 +173,10 @@ class jingles:
          self.entry.set_sensitive(True)
          print "Stop player"
          if flush == True:
+            print "stop with flush"
             self.parent.mixer_write("ACTN=stopjingles\nend\n", True)
          else:
+            print "stop without flush"
             self.stop.clicked()	# this will take care of resetting the play button without triggering a flush
          if self.nomute == False:
             self.parent.deckadj.set_value(self.volume)
@@ -290,6 +292,19 @@ class jingles:
       self.jingleswinx.set_value(event.width)
       self.jingleswiny.set_value(event.height)
       
+   def trigger_index(self, index):
+      if index == -1:
+         if self.playing:
+            self.stop.clicked()
+            self.entry.set_text("1")
+            self.play.set_active(True)
+            self.stop.clicked()
+         return
+      if index < len(self.liststore):
+         self.trigger_index(-1)
+         self.entry.set_text(str(index + 1))
+         self.play.set_active(True)
+
    def __init__(self, parent):
       self.parent = parent
       self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
@@ -299,6 +314,8 @@ class jingles:
       self.window.set_border_width(8)
       self.window.connect("delete_event", self.delete_event)
       self.window.set_icon_from_file(pkgdatadir + "icon" + gfext)
+      self.window.add_events(gtk.gdk.KEY_PRESS_MASK)
+      self.window.connect("key-press-event", parent.cb_key_capture)
 
       hbox = gtk.HBox()
       hbox.set_spacing(8)
diff --git a/idjcpython/IDJCmedia.py b/idjcpython/IDJCmedia.py
index 80c4175..6164565 100644
--- a/idjcpython/IDJCmedia.py
+++ b/idjcpython/IDJCmedia.py
@@ -17,30 +17,68 @@
 
 __all__ = [ 'IDJC_Media_Player', 'make_arrow_button', 'supported' ]
 
-import pygtk
-pygtk.require('2.0')
-import gtk
-import gobject
 import os
 import sys
 import time
-import pango
+import urllib
+import subprocess
 import random
 import signal
-try:
-   import eyeD3
-except:
-   eyeD3 = None
-import popupwindow
 import xml.dom.minidom as mdom
-import urllib
-import subprocess
 from stat import *
-from IDJCmultitagger import*
+from collections import deque
+
+import pygtk
+pygtk.require('2.0')
+import gtk
+import gobject
+import pango
+import mutagen
+from mutagen.mp3 import MP3
+from mutagen.flac import FLAC
+from mutagen.mp4 import MP4
+from mutagen.easyid3 import EasyID3
+from mutagen.apev2 import APEv2
+from mutagen.asf import ASF
+   
+import popupwindow
+from mutagentagger import*
 from IDJCfree import *
 from idjc_config import *
 from ln_text import ln
 
+try:
+   from collections import namedtuple
+except:
+   from nt import namedtuple
+
+# Named tuple for a playlist row.
+class PlayerRow(namedtuple("PlayerRow", "rsmeta filename length meta encoding title artist replaygain")):
+   def __nonzero__(self):
+      return self.rsmeta != "<s>valid</s>"
+
+# Playlist value indicating a file isn't valid.
+NOTVALID = PlayerRow("<s>valid</s>", "", 0, "", "latin1", "", "", 0.0)
+
+# Replay Gain value to indicate default.
+RGDEF = 100.0
+
+
+class ButtonFrame(gtk.Frame):
+   def __init__(self, title):
+      gtk.Frame.__init__(self)
+      attrlist = pango.AttrList()
+      attrlist.insert(pango.AttrSize(8000, 0, len(title)))
+      label = gtk.Label(title)
+      label.set_attributes(attrlist)
+      self.set_label_widget(label)
+      label.show()
+      self.hbox = gtk.HBox()
+      self.add(self.hbox)
+      self.hbox.show()
+      self.set_shadow_type(gtk.SHADOW_NONE)
+      self.set_label_align(0.5, 0.5)
+
 class ExternalPL(gtk.Frame):
    def get_next(self):
       next = self._get_next()
@@ -190,11 +228,17 @@ class AnnouncementDialog(gtk.Dialog):
       if lock:
          gtk.gdk.threads_leave()
       return True
-   
+   def cb_keypress(self, widget, event):
+      self.player.parent.cb_key_capture(widget, event)
+      if event.keyval == 65307:
+         return True
+      if event.keyval == 65288 and self.mode == "active":
+         self.cancel_button.clicked()
    def __init__(self, player, model, iter, mode):
       self.player = player
       self.model = model
       self.iter = iter
+      self.mode = mode
       if mode == "initial":
          model.set_value(iter, 3, "110000")
          gtk.Dialog.__init__(self, ln.announcement_initial, player.parent.window, gtk.DIALOG_MODAL)
@@ -202,6 +246,7 @@ class AnnouncementDialog(gtk.Dialog):
          gtk.Dialog.__init__(self, ln.announcement_delete, player.parent.window, gtk.DIALOG_MODAL)
       elif mode == "active":
          gtk.Dialog.__init__(self, ln.announcement_use, player.parent.window, gtk.DIALOG_MODAL)
+      self.connect("key-press-event", self.cb_keypress)
       ivbox = gtk.VBox()
       ivbox.set_border_width(10)
       ivbox.set_spacing(8)
@@ -353,9 +398,10 @@ class Supported(object):
          self.media.append(".wma")
          self.media.append(".ape")
          self.media.append(".mpc")
-         if mp4enabled:
-            self.media.append(".mp4")
-            self.media.append(".m4a")
+         self.media.append(".mp4")
+         self.media.append(".m4a")
+         self.media.append(".m4b")
+         self.media.append(".m4p")
       if flacenabled:
          self.media.append(".flac")
       if speexenabled:
@@ -415,10 +461,10 @@ class IDJC_Media_Player:
          
       filext = supported.check_media(filename)
       if filext == False or os.path.isfile(filename) == False:
-         return [ "Not a valid file", filename, 0, "", "latin1", "", "" ]   
+         return NOTVALID._replace(filename=filename)
  
-      # Use this name for metadata when we can't get anything from the ID3 tags
-      # The name will also appear grey
+      # Use this name for metadata when we can't get anything from tags.
+      # The name will also appear grey to indicate a tagless state.
       meta_name = os.path.basename(filename)
       enclist = self.parent.fenc.split(",")
       for each in enclist:
@@ -426,12 +472,12 @@ class IDJC_Media_Player:
          if each == "@locale":
             each = self.parent.denc
          try:
-            meta_name = unicode(os.path.splitext(meta_name)[0], each)
+            meta_name = unicode(os.path.splitext(meta_name)[0], each).lstrip("0123456789 -")
          except:
             pass
          else:
             encoding = each
-            rsmeta_name = u'<span foreground="gray">' + rich_safe(meta_name) + '</span>'
+            rsmeta_name = '<span foreground="dark red">(%s)</span> %s' % (ln.notag, rich_safe(meta_name))
             title_retval = meta_name
             break
       else:
@@ -440,77 +486,41 @@ class IDJC_Media_Player:
          rsmeta_name = u'<span foreground="gray">Unknown encoding</span>'
          title_retval = u"Unknown"
          
-      filext = filext.lower()
-      if eyeD3 is not None and (filext == ".mp3" or filext == ".flac" or filext == ".ogg" or filext == ".oga"):
+      # Obtain as much metadata from ubiquitous tags as possible.
+      # Files can have ape and id3 tags. ID3 has priority in this case.
+      try:
+         audio = APEv2(filename)
+      except:
+         rg = RGDEF
+         artist = title = ""
+      else:
+         try: 
+            rg = float(audio["REPLAYGAIN_TRACK_GAIN"][0].rstrip(" dB"))
+         except:
+            rg = RGDEF
+         artist = audio.get("ARTIST", [u""])
+         title = audio.get("TITLE", [u""])
+      # ID3 is tried second so it can supercede APE tag data.
+      try:
+         audio = EasyID3(filename)
+      except:
+         pass
+      else:
          try:
-            if eyeD3.isMp3File(filename):
-               audiofile = eyeD3.Mp3AudioFile(filename, eyeD3.ID3_V2)
-               length = audiofile.getPlayTime()
-               if length == 0:
-                  length = 1
-               tag = audiofile.getTag()
-            else:
-               tag = eyeD3.Tag()		# Attempt to read an id3 tag from a flac file
-               tag.link(filename, eyeD3.ID3_V2)
-            artist = unicode(tag.getArtist())
-            title = unicode(tag.getTitle())
+            rg = float(audio["replaygain_track_gain"][0].rstrip(" dB"))
          except:
-            print "Problem with reading ID3v2 tag"
+            pass
          try:
-            if eyeD3.isMp3File(filename) and length == 0:
-               audiofile = eyeD3.Mp3AudioFile(filename, eyeD3.ID3_V1)
-               length = audiofile.getPlayTime()
-               if length == 0:
-                  length = 1
-               tag = audiofile.getTag()
-            else:
-               tag = eyeD3.Tag()		# Attempt to read an id3 tag from a flac file
-               tag.link(filename, eyeD3.ID3_V1)
-         except eyeD3.tag.TagException:
-            if length == 0:
-               print "Could not get length for the file", filename, "Using a length of zero instead"
-         except eyeD3.tag.InvalidAudioFormatException:
-            return [ "Not a valid file", filename, 0, "", "latin1", "", "" ]  
-         if tag is not None and (artist == u"" or title == u""):
-            artist = unicode(tag.getArtist())
-            title = unicode(tag.getTitle())
-            
-         while artist != u"" and artist[-1] == u"\x00":
-            artist = artist[:-1]
-         artist = artist.strip()
-         while title != u"" and title[-1] == u"\x00":
-            title = title[:-1]
-         title = title.strip()
-         if artist != u"" and title != u"":
-            rsmeta_name = meta_name = artist + u" - " + title
-            title_retval = title
-            artist_retval = artist
-
-      if filext == ".ogg" or filext == ".oga" or filext == ".spx":
-         self.parent.mixer_write("OGGP=%s\nACTN=ogginforequest\nend\n" % filename, True)
-         while 1:
-            line = self.parent.mixer_read()
-            if line == "OIR:NOT VALID\n" or line == "":
-               return [ "Not a valid file", filename, 0, "", "latin1", "", "" ]
-            if line.startswith("OIR:ARTIST="):
-               artist = line[11:].strip()
-            if line.startswith("OIR:TITLE="):
-               title = line[10:].strip()
-            if line.startswith("OIR:LENGTH="):
-               length = int(float(line[11:].strip()))
-               if length == 0:
-                  length = 1
-            if line == "OIR:end\n":
-	       break
-
-         if artist != "" and title != "":
-            artist = artist.decode("utf-8")
-            title = title.decode("utf-8")
-            rsmeta_name = meta_name = artist + u" - " + title
-            title_retval = title
-            artist_retval = artist
-
-      elif (avcodec and avformat) and (filext == ".wma" or filext == ".avi" or filext == ".mpc" or filext == ".ape"):
+            artist = audio["artist"]
+         except:
+            pass
+         try:
+            title = audio["title"]
+         except:
+            pass
+         
+      # Trying for metadata from native tagging formats.
+      if avcodec and avformat and filext == ".avi":
          self.parent.mixer_write("AVFP=%s\nACTN=avformatinforequest\nend\n" % filename, True)
          while 1:
             line = self.parent.mixer_read()
@@ -520,77 +530,17 @@ class IDJC_Media_Player:
                title = line[20:].strip()
             if line.startswith("avformatinfo: duration="):
                length = int(line[23:-1])
-               if length == 0:
-                  length = 1
             if line == "avformatinfo: end\n":
                break
-            if artist and title:
-               artist_retval = artist
-               title_retval = title
-               rsmeta_name = meta_name = artist_retval + u" - " + title_retval
-
-      elif filext == ".flac" and os.environ.get("metaflac") != "missing":
-         try:
-            sp = subprocess.Popen([os.environ.get("metaflac"), "--no-utf8-convert", "--show-sample-rate","--show-total-samples", "--show-tag=TITLE", "--show-tag=ARTIST",filename], bufsize = 4096, stdout = subprocess.PIPE, close_fds = True)
-         except Exception, inst:
-            print inst
-            print "unable to open a pipe to the metaflac program"
-            print "failed to get valid metadata for", filename
-            return [ "Not a valid file", filename, 0, "", "latin1", "", "" ]
-         
-         data = unicode(sp.stdout.read())
-         sp.stdout.close()
-         data = data.splitlines()
-         try:
-            length = int(data[1]) / int(data[0])
-            if length == 0:
-               length = 1
-         except:
-            print "failed to get valid flac metadata for", filename
-            return [ "Not a valid file", filename, 0, "", "latin1", "", "" ]
-         artist = title = u""
-         for each in data:
-            if each[:7].upper() == "ARTIST=":
-               artist = each[7:].strip()
-            if each[:6].upper() == "TITLE=":
-               title = each[6:].strip()
-         if artist != u"" and title != u"":
-            rsmeta_name = meta_name = artist + " - " + title
-            title_retval = title
-            artist_retval = artist
-      elif (filext == ".mp4" or filext == ".m4a") and mp4enabled:
-         print "getting info for mp4 file"
-         self.parent.mixer_write("MP4P=%s\nACTN=mp4inforequest\nend\n" % filename, True)
-         while 1:
-            line = self.parent.mixer_read()
-            if line == "idjcmixer: mp4fileinfo Not Valid\n" or line == "":
-               return [ "Not a valid file", filename, 0, "", "latin1", "", "" ]
-            if line.startswith("idjcmixer: mp4fileinfo artist="):
-               artist = line[30:].strip()
-            if line.startswith("idjcmixer: mp4fileinfo title="):
-               title = line[29:].strip()
-            if line.startswith("idjcmixer: mp4fileinfo length="):
-               length = int(float(line[30:].strip()))
-               if length == 0:
-                  length = 1
-            if line == "idjcmixer: mp4fileinfo end\n":
-	       break
-         if artist != "" and title != "":
-            artist = artist.decode("utf-8")
-            title = title.decode("utf-8")
-            rsmeta_name = meta_name = artist + u" - " + title
-            title_retval = title
-            artist_retval = artist
+      
       elif (filext == ".wav" or filext == ".aiff" or filext == ".au"):
          self.parent.mixer_write("SNDP=%s\nACTN=sndfileinforequest\nend\n" % filename, True)
          while 1:
             line = self.parent.mixer_read()
             if line == "idjcmixer: sndfileinfo Not Valid\n" or line == "":
-               return [ "Not a valid file", filename, 0, "", "latin1", "", "" ] 
+               return NOTVALID._replace(filename=filename)
             if line.startswith("idjcmixer: sndfileinfo length="):
                length = int(line[30:-1])
-               if length == 0:
-                  length = 1
             if line.startswith("idjcmixer: sndfileinfo artist="):
                artist = line[30:-1]
             if line.startswith("idjcmixer: sndfileinfo title="):
@@ -598,38 +548,121 @@ class IDJC_Media_Player:
             if line == "idjcmixer: sndfileinfo end\n":
                break
          if length == None:
-            return [ "Not a valid file", filename, 0, "", "latin1", "", "" ]
-         if artist != "" and title != "":
-            try:
-               artist_retval = artist.decode("utf-8", "strict")
-               title_retval = title.decode("utf-8", "strict")
-            except:
-               artist_retval = artist.decode("latin1", "replace")
-               title_retval = title.decode("latin1", "replace")
-            rsmeta_name = meta_name = artist_retval + u" - " + title_retval
-
-      if rsmeta_name == meta_name:
-         return [ rich_safe(rsmeta_name), filename, length, meta_name, encoding, title_retval, artist_retval ]
+            return NOTVALID._replace(filename=filename)
+     
+      # This handles chained ogg files as generated by IDJC.
+      elif filext == ".ogg" or filext == ".oga" or filext == ".spx":
+         self.parent.mixer_write("OGGP=%s\nACTN=ogginforequest\nend\n" % filename, True)
+         while 1:
+            line = self.parent.mixer_read()
+            if line == "OIR:NOT VALID\n" or line == "":
+               return NOTVALID._replace(filename=filename)
+            if line.startswith("OIR:ARTIST="):
+               artist = line[11:].strip()
+            if line.startswith("OIR:TITLE="):
+               title = line[10:].strip()
+            if line.startswith("OIR:LENGTH="):
+               length = int(float(line[11:].strip()))
+            if line.startswith("OIR:REPLAYGAIN_TRACK_GAIN="):
+               try:
+                  rg = float(line[26:].rstrip(" dB\n"))
+               except:
+                  rg = RGDEF
+            if line == "OIR:end\n":
+               break
       else:
-         return [ rsmeta_name, filename, length, meta_name, encoding, title_retval, artist_retval ]
+         # Mutagen used for all remaining formats.
+         try:
+            audio = mutagen.File(filename)
+         except:
+            return NOTVALID._replace(filename=filename)
+         else:
+            length = int(audio.info.length)
+            if isinstance(audio, MP4):
+               try:
+                  artist = audio["\xa9ART"][0]
+               except:
+                  pass
+               try:
+                  title = audio["\xa9nam"][0]
+               except:
+                  pass
+            elif isinstance(audio, MP3):
+               # The LAME tag is the last port of call for Replay Gain info
+               # due to it frequently being based on the source audio.
+               if rg == RGDEF:
+                  try:
+                     rg = audio.info.track_gain
+                  except:
+                     pass
+                  else:
+                      if rg is None:
+                         rg = RGDEF
+            else:
+               x = list(audio.get("Artist", []))
+               x += list(audio.get("Author", []))
+               if x:
+                  artist = "/".join((unicode(y) for y in x))
+               
+               try:
+                  x = list(audio["Title"])
+               except:
+                  pass
+               else:
+                  title = "/".join((unicode(y) for y in x))
+               
+               try:
+                  rg = float(unicode(audio["replaygain_track_gain"][-1]).rstrip(" dB"))
+               except:
+                  pass 
+      
+      if isinstance(artist, list):
+         artist = u"/".join(artist)
+         
+      if isinstance(title, list):
+         title = u"/".join(title)
+      
+      if isinstance(artist, str):
+         try:
+            artist = artist.decode("utf-8", "strict")
+         except:
+            artist = artist.decode("latin1", "replace")
+            
+      if isinstance(title, str):
+         try:
+            title = title.decode("utf-8", "strict")
+         except:
+            title = title.decode("latin1", "replace")
+            
+      assert(isinstance(artist, unicode))
+      assert(isinstance(title, unicode))
+      
+      if length == 0:
+         length = 1
+      
+      if artist and title:
+         meta_name = artist + u" - " + title
+         return PlayerRow(rich_safe(meta_name), filename, length, meta_name, encoding, title, artist, rg)
+      else:
+         return PlayerRow(rsmeta_name, filename, length, meta_name, encoding, title_retval, artist_retval, rg)
 
    # Update playlist entries for a given filename e.g. when tag has been edited
    def update_playlist(self, newdata):
       update = False
       for item in self.liststore:
          if item[1] == newdata[1]:
-            if item[0][:3] == "<b>":
+            if item[0].startswith("<b>"):
                item[0] = u"<b>" + newdata[0] + u"</b>"
                update = True
             else:
                item[0] = newdata[0]
-            item[3] = newdata[3]
-            item[5] = newdata[5]
-            item[6] = newdata[6]
+            for i in range(2, len(item)):
+               item[i] = newdata[i]
       if update:
-         self.songname = newdata[3]	# update metadata on server
-         self.title = newdata[5].encode("utf-8")
-         self.artist = newdata[6].encode("utf-8")
+         self.songname = item[3]	# update metadata on server
+         self.title = item[5].encode("utf-8")
+         self.artist = item[6].encode("utf-8")
+         self.player_restart()
          self.parent.send_new_mixer_stats()
       
    # Shut down our media players when we exit.
@@ -653,6 +686,7 @@ class IDJC_Media_Player:
       fh.write("playlist_mode=" + str(self.pl_mode.get_active()) + "\n")
       fh.write("plsave_filetype=" + str(self.plsave_filetype) + "\n")
       fh.write("plsave_open=" + str(int(self.plsave_open)) + "\n")
+      fh.write("fade_mode=" + str(self.pl_delay.get_active()) + "\n")
       if self.plsave_folder is not None:
          fh.write("plsave_folder=" + self.plsave_folder + "\n")
       
@@ -662,9 +696,12 @@ class IDJC_Media_Player:
          if entry[0].startswith("<b>"):   # clean off any accidental bold tags
             entry[0] = entry[0][3:-4]
          for item in entry:
-            if type(item) == int:
+            if isinstance(item, int):
                item = str(item)
                fh.write("i")
+            elif isinstance(item, float):
+               item = str(item)
+               fh.write("f")
             else:
                fh.write("s")
             fh.write(str(len(item)) + ":" + item)
@@ -706,14 +743,14 @@ class IDJC_Media_Player:
                self.plsave_open=bool(int(line[12]))
             if line.startswith("plsave_folder="):
                self.plsave_folder=line[14:-1]
+            if line.startswith("fade_mode="):
+               self.pl_delay.set_active(int(line[10]))
             if line.startswith("pe="):
                playlist_entry = self.pl_unpack(line[3:])
-               try:
+               if not playlist_entry or self.playlist_todo:
+                  self.playlist_todo.append(playlist_entry.filename)
+               else:
                   self.liststore.append(playlist_entry)
-               except:		# playlist data may not be compatible across IDJC versions
-                  playlist_entry = self.get_media_metadata(playlist_entry[1])
-                  if playlist_entry[0] != "Not a valid file":
-                     self.liststore.append(playlist_entry)
             if line.startswith("select="):
                path = line[7:-1]
                try:
@@ -723,29 +760,56 @@ class IDJC_Media_Player:
                   pass
          except ValueError:
             pass
+      if self.playlist_todo:
+         print self.playername + " player: the stored playlist data is not compatible with this version\nfiles placed in a queue for rescanning"
+         gobject.idle_add(self.cb_playlist_todo)
+         
+   @threadslock
+   def cb_playlist_todo(self):
+      if self.no_more_files:
+         return False
+      try:
+         pathname = self.playlist_todo.popleft()
+      except:
+         return False
+      line = self.get_media_metadata(pathname)
+      if line:
+         self.liststore.append(line)
+      else:
+         print "file missing or type unsupported %s" % pathname
+      return True
 
    def pl_unpack(self, text):		# converts a string encoded list to a python list
       start = 0	
       item = 0	
-      reply = list()
+      reply = []
       while text[start] != "\n":
          end = start
          while text[end] != ":":
             end = end + 1				
          nextstart = int(text[start + 1 : end]) + end + 1
-         if (text[start] == "s"):
-            reply.append(text[ end+1 : nextstart ])
-         elif (text[start] == "i"):
+         
+         value = text[end + 1 : nextstart]
+         try:
+            if text[start] == "i":
+               value = int(value)
+            elif text[start] == "f":
+               value = float(value)
+            else:
+               assert(text[start] == "s")
+         except:
+            print "pl_unpack: playlist line not valid"
             try:
-               reply.append(int(text[ end+1 : nextstart ]))
-            except:
-               print "pl_unpack: bad integer data"
-               return []
-         else:
-            print "pl_unpack: unknown data type:", text[start]
-            return []
+               return NOTVALID._replace(filename=reply[1])
+            except IndexError:
+               return NOTVALID
+            return nv
+         reply.append(value)
          start = nextstart
-      return reply
+      try:
+         return PlayerRow._make(reply)
+      except:
+         return NOTVALID._replace(filename=reply[1])
              
    def handle_stop_button(self, widget):
       self.restart_cancel = True
@@ -860,8 +924,18 @@ class IDJC_Media_Player:
          except ZeroDivisionError:
             self.start_time = 0
       else:
-         self.start_time = rt	# Seek to the end when file is missing - looks very slick in action.
+         self.start_time = rt	# Seek to the end when file is missing.
       print "Seek time is %d seconds" % self.start_time
+        
+      if self.parent.prefs_window.rg_adjust.get_active():
+         self.gain = model.get_value(iter, 7)
+         if self.gain == RGDEF:
+            self.gain = self.parent.prefs_window.rg_defaultgain.get_value()
+         self.gain += self.parent.prefs_window.rg_boost.get_value()
+         print "final gain value of %f dB" % self.gain      
+      else:
+         self.gain = 0.0
+         print "not using replay gain"
            
       # Now we recalibrate the progress bar to the current song length
       self.digiprogress_f = True
@@ -884,13 +958,8 @@ class IDJC_Media_Player:
       self.silence_count = 0
       
       if self.music_filename != "":
-         if self.gapless == False:
-            self.parent.mixer_write("PLRP=%s\nSEEK=%d\nSIZE=%d\nACTN=play%s\nend\n" % (
-                                 self.music_filename, self.start_time, self.max_seek, self.playername), True)
-         else:
-            print "playing without flush"
-            self.parent.mixer_write("PLRP=%s\nSEEK=%d\nSIZE=%d\nACTN=playnoflush%s\nend\n" % (
-                                 self.music_filename, self.start_time, self.max_seek, self.playername), True)
+         self.parent.mixer_write("PLRP=%s\nSEEK=%d\nSIZE=%d\nRGDB=%f\nACTN=playnoflush%s\nend\n" % (
+                                 self.music_filename, self.start_time, self.max_seek, self.gain, self.playername), True)
          while 1:
             line = self.parent.mixer_read()
             if line.startswith("context_id="):
@@ -922,7 +991,7 @@ class IDJC_Media_Player:
             text = text[3:-4]
             self.model_playing.set_value(self.iter_playing, 0, text)
          self.file_iter_playing = 0
-
+      
       self.player_is_playing = False
       if self.timeout_source_id:
          gobject.source_remove(self.timeout_source_id)
@@ -939,6 +1008,11 @@ class IDJC_Media_Player:
       self.other_player_initiated = False
       self.crossfader_initiated = False
    
+   def set_fade_mode(self, mode):
+      if self.parent.simplemixer:
+         mode = 0
+      self.parent.mixer_write("FADE=%d\nACTN=fademode_%s\nend\n" % (mode, self.playername), True)
+   
    def player_restart(self):
       # remember which player started last so we can decide on metadata
       print "player_restart %s" % self.playername
@@ -967,6 +1041,29 @@ class IDJC_Media_Player:
       self.timeout_source_id = gobject.timeout_add(100,	self.cb_play_progress_timeout, self.player_cid)
       return True
 
+   def next_real_track(self, i):
+      if i == None:
+         return None
+      
+      m = self.model_playing
+      while 1:
+         i = m.iter_next(i)
+         if i is None:
+            return None
+         if m.get_value(i, 0)[0] != ">":
+            return i
+
+   def first_real_track(self):
+      m = self.model_playing
+      i = m.get_iter_first()
+      
+      while 1:
+         if i == None:
+            return None
+         if m.get_value(i, 0)[0] != ">":
+            return i
+         i = m.get_iter_next(i)
+
    def invoke_end_of_track_policy(self):
       # This is where we implement the playlist modes.
       mode_text = self.pl_mode.get_active_text()
@@ -987,44 +1084,33 @@ class IDJC_Media_Player:
             if self.is_playing == False:
                treeselection.select_path(0) # park on the first menu item
       elif mode_text == ln.loop_all or mode_text == ln.cue_up:
-     	 path = self.model_playing.get_path(self.iter_playing)[0]+1
-	 self.stop.clicked()
-         try:
-	    self.model_playing.get_iter(path)
-	    print "Picking the next element in the playlist"
-	 except:
-	    print "We are at the bottom. Picking the first element"
-	    path = 0
-         treeselection = self.treeview.get_selection()
-	 treeselection.select_path(path)
-         if mode_text == ln.loop_all or (mode_text == ln.cue_up and self.model_playing[path][0][0] == ">"):
-            self.play.clicked()
+         iter = self.next_real_track(self.iter_playing)
+         if iter is None:
+            iter = self.first_real_track()
+         self.stop.clicked()
+         if iter is not None:
+            treeselection = self.treeview.get_selection()
+            treeselection.select_iter(iter)
+            if mode_text == ln.loop_all:
+               self.play.clicked()
+         else:
+            treeselection.select_path(0)
       elif mode_text == ln.random:
-	 # Count the number of tracks
-	 self.stop.clicked()	
-	 count = 0
-         while 1:
-	    try:
-               self.model_playing.get_iter(count)
-               count = count + 1 
-	    except:
-               break
-         
-	 print "There are", count, "elements in the playlist"
-         # Pick a new track almost at random
-	 
-         new_path = random.randint(0, count -1)
-	 if count > 3:
-	    # Prevent repetition of songs when there are more than 3 in the playlist
-	    current_path = self.model_playing.get_path(self.iter_playing)[0]
-	    while new_path == current_path:
-	       # Must try again
-	       new_path = random.randint(0, count -1)
-	 
-	 print "New track is:", new_path
-         treeselection = self.treeview.get_selection()	 
-	 treeselection.select_path(new_path)
-	 self.play.clicked()
+         valid = []
+         for i, line in enumerate(self.liststore):
+            if line[0][0] != ">":
+               valid.append(i)
+         path = self.model_playing.get_path(self.iter_playing)[0]
+         self.stop.clicked()
+         if valid:
+            while 1:
+               newpath = valid[random.randint(0, len(valid) - 1)]
+               if newpath != path or valid == 1:
+                  path = newpath
+                  break
+            treeselection = self.treeview.get_selection()	 
+            treeselection.select_path(path)
+            self.play.clicked()
       elif mode_text == ln.external:
          path = self.model_playing.get_path(self.iter_playing)[0]
          self.stop.clicked()
@@ -1038,11 +1124,14 @@ class IDJC_Media_Player:
             treeselection.select_path(path)
             self.play.clicked()
       elif mode_text == ln.alternate:
-         path = self.model_playing.get_path(self.iter_playing)[0]
+         iter = self.next_real_track(self.iter_playing)
+         if iter is None:
+            iter = self.first_real_track()
          self.stop.clicked()
          treeselection = self.treeview.get_selection()
-         treeselection.select_path(path + 1)
-         if not treeselection.path_is_selected(path + 1):
+         if iter is not None:
+            treeselection.select_iter(iter)
+         else:
             treeselection.select_path(0)
          if self.playername == "left":
             self.parent.passright.clicked()
@@ -1119,7 +1208,16 @@ class IDJC_Media_Player:
             treeselection.select_iter(model.iter_next(iter))
          else:
             treeselection.select_path(0)
-
+      if control.startswith("<b>>fade"):
+         if control.endswith("e5</b>"):
+            self.set_fade_mode(1)
+         elif control.endswith("e10</b>"):
+            self.set_fade_mode(2)
+         self.next.clicked()
+         self.set_fade_mode(0)
+         if self.is_playing == False:
+            treeselection.select_path(0)
+      
    def get_pl_block_size(self, iter):
       size = 0
       speedfactor = self.pbspeedfactor
@@ -1157,17 +1255,17 @@ class IDJC_Media_Player:
             iter = model.get_iter_first()
             bs = self.get_pl_block_size(iter)
       else:
-         if model.get_value(iter, 0)[0:3] == "<b>":
+         try:
+            if model.get_value(iter, 0)[0:3] == "<b>":
+               bs = 0
+            else:
+               bs = self.get_pl_block_size(iter)
+         except:
+            print "Playlist data is fucked up"
             bs = 0
-         else:
-            bs = self.get_pl_block_size(iter)
       bsm, bss = divmod(bs, 60)
-      #bss = bs % 60
-      #bsm = (bs - bss) / 60
       if self.is_playing:
          trm, trs = divmod(tr, 60)
-         #trs = tr % 60
-         #trm = (tr - trs) / 60
          tm_end = time.localtime(int(time.time()) + tr)
          tm_end_h = tm_end[3]
          tm_end_m = tm_end[4]
@@ -1194,13 +1292,18 @@ class IDJC_Media_Player:
          self.oldstatusbartext = newtext
 
    def check_mixer_signal(self):
-      if self.progress_press == False and self.progressadj.upper - self.progress_current_figure < 7.0 and self.progressadj.upper > 10.0:
-         if self.mixer_signal_f.value == 0 and int(self.mixer_cid) == self.player_cid and self.parent.prefs_window.silence_killer.get_active():
+      if self.progress_press == False and self.progressadj.upper - self.progress_current_figure < 5.0 and self.progressadj.upper > 10.0:
+         if self.mixer_signal_f.value == 0 and int(self.mixer_cid) == self.player_cid + 1 and self.parent.prefs_window.silence_killer.get_active() and self.eos_inspect() == False:
             print "termination by check mixer signal"
             self.invoke_end_of_track_policy()
 
+   @threadslock
    def cb_play_progress_timeout(self, cid):
-      gtk.gdk.threads_enter()
+      if cid % 2 == 0:
+         # player started at end of track
+         self.invoke_end_of_track_policy()
+         return False
+
       if self.reselect_cursor_please:
          treeselection = self.treeview.get_selection()
          (model, iter) = treeselection.get_selected()
@@ -1224,14 +1327,12 @@ class IDJC_Media_Player:
             print "termination due to end of track"
             self.invoke_end_of_track_policy()
             self.gapless = False
-            gtk.gdk.threads_leave()
             return False
          if self.mixer_signal_f.value == False:
             self.silence_count += 1
             if self.silence_count >= 120 and self.playtime_elapsed.value > 15 and self.parent.prefs_window.bonus_killer.get_active():
                print "termination due to excessive silence"
                self.invoke_end_of_track_policy()
-               gtk.gdk.threads_leave()
                return False
          else:
             self.silence_count = 0
@@ -1243,16 +1344,14 @@ class IDJC_Media_Player:
       else:
          # we stop monitoring the play progress during the progress bar drag operation
          # by cancelling this timeout
-         gtk.gdk.threads_leave()
          return False
       # Calclulate when to sound the DJ alarm (end of music notification)
       # Bugs: does not deep scan the playlist controls for >stopplayer so the alarm will not sound if
       # preceeded by another playlist control
-      if self.progress_current_figure == self.progress_stop_figure -9 and self.progressadj.upper > 10 and self.parent.prefs_window.djalarm.get_active():
-         if ((self.playername == "left" and self.parent.crossadj.get_value() < 50) or (self.playername == "right" and self.parent.crossadj.get_value() >= 50)) and (self.pl_mode.get_active() == 3 or self.pl_mode.get_active() == 4 or (self.pl_mode.get_active() == 0 and (self.model_playing.iter_next(self.iter_playing) is None or (self.pl_mode.get_active() == 0 and self.model_playing.get_value(self.model_playing.iter_next(self.iter_playing), 0) == ">stopplayer")))):
+      if self.progress_current_figure == self.progress_stop_figure -10 and self.progressadj.upper > 11 and self.parent.prefs_window.djalarm.get_active():
+         if ((self.playername == "left" and self.parent.crossadj.get_value() < 50) or (self.playername == "right" and self.parent.crossadj.get_value() >= 50)) and (self.pl_mode.get_active() == 3 or self.pl_mode.get_active() == 4 or (self.pl_mode.get_active() == 0 and (self.model_playing.iter_next(self.iter_playing) is None or (self.pl_mode.get_active() == 0 and self.stop_inspect())))):
             if self.alarm_cid != cid:
-               self.parent.alarm = True
-               self.parent.send_new_mixer_stats()
+               gobject.timeout_add(1000, self.deferred_alarm)
                self.alarm_cid = cid
       # Initial autocrossfade -- start the other player.
       if self.model_playing.iter_next(self.iter_playing) is not None and self.model_playing.get_value(self.model_playing.iter_next(self.iter_playing), 0) == ">crossfade" and self.pl_mode.get_active() == 0 and int(self.progress_current_figure) >= int(self.progress_stop_figure) -15:
@@ -1271,15 +1370,95 @@ class IDJC_Media_Player:
             if desired_direction != self.parent.crossdirection:
                self.parent.passbutton.clicked()
       
-      gtk.gdk.threads_leave()
+      rem = self.progress_stop_figure - self.progress_current_figure
+      if (rem == 5 or rem == 10) and not self.crossfader_initiated and not self.parent.simplemixer:
+         mode = self.pl_mode.get_active()
+         next = self.model_playing.iter_next(self.iter_playing)
+         if next is not None:
+            nextval = self.model_playing.get_value(next, 0)
+         else:
+            nextval = ""
+         if mode == 0 and nextval.startswith(">"):
+            if rem == 5 and nextval == ">fade5":
+               fade = 1
+            elif rem == 10 and nextval == ">fade10":
+               fade = 2
+            else:
+               fade = 0
+            if (fade):
+               self.set_fade_mode(fade)
+               self.stop.clicked()
+               treeselection = self.treeview.get_selection()
+               next = self.model_playing.iter_next(next)
+               if next is not None:
+                  path = self.model_playing.get_path(next)
+                  treeselection.select_path(path)
+                  self.play.clicked()
+               else:
+                  treeselection.select_path(0)
+               self.set_fade_mode(0)
+         else:
+            fade = self.pl_delay.get_active()
+            if (fade == 1 and rem == 10) or (fade == 2 and rem == 5) or self.pl_mode.get_active() in (3, 4, 6) or (mode == 0 and self.islastinplaylist()):
+               fade = 0
+            if fade:
+               self.set_fade_mode(fade)
+               self.invoke_end_of_track_policy()
+               self.set_fade_mode(0)
+      
       return True
 
-   def islastinplaylist(self):
-      ifself.model_playing.iter_next(self.iter_playing)
-      if iter == None:
+   @threadslock
+   def deferred_alarm(self):
+      self.parent.alarm = True
+      self.parent.send_new_mixer_stats()
+      return False
+
+   def stop_inspect(self):
+      stoppers = (">stopplayer", ">announcement")
+      horizon = (">transfer", ">crossfade", ">openaux")
+      i = self.iter_playing
+      m = self.model_playing
+      while 1:
+         i = m.iter_next(i)
+         if i is None:
+            return True
+         v = m.get_value(i, 0)
+         if v and v[0] != ">":
+            return False
+         if v in stoppers:
+            return True
+         if v in horizon:
+            return False
+
+   def eos_inspect(self):
+      # Returns true when playlist ended or stream disconnect is imminent.
+      if self.pl_mode.get_active():
          return False
-      else:
+      if self.islastinplaylist():
+         return True
+      stoppers = (">stopstreaming", )
+      horizon = (">transfer", ">crossfade", ">openaux")
+      i = self.iter_playing
+      m = self.model_playing
+      while 1:
+         i = m.iter_next(i)
+         if i is None:
+            return True
+         v = m.get_value(i, 0)
+         if v and v[0] != ">":
+            return False
+         if v in stoppers:
+            return True
+         if v in horizon:
+            return False
+
+   def islastinplaylist(self):
+      iter = self.model_playing.iter_next(self.iter_playing)
+      if iter is None:
          return True
+      else:
+         return False
           
    def arrow_up(self):
       treeselection = self.treeview.get_selection()
@@ -1308,6 +1487,7 @@ class IDJC_Media_Player:
             pass
           
    def advance(self):
+      self.set_fade_mode(self.pl_delay.get_active())
       if self.is_playing:
          path = self.model_playing.get_path(self.iter_playing)[0]+1
          self.stop.clicked()
@@ -1316,6 +1496,7 @@ class IDJC_Media_Player:
          self.treeview.scroll_to_cell(path, None, False)
       else:
          self.play.clicked()
+      self.set_fade_mode(0)
           
    def callback(self, widget, data):
       if data == "pbspeedzero":
@@ -1332,7 +1513,7 @@ class IDJC_Media_Player:
 	 
       if data == "Next":
          if self.is_playing:
-	    path = self.model_playing.get_path(self.iter_playing)[0]+1
+            path = self.model_playing.get_path(self.iter_playing)[0]+1
             if self.is_paused:
                self.stop.clicked()
             try:
@@ -1350,7 +1531,7 @@ class IDJC_Media_Player:
             treeselection = self.treeview.get_selection()
 	    path = self.model_playing.get_path(self.iter_playing)
             if self.is_paused:
-	       self.stop.clicked()
+               self.stop.clicked()
 	    treeselection.select_path(path[0]-1)
 	    self.new_title = True
 	    self.play.clicked()
@@ -1365,12 +1546,11 @@ class IDJC_Media_Player:
             self.filerq = gtk.FileChooserDialog(filerqtext, None, gtk.FILE_CHOOSER_ACTION_OPEN, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
             self.filerq.set_select_multiple(True)
             self.filerq.set_icon_from_file(pkgdatadir + "icon" + gfext)
-            self.filerq.set_filename(str(self.file_requester_start_dir))
+            self.filerq.set_current_folder(str(self.file_requester_start_dir))
             self.filerq.add_filter(self.plfilefilter_all)
             self.filerq.add_filter(self.plfilefilter_playlists)
             self.filerq.add_filter(self.plfilefilter_media)
             self.filerq.set_filter(self.plsave_filtertype)
-            
             frame = gtk.Frame(ln.formats)
             box = gtk.HBox()
             box.set_border_width(3)
@@ -1385,8 +1565,8 @@ class IDJC_Media_Player:
             box.show()
             self.filerq.set_extra_widget(frame)
             self.filerq.connect("response", self.file_response)
-	    self.filerq.connect("destroy", self.file_destroy)
-	    self.filerq.show()
+            self.filerq.connect("destroy", self.file_destroy)
+            self.filerq.show()
             self.showing_file_requester = True
 	 else:
 	    self.filerq.present()
@@ -1394,12 +1574,16 @@ class IDJC_Media_Player:
    def file_response(self, dialog, response_id):
       chosenfiles = self.filerq.get_filenames()
       if chosenfiles:
-         self.file_requester_start_dir.set_text(chosenfiles[0])
+         self.file_requester_start_dir.set_text(os.path.split(chosenfiles[0])[0])
+         self.plsave_filtertype = self.filerq.get_filter()
       self.filerq.destroy()
       if response_id != gtk.RESPONSE_ACCEPT:
          return
       gen = self.get_elements_from(chosenfiles)
       for each in gen:
+         if self.no_more_files:
+            self.no_more_files = False
+            break
          self.liststore.append(each)
          while gtk.events_pending():
             gtk.main_iteration()
@@ -1607,10 +1791,9 @@ class IDJC_Media_Player:
    # This is really a very convoluted workaround to achieve the effect of a connect_after
    # method on a button_release_event on the player progress bar to run player_restart
    # I tried using connect_after but no such luck hence this retarded idle function.
+   @threadslock
    def player_progress_value_changed_emitter(self):
-      gtk.gdk.threads_enter()
       self.progressadj.emit("value_changed")
-      gtk.gdk.threads_leave()
       return False
 
    def cb_menu_select(self, widget, data):
@@ -1620,6 +1803,7 @@ class IDJC_Media_Player:
       return False
 
    def get_elements_from(self, pathnames):
+      self.no_more_files = False
       l = len(pathnames)
       if l == 1:
          ext = os.path.splitext(pathnames[0])[1]
@@ -1630,23 +1814,54 @@ class IDJC_Media_Player:
          elif ext == ".xspf":
             return self.get_elements_from_xspf(pathnames[0])
          elif os.path.isdir(pathnames[0]):
-            return self.get_elements_from_directory(pathnames[0])
+            return self.get_elements_from_directory(pathnames[0], set(), 2)
       return self.get_elements_from_chosen(pathnames)
 
    def get_elements_from_chosen(self, chosenfiles):
       for each in chosenfiles:
          meta = self.get_media_metadata(each)
-         if meta[0] != "Not a valid file":
+         if meta:
             yield meta
    
-   def get_elements_from_directory(self, chosendir):
+   def get_elements_from_directory_orig(self, chosendir):
       files = os.listdir(chosendir)
       files.sort()
       for each in files:
          path = "/".join((chosendir, each))
          meta = self.get_media_metadata(path)
-         if meta[0] != "Not a valid file":
+         if meta:
             yield meta
+
+   def get_elements_from_directory(self, chosendir, visited, depth):
+      depth -= 1
+      chosendir = os.path.realpath(chosendir)
+      if chosendir in visited or not os.path.isdir(chosendir):
+         return
+      else:
+         visited.add(chosendir)
+
+      directories = set()
+
+      print chosendir
+      files = os.listdir(chosendir)
+      files.sort()
+      for filename in files:
+         pathname = "/".join((chosendir, filename))
+         if os.path.isdir(pathname):
+            #if os.path.realpath(pathname) == pathname:
+            if not filename.startswith("."):
+               directories.add(filename)
+         else:
+            meta = self.get_media_metadata(pathname)
+            if meta:
+               yield meta
+               
+      if depth:
+         for subdir in directories:
+            print "examining", "/".join((chosendir, subdir))
+            gen = self.get_elements_from_directory("/".join((chosendir, subdir)), visited, depth)
+            for meta in gen:
+               yield meta
  
    def get_elements_from_m3u(self, filename):
       try:
@@ -1670,7 +1885,7 @@ class IDJC_Media_Player:
                yield meta
             return
          meta = self.get_media_metadata(each)
-         if meta[0] != "Not a valid file":
+         if meta:
             yield meta
          line += 1
          
@@ -1703,7 +1918,7 @@ class IDJC_Media_Player:
          else:
             if os.path.isfile(path):
                meta = self.get_media_metadata(path)
-               if meta[0] != "Not a valid file":
+               if meta:
                   yield meta
          
    def get_elements_from_xspf(self, filename):
@@ -1770,7 +1985,7 @@ class IDJC_Media_Player:
                   for base in baseurl:
                      url = urllib.unquote(urllib.basejoin(base, location.firstChild.wholeText).encode("ASCII"))
                      meta = self.get_media_metadata(url)
-                     if meta[0] != "Not a valid file":
+                     if meta:
                         yield meta
                         raise GotLocation
             except GotLocation:
@@ -1840,7 +2055,7 @@ class IDJC_Media_Player:
             else:
                path, position = drop_info
                dest_iter = model.get_iter(path)
-               if(position == gtk.TREE_VIEW_DROP_BEFORE or position == 			   gtk.TREE_VIEW_DROP_INTO_OR_BEFORE):
+               if(position == gtk.TREE_VIEW_DROP_BEFORE or position == gtk.TREE_VIEW_DROP_INTO_OR_BEFORE):
                   model.insert_before(dest_iter, newrow)
                else:
                   model.insert_after(dest_iter, newrow)
@@ -1859,7 +2074,7 @@ class IDJC_Media_Player:
          else:
             path, position = drop_info
             dest_iter = model.get_iter(path)
-            if(position == gtk.TREE_VIEW_DROP_BEFORE or position == 			   gtk.TREE_VIEW_DROP_INTO_OR_BEFORE):
+            if(position == gtk.TREE_VIEW_DROP_BEFORE or position == gtk.TREE_VIEW_DROP_INTO_OR_BEFORE):
                self.liststore.move_before(iter, dest_iter)
             else:
                self.liststore.move_after(iter, dest_iter)
@@ -1877,6 +2092,9 @@ class IDJC_Media_Player:
       
       first = True
       for media_data in gen:
+         if self.no_more_files:
+            self.no_more_files = False
+            break
          if first:
             gtk.gdk.threads_enter()
             drop_info = treeview.get_dest_row_at_pos(x, y)
@@ -1977,7 +2195,7 @@ class IDJC_Media_Player:
 	    selection.select_path(path)
             self.menu_iter = self.menu_model.get_iter(path)	# store the context of the menu action
             pathname = self.menu_model.get_value(self.menu_iter, 1)
-            self.item_tag.set_sensitive(eyeD3 is not None and multitag.is_supported(multitag(), pathname) != False)
+            self.item_tag.set_sensitive(MutagenGUI.is_supported(pathname) != False)
 	 else:
             pathname = ""
             self.menu_iter = None
@@ -2046,6 +2264,9 @@ class IDJC_Media_Player:
              "Normal Speed Control"	 : ">normalspeed",
              "Switch To Aux Control"     : ">openaux",
              "Announcement Control"      : ">announcement",
+             "Fade 10"                   : ">fade10",
+             "Fade 5"                    : ">fade5",
+             "Fade none"                 : ">fadenone",
       }
       if dict.has_key(text):
          if iter is not None:
@@ -2073,7 +2294,7 @@ class IDJC_Media_Player:
          except TypeError:
             pass
          else:
-            multitag(pathname, model.get_value(iter, 4) , self.parent)
+            MutagenGUI(pathname, model.get_value(iter, 4) , self.parent)
       
       if text == "Add File":
          self.add.clicked()
@@ -2114,7 +2335,7 @@ class IDJC_Media_Player:
             vbox.add(self.plframe)
                
             self.plfilerq = gtk.FileChooserDialog(filerqtext, None, gtk.FILE_CHOOSER_ACTION_SAVE, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
-	    self.plfilerq.set_icon_from_file(pkgdatadir + "icon" + gfext)
+            self.plfilerq.set_icon_from_file(pkgdatadir + "icon" + gfext)
             self.plfilerq.set_current_folder(self.home)
             self.plfilerq.add_filter(self.plfilefilter_all)
             self.plfilerq.add_filter(self.plfilefilter_playlists)
@@ -2126,16 +2347,17 @@ class IDJC_Media_Player:
                self.plfilerq.set_current_name("idjcplaylist.m3u")
             else:
                self.plfilerq.set_current_name("idjcplaylist")
-	    self.plfilerq.connect("response", self.plfile_response)
+            self.plfilerq.connect("response", self.plfile_response)
             self.plfilerq.connect("destroy", self.plfile_destroy)
-	    self.plfilerq.show()
-	    self.showing_pl_save_requester = True
+            self.plfilerq.show()
+            self.showing_pl_save_requester = True
          else:
             self.plfilerq.present()
        
       if text == "Remove All":
          if self.is_playing:
-	    self.stop.clicked()
+            self.stop.clicked()
+         self.no_more_files = True
          self.liststore.clear()
       
       if text == "Remove This" and iter != None:
@@ -2145,24 +2367,26 @@ class IDJC_Media_Player:
 	 self.liststore.remove(iter)
 	 
       if text == "Remove From Here" and iter != None:	 
-	 path = model.get_path(iter)
-	 try:
-	    while 1:
-	       iter = model.get_iter(path)
-	       if model.get_value(iter, 0)[:3] == "<b>":
-	          self.stop.clicked()
-	       self.liststore.remove(iter)
-	 except:
-	    print "Nothing more to delete"
+         path = model.get_path(iter)
+         try:
+            while 1:
+               iter = model.get_iter(path)
+               if model.get_value(iter, 0)[:3] == "<b>":
+                  self.stop.clicked()
+               self.no_more_files = True
+               self.liststore.remove(iter)
+         except:
+            print "Nothing more to delete"
 	 
       if text == "Remove To Here" and iter != None:
-	 path = model.get_path(iter)[0] -1
-	 while path >= 0:
-	    iter = model.get_iter(path)
-	    if model.get_value(iter, 0)[:3] == "<b>":
-	       self.stop.clicked()
-	    self.liststore.remove(iter)
-	    path = path -1
+         self.no_more_files = True
+         path = model.get_path(iter)[0] -1
+         while path >= 0:
+            iter = model.get_iter(path)
+            if model.get_value(iter, 0)[:3] == "<b>":
+               self.stop.clicked()
+            self.liststore.remove(iter)
+            path = path -1
 
       if text == "Duplicate" and iter != None:
          row = list(model[model.get_path(iter)])
@@ -2171,6 +2395,7 @@ class IDJC_Media_Player:
          model.insert_after(iter, row)
       
       if text == "Playlist Exchange":
+         self.no_more_files = True
          if self.playername == "left":
 	    opposite = self.parent.player_right
 	 else:
@@ -2422,14 +2647,11 @@ class IDJC_Media_Player:
       if event.keyval == 65288:		# backspace key stops the player
          self.stop.clicked()
       if event.string == "t" or event.string == "T":	# t key does metadata tagging
-         if eyeD3 is None:
-            print "Tagging disabled due to eyeD3 not being installed"
-            return True
          model, iter = self.treeview.get_selection().get_selected()
          if iter is not None:
             pathname = model.get_value(iter, 1)
-            if multitag.is_supported(multitag(), pathname):
-               multitag(pathname, model.get_value(iter, 4), self.parent)
+            if MutagenGUI.is_supported(pathname):
+               MutagenGUI(pathname, model.get_value(iter, 4), self.parent)
             else:
                print "File type is not supported by the idjc metadata tagger"
       if (event.string == "s" or event.string == "S") and self.pl_mode.get_active() == 0:
@@ -2460,6 +2682,9 @@ class IDJC_Media_Player:
       if event.string == "p" or event.string == "P":
          self.parent.redphone.set_active(not self.parent.redphone.get_active())
          return True
+      
+      if event.string == "/":
+         self.parent.advance.clicked()
          
       # Allow certain key presses to work but not allow a text entry box to appear.
       if event.string =="\r":
@@ -2470,6 +2695,20 @@ class IDJC_Media_Player:
          return False
       return True
 	    
+   def rgrowconfig(self, tv_column, cell_renderer, model, iter):
+      if self.exiting:
+         return
+      self.rowconfig(tv_column, cell_renderer, model, iter)
+      if model.get_value(iter, 0)[0] == ">":
+         cell_renderer.set_property("text", " ")
+      else:
+         if model.get_value(iter, 7) == RGDEF:
+            # Red triangle.
+            cell_renderer.set_property("markup", '<span foreground="dark red">&#x25b5;</span>')
+         else:
+            # Small green bullet point.
+            cell_renderer.set_property("markup", '<span foreground="dark green">&#x2022;</span>')
+        
    def playtimerowconfig(self, tv_column, cell_renderer, model, iter):
       if self.exiting:
          return
@@ -2513,6 +2752,22 @@ class IDJC_Media_Player:
          cell_renderer.set_property("cell-background-set", True)
          cell_renderer.set_property("background-set", True)
          cell_renderer.set_property("foreground-set", True)
+         
+         if celltext == ">fade10":
+            cell_renderer.set_property("cell-background", "dark red")
+            cell_renderer.set_property("background", "gray")
+            cell_renderer.set_property("foreground", "dark red")
+            cell_renderer.set_property("text", ln.fade_10_menu)
+         if celltext == ">fade5":
+            cell_renderer.set_property("cell-background", "dark red")
+            cell_renderer.set_property("background", "gray")
+            cell_renderer.set_property("foreground", "dark red")
+            cell_renderer.set_property("text", ln.fade_5_menu)
+         if celltext == ">fadenone":
+            cell_renderer.set_property("cell-background", "dark red")
+            cell_renderer.set_property("background", "gray")
+            cell_renderer.set_property("foreground", "dark red")
+            cell_renderer.set_property("text", ln.fade_none_menu)
          if celltext == ">announcement":
             cell_renderer.set_property("cell-background", "dark blue")
             cell_renderer.set_property("background", "gray")
@@ -2571,9 +2826,11 @@ class IDJC_Media_Player:
          cell_renderer.set_property("xalign", 0.0)
          cell_renderer.set_property("ypad", 2)
             
+   def cb_playlist_delay(self, widget):
+      print "inter track fade was changed"
+            
    def cb_playlist_mode(self, widget):
-      # uses a side effect that the entire playlist is re-rendered
-      self.tvcolumn.add_attribute(self.cellrender, "markup", 0)
+      self.pl_delay.set_sensitive(self.pl_mode.get_active() in (0, 1, 2, 5))
       if widget.get_active() == 0:
          self.pl_statusbar.show()
       else:
@@ -2722,13 +2979,16 @@ class IDJC_Media_Player:
       # The first one gets rendered and is derived from id3 tags or just is the filename
       # when the id3 tag is not sufficient.
       # The second one always is the filename and is passed to the player.
-      self.liststore = gtk.ListStore(str, str, int, str, str, str, str)
-      self.templist = gtk.ListStore(str, str, int, str, str, str, str)
+      self.liststore = gtk.ListStore(str, str, int, str, str, str, str, float)
+      self.templist = gtk.ListStore(str, str, int, str, str, str, str, float)
       self.treeview = gtk.TreeView(self.liststore)
+      self.rgcellrender = gtk.CellRendererText()
       self.playtimecellrender = gtk.CellRendererText()
       self.cellrender = gtk.CellRendererText()
+      self.rgtvcolumn = gtk.TreeViewColumn("", self.rgcellrender)
       self.playtimetvcolumn = gtk.TreeViewColumn("Time", self.playtimecellrender)
       self.tvcolumn = gtk.TreeViewColumn("Playlist", self.cellrender)
+      self.rgtvcolumn.set_cell_data_func(self.rgcellrender, self.rgrowconfig)
       self.playtimetvcolumn.set_cell_data_func(self.playtimecellrender, self.playtimerowconfig)
       self.tvcolumn.set_cell_data_func(self.cellrender, self.rowconfig)
       self.playtimetvcolumn.add_attribute(self.playtimecellrender, 'text', 2)
@@ -2740,6 +3000,7 @@ class IDJC_Media_Player:
       self.treeview.append_column(self.playtimetvcolumn)
       self.treeview.set_search_column(0)
       self.treeview.set_headers_visible(False)
+      self.treeview.set_enable_search(False)
       self.treeview.enable_model_drag_source( gtk.gdk.BUTTON1_MASK,
       						self.sourcetargets,
 	      					gtk.gdk.ACTION_DEFAULT |
@@ -2826,7 +3087,12 @@ class IDJC_Media_Player:
       # The box for the mute widgets.
       self.hbox2 = gtk.HBox(False, 0)
       self.hbox2.set_border_width(4)
-      pbox.pack_start(self.hbox2, False, False, 0)
+      self.hbox2.set_spacing(4)
+      frame = gtk.Frame()
+      frame.set_border_width(4)
+      frame.add(self.hbox2)
+      pbox.pack_start(frame, False, False, 0)
+      frame.show()
 
       # A set of buttons for hbox1 namely Prev/Play/Pause/Stop/Next/Playlist : XMMS order
       image = gtk.Image()
@@ -2897,6 +3163,11 @@ class IDJC_Media_Player:
       self.hbox1.show()
 
       # The playlist mode dropdown menu.
+      
+      frame = ButtonFrame(ln.playlistmode)
+      self.hbox2.pack_start(frame, True, True, 0)
+      frame.show()
+      
       self.pl_mode = gtk.combo_box_new_text()
       self.pl_mode.append_text(ln.play_all)
       self.pl_mode.append_text(ln.loop_all)
@@ -2909,17 +3180,34 @@ class IDJC_Media_Player:
       self.pl_mode.connect("changed", self.cb_playlist_mode)
       parent.tooltips.set_tip(self.pl_mode, ln.playlist_modes_tip)
       
-      self.hbox2.pack_start(self.pl_mode, True, True, 0)
+      frame.hbox.pack_start(self.pl_mode, True, True, 0)
       self.pl_mode.show()
       
+      frame = ButtonFrame(ln.trackfade)
+      self.hbox2.pack_start(frame, True, True, 0)
+      frame.show()
+      
+      self.pl_delay = gtk.combo_box_new_text()
+      self.pl_delay.append_text(ln.pldelay_none)
+      self.pl_delay.append_text("5")
+      self.pl_delay.append_text("10")
+      self.pl_delay.set_active(0)
+      self.pl_delay.connect("changed", self.cb_playlist_delay)
+      parent.tooltips.set_tip(self.pl_delay, ln.pldelay_tip)
+      
+      frame.hbox.pack_start(self.pl_delay, True, True, 0)
+      self.pl_delay.show()
+      
       # Up and Down arrows for moving items in the playlist
       self.uparrow = make_arrow_button(self, gtk.ARROW_UP, gtk.SHADOW_IN, "Arrow Up")
       self.hbox2.pack_start(self.uparrow, True, True, 0)
       parent.tooltips.set_tip(self.uparrow, ln.up_arrow_tip)
+      self.uparrow.hide()
       
       self.dnarrow = make_arrow_button(self, gtk.ARROW_DOWN, gtk.SHADOW_IN, "Arrow Dn")
       self.hbox2.pack_start(self.dnarrow, True, True, 0)
       parent.tooltips.set_tip(self.dnarrow, ln.down_arrow_tip)
+      self.dnarrow.hide()
       
       # Delete mode toggle button for playlist
       image = gtk.Image()
@@ -2930,27 +3218,32 @@ class IDJC_Media_Player:
       self.delete_mode = self.delete.get_active()
       self.delete.connect("toggled", self.cb_toggle, "Delete")
       self.hbox2.pack_start(self.delete, True, True, 0)
-      self.delete.show()
+      #self.delete.show()
       parent.tooltips.set_tip(self.delete, ln.delete_mode_tip)
       
       # Mute buttons
+      
+      frame = ButtonFrame(ln.audiofeed)
+      self.hbox2.pack_start(frame, True, True, 0)
+      frame.show()
+      
       self.stream = gtk.ToggleButton(ln.stream)
       self.stream.set_active(True)
       self.stream.connect("toggled", self.cb_toggle, "Stream")
-      self.hbox2.pack_start(self.stream, True, True, 0)
+      frame.hbox.pack_start(self.stream, True, True, 0)
       self.stream.show()
       parent.tooltips.set_tip(self.stream, ln.stream_tip)
             
-      self.listen = nice_listen_togglebutton(ln.listen)
+      self.listen = nice_listen_togglebutton(ln.djlisten)
       self.listen.set_active(True)
       self.listen.connect("toggled", self.cb_toggle, "Listen")
-      self.hbox2.pack_start(self.listen, True, True, 0)
+      frame.hbox.pack_start(self.listen, True, True, 0)
       self.listen.show()
       parent.tooltips.set_tip(self.listen, ln.listen_tip)
       
-      sizegroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
-      sizegroup.add_widget(self.stream)
-      sizegroup.add_widget(self.listen)
+      #sizegroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
+      #sizegroup.add_widget(self.stream)
+      #sizegroup.add_widget(self.listen)
       
       # hbox2 is now filled so lets show it
       self.hbox2.show()
@@ -3016,6 +3309,25 @@ class IDJC_Media_Player:
       self.control_menu.append(separator)
       separator.show()
       
+      self.control_menu_fade_10_control = gtk.MenuItem(ln.fade_10_menu)
+      self.control_menu_fade_10_control.connect("activate", self.menuitem_response, "Fade 10")
+      self.control_menu.append(self.control_menu_fade_10_control)
+      self.control_menu_fade_10_control.show()
+      
+      self.control_menu_fade_5_control = gtk.MenuItem(ln.fade_5_menu)
+      self.control_menu_fade_5_control.connect("activate", self.menuitem_response, "Fade 5")
+      self.control_menu.append(self.control_menu_fade_5_control)
+      self.control_menu_fade_5_control.show()
+      
+      self.control_menu_fade_none_control = gtk.MenuItem(ln.fade_none_menu)
+      self.control_menu_fade_none_control.connect("activate", self.menuitem_response, "Fade none")
+      self.control_menu.append(self.control_menu_fade_none_control)
+      self.control_menu_fade_none_control.show()
+      
+      separator = gtk.SeparatorMenuItem()
+      self.control_menu.append(separator)
+      separator.show()
+      
       self.control_menu_stream_disconnect_control = gtk.MenuItem(ln.stream_disconnect_menu)
       self.control_menu_stream_disconnect_control.connect("activate", self.menuitem_response, "Stream Disconnect Control")
       self.control_menu.append(self.control_menu_stream_disconnect_control)
@@ -3024,8 +3336,8 @@ class IDJC_Media_Player:
       self.control_menu_stop_recording_control = gtk.MenuItem(ln.stop_recording_menu)
       self.control_menu_stop_recording_control.connect("activate", self.menuitem_response, "Stop Recording Control")
       self.control_menu.append(self.control_menu_stop_recording_control)
-      self.control_menu_stop_recording_control.show()    
-        
+      self.control_menu_stop_recording_control.show()
+      
       self.pl_menu_control.set_submenu(self.control_menu)
       self.control_menu.show()
       
@@ -3239,5 +3551,6 @@ class IDJC_Media_Player:
       self.pbspeedfactor = 1.0
       self.playlist_changed = True
       self.alarm_cid = 0
-      if eyeD3 is not None:
-         self.tag = eyeD3.Tag()
+      self.playlist_todo = deque()
+      self.no_more_files = False
+
diff --git a/idjcpython/IDJCmixprefs.py b/idjcpython/IDJCmixprefs.py
index 3e95a66..faebca6 100644
--- a/idjcpython/IDJCmixprefs.py
+++ b/idjcpython/IDJCmixprefs.py
@@ -545,6 +545,7 @@ class mixprefs:
             print "error creating file 'do-not-ask-profile'"
 	 
    def load_player_prefs(self):
+      proktogglevalue = False
       try:
          file = open(self.parent.idjc + "playerdefaults", "r")
 	 
@@ -562,7 +563,10 @@ class mixprefs:
 	    elif value == "False":
 	       value = False
 	    if self.playersettingsdict.has_key(key):
-	       self.playersettingsdict[key].set_active(value)
+               if key == "proktoggle":
+                  proktogglevalue = value
+               else:
+	          self.playersettingsdict[key].set_active(value)
 	    elif self.valuesdict.has_key(key):
 	       self.valuesdict[key].set_value(float(value))
 	    elif self.textdict.has_key(key):
@@ -570,6 +574,8 @@ class mixprefs:
 	 file.close()
       except IOError:
          print "Failed to read playerdefaults file"
+      if proktogglevalue:
+         self.playersettingsdict["proktoggle"].set_active(True)
       self.parent.send_new_mixer_stats()
 	 
    def apply_player_prefs(self):
@@ -664,7 +670,7 @@ class mixprefs:
             data[1].show()
 	 else:
 	    data[1].hide()
-      if self.mic_peak_toggle.get_active() or self.stream_peak_toggle.get_active() or self.vu_toggle.get_active() or self.limiter_toggle.get_active():
+      if self.mic_peak_toggle.get_active() or self.stream_peak_toggle.get_active() or self.vu_toggle.get_active() or self.limiter_toggle.get_active() or self.stream_status_toggle.get_active():
          if self.parent.simplemixer == False:
             self.parent.meterbox.show()
       else:
@@ -781,7 +787,18 @@ class mixprefs:
                   self.r_unp_gain.set_sensitive(False)
                if self.r_unp_active.get_active():
                   self.l_unp_gain.set_sensitive(False)
-   
+
+   def cb_rg_indicate(self, widget):
+      left = self.parent.player_left
+      right = self.parent.player_right
+      
+      if widget.get_active():
+         left.treeview.insert_column(left.rgtvcolumn, 0)
+         right.treeview.insert_column(right.rgtvcolumn, 0)
+      else:         
+         left.treeview.remove_column(left.rgtvcolumn)
+         right.treeview.remove_column(right.rgtvcolumn)
+         
    def __init__(self, parent):
       self.parent = parent
       self.parent.prefs_window = self
@@ -897,6 +914,61 @@ class mixprefs:
       outervbox.pack_start(frame, False, False, 0)
       frame.show()
       
+      # Replay Gain controls
+      
+      frame = gtk.Frame(" " + ln.rg_title + " ")
+      frame.set_border_width(3)
+      outervbox.pack_start(frame, False, False, 0)
+      vbox = gtk.VBox()
+      frame.add(vbox)
+      frame.show()
+      vbox.set_border_width(10)
+      vbox.set_spacing(1)
+      vbox.show()
+      
+      self.rg_indicate = gtk.CheckButton(ln.rg_indicate)
+      parent.tooltips.set_tip(self.rg_indicate, ln.rg_indicate_tip)
+      self.rg_indicate.connect("toggled", self.cb_rg_indicate)
+      vbox.pack_start(self.rg_indicate, False, False, 0)
+      self.rg_indicate.show()
+      
+      self.rg_adjust = gtk.CheckButton(ln.rg_adjust)
+      parent.tooltips.set_tip(self.rg_adjust, ln.rg_adjust_tip)
+      vbox.pack_start(self.rg_adjust, False, False, 0)
+      self.rg_adjust.show()
+      
+      hbox = gtk.HBox()
+      hbox.set_spacing(3)
+      spacer = gtk.HBox()
+      hbox.pack_start(spacer, False, False, 16)
+      spacer.show()
+      label = gtk.Label(ln.rg_defaultgain)
+      hbox.pack_start(label, False, False, 0)
+      label.show()
+      rg_defaultgainadj = gtk.Adjustment(-8.0, -20.0, 10.0, 0.1)
+      self.rg_defaultgain = gtk.SpinButton(rg_defaultgainadj, 0.0, 1)
+      parent.tooltips.set_tip(hbox, ln.rg_defaultgain_tip)
+      hbox.pack_start(self.rg_defaultgain, False, False, 0)
+      self.rg_defaultgain.show()
+      vbox.pack_start(hbox, False, False, 0)
+      hbox.show()
+
+      hbox = gtk.HBox()
+      hbox.set_spacing(3)
+      spacer = gtk.HBox()
+      hbox.pack_start(spacer, False, False, 16)
+      spacer.show()
+      label = gtk.Label(ln.rg_boost)
+      hbox.pack_start(label, False, False, 0)
+      label.show()
+      rg_boostadj = gtk.Adjustment(6.0, -5.0, 15.5, 0.5)
+      self.rg_boost = gtk.SpinButton(rg_boostadj, 0.0, 1)
+      parent.tooltips.set_tip(hbox, ln.rg_boost_tip)
+      hbox.pack_start(self.rg_boost, False, False, 0)
+      self.rg_boost.show()
+      vbox.pack_start(hbox, False, False, 0)
+      hbox.show()
+
       # Miscellaneous Features
       
       frame = gtk.Frame(" " + ln.misc_features + " ")
@@ -951,11 +1023,6 @@ class mixprefs:
       self.dither.show()
       parent.tooltips.set_tip(self.dither, ln.dither_tip)
 
-      self.keeppass = gtk.CheckButton(ln.keeppass)
-      vbox.pack_start(self.keeppass, False, False, 0)
-      self.keeppass.show()
-      parent.tooltips.set_tip(self.keeppass, ln.keep_password_tip)
-
       self.mp3_utf8 = gtk.CheckButton(ln.mp3_utf8)
       self.mp3_utf8.set_active(True)
       vbox.pack_start(self.mp3_utf8, False, False, 0)
@@ -982,6 +1049,7 @@ class mixprefs:
       # Reconnection dialog config
       
       self.recon_config = ReconnectionDialogConfig()
+      parent.tooltips.set_tip(self.recon_config, ln.recon_tip)
       outervbox.pack_start(self.recon_config, False, False, 0)
       self.recon_config.show()
       
@@ -1239,7 +1307,7 @@ class mixprefs:
       self.lstream.set_active(True)
       lvbox.add(self.lstream)
       self.lstream.show()
-      self.llisten = gtk.CheckButton(ln.listen)
+      self.llisten = gtk.CheckButton(ln.djlisten)
       self.llisten.set_border_width(1)
       self.llisten.set_active(True)
       lvbox.add(self.llisten)
@@ -1289,7 +1357,7 @@ class mixprefs:
       self.rstream.set_active(True)
       rvbox.add(self.rstream)
       self.rstream.show()
-      self.rlisten = gtk.CheckButton(ln.listen)
+      self.rlisten = gtk.CheckButton(ln.djlisten)
       self.rlisten.set_border_width(1)
       self.rlisten.set_active(True)
       rvbox.add(self.rlisten)
@@ -1690,14 +1758,9 @@ class mixprefs:
        
       # Jack settings Tab      
                  
-      #jack_window = gtk.ScrolledWindow()
-      #jack_window.set_border_width(8)
-      #jack_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
       jack_vbox = gtk.VBox()
       jack_vbox.set_spacing(3)
       jack_vbox.set_border_width(4)
-      #jack_window.add_with_viewport(jack_vbox)
-      #jack_window.show()
       
       jackname = os.environ["IDJC_JACK_SERVER"]
       if jackname != "default":
@@ -1901,7 +1964,7 @@ class mixprefs:
       
       self.notebook.show()
 
-      # These shown by default
+      # These on by default
       self.mic_peak_toggle.set_active(True)
       self.stream_peak_toggle.set_active(True)
       self.limiter_toggle.set_active(True)
@@ -1916,79 +1979,80 @@ class mixprefs:
       
       self.playersettingsdict = {	# Settings of these will be saved in the config file 
          "lplayall"      : self.lplayall,	# These are all True/False values
-	 "lloopall"      : self.lloopall,
-	 "lrandom"       : self.lrandom,
-	 "lmanual"       : self.lmanual,
-         "lcueup"	 : self.lcueup,
-	 "lcountup"      : self.lcountup,
-	 "lcountdown"    : self.lcountdown,
-	 "lstream"       : self.lstream,
-	 "llisten"       : self.llisten,
-	 "rplayall"      : self.rplayall,
-	 "rloopall"      : self.rloopall,
-	 "rrandom"       : self.rrandom,
-	 "rmanual"       : self.rmanual,
-         "rcueup"	 : self.rcueup,
-	 "rcountdown"    : self.rcountdown,
-	 "rstream"       : self.rstream,
-	 "rlisten"       : self.rlisten,
-	 "startmini"     : self.startmini,
-	 "micpeak"	 : self.mic_peak_toggle,
-	 "vumeters"	 : self.vu_toggle,
-	 "streampeak"	 : self.stream_peak_toggle,
-	 "limitergain"   : self.limiter_toggle,
+         "lloopall"      : self.lloopall,
+         "lrandom"       : self.lrandom,
+         "lmanual"       : self.lmanual,
+         "lcueup"        : self.lcueup,
+         "lcountup"      : self.lcountup,
+         "lcountdown"    : self.lcountdown,
+         "lstream"       : self.lstream,
+         "llisten"       : self.llisten,
+         "rplayall"      : self.rplayall,
+         "rloopall"      : self.rloopall,
+         "rrandom"       : self.rrandom,
+         "rmanual"       : self.rmanual,
+         "rcueup"        : self.rcueup,
+         "rcountdown"    : self.rcountdown,
+         "rstream"       : self.rstream,
+         "rlisten"       : self.rlisten,
+         "startmini"     : self.startmini,
+         "micpeak"       : self.mic_peak_toggle,
+         "vumeters"      : self.vu_toggle,
+         "streampeak"	 : self.stream_peak_toggle,
+         "limitergain"   : self.limiter_toggle,
          "strhealth"     : self.stream_status_toggle,
-	 "announce_en"	 : self.announce_enable,
-	 "timer_en"	 : self.timer_enable,
-         "djalarm"	 : self.djalarm,
-         "trxpld"	 : self.tracks_played,
-         "strmon"	 : self.stream_mon,
+         "announce_en"	 : self.announce_enable,
+         "timer_en"      : self.timer_enable,
+         "djalarm"       : self.djalarm,
+         "trxpld"        : self.tracks_played,
+         "strmon"        : self.stream_mon,
          "bigdigibox"	 : self.bigger_box_toggle, 
          "normalize"	 : self.normalize,
-         "dither"	 : self.dither,
+         "dither"        : self.dither,
          "recallsession" : self.restore_session_option,
-         "keeppass"      : self.keeppass,
          "proktoggle"    : self.p3prefs.proktoggle,
          "ee_appstart"	 : self.appstart_event,
          "ee_appexit"    : self.appexit_event,
-         "ee_micon"	 : self.mic_on_event,
+         "ee_micon"      : self.mic_on_event,
          "ee_micoff"	 : self.mic_off_event,
-         "ee_auxon"	 : self.aux_on_event,
+         "ee_auxon"      : self.aux_on_event,
          "ee_auxoff"	 : self.aux_off_event,
-         "best_rs"	 : self.best_quality_resample,
-         "good_rs"	 : self.good_quality_resample,
-         "fast_rs"	 : self.fast_resample,
+         "best_rs"       : self.best_quality_resample,
+         "good_rs"       : self.good_quality_resample,
+         "fast_rs"       : self.fast_resample,
          "fastest_rs"	 : self.fastest_resample,
          "micauxmutex"	 : self.mic_aux_mutex,
          "speed_var"	 : self.speed_variance,
          "twodblimit"    : self.twodblimit,
          "showtips"      : self.enable_tooltips,
-         "mp3utf8"	 : self.mp3_utf8,
+         "mp3utf8"	     : self.mp3_utf8,
          "mictodj"       : self.mic_to_dj,
          "invertleft"    : self.invert_left,
          "invertright"   : self.invert_right, 
          "lunpactive"    : self.l_unp_active,
          "runpactive"    : self.r_unp_active,
-	 "silencekiller" : self.silence_killer,
+         "silencekiller" : self.silence_killer,
          "bonuskiller"   : self.bonus_killer,
          "unlimretries"  : self.recon_config.unlimited_retries,
          "recondialog"   : self.recon_config.visible,
          "sbfullrecon"   : self.recon_config.attempt_reconnection,
+         "rg_indicate"   : self.rg_indicate,
+         "rg_adjust"     : self.rg_adjust,
          }
          
       self.playersettingsdict.update(self.l_agc_control.booleandict)
       self.playersettingsdict.update(self.r_agc_control.booleandict)
 	 
       self.valuesdict = {
-	 "leftpanadj"    : self.left_pan_adj,
+         "leftpanadj"    : self.left_pan_adj,
          "rightpanadj"   : self.right_pan_adj,
-	 "interval"	 : self.intervaladj,
-         "latency"	 : self.announcedelayadj,
+         "interval"	     : self.intervaladj,
+         "latency"	     : self.announcedelayadj,
          "interval_vol"	 : self.parent.jingles.interadj,
-	 "fullwinx"	 : self.parent.fullwinx,
-         "fullwiny"	 : self.parent.fullwiny,
-         "minwinx"	 : self.parent.minwinx,
-         "minwiny"	 : self.parent.minwiny,
+         "fullwinx"      : self.parent.fullwinx,
+         "fullwiny"      : self.parent.fullwiny,
+         "minwinx"       : self.parent.minwinx,
+         "minwiny"       : self.parent.minwiny,
          "jingleswinx"   : self.parent.jingles.jingleswinx,
          "jingleswiny"   : self.parent.jingles.jingleswiny,
          "passspeed"	 : self.parent.passspeed_adj,
@@ -1996,10 +2060,12 @@ class mixprefs:
          "normceiling"	 : self.normceiling_adj,
          "normrisetc"	 : self.normrise_adj,
          "normfalltc"	 : self.normfall_adj, 
-         "djvolume"	 : self.dj_aud_adj,
+         "djvolume"      : self.dj_aud_adj,
          "headroom"      : self.headroom,
          "lunpgain"      : self.l_unp_gain,
-         "runpgain"      : self.r_unp_gain
+         "runpgain"      : self.r_unp_gain,
+         "rg_default"    : self.rg_defaultgain,
+         "rg_boost"      : self.rg_boost,
          }
 	 
       self.valuesdict.update(self.l_agc_control.valuesdict) 
@@ -2010,20 +2076,21 @@ class mixprefs:
          "prokdatabase"  : self.p3prefs.prokdatabase,
          "prokpassword"  : self.p3prefs.prokpassword,
          "announcenick"	 : self.nickentry,
-	 "announcechan"	 : self.channelsentry, 
-	 "announcemess"	 : self.announcemessageentry,
-	 "timernick"	 : self.timernickentry,
-	 "timerchan"	 : self.timerchannelsentry,
-	 "timermess"	 : self.timermessageentry,
+         "announcechan"	 : self.channelsentry, 
+         "announcemess"	 : self.announcemessageentry,
+         "timernick"	 : self.timernickentry,
+         "timerchan"	 : self.timerchannelsentry,
+         "timermess"	 : self.timermessageentry,
          "ltfilerqdir"   : self.parent.player_left.file_requester_start_dir,
          "rtfilerqdir"   : self.parent.player_right.file_requester_start_dir,
          "et_appstart"	 : self.appstart_event,
          "et_appexit"    : self.appexit_event,
-         "et_micon"	 : self.mic_on_event,
+         "et_micon"      : self.mic_on_event,
          "et_micoff"	 : self.mic_off_event,
-         "et_auxon"	 : self.aux_on_event,
+         "et_auxon"      : self.aux_on_event,
          "et_auxoff"	 : self.aux_off_event,
          "con_delays"    : self.recon_config.csl,
          }
 
       self.rangewidgets = (self.parent.deckadj,)
+
diff --git a/idjcpython/IDJCmultitagger.py b/idjcpython/IDJCmultitagger.py
deleted file mode 100755
index 7c95a10..0000000
--- a/idjcpython/IDJCmultitagger.py
+++ /dev/null
@@ -1,604 +0,0 @@
-#!/usr/bin/python
-
-#   IDJCmultitagger.py: GTK based id3 and vorbis tagger for mp3/ogg/flac files.
-#   Copyright (C) 2006-2007 Stephen Fairchild (s-fairchild at users.sourceforge.net)
-#
-#   This program is free software: you can redistribute it and/or modify
-#   it under the terms of the GNU General Public License as published by
-#   the Free Software Foundation, either version 3 of the License, or
-#   (at your option) any later version.
-#
-#   This program is distributed in the hope that it will be useful,
-#   but WITHOUT ANY WARRANTY; without even the implied warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#   GNU General Public License for more details.
-#
-#   You should have received a copy of the GNU General Public License
-#   along with this program in the file entitled COPYING.
-#   If not, see <http://www.gnu.org/licenses/>.
-
-__all__ = ['multitag']
-
-import pygtk
-pygtk.require('2.0')
-import gtk, os, sys, subprocess
-try:
-   import eyeD3
-except:
-   eyeD3 = None
-from IDJCfree import *
-from idjc_config import *
-from ln_text import *
-
-class mp4tagger(gtk.VBox):
-   def load_tag(self, pathname):
-      self.idjc.mixer_write("MP4P=%s\nACTN=mp4readtagrequest\nend\n" % pathname, True)
-      data = ""
-      while 1:
-         line = self.idjc.mixer_read()
-         if line == "":
-            print "mixer crashed during mp4 tag read operation"
-            return
-         if line == "idjcmixer: mp4fileinfo Not Valid\n":
-            return
-         if line == "idjcmixer: mp4tagread end\n":
-            break
-         if line.startswith("idjcmixer: mp4tagread "):
-            data += line[22:]
-      kvplist = self.make_pairs(data)
-      recommended = [ u"artist", u"name", u"tracknum", u"album", u"genre", u"year" ]
-      precede = u""
-      for recommend in recommended:
-         for key, value in kvplist:
-            if key == recommend:
-               break
-         else:
-            precede = precede + recommend + u"=\n"
-      print precede
-      print "----------"
-      print data
-      self.textbuffer.set_text(precede + data)
-
-   def save_tag(self, pathname):
-      kvp = self.make_pairs()
-      text = u""
-      self.idjc.mixer_write("MP4T=\n")
-      for key, value in kvp:
-         self.idjc.mixer_write("+MP4T=" + key + "=" + value + "\n")
-      self.idjc.mixer_write("MP4P=" + pathname + "\n")
-      self.idjc.mixer_write("ACTN=mp4writetagrequest\nend\n", True)
-      print "mp4 tag saved"
-
-   def make_pairs(self, data = None):	# Returns a list of tuples of key value pairs
-      kvp = [ ]			# Any keys containing a space are rejected
-      if data == None:
-         textiter = self.textbuffer.get_start_iter()
-         data = textiter.get_text(self.textbuffer.get_end_iter())
-      data = data.splitlines()
-      for line in data:
-         if line.count("="):
-            key, value = line.split("=", 1)
-            key = key.strip()
-            value = value.strip()
-            if key != "" and value != "" and key.count(" ") == 0:
-               kvp.append((key.strip(), value.strip()))
-      return kvp
-
-   def __init__(self, pathname, idjcroot):
-      self.idjc = idjcroot
-      gtk.VBox.__init__(self)
-      scrolled_window = gtk.ScrolledWindow()
-      scrolled_window.set_size_request(350, 250)
-      scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
-      textview = gtk.TextView()
-      self.textbuffer = textview.get_buffer()
-      scrolled_window.add(textview)
-      textview.show()
-      gtk.VBox.add(self, scrolled_window)
-      scrolled_window.show()
-      textview.set_editable(True)
-      textview.set_cursor_visible(True)
-      textview.set_wrap_mode(gtk.WRAP_NONE)
-      textview.set_justification(gtk.JUSTIFY_LEFT)
-
-class vorbistagger(gtk.VBox):
-   def load_speex_tag(self, pathname):
-      self.idjc.mixer_write("SPXP=%s\nACTN=speexreadtagrequest\nend\n" % pathname, True)
-      data = ""
-      while 1:
-         line = self.idjc.mixer_read()
-         if line == "":
-            print "mixer crashed during speex tag read operation"
-            return
-         if line == "idjcmixer: speexfileinfo Not Valid\n":
-            return
-         if line == "idjcmixer: speextagread end\n":
-            break
-         if line.startswith("idjcmixer: speextagread "):
-            data += line[24:]
-         if line.startswith("idjcmixer: speexcreatedread "):
-            self.createdby = line[28:]
-      kvplist = self.make_pairs(data)
-      recommended = [ u"author", u"title" ]
-      precede = u""
-      for recommend in recommended:
-         for key, value in kvplist:
-            if key == recommend:
-               break
-         else:
-            precede = precede + recommend + u"=\n"
-      self.textbuffer.set_text(precede + data)
-      print "creation string says:", self.createdby
-
-   def load_ogg_tag(self, pathname):
-      self.vc = os.getenv("vorbiscomment")
-      if self.vc == "" or self.vc == None:
-         self.vc = "vorbiscomment"	# For standalone version
-      if self.vc != "missing":
-         try:
-            read = subprocess.Popen([ self.vc, "--raw", pathname ], stdout=subprocess.PIPE, close_fds=True).stdout
-            data = read.read()
-            read.close()
-         except:
-            print "Problem reading in file", pathname
-         else:
-            self.load_tag(data)
-      
-   def load_flac_tag(self, pathname):
-      self.mf = os.getenv("metaflac")
-      if self.mf == "" or self.mf == None:
-         self.mf = "metaflac"	# For standalone version
-      if self.mf != "missing":
-         try:
-            read = subprocess.Popen([ self.mf, "--no-utf8-convert", "--export-tags-to=-" , pathname ], stdout=subprocess.PIPE, close_fds=True).stdout
-            data = read.read()
-            read.close()
-         except Exception, inst:
-            print inst
-            print "Problem reading in file", pathname
-         else:
-            self.load_tag(data)
-      
-   def load_tag(self, data):
-      # Have some fun here by adding empty keys that are recommended like ALBUM=
-      # whenever none is present in the tag.  It saves the user from having to type them.
-      kvplist = self.make_pairs(data)
-      recommended = [ u"ARTIST", u"TITLE", u"TRACKNUMBER", u"ALBUM", u"GENRE", u"DATE" ]
-      precede = u""
-      for recommend in recommended:
-         for key, value in kvplist:
-            if key.lower() == recommend.lower():
-               break
-         else:
-            precede = precede + recommend + u"=\n"
-      self.textbuffer.set_text(precede + data)
-      
-   def save_speex_tag(self, pathname):
-      kvp = self.make_pairs()
-      text = u""
-      
-      self.idjc.mixer_write("SPXC=%s" % self.createdby) # contains '\n'
-      self.idjc.mixer_write("SPXT=\n")
-      for key, value in kvp:
-         self.idjc.mixer_write("+SPXT=" + key + "=" + value + "\n")
-      self.idjc.mixer_write("SPXP=" + pathname + "\n")
-      self.idjc.mixer_write("ACTN=speexwritetagrequest\nend\n", True)
-      print "speex tag saved"
-      
-   def save_ogg_tag(self, pathname):
-      if self.vc != "missing":
-         kvp = self.make_pairs()
-         text = u""
-         for key, value in kvp:
-            text = text + key + "=" + value + "\n"
-         try:
-            write = subprocess.Popen([self.vc, "--raw", "-w", pathname], stdin=subprocess.PIPE, close_fds=True).stdin
-            write.write(text)
-            write.close()
-         except:
-            print "failed to save Ogg tag"
-         else:
-            print "Ogg tag saved"
-      
-   def save_flac_tag(self, pathname):
-      if self.mf != "missing":
-         kvp = self.make_pairs()
-         text = u""
-         for key, value in kvp:
-            text = text + key + "=" + value + "\n"
-         try:
-            write = subprocess.Popen([self.mf, "--no-utf8-convert", "--remove-all-tags", "--import-tags-from=-", pathname], stdin=subprocess.PIPE, close_fds=True).stdin
-            write.write(text)
-            write.close()
-         except:
-            print "failed to save FLAC tag"
-         else:
-            print "FLAC tag saved"
-      
-   def make_pairs(self, data = None):	# Returns a list of tuples of key value pairs
-      kvp = [ ]			# Any keys containing a space are rejected
-      if data == None:
-         textiter = self.textbuffer.get_start_iter()
-         data = textiter.get_text(self.textbuffer.get_end_iter())
-      data = data.splitlines()
-      for line in data:
-         if line.count("="):
-            key, value = line.split("=", 1)
-            key = key.strip()
-            value = value.strip()
-            if key != "" and value != "" and key.count(" ") == 0:
-               kvp.append((key.strip(), value.strip()))
-      return kvp
-
-   def __init__(self, pathname, idjcroot):
-      gtk.VBox.__init__(self)
-      self.idjc = idjcroot
-      scrolled_window = gtk.ScrolledWindow()
-      scrolled_window.set_size_request(350, 250)
-      scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
-      textview = gtk.TextView()
-      self.textbuffer = textview.get_buffer()
-      scrolled_window.add(textview)
-      textview.show()
-      gtk.VBox.add(self, scrolled_window)
-      scrolled_window.show()
-      textview.set_editable(True)
-      textview.set_cursor_visible(True)
-      textview.set_wrap_mode(gtk.WRAP_NONE)
-      textview.set_justification(gtk.JUSTIFY_LEFT)
-
-class id3tagger(gtk.VBox):
-   def textfilter(self, text):
-      if text == None:
-         text = ""
-      while text != "" and text[-1] == "\x00":
-         text = text[:-1]
-      return unicode(text.strip())
-      
-   def cb_genre(self, combo, textbox):
-      if combo.get_active() != 255:
-         newtext = eyeD3.genres[combo.get_active()]
-         textbox.set_text(newtext)
-         if newtext == "Unknown":
-            combo.set_active(255)
-      
-   def cb_genre_unpress(self, textbox, event, combo):
-      lt = textbox.get_text().lstrip()
-      textbox.set_text(lt)
-      lt = lt.lower().strip()
-      cursor_pos = textbox.get_position()
-      if lt == "unknown":
-         combo.set_active(255)
-      else:
-         value = 0
-         for each in eyeD3.genres:
-            if each.lower() == lt:
-               combo.set_active(value)
-               break
-            value = value + 1
-         else:
-            combo.set_active(255)
-      textbox.set_position(cursor_pos)
-      return False
-         
-   def load_tag(self, pathname, extension):
-      self.tag = eyeD3.Tag()
-      exception = False
-      if True or extension == "mp3":
-         try:
-            self.tagv2found = self.tag.link(pathname, eyeD3.ID3_V2)
-         except:
-            self.tagv2found = 0
-      else:
-         self.tagv2found = 0
-      if self.tagv2found == 0:
-         try:
-            self.tagv1found = self.tag.link(pathname, eyeD3.ID3_V1)
-         except eyeD3.tag.TagException:
-            self.tagv2found = 1
-            self.tag.link(pathname, eyeD3.ID3_V2)	# Use a blank v2 tag as the basis
-      # Now we can load up the fields from what is in the tag.
-      self.title.set_text(self.textfilter(self.tag.getTitle()))
-      self.artist.set_text(self.textfilter(self.tag.getArtist()))
-      self.album.set_text(self.textfilter(self.tag.getAlbum()))
-      self.year.set_text(self.textfilter(self.tag.getYear()))
-      genre = self.tag.getGenre()
-      if genre == None or genre.id == None or genre.id == 255:
-         genre_value = 255
-         self.genre_text.set_text("Unknown")
-      else:
-         genre_value = genre.id
-      self.std_genre.set_active(genre_value)
-      track = self.tag.getTrackNum()
-      if type(track[0]) is int:
-         tracktext = str(track[0])
-         if type(track[1]) is int and track[1] > 0:
-            tracktext = tracktext + "/" + str(track[1])
-         self.track.set_text(tracktext)
-      comments = self.tag.getComments()
-      if len(comments):
-         for self.ourcomment in comments: # Show the idjc comment in preference to the others
-            if self.ourcomment.description == self.idjc_comment_desc:
-               break
-         else:
-            self.ourcomment = comments[0]
-         self.comment.set_text(self.textfilter(self.ourcomment.comment))
-      else:
-         self.ourcomment = None
-   
-   def save_tag(self, pathname):
-      self.tag.setVersion(eyeD3.ID3_V2_4)
-      self.tag.setTextEncoding(eyeD3.UTF_8_ENCODING)
-      self.tag.setArtist(self.textfilter(self.artist.get_text()))
-      self.tag.setTitle(self.textfilter(self.title.get_text()))
-      self.tag.setAlbum(self.textfilter(self.album.get_text()))
-      trackstring = self.track.get_text().split("/")
-      if len(trackstring) >= 1 and len(trackstring) <= 2:
-         try:
-            tracknum = int(trackstring[0].strip())
-            if tracknum < 0:
-               raise ValueError
-            if len(trackstring) == 2:
-               tracktotal = int(trackstring[1].strip())
-               if tracktotal < 0:
-                  raise ValueError
-            else:
-               tracktotal = None
-         except ValueError:
-            print "Bad entry for track"
-            self.tag.setTrackNum([ None, None ])
-         else:
-            self.tag.setTrackNum([ tracknum, tracktotal])
-      self.tag.frames.removeFramesByID("TYER")
-      try:
-         datevalue = int(self.textfilter(self.year.get_text()))
-         if datevalue >= 1000 and datevalue <= 9999:
-            self.tag.setDate(int(self.textfilter(self.year.get_text())))
-         else:
-            raise ValueError
-      except ValueError:
-         print "Year field will be left blank"
-      self.tag.setGenre(self.std_genre.get_active())   
-      self.tag.addComment(self.textfilter(self.comment.get_text()), self.idjc_comment_desc, self.idjc_comment_lang)
-      try:
-         self.tag.update(eyeD3.ID3_V1_1)
-      except UnicodeEncodeError:
-         print "ID3 v1.1 tag was not written because of an illegal character in one of the fields (not a member of the ISO-8859-1 character set)"
-      else:
-         print "Wrote ID3 v1.1 tag."
-      if True or os.path.splitext(pathname)[1] == ".mp3":
-         self.tag.update(eyeD3.ID3_V2_4)
-         print "Wrote ID3 v2.4 tag."
-      else:
-         print "ID3 v2.4 tag not written for non-mp3 files."
-   
-   def __init__(self, pathname):
-      gtk.VBox.__init__(self)
-      self.idjc_comment_desc = "idjc-comment"
-      self.idjc_comment_lang = "XXX"
-      
-      frame = gtk.Frame(" " + ln.standard_tags + " ")
-      frame.set_border_width(6)
-      gtk.VBox.pack_start(self, frame, False, False, 0)
-      sthbox = gtk.HBox()
-      sthbox.set_spacing(2)
-      sthbox.set_border_width(8)
-      frame.add(sthbox)
-      frame.show()
-      sthbox.show()
-      stlvbox = gtk.VBox()
-      sthbox.pack_start(stlvbox, False, False, 1)
-      stlvbox.show()
-      strvbox = gtk.VBox()
-      sthbox.pack_start(strvbox, True, True, 1)
-      strvbox.show()
-      
-      title = gtk.Label(ln.tag_title)
-      stlvbox.add(title)
-      title.show()
-      
-      self.title = gtk.Entry()
-      self.title.set_width_chars(30)
-      strvbox.add(self.title)
-      self.title.show()
-      
-      artist = gtk.Label(ln.tag_artist)
-      stlvbox.add(artist)
-      artist.show()
-      
-      self.artist = gtk.Entry()
-      strvbox.add(self.artist)
-      self.artist.show()
-      
-      album = gtk.Label(ln.tag_album)
-      stlvbox.add(album)
-      album.show()
-      
-      self.album = gtk.Entry()
-      strvbox.add(self.album)
-      self.album.show()
-      
-      track = gtk.Label(ln.tag_track)
-      stlvbox.add(track)
-      track.show()
-      
-      self.track = gtk.Entry()
-      strvbox.add(self.track)
-      self.track.show()
-      
-      year = gtk.Label(ln.tag_year)
-      stlvbox.add(year)
-      year.show()
-      
-      self.year = gtk.Entry()
-      strvbox.add(self.year)
-      self.year.show()
-      
-      genre = gtk.Label(ln.tag_genre)
-      stlvbox.add(genre)
-      genre.show()
-      
-      genre_box = gtk.HBox()
-      self.genre_text = gtk.Entry()
-      genre_box.pack_start(self.genre_text, True, True, 0)
-      self.genre_text.show()
-      self.genre_text.set_text("Unknown")
-      self.std_genre = gtk.combo_box_new_text()
-      self.std_genre.set_wrap_width(5)
-      value = 0
-      for each in eyeD3.genres:
-         self.std_genre.append_text(each + " (" + str(value) + ")")
-         value = value + 1
-      self.std_genre.connect("changed", self.cb_genre, self.genre_text)
-      self.genre_text.connect("key_release_event", self.cb_genre_unpress, self.std_genre)
-      self.std_genre.set_active(255)
-      genre_box.pack_end(self.std_genre, False, False, 0)
-      self.std_genre.show()
-      strvbox.add(genre_box)
-      genre_box.show()
-      
-      comment = gtk.Label(ln.tag_comment)
-      stlvbox.add(comment)
-      comment.show()
-      
-      self.comment = gtk.Entry()
-      strvbox.add(self.comment)
-      self.comment.show()
-
-
-class multitag:
-   def destroy_and_quit(self, widget, data = None):
-      gtk.main_quit()
-      sys.exit(0)
-   
-   def update_playlists(self, pathname, idjcroot):
-      newplaylistdata = idjcroot.player_left.get_media_metadata(pathname)
-      idjcroot.player_left.update_playlist(newplaylistdata)
-      idjcroot.player_right.update_playlist(newplaylistdata)
-   
-   def is_supported(self, pathname):
-      supported = [ "mp3", "ogg", "oga" ]
-      if mp4enabled:
-         supported.append("mp4")
-         supported.append("m4a")
-      if flacenabled:
-         supported.append("flac")
-      if speexenabled:
-         supported.append("spx")
-      extension = os.path.splitext(pathname)[1][1:].lower()
-      if supported.count(extension) != 1:
-         if extension:
-            print "File type", extension, "is not supported for tagging"
-         return False
-      else:
-         return extension
-   
-   def __init__(self, pathname = None, encoding = "latin1", idjcroot = None):
-      if pathname == None:
-         return
-      extension = self.is_supported(pathname)
-      if extension == False:
-         return
-      
-      self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
-      if idjcroot is not None:
-         idjcroot.window_group.add_window(self.window)
-      self.window.set_title(ln.tagger_window_title)
-      self.window.set_destroy_with_parent(True)
-      self.window.set_border_width(9)
-      self.window.set_resizable(True)
-      self.window.set_icon_from_file(pkgdatadir + "icon" + gfext)
-      if idjcroot == None:
-         self.window.connect("destroy", self.destroy_and_quit)
-      vbox = gtk.VBox()
-      self.window.add(vbox)
-      vbox.show()
-      label = gtk.Label()
-      if idjcroot:
-         label.set_markup(u"<b>" + ln.tagger_filename + u" " + rich_safe(unicode(os.path.split(pathname)[1], encoding).encode("utf-8", "replace")) + u"</b>")
-      else:
-         label.set_markup(u"<b>" + ln.tagger_filename + u" " + rich_safe(unicode(os.path.split(pathname)[1], "latin1").encode("utf-8", "replace")) + u"</b>")
-      vbox.pack_start(label, False, False, 6)
-      label.show()
-      
-      hbox = gtk.HBox()
-      hbox.set_border_width(2)
-      apply_button = gtk.Button(None, gtk.STOCK_APPLY)
-      if idjcroot is not None:
-         apply_button.connect_object_after("clicked", self.update_playlists, pathname, idjcroot)
-      hbox.pack_end(apply_button, False, False, 0)
-      apply_button.show()
-      close_button = gtk.Button(None, gtk.STOCK_CLOSE)
-      close_button.connect_object("clicked", gtk.Window.destroy, self.window)
-      hbox.pack_end(close_button, False, False, 10)
-      close_button.show()
-      reload_button = gtk.Button(None, gtk.STOCK_REVERT_TO_SAVED)
-      hbox.pack_start(reload_button, False, False, 10)
-      reload_button.show()
-      vbox.pack_end(hbox, False, False, 0)
-      hbox.show()
-      hbox = gtk.HBox()
-      vbox.pack_end(hbox, False, False, 2)
-      hbox.show()
-      
-      notebook = gtk.Notebook()
-      notebook.set_border_width(2)
-      vbox.pack_start(notebook, True, True, 0)
-      notebook.show()
-      if (extension == "mp4" or extension == "m4a") and idjcroot != None and mp4enabled:
-         self.mp4 = mp4tagger(pathname, idjcroot)
-         reload_button.connect_object("clicked", self.mp4.load_tag, pathname)
-         apply_button.connect_object("clicked", self.mp4.save_tag, pathname)
-         reload_button.clicked()
-         label = gtk.Label("MP4 Tag")
-         notebook.append_page(self.mp4, label)
-         label.show()
-         self.mp4.show()
-      elif extension == "mp3":
-         self.id3 = id3tagger(pathname)
-         reload_button.connect_object("clicked", self.id3.load_tag, pathname, extension)
-         apply_button.connect_object("clicked", self.id3.save_tag, pathname)
-         reload_button.clicked()
-         self.vorbis = None
-         label = gtk.Label("ID3 Tag")
-         notebook.append_page(self.id3, label)
-         self.id3.show()
-         label.show()
-      else:
-         self.vorbis = vorbistagger(pathname, idjcroot)
-         if extension == "ogg" or extension == "oga":
-            reload_button.connect_object("clicked", self.vorbis.load_ogg_tag, pathname)
-            apply_button.connect_object("clicked", self.vorbis.save_ogg_tag, pathname)
-         elif extension == "spx":
-            reload_button.connect_object("clicked", self.vorbis.load_speex_tag, pathname)
-            apply_button.connect_object("clicked", self.vorbis.save_speex_tag, pathname)
-         elif extension == "flac":
-            reload_button.connect_object("clicked", self.vorbis.load_flac_tag, pathname)
-            apply_button.connect_object("clicked", self.vorbis.save_flac_tag, pathname)
-         reload_button.clicked()
-         label = gtk.Label(ln.vorbis_tag)
-         notebook.append_page(self.vorbis, label)
-         self.vorbis.show()
-         label.show()
-         self.id3 = id3tagger(pathname)
-         self.id3.load_tag(pathname, extension)
-	 if (self.id3.tagv2found == 0 and self.id3.tagv1found == 0) or extension == "ogg":
-            self.id3.destroy()
-            self.id3 = None
-         else:
-            reload_button.connect_object("clicked", self.id3.load_tag, pathname, extension)
-            apply_button.connect_object("clicked", self.id3.save_tag, pathname)
-            label = gtk.Label(ln.id3_tag)
-            notebook.append_page(self.id3, label)
-            self.id3.show()
-            label.show()
-      apply_button.connect_object_after("clicked", gtk.Window.destroy, self.window)
-      self.window.show()
-
-if __name__ == "__main__":
-   os.environ["CHARSET"]="UTF-8"
-   if len(sys.argv) != 2 or os.path.isfile(sys.argv[1]) == False:
-      print "The media tagger from IDJC.  Copyright Stephen Fairchild 2006\nReleased under the GNU General Public License V2.0\nUsage:", sys.argv[0], "filename"
-   else:
-      multitag(sys.argv[1])
-      gtk.main()
diff --git a/idjcpython/Makefile.am b/idjcpython/Makefile.am
index 0216fc2..2d93430 100644
--- a/idjcpython/Makefile.am
+++ b/idjcpython/Makefile.am
@@ -1,5 +1,5 @@
 python_PYTHON=idjcgui.py
-pkgpython_PYTHON=IDJCfree.py IDJCjingles.py IDJCmedia.py IDJCmixprefs.py IDJCmultitagger.py sourceclientgui.py IDJCservdialog.py idjc_config.py popupwindow.py tooltips.py licence_window.py p3db.py ln_text.py en_GB_text.py en_US_text.py de_DE_text.py
+pkgpython_PYTHON=IDJCfree.py IDJCjingles.py IDJCmedia.py IDJCmixprefs.py mutagentagger.py sourceclientgui.py IDJCservdialog.py idjc_config.py popupwindow.py tooltips.py licence_window.py p3db.py ln_text.py en_GB_text.py en_US_text.py de_DE_text.py nt.py
 dist_pkgdata_DATA=idjc-announce.py
 
 all: idjc_config.py
@@ -11,7 +11,6 @@ idjc_config.py:
 	@echo "pkgdatadir = \"${pkgdatadir}/\"" >> idjc_config.py
 	@echo "avformat = "${HAVE_AVFORMAT} >> idjc_config.py
 	@echo "avcodec = "${HAVE_AVCODEC} >> idjc_config.py
-	@echo "mp4enabled = "${HAVE_MP4V2} >> idjc_config.py
 	@echo "flacenabled = "${HAVE_FLAC} >> idjc_config.py
 	@echo "oggflacenabled = "${HAVE_OGGFLAC} >> idjc_config.py
 	@echo "speexenabled = "${HAVE_SPEEX} >> idjc_config.py
@@ -22,12 +21,5 @@ idjc_config.py:
 	@echo "num_encoders = "@STREAMERS_S@ >> idjc_config.py
 	@echo "num_recorders = "@RECORDERS_S@ >> idjc_config.py
 	@echo "enh_libshout = "${ENH_SHOUT} >> idjc_config.py
-	@echo "*"
-	@echo "* 'idjc-announce.py' will be installed to ${pkgdatadir}"
-	@echo "* you should make a symbolic link to this file in your ~/.xchat2 folder"
-	@echo "* e.g. ln -s ${pkgdatadir}/idjc-announce.py ~/.xchat2/"
-	@echo "*"
-	@echo "* The application icon idjc.png will be installed to /usr/share/pixmaps"
-	@echo "*"
 
 .PHONY: idjc_config.py
diff --git a/idjcpython/Makefile.in b/idjcpython/Makefile.in
index 3d06b61..b79edf1 100644
--- a/idjcpython/Makefile.in
+++ b/idjcpython/Makefile.in
@@ -67,10 +67,6 @@ AMTAR = @AMTAR@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
 AUTOMAKE = @AUTOMAKE@
-AVCODEC_CFLAGS = @AVCODEC_CFLAGS@
-AVCODEC_LIBS = @AVCODEC_LIBS@
-AVFORMAT_CFLAGS = @AVFORMAT_CFLAGS@
-AVFORMAT_LIBS = @AVFORMAT_LIBS@
 AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
@@ -89,32 +85,46 @@ EGREP = @EGREP@
 ENH_SHOUT = @ENH_SHOUT@
 EXEEXT = @EXEEXT@
 EXT = @EXT@
-FLAC_CFLAGS = @FLAC_CFLAGS@
-FLAC_LIBS = @FLAC_LIBS@
 GREP = @GREP@
 HAVE_AVCODEC = @HAVE_AVCODEC@
 HAVE_AVFORMAT = @HAVE_AVFORMAT@
 HAVE_FLAC = @HAVE_FLAC@
-HAVE_MP4V2 = @HAVE_MP4V2@
 HAVE_OGGFLAC = @HAVE_OGGFLAC@
 HAVE_SPEEX = @HAVE_SPEEX@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-JACK_CFLAGS = @JACK_CFLAGS@
-JACK_LIBS = @JACK_LIBS@
 LDFLAGS = @LDFLAGS@
+LIBAVCODEC_CFLAGS = @LIBAVCODEC_CFLAGS@
+LIBAVCODEC_LIBS = @LIBAVCODEC_LIBS@
+LIBAVFORMAT_CFLAGS = @LIBAVFORMAT_CFLAGS@
+LIBAVFORMAT_LIBS = @LIBAVFORMAT_LIBS@
+LIBFLAC_CFLAGS = @LIBFLAC_CFLAGS@
+LIBFLAC_LIBS = @LIBFLAC_LIBS@
+LIBJACK_CFLAGS = @LIBJACK_CFLAGS@
+LIBJACK_LIBS = @LIBJACK_LIBS@
 LIBM = @LIBM@
+LIBMAD_CFLAGS = @LIBMAD_CFLAGS@
+LIBMAD_LIBS = @LIBMAD_LIBS@
+LIBMP3LAME = @LIBMP3LAME@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LIBSAMPLERATE_CFLAGS = @LIBSAMPLERATE_CFLAGS@
+LIBSAMPLERATE_LIBS = @LIBSAMPLERATE_LIBS@
+LIBSHOUT_CFLAGS = @LIBSHOUT_CFLAGS@
+LIBSHOUT_LIBS = @LIBSHOUT_LIBS@
+LIBSNDFILE_CFLAGS = @LIBSNDFILE_CFLAGS@
+LIBSNDFILE_LIBS = @LIBSNDFILE_LIBS@
+LIBSPEEX_CFLAGS = @LIBSPEEX_CFLAGS@
+LIBSPEEX_LIBS = @LIBSPEEX_LIBS@
+LIBVORBISENC_CFLAGS = @LIBVORBISENC_CFLAGS@
+LIBVORBISENC_LIBS = @LIBVORBISENC_LIBS@
+LIBVORBIS_CFLAGS = @LIBVORBIS_CFLAGS@
+LIBVORBIS_LIBS = @LIBVORBIS_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
-MAD_CFLAGS = @MAD_CFLAGS@
-MAD_LIBS = @MAD_LIBS@
 MAKEINFO = @MAKEINFO@
 MAYBE_LIBSHOUT = @MAYBE_LIBSHOUT@
-MP3LAME = @MP3LAME@
-MP4V2_LIBS = @MP4V2_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -133,27 +143,13 @@ PYTHON_PREFIX = @PYTHON_PREFIX@
 PYTHON_VERSION = @PYTHON_VERSION@
 RECORDERS = @RECORDERS@
 RECORDERS_S = @RECORDERS_S@
-SAMPLERATE_CFLAGS = @SAMPLERATE_CFLAGS@
-SAMPLERATE_LIBS = @SAMPLERATE_LIBS@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
-SHOUT_CFLAGS = @SHOUT_CFLAGS@
-SHOUT_LIBS = @SHOUT_LIBS@
-SNDFILE_CFLAGS = @SNDFILE_CFLAGS@
-SNDFILE_LIBS = @SNDFILE_LIBS@
-SPEEX_CFLAGS = @SPEEX_CFLAGS@
-SPEEX_LIBS = @SPEEX_LIBS@
 STREAMERS = @STREAMERS@
 STREAMERS_S = @STREAMERS_S@
 STRIP = @STRIP@
 TOOLTIPS = @TOOLTIPS@
 VERSION = @VERSION@
-VORBISENC_CFLAGS = @VORBISENC_CFLAGS@
-VORBISENC_LIBS = @VORBISENC_LIBS@
-VORBISFILE_CFLAGS = @VORBISFILE_CFLAGS@
-VORBISFILE_LIBS = @VORBISFILE_LIBS@
-VORBIS_CFLAGS = @VORBIS_CFLAGS@
-VORBIS_LIBS = @VORBIS_LIBS@
 ac_ct_CC = @ac_ct_CC@
 am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
 am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
@@ -195,7 +191,7 @@ subdirs = @subdirs@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
 python_PYTHON = idjcgui.py
-pkgpython_PYTHON = IDJCfree.py IDJCjingles.py IDJCmedia.py IDJCmixprefs.py IDJCmultitagger.py sourceclientgui.py IDJCservdialog.py idjc_config.py popupwindow.py tooltips.py licence_window.py p3db.py ln_text.py en_GB_text.py en_US_text.py de_DE_text.py
+pkgpython_PYTHON = IDJCfree.py IDJCjingles.py IDJCmedia.py IDJCmixprefs.py mutagentagger.py sourceclientgui.py IDJCservdialog.py idjc_config.py popupwindow.py tooltips.py licence_window.py p3db.py ln_text.py en_GB_text.py en_US_text.py de_DE_text.py nt.py
 dist_pkgdata_DATA = idjc-announce.py
 all: all-am
 
@@ -438,7 +434,6 @@ idjc_config.py:
 	@echo "pkgdatadir = \"${pkgdatadir}/\"" >> idjc_config.py
 	@echo "avformat = "${HAVE_AVFORMAT} >> idjc_config.py
 	@echo "avcodec = "${HAVE_AVCODEC} >> idjc_config.py
-	@echo "mp4enabled = "${HAVE_MP4V2} >> idjc_config.py
 	@echo "flacenabled = "${HAVE_FLAC} >> idjc_config.py
 	@echo "oggflacenabled = "${HAVE_OGGFLAC} >> idjc_config.py
 	@echo "speexenabled = "${HAVE_SPEEX} >> idjc_config.py
@@ -449,13 +444,6 @@ idjc_config.py:
 	@echo "num_encoders = "@STREAMERS_S@ >> idjc_config.py
 	@echo "num_recorders = "@RECORDERS_S@ >> idjc_config.py
 	@echo "enh_libshout = "${ENH_SHOUT} >> idjc_config.py
-	@echo "*"
-	@echo "* 'idjc-announce.py' will be installed to ${pkgdatadir}"
-	@echo "* you should make a symbolic link to this file in your ~/.xchat2 folder"
-	@echo "* e.g. ln -s ${pkgdatadir}/idjc-announce.py ~/.xchat2/"
-	@echo "*"
-	@echo "* The application icon idjc.png will be installed to /usr/share/pixmaps"
-	@echo "*"
 
 .PHONY: idjc_config.py
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/idjcpython/de_DE_text.py b/idjcpython/de_DE_text.py
index 286b692..736de87 100644
--- a/idjcpython/de_DE_text.py
+++ b/idjcpython/de_DE_text.py
@@ -27,8 +27,6 @@ add_file = "Datei hinzufügen"
 
 add_to_jingles = "Zu den Jingles hinzufügen"
 
-af_h_sm = "Audio Filter, Headroom, und Stereo Mix"
-
 all = "Alle"
 
 append = "Unten anhängen"
@@ -127,8 +125,6 @@ item_menu = "Objekt"
 
 jack_ports_tab = "Jack-Anschlüsse"
 
-keep_password_tip = "Choosing this option will cause the server passwords to be saved to the IDJC configuration file so they will be there when you next restart IDJC. If this is a security concern to you it would be wise to turn this feature off. Those doing so will have to type in their server passwords each time IDJC is run."
-
 latency = "Verzögerung:"
 
 left = "Links:"
@@ -139,8 +135,6 @@ left_playlist_save = "Linke Abspielliste speichern"
 
 licence = "Veröffentlicht unter der GNU General Public License V3.0"
 
-listen = "Hören"
-
 listen_url = "Radio-URL:"
 
 loop_all = "Endlos"
@@ -497,7 +491,7 @@ use_jack_srate_tip = "No additional resampling will occur. The stream sample rat
 
 #dither_tip = "This feature possibly improves the sound quality a little when listening on a 24 bit sound card."
 
-#dither_toggle = "Apply triangular shaped dither to FLAC playback"
+#dither_toggle = "Apply dither to MP3 and FLAC playback"
 
 #dj_alarm_tip = "An alarm tone alerting the DJ that dead-air is just nine seconds away."
 
diff --git a/idjcpython/en_GB_text.py b/idjcpython/en_GB_text.py
index 49058ee..0a49a4a 100644
--- a/idjcpython/en_GB_text.py
+++ b/idjcpython/en_GB_text.py
@@ -20,12 +20,18 @@
 
 about_tab = "About"
 
+add = "Add"
+
 add_file = "Add Music"
 
 add_to_jingles = "Add To Jingles"
 
 add_track_tip = "Add tracks to the playlist."
 
+admin_passwd = "Admin:"
+
+admin_tip = "Set this if you know the administrator password for the server and need it to obtain listener stats, otherwise leave it blank. The stats login will be assumed to be 'admin' if you set this."
+
 advance_tip = "This button either starts the currently highlighted track playing or stops the currently playing one and highlights the next track."
 
 agc_compressor = "Compressor"
@@ -210,12 +216,34 @@ comp_release = "Release"
 
 compression_meter_tip = "A meter indicating the current amount of attenuation being applied to each microphone input by the compressor."
 
+conn_col_type = "Type"
+
+conn_col_host = "Hostname/IP"
+
+conn_col_port = "Port"
+
+conn_col_mount = "Mount point"
+
+conn_col_listeners = "Listeners"
+
 connected_to_history = "connected to"
 
 connection = " Connection "
 
 connection_lost = "Connection Lost"
 
+connection_undefined = " Connection "
+
+connection_icecast2 = " Connection: Icecast 2 server "
+
+connection_shoutcast = " Connection: Shoutcast server "
+
+connections_table_tip = "A table of servers with which to connect. Only one master server can be added for the purpose of streaming. All other servers will appear below the master server in the list for the purpose of stats collection which can be toggled on a per server basis by the check button in the left hand column. The type column consists of a code pertaining to the type of server: Icecast2/Shoutcast, Master/Relay."
+
+connections_add_tip = "Click this to add server information from the entry boxes below into the table above. Fields below cannot be left blank or else nothing will happen."
+
+connections_editremove_tip = "Click this when you want to remove a server from the list above for editing/removal. Highlight the particular server first. The information will be transferred to the entry boxes below."
+
 contact_info = " Shoutcast Contact Info "
 
 contrib_label = "Contributors"
@@ -296,9 +324,9 @@ disconnected_history = "disconnected from server"
 
 disconnection = "IDJC Disconnection"
 
-dither_tip = "This feature possibly improves the sound quality a little when listening on a 24 bit sound card."
+dither_tip = "This feature improves the sound quality a little when listening on a 24 bit sound card."
 
-dither_toggle = "Apply triangular shaped dither to FLAC playback"
+dither_toggle = "Apply dither to MP3 and FLAC playback."
 
 dj_alarm_tip = "An alarm tone alerting the DJ that dead-air is just nine seconds away."
 
@@ -346,6 +374,8 @@ duplicate = "Duplicate"
 
 elapsed_recording = "Elapsed:"
 
+edit_remove = "Edit/Remove"
+
 empty = "Empty"
 
 enable = "Enable"
@@ -384,6 +414,12 @@ external_playlist = "Choose a playlist file."
 
 external_directory = "Choose a folder/directory of music."
 
+fade_none_menu = "No Fade"
+
+fade_5_menu = "Fade 5s"
+
+fade_10_menu = "Fade 10s"
+
 fadeout_toggle = "Fadeout"
 
 fall = "Fall"
@@ -428,12 +464,24 @@ fully_featured = "Fully Featured"
 
 fully_featured_tip = "Run in full functionality mode which uses more CPU power."
 
+gather_stats = "Obtain listener stats"
+
+gather_stats_tip = "Setting this will cause IDJC to attempt to obtain the number of listeners from the server and display the sum total number of listeners in the main application window and the individual server listener count to the left."
+
 general_tab = "General"
 
 genre = "Genre:"
 
 genre_tip = "The musical genres you are likely to play."
 
+get_stats = "Get listener stats:"
+
+get_stats_never = "Never"
+
+get_stats_always = "Always"
+
+get_stats_ifconnected = "If connected"
+
 good_quality_resample = "Good"
 
 green_phone_tip = "Mix voice over IP audio to the output stream."
@@ -466,6 +514,29 @@ icy_irc_tip = "Internet Relay Chat connection info goes here."
 
 id3_tag = "ID3 Tag"
 
+id3title = "title"
+
+id3artist = "artist"
+
+id3album = "album"
+
+id3track = "track/total"
+
+id3genre = "genre"
+
+id3recorddate = "record date"
+
+id3textframes = " Additional Text Frames "
+
+id3freeform = """Add any other ID3 text frames here.
+e.g. TIT2:Alternate Title
+This will be appended onto the main TIT2 tag.
+
+Enter user defined text frames like this:
+TXXX:foo=bar
+
+For more information visit www.id3.org."""
+
 idjc_launch_failed = "IDJC Launch Failed"
 
 idjc_shutdown = "IDJC Shutdown"
@@ -527,11 +598,15 @@ jingles_window = "IDJC Jingles"
 
 jingles_window_open_tip = "Open the jingles player window."
 
-keep_password_tip = "Choosing this option will cause the server passwords to be saved to the IDJC configuration file so they will be there when you next restart IDJC. If this is a security concern to you it would be wise to keep this feature turned off. Those doing so will have to type in their server passwords each time IDJC is run."
+l = "L"
+
+label_icecast_master = "Icecast 2 Master"
 
-keeppass = "Remember server passwords (potential security risk)"
+label_icecast_relay = "Icecast 2 Stats/Relay"
 
-l = "L"
+label_shoutcast_master = "Shoutcast Master"
+
+label_shoutcast_relay = "Shoutcast Stats/Relay"
 
 latency = "Latency:"
 
@@ -549,9 +624,11 @@ licence = "Released under the GNU General Public License V3.0"
 
 licence_tab = "Licence"
 
-listen = " Listen "
+audiofeed = " Audio Feed "
 
-listener_indicator_tip = "The combined total number of listeners some time in the last thirty seconds."
+djlisten = " DJ "
+
+listener_indicator_tip = "The combined total number of listeners in all server tabs."
 
 listen_tip = "Make output from this player audible to the DJ."
 
@@ -559,11 +636,17 @@ listen_url = "Listen URL:"
 
 listen_url_tip = "The URL of your radio station. This and the rest of the information below is intended for display on a radio station listings website."
 
+listeners_failed = "Failed"
+
+listeners_unknown = "Unknown"
+
+listeners_total_tip = "The sum total of listeners in this server tab."
+
 lmic_toggle_tip = "This button toggles the left microphone input."
 
 localhost = "Localhost"
 
-login_tip = "Icecast servers can be configured to have individual per-user source passwords to facilitate efficient password revocation. This requires that every user must have a separate login name which is entered here. The default login name is 'source'."
+login_tip = "Icecast servers require a login password. On a server where no fixed mountpoints have been configured the source login will be 'source'. For collecting stats the admin password can be given for which the login is by default, 'admin' but could have been changed to something else. Stats may be collected with a source login provided the mountpoint matches."
 
 loop_all = "Loop All"
 
@@ -677,6 +760,20 @@ mp3_utf8 = "Use utf-8 encoding when streaming mp3 metadata"
 
 mp3_utf8_tip = "It is standard practice when streaming metadata in mp3 streams to use iso-8859-1 character encoding. This is unfortunate since with utf-8 practically anything can be encoded. In deciding whether to use this feature you have to consider the proportion of listener clients that will be capable of correctly decoding text encoded with utf-8."
 
+mp4title = "Title"
+
+mp4artist = "Artist"
+
+mp4album = "Album"
+
+mp4track = "Track"
+
+mp4genre = "Genre"
+
+mp4year = "Year"
+
+native = "Native"
+
 new_profile_body = """Profile '%s' does
 not currently exist.
 Would you like to create it?"""
@@ -729,6 +826,10 @@ normfall = "Fall"
 
 normrise = "Rise"
 
+not_connected = "Not Connected"
+
+notag = "No Tag"
+
 off = "Off"
 
 ogg_streamtab_tip = "Clicking this tab selects the Ogg family of file formats."
@@ -747,12 +848,16 @@ pass_button_tip = "This button causes the crossfader to move to the opposite sid
 
 pass_speed_tip = "The time in seconds that the crossfader will take to automatically pass across when the button to the right is clicked."
 
-password_tip = "The server password goes here."
+password_tip = "The password matching the above login goes here. For collecting listener stats on Shoutcast servers the password needs to be the admin password whenever an admin password is set on the server."
 
 pause_rec_tip = "Pause recording."
 
 pause_tip = "Pause."
 
+pldelay_none = "None"
+
+pldelay_tip = "This controls the amount of fade between tracks."
+
 play_all = "Play All"
 
 play_jingles_tip = "Play the jingles sequence specified above or if none is specified play the jingle highlighted in the playlist. The volume level of the main media players will be reduced somewhat for the duration."
@@ -811,6 +916,10 @@ playlisttype_header1 = "File Type"
 
 playlisttype_header2 = "Extension"
 
+playlistmode = "Playlist Mode"
+
+populating = "Populating"
+
 popupwindowplayduration = "Total play duration %s"
 
 popupwindowplaying = "Playing track %d of %d"
@@ -819,7 +928,7 @@ popupwindowtracktotal = "Total number of tracks %d"
 
 port = "Port"
 
-port_tip = "The network port number which the server is using. Frequently it is 8000."
+port_tip = "The base port number which the server is using."
 
 prefs_button = "Prefs"
 
@@ -883,6 +992,12 @@ rec_directory_tip = "Choose which directory you want to save to. All file names
 
 rec_source_tip = "Chooses which stream to record. If the stream isn't running the encoder will be started for you. Remember to make sure the encoder settings are to your liking before you start recording."
 
+recon_tip = """A set of controls for managing what happens when the server connection either breaks or suffers prolonged congestion.
+ 
+The 'delays of' control consists of a comma separated list of time delays for the reconnection dialog. When the list is exhausted further attempts to reconnect to the server are abandoned, so three numbers denote a maximum three reconnection attempts.
+
+You also have the option to attempt reconnection when the stream buffer becomes full. Use this option if waiting out the congestion is not helpful."""
+
 reconnected = "IDJC Reconnected"
 
 reconnected_additional = ('Automatically reconnected to the server', 'after the server module crashed')
@@ -933,6 +1048,24 @@ restore_session = "Restore previous session"
 
 restore_session_tip = "When starting IDJC most of the main window settings will be as they were left. As an alternative you may specify below how you want the various settings to be when IDJC starts."
 
+rg_indicate = "Indicate which tracks have Replay Gain values."
+
+rg_adjust = "Adjust playback volume."
+
+rg_defaultgain = "Gain value for unmarked tracks:"
+
+rg_defaultgain_tip = "Set this to the typical track gain values you would expect for the programme material you are currently playing. For pop and rock music (especially modern studio recordings) this should be about a -8 or -9 and classical music much closer to zero."
+
+rg_title = "Replay Gain"
+
+rg_boost = "Boost (for pop/rock):"
+
+rg_boost_tip = "For material that is generally loud it is recommended to set this between 4 and 8 dB however going too high will result in a loss of dynamic range. The Str Peak meter is a useful guide for getting this right."
+
+rg_adjust_tip = "Effective only on newly started tracks."
+
+rg_indicate_tip = "Show a marker in the playlists next to each track."
+
 right = "Right:"
 
 right_mic_stereo_tip = "This controls the stereo balance of the right microphone."
@@ -987,7 +1120,12 @@ server_type_icecast2 = "Icecast 2"
 
 server_type_shoutcast = "Shoutcast"
 
-server_type_tip = "IDJC can connect to both Icecast and Shoutcast servers. For this to be successful you need to specify the type of server that you wish to connect to since each type has a different connection protocol."
+server_type_tip = "IDJC can connect to both Icecast and Shoutcast servers. For connection to be successful you need to specify the type of server that you wish to connect to. Also note, you can specify a relay here for the purpose of stats collection. If a master has already been added to the list above you can't add another one - to stream to more than one server use a different server tab instead."
+
+server_type_codes = ("I2M", "SM", "I2R", "SR")
+
+server_type_labels = ("Icecast 2 Master", "Shoutcast Master",
+                      "Icecast 2 Stats/Relay", "Shoutcast Stats/Relay")
 
 server_window = "Radio Server"
 
@@ -1159,6 +1297,8 @@ track_announcer = "Track Announcer"
 
 track_announcer_latency_tip = "A delay to the displaying of the change of track information in IRC. The idea is to match this number to the average audio latency in seconds that the listeners will be experiencing. Ten to fifteen seconds typically."
 
+trackfade = "Fade"
+
 track_history_clear = "Remove Contents"
 
 tracks_played = "Tracks Played"
diff --git a/idjcpython/en_US_text.py b/idjcpython/en_US_text.py
index 58ab1b4..abaa9da 100644
--- a/idjcpython/en_US_text.py
+++ b/idjcpython/en_US_text.py
@@ -54,6 +54,8 @@ If this button is grayed out it means that the encoder settings are not valid. T
 
 Also check that you have write permission on the folder you have selected to record to."""
 
+rg_defaultgain_tip = "Set this to the typical track gain values you would expect for the program material you are currently playing. For pop and rock music (especially modern studio recordings) this should be about a -8 or -9 and classical music much closer to zero."
+
 server_connect_tip = """Connect to or disconnect from the radio server. If the button does not stay in, the connection failed for some reason.
  
 If the button is grayed out it means you are using unsupported settings. Shoutcast only supports mp3 and mp3 requires that you use one of the samplerates in the drop down box. Ogg only supports certain sample rate, bitrate, and stereo combinations."""
diff --git a/idjcpython/idjc_config.py b/idjcpython/idjc_config.py
new file mode 100644
index 0000000..97510a3
--- /dev/null
+++ b/idjcpython/idjc_config.py
@@ -0,0 +1,16 @@
+# config.py: Automatically generated by make.
+localversion = False
+libexecdir = "/usr/local/libexec/"
+pkgdatadir = "/usr/local/share/idjc/"
+avformat = 1
+avcodec = 1
+flacenabled = 1
+oggflacenabled = 1
+speexenabled = 1
+version = "0.8.1"
+gfext = ".png"
+tipsenabled = 1
+num_streamers = 6
+num_encoders = 6
+num_recorders = 2
+enh_libshout = 1
diff --git a/idjcpython/idjcgui.py b/idjcpython/idjcgui.py
index e97eefa..f2b35c2 100755
--- a/idjcpython/idjcgui.py
+++ b/idjcpython/idjcgui.py
@@ -55,7 +55,7 @@ def locale_encoding():
    os.environ["LANG"] = locale.setlocale(locale.LC_ALL, "")
    try:
       locale.getpreferredencoding()
-   except locale.Error:
+   except (locale.Error, Exception):
       del os.environ["LANG"] 
       locale.setlocale(locale.LC_ALL, "")
       de = "iso8859-1"
@@ -87,7 +87,7 @@ except:
 
 import pygtk
 pygtk.require('2.0')
-import gtk, gobject, time, fcntl, signal, stat, cairo
+import gtk, gobject, time, fcntl, signal, stat, cairo, socket
 
 try:
    pango.Font	# some users will not need to import pango explicitly
@@ -100,7 +100,7 @@ from IDJCmedia import *
 from sourceclientgui import *
 from IDJCmixprefs import *
 from IDJCjingles import *
-from IDJCfree import int_object
+from IDJCfree import int_object, threadslock
 import tooltips
 import p3db
 
@@ -981,8 +981,8 @@ class MainWindow:
          time_lag = int(time_lag / player.pbspeedfactor)
       gobject.timeout_add(time_lag, self.new_songname_timeout, (song, artist, title, player, player_context))
 
+   @threadslock
    def new_songname_timeout(self, (song, artist, title, player, player_context)):
-      gtk.gdk.threads_enter()
       if player.player_cid == (player_context | 1):
          player.songname = song
          player.artist = artist
@@ -990,7 +990,6 @@ class MainWindow:
          self.send_new_mixer_stats()
       else:
          print "context mismatch, player context id =", player.player_cid, "metadata update carries context id =", player_context
-      gtk.gdk.threads_leave()
       return False
 
    def callback(self, widget, data):
@@ -1016,6 +1015,8 @@ class MainWindow:
 	    self.window.show()
             self.window.resize(self.fullwinx, self.fullwiny)
 	    self.send_new_mixer_stats()
+            for each in (self.player_left, self.player_right):
+               each.pl_mode.emit("changed")
          else:
 	    self.simplemixer = True
             self.window.hide()
@@ -1035,6 +1036,8 @@ class MainWindow:
             self.abox.hide()
             self.window.show()
             self.window.resize(self.minwinx, self.minwiny)
+            for each in (self.player_left, self.player_right):
+               each.pl_delay.set_sensitive(False)
       if data == "Advance":
          if self.crossfade.get_value() < 50:
             self.player_left.advance()
@@ -1072,18 +1075,16 @@ class MainWindow:
       if self.player_right.is_playing:
          self.player_right.reselect_cursor_please = True
 
+   @threadslock
    def cb_crosspass(self):
-      gtk.gdk.threads_enter()
       x = self.crossadj.get_value()
       if x == 100 * self.crossdirection:
          self.crosspass = 0
-         gtk.gdk.threads_leave()
 	 return False
       if self.crossdirection:
 	 self.crossfade.set_value(x+1)
       else:
 	 self.crossfade.set_value(x-1)
-      gtk.gdk.threads_leave()
       return True
 
    # handles selection of metadata source
@@ -1512,6 +1513,27 @@ class MainWindow:
          else:
             self.server_window.streamtabframe.tabs[value].server_connect.set_active(False)
    
+   def process_record_start_command(self, tablist):
+      for each in tablist:
+         try:
+            value = int(each) -1
+         except ValueError:
+            pass
+         else:
+            try:
+               self.server_window.recordtabframe.tabs[value].record_buttons.record_button.set_active(True)
+            except IndexError:
+               print "idjcctrl tried to start/stop a non existent stream"
+
+   def process_record_stop_command(self, tablist):
+      for each in tablist:
+         try:
+            value = int(each) -1
+         except ValueError:
+            pass
+         else:
+            self.server_window.recordtabframe.tabs[value].record_buttons.stop_button.clicked()
+   
    def process_testmonitor_on_command(self, tablist):
       for each in tablist:
          try:
@@ -1537,7 +1559,7 @@ class MainWindow:
          except ValueError:
             pass
          else:
-            self.server_window.streamtabframe.tabs[value].update_button.clicked(False)
+            self.server_window.streamtabframe.tabs[value].update_button.clicked()
    
    def process_m3u_file(self, filename):
       contents = []
@@ -1617,6 +1639,10 @@ class MainWindow:
                   self.process_connect_command(command_data)
                elif command == "disconnect":
                   self.process_disconnect_command(command_data)
+               elif command == "record_start":
+                  self.process_record_start_command(command_data)
+               elif command == "record_stop":
+                  self.process_record_stop_command(command_data)
                elif command == "testmonitor_on":
                   self.process_testmonitor_on_command(command_data)
                elif command == "testmonitor_off":
@@ -1696,8 +1722,8 @@ class MainWindow:
          gtk.gdk.threads_leave()
       return True
       
+   @threadslock 
    def stats_update(self):
-      gtk.gdk.threads_enter()
       if not self.player_left.player_is_playing:
          self.player_left.update_time_stats()
       else:
@@ -1706,7 +1732,6 @@ class MainWindow:
          self.player_right.update_time_stats()
       else:
          self.player_right.check_mixer_signal()
-      gtk.gdk.threads_leave()
       return True
 
    def cb_history_populate(self, textview, menu):
@@ -1718,6 +1743,14 @@ class MainWindow:
       menu.append(menuitem)
       menuitem.show()
 
+   def cb_key_capture(self, widget, event):
+      keybase = 65470 # the F1 key
+      if event.type == gtk.gdk.KEY_PRESS:
+         if event.keyval >= keybase and event.keyval < keybase + 12:
+            self.jingles.trigger_index(event.keyval - keybase)
+         elif event.keyval == 65307:
+            self.jingles.trigger_index(-1)
+
    def configure_event(self, widget, event):
       if self.player_left.is_playing:
          self.player_left.reselect_cursor_please = True
@@ -1796,8 +1829,13 @@ class MainWindow:
                self.profile = spd.new_profile_box.get_text()
             if spd.no_more_ask.get_active():
                if not os.path.isfile(self.idjcroot + "do-not-ask-profile"):
-                  os.mknod(self.idjcroot + "do-not-ask-profile")
-               self.ask_profile_next_time = False
+                  dnap = "do-not-ask-profile"
+                  try:
+                     os.mknod(self.idjcroot + dnap)
+                  except OSError:
+                     # mknod has been reported to fail on mac
+                     os.system("touch %s%s" % (self.idjcroot, dnap))
+                  self.ask_profile_next_time = False
             spd.destroy()
          else:
             if response == gtk.RESPONSE_CANCEL:
@@ -1885,6 +1923,8 @@ class MainWindow:
       signal.signal(signal.SIGUSR2, self.second_instance_handler)
       signal.signal(signal.SIGINT, self.destroy_hard)
       
+      socket.setdefaulttimeout(15)
+      
       home = os.environ.get("HOME")
       if home == "":
          raise self.initfailed("Error, HOME environment variable is not set")
@@ -1960,6 +2000,11 @@ class MainWindow:
          message_dialog.destroy()
          raise self.initfailed()
   
+      self.mixer_write("ACTN=mp3status\nend\n", True)
+      rply = self.mixer_read()
+      if rply == "IDJC: mp3=1\n":
+         supported.media.append(".mp3")
+  
       # create the GUI elements
       self.window_group = gtk.WindowGroup()
       self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
@@ -1980,15 +2025,16 @@ class MainWindow:
       self.leftpane = gtk.VPaned()
       self.paned.pack1(self.leftpane)
       self.topleftpane = p3db.MediaPane()
+      self.leftpane.pack1(self.topleftpane)
       self.topleftpane.connect_object("show", gtk.VPaned.show, self.leftpane)
       self.topleftpane.connect_object("hide", self.cb_panehide, self.leftpane)
-      self.leftpane.pack1(self.topleftpane)
       
       # Expand features by adding something useful here
-      #self.bottomleftpane = gtk.Button("Bottom")
+      # a dummy widget is needed to prevent a segfault when F8 is pressed
+      self.bottomleftpane = gtk.Button("Bottom")
       #self.bottomleftpane.connect_object("show", gtk.VPaned.show, self.leftpane)
       #self.bottomleftpane.connect_object("hide", self.cb_panehide, self.leftpane)
-      #self.leftpane.pack2(self.bottomleftpane)
+      self.leftpane.pack2(self.bottomleftpane)
       #self.bottomleftpane.show()
       
       self.rightpane = gtk.HBox(False, 0)
@@ -2882,10 +2928,8 @@ class MainWindow:
       self.player_right.treeview.set_flags(gtk.CAN_FOCUS)
       self.player_left.treeview.grab_focus()
      
-      self.mixer_write("ACTN=mp3status\nend\n", True)
-      rply = self.mixer_read()
-      if rply == "IDJC: mp3=1\n":
-         supported.media.append(".mp3")
+      self.window.add_events(gtk.gdk.KEY_PRESS_MASK)
+      self.window.connect("key-press-event", self.cb_key_capture)
      
       self.window.show()
 
@@ -2925,10 +2969,6 @@ class MainWindow:
 def environment_variables_okay():
    # Shows a dialog box when one or more of the helper programs is missing
    environvars = (
-      ("metaflac from the flac package needed to play flac files\n", ("metaflac", "missing")),
-      ("lame needed for the encoding of mp3 streams\n", ("lame", "disabled")),
-      ("oggenc needed for the encoding of ogg/vorbis\n", ("oggenc", "missing")),
-      ("ogginfo needed for ogg track length and tags\n", ("ogginfo", "missing")),
       ("jackd from the jack-audio-connection-kit package\n", ("jackd", "missing")),
       ("vorbiscomment from the vorbistools package\n", ("vorbiscomment", "missing")) )
    error_message = "The following programs were found to be missing...\n\n"
@@ -2949,24 +2989,24 @@ def environment_variables_okay():
          message_dialog.destroy()
    return True
 
-# Let's run this...
-if __name__ == "__main__":
-   gtk.gdk.threads_init()
-   gtk.gdk.threads_enter()
-   retcode = 0
+ at threadslock
+def main():
    if environment_variables_okay() == True:
       try:
          run_instance = MainWindow()
-      except MainWindow.initfailed:
-         retcode = 5
-      except MainWindow.initcleanexit:
-         pass
-      except KeyboardInterrupt:
-         pass
+      except (MainWindow.initfailed,
+              MainWindow.initcleanexit,
+              KeyboardInterrupt):
+         return 5
       else:
          try:
             run_instance.main()
          except KeyboardInterrupt:
-            pass
-   gtk.gdk.threads_leave()
-   sys.exit(retcode)
+            return 5
+         else:
+            return 0
+   return 5
+
+if __name__ == "__main__":
+   gtk.gdk.threads_init()
+   sys.exit(main())
diff --git a/idjcpython/mutagentagger.py b/idjcpython/mutagentagger.py
new file mode 100755
index 0000000..de05fb9
--- /dev/null
+++ b/idjcpython/mutagentagger.py
@@ -0,0 +1,737 @@
+#!/usr/bin/python
+
+#   mutagengui.py: GTK based file tagger.
+#   Copyright (C) 2009 Stephen Fairchild (s-fairchild at users.sourceforge.net)
+#
+#   This program is free software: you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation, either version 3 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program in the file entitled COPYING.
+#   If not, see <http://www.gnu.org/licenses/>.
+
+
+__all__ = ['MutagenGUI']
+
+import os
+import sys
+import string
+import re
+import pango
+
+import pygtk
+pygtk.require('2.0')
+import gtk
+import mutagen
+
+import mutagen.id3 as id3
+
+from idjc_config import *
+from IDJCfree import *
+from ln_text import ln
+from mutagen.mp3 import MP3
+from mutagen.apev2 import APEv2, APETextValue
+from mutagen.musepack import Musepack
+from mutagen.monkeysaudio import MonkeysAudio
+from mutagen.asf import ASF, ASFUnicodeAttribute
+
+def set_tip(*args):
+   """Dummy tooltips setter."""
+   
+   pass
+
+
+class LeftLabel(gtk.HBox):
+   """Use in place of gtk.Label where left justification is needed."""
+   
+   def __init__(self, text):
+      gtk.HBox.__init__(self)
+      self.label = gtk.Label(text)
+      self.pack_start(self.label, False, False, 0)
+
+
+class RightLabel(gtk.HBox):
+   """Use in place of gtk.Label where right justification is needed."""
+   
+   def __init__(self, text):
+      gtk.HBox.__init__(self)
+      self.pack_end(gtk.Label(text), False, False, 0)
+
+
+class FreeTagFrame(gtk.Frame):
+   def __init__(self):
+      gtk.Frame.__init__(self)
+      sw = gtk.ScrolledWindow()
+      sw.set_border_width(5)
+      sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
+      self.add(sw)
+      sw.show()
+      self.tb = gtk.TextBuffer()
+      tv = gtk.TextView(self.tb)
+      tv.set_wrap_mode(gtk.WRAP_CHAR)
+      tv.modify_font(pango.FontDescription('sans 12'))
+      sw.add(tv)
+      tv.show()
+
+
+class MutagenTagger(gtk.VBox):
+   """Base class for ID3Tagger and NativeTagger."""
+   
+   def __init__(self, pathname):
+      gtk.VBox.__init__(self)
+      self.pathname = pathname
+
+class WMATagger(MutagenTagger):
+   """Handles tagging of WMA files"""
+   
+   primary_data = ("Title", "Author")
+   secondaries = ("WM/AlbumTitle", "WM/AlbumArtist", "WM/Year", "WM/Genre")
+   
+   def save_tag(self):
+      """Updates the tag with the GUI data."""
+       
+      tag = self.tag
+      tb = self.tag_frame.tb
+       
+      for key in self.text_set:
+         try:
+            del tag[key]
+         except KeyError:
+            pass
+
+      for each in self.primary_line:
+         val = each[1].get_text().strip()
+         if val:
+            tag[each[0]] = val
+         else:
+            try:
+               del tag[each[0]]
+            except KeyError:
+               pass
+             
+      lines = tb.get_text(tb.get_start_iter(), tb.get_end_iter()).splitlines()
+      for line in lines:
+         try:
+            key, val = line.split("=", 1)
+         except ValueError:
+            continue
+         else:
+            key = key.strip()
+            val = val.strip()
+            if val:
+               try:
+                  tag[key] += [ASFUnicodeAttribute(val.decode("utf-8"))]
+               except (KeyError, AttributeError):
+                  try:
+                     tag[key] = [ASFUnicodeAttribute(val.decode("utf-8"))]
+                  except KeyError:
+                     print "Unacceptable key", key
+      tag.save()
+   
+   def load_tag(self):
+      """(re)Writes the tag data to the GUI."""
+      
+      tag = self.tag
+      
+      for each in self.primary_line:
+         try:
+            data = tag[each[0]]
+         except KeyError:
+            pass
+         else:
+            each[1].set_text("/".join(unicode(y) for y in data))
+
+      additional = []
+
+      for key in self.secondaries:
+         values = tag.get(key, [ASFUnicodeAttribute("")])
+         for val in values:
+            additional.append(key.encode("utf-8") + "=" + unicode(val).encode("utf-8"))
+
+      for key in self.text_set:
+         if key not in self.primary_data and key not in self.secondaries:
+            values = tag[key]
+            for val in values:
+               additional.append(key.encode("utf-8") + "=" + unicode(val).encode("utf-8"))
+      
+      self.tag_frame.tb.set_text("\n".join(additional))
+   
+   def __init__(self, pathname):
+      MutagenTagger.__init__(self, pathname)
+      try:
+         self.tag = mutagen.asf.ASF(pathname)
+         if not isinstance(self.tag, mutagen.asf.ASF):
+            raise mutagen.asf.error
+      except mutagen.asf.error:
+         print "Not a real wma/asf file apparently."
+         self.tag = None
+         return
+         
+      hbox = gtk.HBox()
+      hbox.set_border_width(5)
+      hbox.set_spacing(8)
+      self.pack_start(hbox, False, False, 0)
+      vbox_text = gtk.VBox()
+      hbox.pack_start(vbox_text, False, False, 0)
+      vbox_entry = gtk.VBox()
+      hbox.pack_start(vbox_entry, True, True, 0)
+      
+      self.primary_line = []
+      for text, entry in ((x, gtk.Entry()) for x in self.primary_data):
+         self.primary_line.append((text, entry))
+         vbox_text.add(LeftLabel(text))
+         vbox_entry.add(entry)
+      hbox.show_all()
+
+      self.tag_frame = FreeTagFrame()
+      self.tag_frame.set_border_width(5)
+      self.add(self.tag_frame)
+      self.tag_frame.show()
+
+      self.text_set = []
+
+      for key, val in self.tag.iteritems():
+         if key not in self.primary_line and all(isinstance(v, (ASFUnicodeAttribute, unicode)) for v in val):
+            self.text_set.append(key)
+
+
+class ID3Tagger(MutagenTagger):
+   """ID3 tagging with Mutagen."""
+   
+   primary_data = (("TIT2", ln.id3title), ("TPE1", ln.id3artist),
+                   ("TALB", ln.id3album), ("TRCK", ln.id3track),
+                   ("TCON", ln.id3genre), ("TDRC", ln.id3recorddate))
+   
+   def save_tag(self):
+      """Updates the tag with the GUI data."""
+      
+      tag = self.tag
+      
+      # Remove all text tags.
+      for fid in tag.iterkeys():
+         if fid[0] == "T":
+            del tag[fid]
+   
+      # Add the primary tags.
+      for fid, entry in self.primary_line:
+         text = entry.get_text().strip()
+         if text:
+            frame = getattr(id3, fid)
+            tag[fid] = frame(3, [text])
+ 
+      # Add the freeform text tags.
+      tb = self.tag_frame.tb
+      lines = tb.get_text(tb.get_start_iter(), tb.get_end_iter()).splitlines()
+          
+      for line in lines:
+         try:
+            fid, val = line.split(":", 1)
+         
+         except ValueError:
+            continue
+         
+         fid = fid.strip()
+         val = val.strip().decode("utf-8")
+         
+         try:
+            frame = id3.Frames[fid]
+         except NameError:
+            continue
+ 
+         if not issubclass(frame, id3.TextFrame):
+            continue
+ 
+         if frame is id3.TXXX:
+            try:
+               key, val = val.split(u"=", 1)
+            
+            except ValueError:
+               continue
+            
+            f = frame(3, key.strip(), [val.strip()])
+            tag[f.HashKey] = f
+            
+         else:
+            try:
+               val_list = tag[fid].text
+            except KeyError:
+               tag[fid] = frame(3, [val])
+            else:
+               val_list.append(val)
+
+      tag.save()
+            
+   def load_tag(self):
+      """(re)Writes the tag data to the GUI."""
+      
+      additional = []
+      done = []
+      
+      for fid, entry in self.primary_line:
+         try:
+            frame = self.tag[fid]
+            if fid[0] == "T":
+               try:
+                  entry.set_text(frame.text[0])
+               except TypeError:
+                  # Handle occurrence of ID3Timestamp.
+                  entry.set_text(str(frame.text[0]))
+               for each in frame.text[1:]:
+                  additional.append(fid + ":" + each.encode("utf-8"))
+         except KeyError:
+            entry.set_text("")
+         
+         done.append(fid)
+            
+      for fid, frame in self.tag.iteritems():
+         if fid[0] == "T" and fid not in done:
+            sep = "=" if fid.startswith("TXXX:") else ":"
+            for text in frame.text:
+               additional.append(fid + sep + text.encode("utf-8"))
+            
+      self.tag_frame.tb.set_text("\n".join(additional))
+      
+   def __init__(self, pathname, force=False):
+      MutagenTagger.__init__(self, pathname)
+      if force:
+         try:
+            self.tag = mutagen.File(pathname)
+            if not isinstance(self.tag, MP3):
+               raise mutagen.mp3.error
+         except mutagen.mp3.error:
+            print "Not a real mp3 file apparently."
+            self.tag = None
+            return
+         try:
+            self.tag.add_tags()
+            print "Added ID3 tags to", pathname
+         except mutagen.id3.error:
+            print "Existing ID3 tags found."
+      else:
+         try:
+            # Obtain ID3 tags from a non mp3 file.
+            self.tag = mutagen.id3.ID3(pathname)
+         except mutagen.id3.error:
+            self.tag = None
+            return
+         
+      hbox = gtk.HBox()
+      hbox.set_border_width(5)
+      hbox.set_spacing(8)
+      self.pack_start(hbox, False, False, 0)
+      vbox_frame = gtk.VBox()
+      hbox.pack_start(vbox_frame, False, False, 0)
+      vbox_text = gtk.VBox()
+      hbox.pack_start(vbox_text, False, False, 0)
+      vbox_entry = gtk.VBox()
+      hbox.pack_start(vbox_entry, True, True, 0)
+      
+      self.primary_line = []
+      for frame, text, entry in ((x, y, gtk.Entry()) for x, y in self.primary_data):
+         self.primary_line.append((frame, entry))
+         vbox_frame.add(LeftLabel(frame))
+         vbox_text.add(RightLabel(text))
+         vbox_entry.add(entry)
+      hbox.show_all()
+      
+      self.tag_frame = FreeTagFrame()
+      set_tip(self.tag_frame, ln.id3freeform)
+      self.tag_frame.set_border_width(5)
+      self.tag_frame.set_label(ln.id3textframes)
+      self.add(self.tag_frame)
+      self.tag_frame.show()
+
+
+class MP4Tagger(MutagenTagger):
+   """MP4 tagging with Mutagen."""
+   
+   primary_data = (("\xa9nam", ln.mp4title), ("\xa9ART", ln.mp4artist),
+                   ("\xa9alb", ln.mp4album), ("trkn", ln.mp4track),
+                   ("\xa9gen", ln.mp4genre), ("\xa9day", ln.mp4year))
+   
+   def save_tag(self):
+      """Updates the tag with the GUI data."""
+      
+      tag = self.tag
+      for fid, entry in self.primary_line:
+         text = entry.get_text().strip()
+         if fid == "trkn":
+            mo1 = re.search("\d+", text)
+            try:
+               track = int(text[mo1.start():mo1.end()])
+            except AttributeError:
+               new_val = None
+            else:
+               text = text[mo1.end():]
+               mo2 = re.search("\d+", text)
+               try:
+                  total = int(text[mo2.start():mo2.end()])
+               except AttributeError:
+                  new_val = [(track, 0)]
+               else:
+                  new_val = [(track, total)]
+         else:
+            new_val = [text] if text else None
+
+         if new_val is not None:
+            tag[fid] = new_val
+         else:
+            try:
+               del tag[fid]
+            except KeyError:
+               pass
+
+      tag.save()
+            
+   def load_tag(self):
+      """(re)Writes the tag data to the GUI."""
+      
+      additional = []
+      
+      for fid, entry in self.primary_line:
+         try:
+            frame = self.tag[fid][0]
+         except KeyError:
+            entry.set_text("")
+         else:
+            if fid == "trkn":
+               if frame[1]:
+                  entry.set_text("%d/%d" % frame)
+               else:
+                  entry.set_text(str(frame[0]))
+            else:
+               entry.set_text(frame)
+          
+   def __init__(self, pathname):
+      MutagenTagger.__init__(self, pathname)
+      try:
+         self.tag = mutagen.mp4.MP4(pathname)
+         if not isinstance(self.tag, mutagen.mp4.MP4):
+            raise mutagen.mp4.error
+      except mutagen.mp4.error:
+         print "Not a real mp4 file apparently."
+         self.tag = None
+         return
+         
+      hbox = gtk.HBox()
+      hbox.set_border_width(5)
+      hbox.set_spacing(8)
+      self.pack_start(hbox, False, False, 0)
+      vbox_text = gtk.VBox()
+      hbox.pack_start(vbox_text, False, False, 0)
+      vbox_entry = gtk.VBox()
+      hbox.pack_start(vbox_entry, True, True, 0)
+      
+      self.primary_line = []
+      for frame, text, entry in ((x, y, gtk.Entry()) for x, y in self.primary_data):
+         self.primary_line.append((frame, entry))
+         vbox_text.add(LeftLabel(text))
+         vbox_entry.add(entry)
+      hbox.show_all()
+
+
+class NativeTagger(MutagenTagger):
+   """Native format tagging with Mutagen. Mostly FLAC and Ogg."""
+   
+   blacklist = "coverart", "metadata_block_picture"
+   
+   def save_tag(self):
+      """Updates the tag with the GUI data."""
+      
+      tag = self.tag
+      
+      for key in tag.iterkeys():
+         if key not in self.blacklist:
+            del tag[key]
+            
+      tb = self.tag_frame.tb
+      lines = tb.get_text(tb.get_start_iter(), tb.get_end_iter()).splitlines()
+      
+      for line in lines:
+         try:
+            key, val = line.split("=", 1)
+         except ValueError:
+            continue
+         else:
+            key = key.strip()
+            val = val.strip()
+            if key not in self.blacklist and val:
+               try:
+                  tag[key] += [val.decode("utf-8")]
+               except (KeyError, AttributeError):
+                  try:
+                     tag[key] = [val.decode("utf-8")]
+                  except KeyError:
+                     print "Unacceptable key", key
+   
+      tag.save() 
+   
+   def load_tag(self):
+      """(re)Writes the tag data to the GUI."""
+      
+      tag = self.tag
+      lines = []
+      primaries = "title", "artist", "author", "album",\
+                          "tracknumber", "tracktotal", "genre", "date"
+      
+      for key in primaries:
+         try:
+            values = tag[key]
+         except KeyError:
+            lines.append(key + "=")
+         else:
+            for val in values:
+               lines.append(key + "=" + val.encode("utf-8"))
+
+      for key, values in tag.iteritems():
+         if key not in primaries and key not in self.blacklist:
+            for val in values:
+               lines.append(key + "=" + val.encode("utf-8"))
+            
+      self.tag_frame.tb.set_text("\n".join(lines))
+   
+   def __init__(self, pathname, ext):
+      MutagenTagger.__init__(self, pathname)
+      self.tag = mutagen.File(pathname)
+      if isinstance(self.tag, (MP3, APEv2)):
+         # MP3 and APEv2 have their own specialised tagger.
+         self.tag = None
+         return
+      
+      self.tag_frame = FreeTagFrame()
+      self.add(self.tag_frame)
+      self.tag_frame.show()
+
+
+class ApeTagger(MutagenTagger):
+   """APEv2 tagging with Mutagen."""
+   
+   opener = {"ape": MonkeysAudio, "mpc": Musepack }
+   
+   def save_tag(self):
+      """Updates the tag with the GUI data."""
+      
+      tag = self.tag
+      
+      for key, values in tag.iteritems():
+         if isinstance(values, APETextValue):
+            del tag[key]
+            
+      tb = self.tag_frame.tb
+      lines = tb.get_text(tb.get_start_iter(), tb.get_end_iter()).splitlines()
+      
+      for line in lines:
+         try:
+            key, val = line.split("=", 1)
+         except ValueError:
+            continue
+         else:
+            key = key.strip()
+            val = val.strip()
+            if val:
+               try:
+                  tag[key].value += "\0" + val.decode("utf-8")
+               except (KeyError, AttributeError):
+                  try:
+                     tag[key] = APETextValue(val.decode("utf-8"), 0)
+                  except KeyError:
+                     print "Unacceptable key", key
+   
+      tag.save() 
+   
+   def load_tag(self):
+      """(re)Writes the tag data to the GUI."""
+      
+      tag = self.tag
+      lines = []
+      primaries = "TITLE", "ARTIST", "AUTHOR", "ALBUM",\
+                          "TRACKNUMBER", "TRACKTOTAL", "GENRE", "DATE"
+      
+      for key in primaries:
+         try:
+            values = tag[key]
+         except KeyError:
+            lines.append(key + "=")
+         else:
+            for val in values:
+               lines.append(key + "=" + val.encode("utf-8"))
+
+      for key, values in tag.iteritems():
+         if key not in primaries and isinstance(values, APETextValue):
+            for val in values:
+               lines.append(key + "=" + val.encode("utf-8"))
+            
+      self.tag_frame.tb.set_text("\n".join(lines))
+   
+   def __init__(self, pathname, extension):
+      MutagenTagger.__init__(self, pathname)
+      
+      try:
+         self.tag = self.opener[extension](pathname)
+      except KeyError:
+         try:
+            self.tag = APEv2(pathname)
+         except:
+            print "ape tag not found"
+            self.tag = None
+            return
+         else:
+            print "ape tag found on non-native format"
+      except:
+         print "failed to create tagger for native format"
+         self.tag = None
+         return
+      else:
+         try:
+            self.tag.add_tags()
+         except:
+            print "ape tag found on native format"
+         else:
+            print "no existing ape tags found"
+         
+      self.tag_frame = FreeTagFrame()
+      self.add(self.tag_frame)
+      self.tag_frame.show()
+
+
+class MutagenGUI:
+   ext2name = { "mp3": "ID3", "mp4": "MP4", "m4a": "MP4", "spx": "Speex",
+               "flac": "FLAC", "ogg": "Ogg Vorbis", "oga": "XIPH Ogg audio",
+               "m4b": "MP4", "m4p": "MP4", "wma": "Windows Media Audio" }
+   
+   def destroy_and_quit(self, widget, data = None):
+      gtk.main_quit()
+      sys.exit(0)
+   
+   def update_playlists(self, pathname, idjcroot):
+      newplaylistdata = idjcroot.player_left.get_media_metadata(pathname)
+      idjcroot.player_left.update_playlist(newplaylistdata)
+      idjcroot.player_right.update_playlist(newplaylistdata)
+   
+   @staticmethod
+   def is_supported(pathname):
+      supported = [ "mp3", "ogg", "oga" ]
+      if avcodec and avformat:
+         supported += ["mp4", "m4a", "m4b", "m4p", "ape", "mpc", "wma"]
+      if flacenabled:
+         supported.append("flac")
+      if speexenabled:
+         supported.append("spx")
+      extension = os.path.splitext(pathname)[1][1:].lower()
+      if supported.count(extension) != 1:
+         if extension:
+            print "File type", extension, "is not supported for tagging"
+         return False
+      else:
+         return extension
+   
+   def __init__(self, pathname, encoding, idjcroot = None):
+      if not pathname:
+         print "Tagger not supplied any pathname."
+         return
+      
+      extension = self.is_supported(pathname)
+      if extension == False:
+         print "Tagger file extension", extension, "not supported."
+         return
+      
+      global set_tip
+      if idjcroot:
+         set_tip = idjcroot.tooltips.set_tip
+      
+      self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
+      if idjcroot is not None:
+         idjcroot.window_group.add_window(self.window)
+      self.window.set_size_request(550, 450)
+      self.window.set_title(ln.tagger_window_title)
+      self.window.set_destroy_with_parent(True)
+      self.window.set_border_width(9)
+      self.window.set_resizable(True)
+      self.window.set_icon_from_file(pkgdatadir + "icon" + gfext)
+      if idjcroot == None:
+         self.window.connect("destroy", self.destroy_and_quit)
+      vbox = gtk.VBox()
+      self.window.add(vbox)
+      vbox.show()
+      label = gtk.Label()
+      if idjcroot:
+         label.set_markup(u"<b>" + ln.tagger_filename + u" " + rich_safe(unicode(os.path.split(pathname)[1], encoding).encode("utf-8", "replace")) + u"</b>")
+      else:
+         label.set_markup(u"<b>" + ln.tagger_filename + u" " + rich_safe(unicode(os.path.split(pathname)[1], "latin1").encode("utf-8", "replace")) + u"</b>")
+      vbox.pack_start(label, False, False, 6)
+      label.show()
+      
+      hbox = gtk.HBox()
+      hbox.set_border_width(2)
+      apply_button = gtk.Button(None, gtk.STOCK_APPLY)
+      if idjcroot is not None:
+         apply_button.connect_object_after("clicked", self.update_playlists, pathname, idjcroot)
+      hbox.pack_end(apply_button, False, False, 0)
+      apply_button.show()
+      close_button = gtk.Button(None, gtk.STOCK_CLOSE)
+      close_button.connect_object("clicked", gtk.Window.destroy, self.window)
+      hbox.pack_end(close_button, False, False, 10)
+      close_button.show()
+      reload_button = gtk.Button(None, gtk.STOCK_REVERT_TO_SAVED)
+      hbox.pack_start(reload_button, False, False, 10)
+      reload_button.show()
+      vbox.pack_end(hbox, False, False, 0)
+      hbox.show()
+      hbox = gtk.HBox()
+      vbox.pack_end(hbox, False, False, 2)
+      hbox.show()
+      
+      notebook = gtk.Notebook()
+      notebook.set_border_width(2)
+      vbox.pack_start(notebook, True, True, 0)
+      notebook.show()
+      
+      self.ape = ApeTagger(pathname, extension)
+      
+      if extension == "mp3":
+         self.id3 = ID3Tagger(pathname, True)
+         self.native = None
+      else:
+         self.id3 = ID3Tagger(pathname, False)
+         if extension in ("mp4", "m4a", "m4b", "m4p"):
+            self.native = MP4Tagger(pathname)
+         elif extension == "wma":
+            self.native = WMATagger(pathname)
+         elif extension in ("ape", "mpc"):
+            # APE tags are native to this format.
+            self.native = None
+         else:
+            self.native = NativeTagger(pathname, ext=extension)
+      
+      if self.id3 is not None and self.id3.tag is not None:
+         reload_button.connect("clicked", lambda x: self.id3.load_tag())
+         apply_button.connect("clicked", lambda x: self.id3.save_tag())
+         label = gtk.Label("ID3")
+         notebook.append_page(self.id3, label)
+         self.id3.show()
+      
+      if self.ape is not None and self.ape.tag is not None:
+         reload_button.connect("clicked", lambda x: self.ape.load_tag())
+         apply_button.connect("clicked", lambda x: self.ape.save_tag())
+         label = gtk.Label("APE v2")
+         notebook.append_page(self.ape, label)
+         self.ape.show()   
+      
+      if self.native is not None and self.native.tag is not None:
+         reload_button.connect("clicked", lambda x: self.native.load_tag())
+         apply_button.connect("clicked", lambda x: self.native.save_tag())
+         label = gtk.Label(ln.native + " (" + self.ext2name[extension] + ")")
+         notebook.append_page(self.native, label)
+         self.native.show()
+      
+      reload_button.clicked()
+
+      apply_button.connect_object_after("clicked", gtk.Window.destroy, self.window)
+      self.window.show()
diff --git a/idjcpython/nt.py b/idjcpython/nt.py
new file mode 100644
index 0000000..50d7da3
--- /dev/null
+++ b/idjcpython/nt.py
@@ -0,0 +1,113 @@
+from operator import itemgetter as _itemgetter
+from keyword import iskeyword as _iskeyword
+import sys as _sys
+
+def namedtuple(typename, field_names, verbose=False, rename=False):
+    """Returns a new subclass of tuple with named fields.
+
+    >>> Point = namedtuple('Point', 'x y')
+    >>> Point.__doc__                   # docstring for the new class
+    'Point(x, y)'
+    >>> p = Point(11, y=22)             # instantiate with positional args or keywords
+    >>> p[0] + p[1]                     # indexable like a plain tuple
+    33
+    >>> x, y = p                        # unpack like a regular tuple
+    >>> x, y
+    (11, 22)
+    >>> p.x + p.y                       # fields also accessable by name
+    33
+    >>> d = p._asdict()                 # convert to a dictionary
+    >>> d['x']
+    11
+    >>> Point(**d)                      # convert from a dictionary
+    Point(x=11, y=22)
+    >>> p._replace(x=100)               # _replace() is like str.replace() but targets named fields
+    Point(x=100, y=22)
+
+    """
+
+    # Parse and validate the field names.  Validation serves two purposes,
+    # generating informative error messages and preventing template injection attacks.
+    if isinstance(field_names, basestring):
+        field_names = field_names.replace(',', ' ').split() # names separated by whitespace and/or commas
+    field_names = tuple(map(str, field_names))
+    if rename:
+        names = list(field_names)
+        seen = set()
+        for i, name in enumerate(names):
+            if (not min(c.isalnum() or c=='_' for c in name) or _iskeyword(name)
+                or not name or name[0].isdigit() or name.startswith('_')
+                or name in seen):
+                    names[i] = '_%d' % i
+            seen.add(name)
+        field_names = tuple(names)
+    for name in (typename,) + field_names:
+        if not min(c.isalnum() or c=='_' for c in name):
+            raise ValueError('Type names and field names can only contain alphanumeric characters and underscores: %r' % name)
+        if _iskeyword(name):
+            raise ValueError('Type names and field names cannot be a keyword: %r' % name)
+        if name[0].isdigit():
+            raise ValueError('Type names and field names cannot start with a number: %r' % name)
+    seen_names = set()
+    for name in field_names:
+        if name.startswith('_') and not rename:
+            raise ValueError('Field names cannot start with an underscore: %r' % name)
+        if name in seen_names:
+            raise ValueError('Encountered duplicate field name: %r' % name)
+        seen_names.add(name)
+
+    # Create and fill-in the class template
+    numfields = len(field_names)
+    argtxt = repr(field_names).replace("'", "")[1:-1]   # tuple repr without parens or quotes
+    reprtxt = ', '.join('%s=%%r' % name for name in field_names)
+    template = '''class %(typename)s(tuple):
+        '%(typename)s(%(argtxt)s)' \n
+        __slots__ = () \n
+        _fields = %(field_names)r \n
+        def __new__(_cls, %(argtxt)s):
+            return _tuple.__new__(_cls, (%(argtxt)s)) \n
+        @classmethod
+        def _make(cls, iterable, new=tuple.__new__, len=len):
+            'Make a new %(typename)s object from a sequence or iterable'
+            result = new(cls, iterable)
+            if len(result) != %(numfields)d:
+                raise TypeError('Expected %(numfields)d arguments, got %%d' %% len(result))
+            return result \n
+        def __repr__(self):
+            return '%(typename)s(%(reprtxt)s)' %% self \n
+        def _asdict(self):
+            'Return a new dict which maps field names to their values'
+            return dict(zip(self._fields, self)) \n
+        def _replace(_self, **kwds):
+            'Return a new %(typename)s object replacing specified fields with new values'
+            result = _self._make(map(kwds.pop, %(field_names)r, _self))
+            if kwds:
+                raise ValueError('Got unexpected field names: %%r' %% kwds.keys())
+            return result \n
+        def __getnewargs__(self):
+            return tuple(self) \n\n''' % locals()
+    for i, name in enumerate(field_names):
+        template += '        %s = _property(_itemgetter(%d))\n' % (name, i)
+    if verbose:
+        print template
+
+    # Execute the template string in a temporary namespace
+    namespace = dict(_itemgetter=_itemgetter, __name__='namedtuple_%s' % typename,
+                     _property=property, _tuple=tuple)
+    try:
+        exec template in namespace
+    except SyntaxError, e:
+        raise SyntaxError(e.message + ':\n' + template)
+    result = namespace[typename]
+
+    # For pickling to work, the __module__ variable needs to be set to the frame
+    # where the named tuple is created.  Bypass this step in enviroments where
+    # sys._getframe is not defined (Jython for example) or sys._getframe is not
+    # defined for arguments greater than 0 (IronPython).
+    try:
+        result.__module__ = _sys._getframe(1).f_globals.get('__name__', '__main__')
+    except (AttributeError, ValueError):
+        pass
+
+    return result
+
diff --git a/idjcpython/p3db.py b/idjcpython/p3db.py
index 7f85c87..902fb1d 100644
--- a/idjcpython/p3db.py
+++ b/idjcpython/p3db.py
@@ -19,8 +19,9 @@ __all__ = ['MediaPane', 'Prefs']
 
 import pygtk
 pygtk.require('2.0')
-import gtk
+import gtk, gobject, time
 from idjc_config import *
+from IDJCfree import threadslock
 from ln_text import ln
 from urllib import quote
 
@@ -34,7 +35,9 @@ def makeview(notebook, label_text, additional = None):
    vbox = gtk.VBox()
    vbox.set_spacing(2)
    scrollwindow = gtk.ScrolledWindow()
+   alternate = gtk.VBox()
    vbox.pack_start(scrollwindow, True, True, 0)
+   vbox.pack_start(alternate, True, True, 0)
    if additional is not None:
       vbox.pack_start(additional, False, False, 0)
    vbox.show()
@@ -46,7 +49,7 @@ def makeview(notebook, label_text, additional = None):
    treeview = gtk.TreeView()
    scrollwindow.add(treeview)
    treeview.show()
-   return treeview
+   return treeview, scrollwindow, alternate
 
 def makecolumns(view, name_ix_rf_mw):
    l = []
@@ -74,6 +77,60 @@ class DNDAccumulator(list):
    def __init__(self):
       list.__init__(self)
 
+class TreePopulate(object):
+   """ runs as an idle process building the tree view of the p3 database """
+   @threadslock
+   def run(self):
+      i = 10
+      append = self.mp.treestore.append
+      d = self.d
+      while i > 0:
+         i -= 1
+         row = self.c.fetchone()
+         if row is None:
+            self.mp.treeview.set_model(self.mp.treestore)
+            self.mp.treealt.hide()
+            self.mp.treescroll.show()
+            self.mp.tree_idle = None
+            retval = False
+            #print "Database parsed in %f seconds" % (time.time() - self.start_time)
+            break
+         else:
+            while 1:
+               if d == 0:
+                  self.art = row[1]
+                  self.artlower = self.art.lower()
+                  self.iter1 = append(None, (-1, self.art, 0, 0, 0, "", "")) 
+                  d = 1
+               if d == 1:
+                  if self.artlower == row[1].lower():
+                     self.alb = row[2]
+                     self.alblower = self.alb.lower()
+                     self.iter2 = append(self.iter1, (-2, self.alb, 0, 0, 0, "", "")) 
+                     d = 2
+                  else:
+                     d = 0
+               if d == 2:
+                  if self.artlower == row[1].lower() and self.alblower == row[2].lower():
+                     append(self.iter2, (row[0], row[4], row[3], row[5], row[6], row[7], row[8]))
+                     break
+                  else:
+                     d = 1
+            retval = True
+      self.d = d
+      self.done += 10.0
+      if int(self.done) % 100 == 0:
+         self.mp.tree_pb.set_fraction(self.done / self.total)
+      return retval
+   def __init__(self, mp, c, total, start_time):
+      self.mp = mp
+      self.c = c
+      self.total = float(total)
+      self.start_time = start_time
+      self.done = 0.0
+      self.d = 0
+      self.art = self.alb = ""
+
 class MediaPane(gtk.Frame):
    """ UI for viewing the prokyon 3 database"""
    
@@ -165,48 +222,33 @@ class MediaPane(gtk.Frame):
       self.db = db
       self.whereentry.set_text("")
       self.fuzzyentry.set_text("")
-      self.tree_update.clicked()
       self.show()
+      self.tree_update.clicked()
    
    def deactivate(self):
       self.hide()
-      del self.db
+      try:
+         del self.db
+      except AttributeError:
+         pass
 
    def cb_tree_update(self, widget):
       c = self.db.cursor()
       try:
-         c.execute("""SELECT id,artist,album,tracknumber,title,length,bitrate,filename,path FROM tracks ORDER BY artist,album,path,tracknumber,title""")
+         total = c.execute("""SELECT id,artist,album,tracknumber,title,length,bitrate,filename,path FROM tracks ORDER BY artist,album,path,tracknumber,title""")
       except dberror.MySQLError, inst:
          print inst
+         c.close()
       else:
          self.treeview.set_model(None)
          self.treestore.clear()
-         art = alb = ""
-         d = 0
-         while 1:
-            row = c.fetchone()
-            if row is None:
-               break
-            while 1:
-               if d == 0:
-                  art = row[1]
-                  iter1 = self.treestore.append(None, (-1, art, 0, 0, 0, "", "")) 
-                  d = 1
-               if d == 1:
-                  if art.lower() == row[1].lower():
-                     alb = row[2]
-                     iter2 = self.treestore.append(iter1, (-2, alb, 0, 0, 0, "", "")) 
-                     d = 2
-                  else:
-                     d = 0
-               if d == 2:
-                  if art.lower() == row[1].lower() and alb.lower() == row[2].lower():
-                     self.treestore.append(iter2, (row[0], row[4], row[3], row[5], row[6], row[7], row[8]))
-                     break
-                  else:
-                     d = 1
-         self.treeview.set_model(self.treestore)
-      c.close()
+         self.treescroll.hide()
+         self.treealt.show()
+         self.tree_pb.set_fraction(0.0)
+         if self.tree_idle is not None:
+            gobject.source_remove(self.tree_idle)
+         tree_populate = TreePopulate(self, c, total, time.time())
+         self.tree_idle = gobject.idle_add(tree_populate.run)
       
    def cb_update(self, widget):
       """ Database lookup performed here """
@@ -302,7 +344,7 @@ class MediaPane(gtk.Frame):
       
       buttonbox.show()
       
-      self.treeview = makeview(self.notebook, ln.media_tree, buttonbox)
+      self.treeview, self.treescroll, self.treealt = makeview(self.notebook, ln.media_tree, buttonbox)
       self.treeview.set_enable_tree_lines(True)
       self.treeview.set_rubber_banding(True)
       treeselection = self.treeview.get_selection()
@@ -326,6 +368,17 @@ class MediaPane(gtk.Frame):
       self.treeview.connect_after("drag-begin", self.cb_drag_begin)
       self.treeview.connect("drag_data_get", self.cb_tree_drag_data_get)
       
+      vbox = gtk.VBox()
+      vbox.set_border_width(20)
+      vbox.set_spacing(20)
+      label = gtk.Label(ln.populating)
+      vbox.pack_start(label, False, False, 0)
+      self.tree_pb = gtk.ProgressBar()
+      vbox.pack_start(self.tree_pb, False, False, 0)
+      self.treealt.add(vbox)
+      vbox.show_all()
+      
+      self.tree_idle = None
       
       # flat gui
       filterframe = gtk.Frame(ln.dbfilters)
@@ -368,7 +421,7 @@ class MediaPane(gtk.Frame):
       wherehbox.pack_start(self.update, False, False, 0)
       self.update.show()
       
-      self.flatview = makeview(self.notebook, ln.media_flat, filterframe)
+      self.flatview, self.flatscroll, self.flatalt = makeview(self.notebook, ln.media_flat, filterframe)
       self.flatview.set_rules_hint(True)
       self.flatview.set_rubber_banding(True)
       treeselection = self.flatview.get_selection()
@@ -387,9 +440,6 @@ class MediaPane(gtk.Frame):
             (ln.dbfilename, 8, None, 100),
             (ln.dbpath, 9, None, -1),
             ))
-      #for ix, col in enumerate(self.flatcols):
-      #   col.set_sort_column_id((0,2,3,4,5,6,7,8,9)[ix])
-      #   col.set_clickable(False)
          
       self.flatview.enable_model_drag_source(gtk.gdk.BUTTON1_MASK, self.sourcetargets, gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_COPY)
       self.flatview.connect_after("drag-begin", self.cb_drag_begin)
@@ -442,7 +492,7 @@ class Prefs(gtk.Frame):
          else:
             try:
                self.db.close()
-            except (NameError, dberror.MySQLError):
+            except (AttributeError, NameError, dberror.MySQLError):
                pass
             else:
                self.set_ui_state(False)
@@ -510,6 +560,7 @@ class Prefs(gtk.Frame):
       table.attach(passwordlabel, 0, 1, 1, 2, gtk.SHRINK | gtk.FILL)
       passwordlabel.show()
       self.prokpassword = self.ProkEntry()
+      self.prokpassword.set_visibility(False)
       table.attach(self.prokpassword, 1, 2, 1, 2)
       self.prokpassword.show()
       self.proktoggle = gtk.ToggleButton(ln.prokyon3_connect)
diff --git a/idjcpython/popupwindow.py b/idjcpython/popupwindow.py
index 909ad8d..98016aa 100644
--- a/idjcpython/popupwindow.py
+++ b/idjcpython/popupwindow.py
@@ -21,6 +21,7 @@ import pygtk
 pygtk.require('2.0')
 import gtk
 import gobject
+from IDJCfree import threadslock
 
 class PopupWindow:
    def message(self, text):
@@ -38,6 +39,7 @@ class PopupWindow:
          gtk.Window.__init__(self, gtk.WINDOW_POPUP)
          gtk.Window.set_decorated(self, False)
    
+   @threadslock
    def timeout_callback(self):
       class bugout:
          def __init__(self, parent, text):
@@ -45,7 +47,6 @@ class PopupWindow:
                parent.popup_window.destroy()
                parent.popup_window = None
             parent.message(text)
-      gtk.gdk.threads_enter()
       try:
          self.timer_count += 1
          self.total_timer_count += 1
@@ -73,10 +74,8 @@ class PopupWindow:
          if self.timer_count > self.popdowntime:
             raise bugout(self, "popdown time reached")
       except bugout:
-         gtk.gdk.threads_leave()
          return False
       else:
-         gtk.gdk.threads_leave()
          return True
    
    def handle_mouse(self, widget, event, data):
diff --git a/idjcpython/sourceclientgui.py b/idjcpython/sourceclientgui.py
index e0456c9..ea10dd7 100644
--- a/idjcpython/sourceclientgui.py
+++ b/idjcpython/sourceclientgui.py
@@ -23,13 +23,19 @@ pygtk.require('2.0')
 import gtk
 import gobject
 
-import os, time, fcntl, subprocess, urllib2
+import os, time, fcntl, subprocess, urllib, urllib2, base64
 import xml.dom.minidom as mdom
 
 from idjc_config import *
 from ln_text import ln
-from IDJCfree import int_object
+from IDJCfree import int_object, threadslock
 from IDJCservdialog import *
+from threading import Thread
+
+try:
+   from collections import namedtuple
+except:
+   from nt import namedtuple
 
 ENCODER_START=1; ENCODER_STOP=0					# start_stop_encoder constants
 
@@ -48,6 +54,492 @@ class SubcategoryFrame(gtk.Frame):
       gtk.Frame.__init__(self, frametext)
       gtk.Frame.set_shadow_type(self, gtk.SHADOW_ETCHED_IN)
 
+class StatsThread(Thread):
+   def __init__(self, d):
+      Thread.__init__(self)
+      self.is_shoutcast = d["server_type"] % 2
+      self.host = d["host"]
+      self.port = d["port"]
+      self.mount = d["mount"]
+      if self.is_shoutcast:
+         self.login = "admin"
+      else:
+         self.login = d["login"]
+      self.passwd = d["password"]
+      self.listeners = -2         # preset error code for failed/timeout
+      self.url = "http://%s:%d%s" % (self.host, self.port, self.mount)
+   def run(self):
+      class BadXML(ValueError):
+         pass
+      
+      hostport = "%s:%d" % (self.host, self.port)
+      if self.is_shoutcast:
+         stats_url = "http://%s/admin.cgi?mode=viewxml" % hostport
+         realm = "Shoutcast Server"
+      else:
+         stats_url = "http://%s/admin/listclients?mount=%s" % (hostport, self.mount)
+         realm = "Icecast2 Server"
+      auth_handler = urllib2.HTTPBasicAuthHandler()
+      auth_handler.add_password(realm, hostport, self.login, self.passwd)
+      opener = urllib2.build_opener(auth_handler)
+      opener.addheaders = [('User-agent', 'Mozilla/5.0')]
+      
+      try:
+         f = opener.open(stats_url)
+         xmlfeed = f.read()
+      except:
+         print "failed to get server stats for", self.url
+         return
+      f.close()
+      try:
+         dom = mdom.parseString(xmlfeed)
+      except:
+         print "failed to parse server stats for", self.url
+         return
+      
+      try:
+         if self.is_shoutcast:
+            if dom.documentElement.tagName == u'SHOUTCASTSERVER':
+               shoutcastserver = dom.documentElement
+            else:
+               raise BadXML
+            currentlisteners = shoutcastserver.getElementsByTagName('CURRENTLISTENERS')
+            try:
+               self.listeners = int(currentlisteners[0].firstChild.wholeText.strip())
+            except:
+               raise BadXML
+         else:
+            if dom.documentElement.tagName == u'icestats':
+               icestats = dom.documentElement
+            else:
+               raise BadXML
+            sources = icestats.getElementsByTagName('source')
+            for source in sources:
+               mount = source.getAttribute('mount')
+               if stats_url.endswith(mount):
+                  listeners = source.getElementsByTagName('Listeners')
+                  try:
+                     self.listeners = int(listeners[0].firstChild.wholeText.strip())
+                     break
+                  except:
+                     raise BadXML
+            else:
+               raise BadXML
+      except BadXML:
+         print "Unexpected data in server stats XML file"
+      dom.unlink()
+      print "server", self.url, "has", self.listeners, "listeners"
+
+class ActionTimer(object):
+   def run(self):
+      if self.n == 0:
+         self.first()
+      self.n += 1
+      if self.n == self.ticks:
+         self.n = 0
+         self.last()
+   def __init__(self, ticks, first, last):
+      assert(ticks)
+      self.ticks = ticks
+      self.n = 0
+      self.first = first
+      self.last = last
+
+class ConnectionFrame(CategoryFrame):
+   frametext = (ln.connection_undefined, ln.connection_icecast2, ln.connection_shoutcast)
+   def set_frame_mode(self, mode):
+      self.set_label(self.frametext[mode])
+      self.mode = mode
+   def get_frame_mode(self):
+      return self.mode
+   def __init__(self):
+      CategoryFrame.__init__(self)
+      self.set_frame_mode(0)
+
+class ConnectionPane(ConnectionFrame):
+   LISTFORMAT = (("check_stats", bool), ("server_type", int), ("host", str), ("port", int), ("mount", str), ("listeners", int), ("login", str), ("password", str))
+   ListLine = namedtuple("ListLine", " ".join([x[0] for x in LISTFORMAT]))
+   
+   def label_item_layout(self, label_item_pairs, sizegroup):	# align vertical colums of label : item
+      hbox = gtk.HBox()						# label is right justified and narrow as possible
+      vbox_left = gtk.VBox()					# the item widget is free to expand
+      vbox_left.set_spacing(1)
+      vbox_right = gtk.VBox()
+      vbox_right.set_spacing(1)
+      hbox.pack_start(vbox_left, False, False, 0)
+      hbox.pack_start(vbox_right, True, True, 0)
+      hbox.set_spacing(5)
+      for text, item in label_item_pairs:
+         if text is not None:
+            labelbox = gtk.HBox()
+            if type(text) == str:
+               label = gtk.Label(text)
+            else:
+               label = text
+            sizegroup.add_widget(label)
+            labelbox.pack_end(label, False, False)
+            label.show()
+            vbox_left.pack_start(labelbox, False, False, 0)
+            labelbox.show()
+         itembox = gtk.HBox()
+         sizegroup.add_widget(itembox)
+         itembox.add(item)
+         item.show()
+         vbox_right.pack_start(itembox, False, False, 0)
+         itembox.show()
+      vbox_left.show()
+      vbox_right.show()
+      return hbox   
+   def individual_listeners_toggle_cb(self, cell, path):
+      self.liststore[path][0] = not self.liststore[path][0]
+   def server_type_data_func(self, column, cell, model, iter):
+      cell.set_property("text", model.get_value(iter, 0))
+      sens = model.get_path(iter)[0] >= 2 or self.master_is_set() == False
+      cell.set_property("sensitive", sens)
+   def server_type_changed(self, combo):
+      active = combo.get_active()
+      self.ic2 = not active % 2
+      self.master = active < 2
+      for each in (self.mount, self.login):
+         each.set_sensitive(self.ic2)
+   def listeners_renderer_cb(self, column, cell, model, iter):
+      listeners = model.get_value(iter, 5)
+      if listeners == -1:
+         cell.set_property("text", ln.listeners_unknown)
+         cell.set_property("xalign", 0.5)
+      elif listeners == -2:
+         cell.set_property("text", ln.listeners_failed)
+         cell.set_property("xalign", 0.5)
+      else:
+         cell.set_property("text", listeners)
+         cell.set_property("xalign", 1.0)
+   def type_renderer_cb(self, column, cell, model, iter):
+      server_type = model.get_value(iter, 1)
+      cell.set_property("text", ln.server_type_codes[server_type])
+   def master_set(self, val):
+      self._master_set = val
+   def master_is_set(self):
+      return self._master_set
+   def streaming_set(self, val):
+      self._streaming_set = val
+   def streaming_is_set(self):
+      return self._streaming_set
+   def add_cb(self, button):
+      masters = ln.server_type_codes[:2]
+      requirements = ("host", "password")
+      also = ("mount", "login")
+      if self.master and len(self.liststore) and self.liststore[0][1] in masters:
+         print "already have a master server in the list so we won't add another"
+         return
+      if self.ic2:
+         requirements += also
+         d = {}
+      else:
+         d = dict.fromkeys(also, "")
+      for each in requirements:
+         val = self.__getattribute__(each).get_text().strip()
+         if not val:
+            print "to add the server you need to set", each
+            return
+         d[each] = val
+      if self.ic2 and d["mount"][0] != "/":
+         d["mount"] = "/" + d["mount"]
+      row = (True, self.server_type.get_active(), d["host"], self.port.get_value(), d["mount"], -1, d["login"], d["password"])
+      if self.master:
+         self.set_frame_mode((2, 1)[self.ic2])
+         self.master_set(True)
+         self.server_type.set_active(self.server_type.get_active() + 2)
+         iter = self.liststore.insert(0, row)
+         self.treeview.scroll_to_cell(0)
+      else:
+         iter = self.liststore.append(row)
+         self.treeview.scroll_to_cell(self.liststore.get_path(iter))
+      self.treeview.get_selection().select_iter(iter)
+      for each in (self.host, self.mount, self.login, self.password):
+         each.set_text("")
+      self.port.set_value(8000)
+   def edit_remove_cb(self, button):
+      selection = self.treeview.get_selection()
+      model, treeiter = selection.get_selected()
+      if treeiter is None:
+         print "nothing is selected to remove"
+         return
+      path = model.get_path(treeiter)[0]
+      d = self.row_to_dict(path)
+      st = d["server_type"]
+      if st < 2:
+         self.set_frame_mode(0)
+         self.master_set(False)
+      self.server_type.set_active(st)
+      self.host.set_text(d["host"])
+      self.port.set_value(d["port"])
+      self.mount.set_text(d["mount"])
+      self.login.set_text(d["login"])
+      self.password.set_text(d["password"])
+      if not model.remove(treeiter):
+         path -= 1
+      if path >= 0:
+         selection.select_path(path)
+         self.treeview.scroll_to_cell(path)
+   def row_to_dict(self, rownum):
+      """ obtain a dictionary of server data for a specified row """
+            
+      return self.ListLine._make(self.liststore[rownum])._asdict()
+   
+   def dict_to_row(self, _dict):
+      """ append a row of server data from a dictionary """
+      
+      _dict["listeners"] = -1
+      row = self.ListLine(**_dict)
+      t = row.server_type
+      if t < 2:                           # check if first line contains master server info
+         if t == 0:
+            self.set_frame_mode(1)
+         if t == 1:
+            self.set_frame_mode(2)
+         self.server_type.set_active(t + 2)
+         self.master_set(True)
+         self.liststore.insert(0, row)
+      else:
+         self.liststore.append(row)
+      return
+
+   def saver(self):
+      server = []
+      template = ("<%s dtype=\"int\">%d</%s>", "<%s dtype=\"str\">%s</%s>")
+      for i in range(len(self.liststore)):
+         s = self.row_to_dict(i)
+         del s["listeners"]
+         s["password"] = base64.encodestring(s["password"])
+         d = []
+         for key, value in s.iteritems():
+            if type(value) == str:
+               t = template[1]
+               value = urllib.quote(value)
+            else:
+               t = template[0]
+            d.append(t % (key, value, key))
+         server.append("".join(("<server>", "".join(d), "</server>")))
+      return "<connections>%s</connections>" % "".join(server)
+   
+   def loader(self, xmldata):
+      def get_child_text(nodelist):
+         t = []
+         for node in nodelist:
+            if node.nodeType == node.TEXT_NODE:
+               t.append(node.data)
+         return "".join(t)
+      if not xmldata:
+         return
+      try:
+         try:
+            dom = mdom.parseString(xmldata)
+         except:
+            print "ConnectionPane.loader: failed to parse xml data...\n", xmldata
+            raise
+         assert(dom.documentElement.tagName == "connections")
+         for server in dom.getElementsByTagName("server"):
+            d = {}
+            for node in server.childNodes:
+               key = str(node.tagName)
+               dtype = node.getAttribute("dtype")
+               raw = get_child_text(node.childNodes)
+               if dtype == "str":
+                  value = urllib.unquote(raw)
+               elif dtype == "int":
+                  value = int(raw)
+               else:
+                  raise ValueError("ConnectionPane.loader: dtype (%s) is unhandled" % dtype)
+               d[key] = value
+            try:
+               d["password"] = base64.decodestring(d["password"])
+            except KeyError:
+               pass
+            self.dict_to_row(d)
+      except Exception, e:
+         print e
+      self.treeview.get_selection().select_path(0)
+         
+   def stats_commence(self):
+      self.stats_rows = []
+      getstats = self.stats_always.get_active() or (self.stats_ifconnected.get_active() and self.streaming_is_set())
+      for i, row in enumerate(self.liststore):
+         if row[0] and getstats:
+            stats_thread = StatsThread(self.row_to_dict(i))
+            stats_thread.start()
+            ref = gtk.TreeRowReference(self.liststore, i)
+            self.stats_rows.append((ref, stats_thread))
+         else:
+            row[5] = -1       # sets listeners text to 'unknown'
+   def stats_collate(self):
+      count = 0
+      for ref, thread in self.stats_rows:
+         if ref.valid() == False:
+            print "stats_collate:", thread.url, "invalidated by its removal from the stats list"
+            continue
+         row = ref.get_model()[ref.get_path()[0]]
+         row[5] = thread.listeners
+         if thread.listeners > 0:
+            count += thread.listeners
+      self.listeners_display.set_text(str(count))
+      self.listeners = count
+   def __init__(self, set_tip):
+      ConnectionFrame.__init__(self)
+      self.master_set(False)
+      self.streaming_set(False)
+      vbox = gtk.VBox()
+      vbox.set_border_width(10)
+      vbox.set_spacing(6)
+      self.add(vbox)
+      vbox.show()
+      scrolled = gtk.ScrolledWindow()
+      scrolled.set_size_request(-1, 90)
+      scrolled.set_shadow_type(gtk.SHADOW_ETCHED_IN)
+      scrolled.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
+      vbox.pack_start(scrolled, False, False, 0)
+      scrolled.show()
+      self.liststore = gtk.ListStore(*[x[1] for x in self.LISTFORMAT])
+      self.treeview = gtk.TreeView(self.liststore)
+      set_tip(self.treeview, ln.connections_table_tip)
+      self.treeview.set_enable_search(False)
+      rend_enabled = gtk.CellRendererToggle()
+      rend_enabled.connect("toggled", self.individual_listeners_toggle_cb)
+      col_enabled = gtk.TreeViewColumn("*", rend_enabled, active = 0)
+      col_enabled.set_alignment(0.5)
+      self.treeview.append_column(col_enabled)
+      rend_type = gtk.CellRendererText()
+      rend_type.set_property("xalign", 0.5) 
+      col_type = gtk.TreeViewColumn(ln.conn_col_type, rend_type)
+      col_type.set_alignment(0.5)
+      col_type.set_cell_data_func(rend_type, self.type_renderer_cb)
+      self.treeview.append_column(col_type)
+      rend_host = gtk.CellRendererText()
+      col_host = gtk.TreeViewColumn(ln.conn_col_host, rend_host, text = 2)
+      col_host.set_sizing = gtk.TREE_VIEW_COLUMN_FIXED
+      col_host.set_expand(True)
+      self.treeview.append_column(col_host)
+      rend_port = gtk.CellRendererText()
+      rend_port.set_property("xalign", 1.0)
+      col_port = gtk.TreeViewColumn(ln.conn_col_port, rend_port, text = 3)
+      col_port.set_alignment(0.5)
+      self.treeview.append_column(col_port)
+      rend_mount = gtk.CellRendererText()
+      col_mount = gtk.TreeViewColumn(ln.conn_col_mount, rend_mount, text = 4)
+      col_mount.set_sizing = gtk.TREE_VIEW_COLUMN_FIXED
+      col_mount.set_expand(True)
+      self.treeview.append_column(col_mount)
+      rend_listeners = gtk.CellRendererText()
+      col_listeners = gtk.TreeViewColumn(ln.conn_col_listeners, rend_listeners)
+      col_listeners.set_sizing = gtk.TREE_VIEW_COLUMN_AUTOSIZE
+      col_listeners.set_alignment(0.5)
+      col_listeners.set_cell_data_func(rend_listeners, self.listeners_renderer_cb)
+      self.treeview.append_column(col_listeners)
+      scrolled.add(self.treeview)
+      self.treeview.show()
+      
+      edit_add_hbox = gtk.HBox()
+      sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
+      self.edit_remove = gtk.Button(ln.edit_remove)
+      set_tip(self.edit_remove, ln.connections_editremove_tip)
+      self.edit_remove.connect("clicked", self.edit_remove_cb)
+      sg.add_widget(self.edit_remove)
+      edit_add_hbox.pack_start(self.edit_remove, False, False, 0)
+      self.edit_remove.show()
+      self.add = gtk.Button(ln.add)
+      set_tip(self.add, ln.connections_add_tip)
+      self.add.connect("clicked", self.add_cb)
+      sg.add_widget(self.add)
+      edit_add_hbox.pack_end(self.add, False, False, 0)
+      self.add.show()
+      vbox.pack_start(edit_add_hbox, False, False, 0)
+      edit_add_hbox.show()
+      sep = gtk.HSeparator()
+      vbox.pack_start(sep, False, False, 0)
+      sep.show()
+      
+      cpsizegroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
+      ls = gtk.ListStore(str)
+      for x in ln.server_type_labels:
+         ls.append((x,))
+      self.server_type = gtk.ComboBox(ls)
+      set_tip(self.server_type, ln.server_type_tip)
+      cell = gtk.CellRendererText()
+      self.server_type.pack_start(cell, True)
+      self.server_type.set_cell_data_func(cell, self.server_type_data_func)
+      self.server_type.connect("changed", self.server_type_changed)
+      self.host = gtk.Entry()
+      set_tip(self.host, ln.hostname_tip)
+      port_adj = gtk.Adjustment(8000, 0, 65535, 1, 10)
+      self.port = gtk.SpinButton(port_adj, 0.0, 0)
+      set_tip(self.port, ln.port_tip)
+      sg = gtk.SizeGroup(gtk.SIZE_GROUP_VERTICAL)
+      left_pane = self.label_item_layout( ((ln.server_type, self.server_type),
+                                           (ln.server_host, self.host),
+                                           (ln.server_port, self.port)), sg)
+      cpsizegroup.add_widget(left_pane)
+      self.mount = gtk.Entry()
+      set_tip(self.mount, ln.mount_point_tip)
+      self.login = gtk.Entry()
+      set_tip(self.login, ln.login_tip)
+      self.password = gtk.Entry()
+      set_tip(self.password, ln.password_tip)
+      self.password.set_visibility(False)
+      right_pane = self.label_item_layout( ((ln.server_mount, self.mount),
+                                            (ln.server_login, self.login),
+                                            (ln.server_passwd, self.password)), sg)
+      cpsizegroup.add_widget(right_pane)
+      hbox = gtk.HBox()
+      hbox.set_spacing(6)
+      hbox.add(left_pane)
+      left_pane.show()
+      sep = gtk.VSeparator()
+      hbox.add(sep)
+      sep.show()
+      hbox.add(right_pane)
+      right_pane.show()
+      vbox.pack_start(hbox, False, False, 0)
+      hbox.show()
+      
+      sep = gtk.HSeparator()
+      vbox.pack_start(sep, False, False, 0)
+      sep.show()
+      
+      hbox = gtk.HBox()
+      hbox.set_spacing(6)
+      label = gtk.Label(ln.get_stats)
+      hbox.pack_start(label, False, False, 0)
+      label.show()
+      self.stats_never = gtk.RadioButton(None, ln.get_stats_never)
+      hbox.pack_start(self.stats_never, False, False, 0)
+      self.stats_never.show()
+      self.stats_always = gtk.RadioButton(self.stats_never, ln.get_stats_always)
+      hbox.pack_start(self.stats_always, False, False, 0)
+      self.stats_always.show()
+      self.stats_ifconnected = gtk.RadioButton(self.stats_never, ln.get_stats_ifconnected)
+      self.stats_ifconnected.set_active(True)
+      hbox.pack_start(self.stats_ifconnected, False, False, 0)
+      self.stats_ifconnected.show()
+      
+      ihbox = gtk.HBox()
+      set_tip(ihbox, ln.listeners_total_tip)
+      pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(pkgdatadir + "listenerphones" + gfext, 20, 16)
+      image = gtk.image_new_from_pixbuf(pixbuf)
+      ihbox.pack_start(image, False, False, 0)
+      image.show()
+      frame = gtk.Frame()
+      ihbox.pack_start(frame, True, True, 0)
+      frame.show()
+      hbox.pack_start(ihbox, True, True, 0)
+      ihbox.show()
+      self.listeners_display = gtk.Label("0")
+      frame.add(self.listeners_display)
+      self.listeners_display.show()
+      vbox.pack_start(hbox, False, False, 0)
+      hbox.show()
+      
+      self.server_type.set_active(0)
+      self.timer = ActionTimer(40, self.stats_commence, self.stats_collate)
+
 class TimeEntry(gtk.HBox):		# A 24-hour-time entry widget with a checkbutton
    def time_valid(self):
       return self.seconds_past_midnight >= 0
@@ -443,7 +935,10 @@ class StreamTab(Tab):
       for text, item in label_item_pairs:
          if text is not None:
             labelbox = gtk.HBox()
-            label = gtk.Label(text)
+            if type(text) == str:
+               label = gtk.Label(text)
+            else:
+               label = text
             sizegroup.add_widget(label)
             labelbox.pack_end(label, False, False)
             label.show()
@@ -467,13 +962,14 @@ class StreamTab(Tab):
       for each in (self.mount_entry, self.login_entry):
          each.set_sensitive(sens)
       self.update_sensitives()
-   def update_sensitives(self):
+   def update_sensitives(self, *params):
       if self.encoder == "off":
          self.update_button.set_sensitive(False)
-      non_shoutcast = bool(self.server_type_dropdown.get_active())
+      mode = self.connection_pane.get_frame_mode() # 0 = none, 1 = icecast2, 2 = shoutcast
       self.recorder_valid_override = False
+      
       if self.encoder == "ogg":
-         self.server_connect.set_sensitive(non_shoutcast or self.server_connect.get_active())
+         self.server_connect.set_sensitive(mode == 1 or self.server_connect.get_active())
          if self.format_page == 0:
             self.update_button.set_sensitive(False)
          elif self.format_page == 1:
@@ -486,11 +982,11 @@ class StreamTab(Tab):
          else:
             print "update_sensitives: unhandled format page"
       elif self.encoder == "mp3":
-         self.server_connect.set_sensitive(True)
+         self.server_connect.set_sensitive(mode != 0 or self.server_connect.get_active())
          if self.format_page == 0:
             self.update_button.set_sensitive(self.mp3_compatibility != "s-rate!")
          elif self.format_page == 1:
-           self.update_button.set_sensitive(False)
+            self.update_button.set_sensitive(False)
          elif self.format_page == 2:
             try:
                self.update_button.set_sensitive(self.file_dialog.get_filename().lower().endswith(".mp3"))
@@ -501,7 +997,8 @@ class StreamTab(Tab):
       elif self.encoder == "off":
          self.test_monitor.set_sensitive(True)
          if self.format_page == 0:
-            sens = bool(self.mp3_compatibility != "s-rate!" and lameenabled)
+            self.recorder_valid_override = sens = bool(self.mp3_compatibility != "s-rate!" and lameenabled)
+            sens = sens and mode
             self.server_connect.set_sensitive(sens)
             self.test_monitor.set_sensitive(sens)
          elif self.format_page == 1:
@@ -512,18 +1009,8 @@ class StreamTab(Tab):
                self.recorder_valid_override = sens = sr <= 65535 or sr % 10 == 0
             elif self.subformat_page == 2:   # Speex
                self.recorder_valid_override = sens = True                   # True always for now
-            self.server_connect.set_sensitive(sens and non_shoutcast or self.server_connect.get_active())
+            self.server_connect.set_sensitive(sens and mode == 1)
             self.test_monitor.set_sensitive(sens)
-         elif self.format_page == 2:
-            filename = self.file_dialog.get_filename()
-            if filename is not None:
-               if filename.lower().endswith(".ogg") and not non_shoutcast:
-                  self.server_connect.set_sensitive(False)
-               else:
-                  self.server_connect.set_sensitive(True)
-            else:
-               self.server_connect.set_sensitive(False)
-               self.test_monitor.set_sensitive(False)
          try:
             record_tabs = self.source_client_gui.recordtabframe.tabs
          except:
@@ -537,10 +1024,7 @@ class StreamTab(Tab):
                self.update_button.set_sensitive(False)
          if self.format_page == 1 and self.encoder == "mp3":
                self.update_button.set_sensitive(False)
-         if self.format_page == 2:
-            filename = self.file_dialog.get_filename()
-            if filename is None or (filename.lower().endswith(".mp3") and self.encoder == "ogg") or (filename.lower().endswith(".ogg") and self.encoder == "mp3"):
-               self.update_button.set_sensitive(False)
+   
    def cb_file_dialog_response(self, widget, response_id):
       self.update_sensitives()
    def cb_format_notebook(self, widget, page, page_num):
@@ -624,45 +1108,38 @@ class StreamTab(Tab):
    def cb_server_connect(self, widget):
       if widget.get_active():
          self.start_stop_encoder(ENCODER_START)
-         self.connection_string = "\n".join((    "stream_source=" + str(self.numeric_id),
-         			  "server_type=" + ("Shoutcast", "Icecast 2") [self.server_type_dropdown.get_active()],
-      				  "host=" + self.host_entry.get_text().strip(),
-                                  "port=" + str(self.port_adj.get_value()),
-      				  "mount=" + self.mount_entry.get_text().strip(),
-                                  "login=" + self.login_entry.get_text().strip(),
-                                  "password=" + self.passwd_entry.get_text().strip(),
-                                  "dj_name=" + self.dj_name_entry.get_text().strip(),
-                                  "listen_url=" + self.listen_url_entry.get_text().strip(),
-                                  "description=" + self.description_entry.get_text().strip(),
-                                  "genre=" + self.genre_entry.get_text().strip(),
-                                  "irc=" + self.irc_entry.get_text().strip(),
-                                  "aim=" + self.aim_entry.get_text().strip(),
-                                  "icq=" + self.icq_entry.get_text().strip(),
-                                  "make_public=" + str(bool(self.make_public.get_active())),
-                                  "command=server_connect\n"))
+         d = self.connection_pane.row_to_dict(0)
+
+         self.connection_string = "\n".join((
+               "stream_source=" + str(self.numeric_id),
+               "server_type=" + ("Icecast 2", "Shoutcast")[d["server_type"]],
+               "host=" + d["host"],
+               "port=%d" % d["port"],
+               "mount=" + d["mount"],
+               "login=" + d["login"],
+               "password=" + d["password"],
+               "dj_name=" + self.dj_name_entry.get_text().strip(),
+               "listen_url=" + self.listen_url_entry.get_text().strip(),
+               "description=" + self.description_entry.get_text().strip(),
+               "genre=" + self.genre_entry.get_text().strip(),
+               "irc=" + self.irc_entry.get_text().strip(),
+               "aim=" + self.aim_entry.get_text().strip(),
+               "icq=" + self.icq_entry.get_text().strip(),
+               "make_public=" + str(bool(self.make_public.get_active())),
+               "command=server_connect\n"))
          self.send(self.connection_string)
-         self.is_shoutcast = self.server_type_dropdown.get_active() == 0
+         self.is_shoutcast = d["server_type"] == 1
          if self.receive() == "failed":
             self.server_connect.set_active(False)
             self.connection_string = None
          else:
-            if self.is_shoutcast:
-               self.stats_url = "http://%s:%d/admin.cgi?mode=viewxml" % (self.host_entry.get_text(), self.port_adj.get_value())
-               auth = urllib2.HTTPBasicAuthHandler()
-               auth.add_password(realm="Shoutcast Server", uri="https://%s:%d" % (self.host_entry.get_text(), self.port_adj.get_value()), user="admin", passwd=self.passwd_entry.get_text())
-            else:
-               self.stats_url = "http://%s:%d/admin/listclients?mount=%s" % (self.host_entry.get_text(), self.port_adj.get_value(), self.mount_entry.get_text())
-               auth_url = "https" + self.stats_url[4:]
-               auth = urllib2.HTTPBasicAuthHandler()
-               auth.add_password(realm="Icecast2 Server", uri=auth_url, user=self.login_entry.get_text(), passwd=self.passwd_entry.get_text())
-            opener = urllib2.build_opener(auth)
-            urllib2.install_opener(opener)
+            self.connection_pane.streaming_set(True)
       else:
          self.send("command=server_disconnect\n")
          self.receive()
          self.start_stop_encoder(ENCODER_STOP)
          self.connection_string = None
-         self.stats_url = None
+         self.connection_pane.streaming_set(False)
    def cb_test_monitor(self, widget):
       if widget.get_active():
          self.start_stop_encoder(ENCODER_START)
@@ -763,12 +1240,11 @@ class StreamTab(Tab):
       self.scg = scg
       self.show_indicator("clear")
       self.tab_type = "streamer"
+      set_tip = self.scg.parent.tooltips.set_tip
       self.encoder = "off"			# can also be set to "mp3" or "ogg" depending on what is encoded
       self.encoder_on_count = 0			# when this counter hits zero the encoder is turned off
       self.format_page = 0			# the current format page
       self.subformat_page = 0                   # the Ogg sub-format
-      self.stats_url = None
-      self.currentlisteners = 0
       Tab.set_spacing(self, 10)
       scrolled = gtk.ScrolledWindow()
       Tab.add(self, scrolled)
@@ -781,60 +1257,13 @@ class StreamTab(Tab):
       scrolled_vbox.set_spacing(10)
       scrolled.add_with_viewport(scrolled_vbox)
       scrolled_vbox.show()
-      frame = CategoryFrame(ln.connection)		# Connection Frame
-      scrolled_vbox.pack_start(frame, False, False, 0)
-      frame.show()
-      sizegroup = gtk.SizeGroup(gtk.SIZE_GROUP_VERTICAL)
       
-      ls = gtk.ListStore(str)
-      self.server_type_dropdown = gtk.ComboBox(ls)
-      cell = gtk.CellRendererText()
-      self.server_type_dropdown.pack_start(cell, True)
-      self.server_type_dropdown.add_attribute(cell, 'text', 0)
-      self.server_type_dropdown.set_cell_data_func(cell, self.server_type_cell_data_func)
-      self.server_type_dropdown.append_text(ln.server_type_shoutcast)
-      self.server_type_dropdown.append_text(ln.server_type_icecast2)
-      self.server_type_dropdown.set_active(1)
-      self.server_type_dropdown.connect("changed", self.cb_servertype)
-      set_tip = scg.parent.tooltips.set_tip
-      set_tip(self.server_type_dropdown, ln.server_type_tip)
-      self.host_entry = gtk.Entry()
-      self.host_entry.set_text("localhost")
-      set_tip(self.host_entry, ln.hostname_tip)
-      self.port_adj = gtk.Adjustment(8000, 0, 65535, 1, 1)
-      self.port_spinbox = gtk.SpinButton(self.port_adj, 0.4, 0)
-      set_tip(self.port_spinbox, ln.port_tip)
-      self.mount_entry = gtk.Entry()
-      self.mount_entry.set_text("/listen")
-      set_tip(self.mount_entry, ln.mount_point_tip)
-      self.login_entry = gtk.Entry()
-      self.login_entry.set_text("source")
-      set_tip(self.login_entry, ln.login_tip)
-      self.passwd_entry = gtk.Entry()
-      self.passwd_entry.set_text("hackme")
-      self.passwd_entry.set_visibility(False)
-      set_tip(self.passwd_entry, ln.password_tip)
-      connectionpanesizegroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
-      left_pane = self.label_item_layout( ((ln.server_type, self.server_type_dropdown),
-      				           (ln.server_host, self.host_entry),
-                                           (ln.server_port, self.port_spinbox)), sizegroup)
-      connectionpanesizegroup.add_widget(left_pane)
-      right_pane = self.label_item_layout(((ln.server_mount, self.mount_entry),
-      				           (ln.server_login, self.login_entry),
-                                           (ln.server_passwd, self.passwd_entry)), sizegroup)
-      connectionpanesizegroup.add_widget(right_pane)
-      hbox = gtk.HBox()
-      hbox.set_border_width(10)
-      hbox.set_spacing(15)
-      hbox.add(left_pane)
-      left_pane.show()
-      divider = gtk.VSeparator()
-      hbox.pack_start(divider, False, False, 0)
-      divider.show()
-      hbox.add(right_pane)
-      right_pane.show()
-      frame.add(hbox)
-      hbox.show()
+      self.connection_pane = ConnectionPane(set_tip)
+      self.connection_pane.liststore.connect("row-deleted", self.update_sensitives)
+      self.connection_pane.liststore.connect("row-inserted", self.update_sensitives)
+      scrolled_vbox.pack_start(self.connection_pane, False, False, 0)
+      self.connection_pane.show()
+       
       frame = CategoryFrame(ln.format)		# Format Frame
       scrolled_vbox.pack_start(frame, False, False, 0)
       frame.show()
@@ -847,6 +1276,7 @@ class StreamTab(Tab):
       hbox.set_spacing(16)
       vbox.add(hbox)
       hbox.show()
+      sizegroup = gtk.SizeGroup(gtk.SIZE_GROUP_VERTICAL)
       self.stream_resample_frame = self.ResampleFrame(self, sizegroup)	# stream resample frame
       hbox.add(self.stream_resample_frame)
       self.stream_resample_frame.show()
@@ -1034,39 +1464,6 @@ class StreamTab(Tab):
          self.oggspeextab.add(label)
          label.show()
       
-      # File tab contents
-      self.filetab = self.make_notebook_tab(self.format_notebook, "File")	# File tab
-      filefilter = gtk.FileFilter()
-      filefilter.add_pattern("*.[mM]p3")
-      filefilter.add_pattern("*.MP3")
-      filefilter.add_pattern("*.[oO]gg")
-      filefilter.add_pattern("*.OGG")
-      self.file_dialog = gtk.FileChooserDialog("", None, gtk.FILE_CHOOSER_ACTION_OPEN, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OPEN, gtk.RESPONSE_ACCEPT))
-      self.file_dialog.set_filter(filefilter)
-      fcb = gtk.FileChooserButton(self.file_dialog)
-      self.file_dialog.set_title(ln.stream_file_chooser_title)
-      self.file_dialog.set_current_folder(os.environ["HOME"])
-      self.file_dialog.connect("response", self.cb_file_dialog_response)
-      self.file_offset_checkbutton = gtk.CheckButton("Start offset (s)")
-      self.file_offset_adj = gtk.Adjustment(0, 0, 30000, 1, 10, 0)
-      self.file_offset_spinbutton = gtk.SpinButton(self.file_offset_adj)
-      self.textbuffer = gtk.TextBuffer()
-      self.textbuffer.set_text("0:00:00 / 0:00:00\nFinish: 00:00:00\n0Kb/s 0Hz")
-      self.file_textview = gtk.TextView(self.textbuffer)
-      self.file_textview.set_cursor_visible(False)
-      self.file_textview.set_editable(False)
-      frame = gtk.Frame()
-      frame.set_shadow_type(gtk.SHADOW_IN)
-      frame.add(self.file_textview)
-      self.file_textview.show()
-      file_pane = self.item_item_layout(((None, fcb), (self.file_offset_checkbutton, self.file_offset_spinbutton)), sizegroup)
-      file_pane.set_border_width(10)
-      file_pane.add(frame)
-      frame.show()
-      self.filetab.add(file_pane)
-      file_pane.show()
-      self.filetab.hide()		# TODO: add this feature
-      
       format_control_bar = gtk.HBox()				# Button box in Format frame
       format_control_sizegroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
       format_control_bar.set_spacing(10)
@@ -1187,12 +1584,9 @@ class StreamTab(Tab):
       Tab.pack_start(self, hbox, False, False, 0)
       hbox.show()
       self.stream_resample_frame.resample_no_resample.emit("clicked")	# bogus signal to update mp3 pane
-      self.objects = {  "server_type" : (self.server_type_dropdown, "active"),
-      			"hostname" : (self.host_entry, "text"),
-                        "portnum" : (self.port_adj, "value"),
-                        "mountpoint" : (self.mount_entry, "text"),
-                        "source_login" : (self.login_entry, "text"),
-                        "source_password" : (self.passwd_entry, "password"),
+      self.objects = {  "connections" : (self.connection_pane, ("loader", "saver")),
+                        "stats_never" : (self.connection_pane.stats_never, "active"),
+                        "stats_always": (self.connection_pane.stats_always, "active"),
                         "rs_use_jack" : (self.stream_resample_frame.resample_no_resample, "active"),
                         "rs_use_std" : (self.stream_resample_frame.resample_standard, "active"),
                         "rs_use_custom_rate" : (self.stream_resample_frame.resample_custom, "active"),
@@ -1222,9 +1616,6 @@ class StreamTab(Tab):
                         "speex_metadata": (self.speex_metadata, "active"), 
                         "speex_quality": (self.speex_quality, "active"),
                         "speex_complexity": (self.speex_complexity, "active"),
-                        "file_source" : (self.file_dialog, "filename"),
-                        "file_use_offset" : (self.file_offset_checkbutton, "active"),
-                        "file_offset" : (self.file_offset_adj, "value"),
                         "dj_name" : (self.dj_name_entry, "text"),
                         "listen_url" : (self.listen_url_entry, "text"),
                         "description" : (self.description_entry, "text"),
@@ -1434,68 +1825,13 @@ class TabFrame(ModuleFrame):
          scg.parent.tooltips.set_tip(labelbox, tab_tip_text)
 
 class SourceClientGui:
-   server_errmsg = "idjc: the server module appears to have crashed -- possible segfault"
+   server_errmsg = "idjc: idjcsourceclient appears to have crashed -- possible segfault"
    unexpected_reply = "unexpected reply from idjcsourceclient"
-   def get_stats(self, streamtab):
-      """recover the listener stats from the server
-      note that this runs asynchronously"""
-      class BadXML(ValueError):
-         pass
-      
-      req = urllib2.Request(streamtab.stats_url)
-      req.add_header("User-agent", "Mozilla/5.0")
-      try:
-         f = urllib2.urlopen(req)
-         xmlfeed = f.read()
-      except:
-         print "failed to get server stats for tab", streamtab.numeric_id + 1
-         return
-      f.close()
-      try:
-         dom = mdom.parseString(xmlfeed)
-      except:
-         print "failed to parse server stats for tab", streamtab.numeric_id + 1
-         return
-      
-      try:
-         if streamtab.is_shoutcast:
-            if dom.documentElement.tagName == u'SHOUTCASTSERVER':
-               shoutcastserver = dom.documentElement
-            else:
-               raise BadXML
-            currentlisteners = shoutcastserver.getElementsByTagName('CURRENTLISTENERS')
-            try:
-               streamtab.currentlisteners = int(currentlisteners[0].firstChild.wholeText.strip())
-            except:
-               raise BadXML
-         else:
-            if dom.documentElement.tagName == u'icestats':
-               icestats = dom.documentElement
-            else:
-               raise BadXML
-            sources = icestats.getElementsByTagName('source')
-            for source in sources:
-               mount = source.getAttribute('mount')
-               if streamtab.stats_url.endswith(mount):
-                  listeners = source.getElementsByTagName('Listeners')
-                  try:
-                     streamtab.currentlisteners = int(listeners[0].firstChild.wholeText.strip())
-                     break
-                  except:
-                     raise BadXML
-            else:
-               raise BadXML
-      except BadXML:
-         print "Unexpected data in server stats XML file"
-         streamtab.currentlisteners = 0
-      dom.unlink()
-      print "server", streamtab.numeric_id + 1, "has", streamtab.currentlisteners, "listeners"
 
+   @threadslock
    def monitor(self):
-      self.monitor_count += 1
       self.led_alternate = not self.led_alternate
       streaming = recording = False
-      gtk.gdk.threads_enter()
       # update the recorder LED indicators 
       for rectab in self.recordtabframe.tabs:
          self.send("dev_type=recorder\ntab_id=%d\ncommand=get_report\n" % rectab.numeric_id)
@@ -1509,16 +1845,15 @@ class SourceClientGui:
                rectab.time_indicator.set_value(int(recorded_seconds))
                if recorder_state != "0":
                   recording = True
-      listeners = 0
+      update_listeners = False
+      l_count = 0
       for streamtab in self.streamtabframe.tabs:
-         monitor_phase = self.monitor_count & 63
-         if monitor_phase == 0:
-            if streamtab.stats_url is not None:
-               gobject.idle_add(self.get_stats, streamtab)
-            else:
-               streamtab.currentlisteners = 0
-         if monitor_phase == 63:
-            listeners += streamtab.currentlisteners
+         cp = streamtab.connection_pane
+         cp.timer.run()   # obtain connection stats
+         if cp.timer.n == 0:
+            update_listeners = True
+            l_count += cp.listeners
+         
          self.send("dev_type=streamer\ntab_id=%d\ncommand=get_report\n" % streamtab.numeric_id)
          reply = self.receive()
          if reply != "failed":
@@ -1557,7 +1892,7 @@ class SourceClientGui:
                print "sourceclientgui.monitor: bad reply for streamer data:", reply
          else:
             print "sourceclientgui.monitor: failed to get a report from the streamer"
-	 # the connection start/stop timers are processed here
+         # the connection start/stop timers are processed here
          if streamtab.start_timer.get_active():
             diff = time.localtime(time.time() - streamtab.start_timer.get_seconds_past_midnight())
             # check hours, minutes, seconds for midnightness
@@ -1589,9 +1924,8 @@ class SourceClientGui:
             file.close()
          except IOError:
             print "Problem writing the timer file to disk"
-      if monitor_phase == 63:
-         self.parent.listener_indicator.set_text(str(listeners))
-      gtk.gdk.threads_leave()
+      if update_listeners:
+         self.parent.listener_indicator.set_text(str(l_count))
       return True
    def stop_streaming_all(self):
       for streamtab in self.streamtabframe.tabs:
@@ -1612,16 +1946,16 @@ class SourceClientGui:
          self.parent.destroy()
       else:
          self.parent.destroy_hard()
+   
    def receive(self):
       if not self.comms_reply_pending:
          print "sourceclientgui.receive: nothing to receive"
-         time.sleep(0.5)
-         return ""
+         return "failed"
       while 1:
          try:
             reply = self.comms_rply.readline()
          except:
-            return ""
+            return "failed"
          if reply.startswith("idjcsc: "):
             reply = reply[8:-1]
             if reply == "succeeded" or reply == "failed":
@@ -1629,9 +1963,9 @@ class SourceClientGui:
             return reply
          else:
             print self.unexpected_reply, reply
-            time.sleep(0.5)
          if reply == "" or reply == "Segmentation Fault\n":
-            return ""
+            self.comms_reply_pending = False
+            return "failed"
    def send(self, string_to_send):
       while self.comms_reply_pending:	# dump unused replies from previous send
          self.receive()
@@ -1646,12 +1980,18 @@ class SourceClientGui:
          self.source_client_crash_count += 1
          self.source_client_close()
          print self.server_errmsg
-         time.sleep(1.0)
+         time.sleep(0.5)
          if self.source_client_crash_count == 3:
-            print "source client module has crashed too many times - exiting\n"
+            print "idjcsourceclient is crashing repeatedly - exiting\n"
             self.app_exit()
          self.source_client_open()
-         self.source_client_crash_count -= 1
+         self.comms_reply_pending = False
+      else:
+         if self.source_client_crash_count:
+            if time.time() > self.uptime + 15.0:
+               self.source_client_crash_count -= 1
+               self.uptime = time.time()
+         
    def new_metadata(self, artist, title, artist_title):
       if self.parent.prefs_window.mp3_utf8.get_active():
          artist_title_mp3 = artist_title.encode("utf-8", "replace")
@@ -1711,7 +2051,10 @@ class SourceClientGui:
             streamtab.stream_resample_frame.resample_dummy_object.clicked()
             # update the stream tabs with the current jack sample rate
       except (NameError, AttributeError):
-         pass	# stream tabs will not have been created yet and no further action is needed
+       	 # If this is the initial call the stream tabs will not exist yet.
+         pass
+      self.uptime = time.time()
+
    def source_client_close(self):
       try:
          self.comms_cmd
@@ -1736,7 +2079,9 @@ class SourceClientGui:
             for tab in tabframe.tabs:
                file.write("".join(("[", tab.tab_type, " ", str(tab.numeric_id), "]\n")))
                for lvalue, (widget, method) in tab.objects.iteritems():
-                  if method == "active":
+                  if type(method) == tuple:
+                     rvalue = widget.__getattribute__(method[1])()
+                  elif method == "active":
                      rvalue = str(int(widget.get_active()))
                   elif method == "text":
                      rvalue = widget.get_text()
@@ -1799,7 +2144,7 @@ class SourceClientGui:
             else:
                if tabframe is not None:
                   try:
-                     lvalue, rvalue = line.split("=")
+                     lvalue, rvalue = line.split("=", 1)
                   except:
                      print "not a valid key, value pair:", line, "in serverdata file"
                   else:
@@ -1819,7 +2164,9 @@ class SourceClientGui:
                               float_rvalue = float(rvalue)
                            except:
                               float_rvalue = None
-                           if method == "active":
+                           if type(method) == tuple:
+                              widget.__getattribute__(method[0])(rvalue)
+                           elif method == "active":
                               if int_rvalue is not None:
                                  widget.set_active(int_rvalue)
                            elif method == "value":
@@ -1910,7 +2257,5 @@ class SourceClientGui:
 
       self.autoshutdown_dialog = error_notification_dialog(self.dialog_group, self.parent.window_group, ln.disconnected, ln.autoshutdown)
       
-      self.monitor_count = 0
-      
       self.monitor_source_id = gobject.timeout_add(250, self.monitor)
       self.window.realize()   # prevent rendering bug and problems with sizegroups on certain widgets
diff --git a/ltmain.sh b/ltmain.sh
new file mode 100755
index 0000000..b36c4ad
--- /dev/null
+++ b/ltmain.sh
@@ -0,0 +1,8406 @@
+# Generated from ltmain.m4sh.
+
+# ltmain.sh (GNU libtool) 2.2.6
+# Written by Gordon Matzigkeit <gord at gnu.ai.mit.edu>, 1996
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# GNU Libtool is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html,
+# or obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# Usage: $progname [OPTION]... [MODE-ARG]...
+#
+# Provide generalized library-building support services.
+#
+#     --config             show all configuration variables
+#     --debug              enable verbose shell tracing
+# -n, --dry-run            display commands without modifying any files
+#     --features           display basic configuration information and exit
+#     --mode=MODE          use operation mode MODE
+#     --preserve-dup-deps  don't remove duplicate dependency libraries
+#     --quiet, --silent    don't print informational messages
+#     --tag=TAG            use configuration variables from tag TAG
+# -v, --verbose            print informational messages (default)
+#     --version            print version information
+# -h, --help               print short or long help message
+#
+# MODE must be one of the following:
+#
+#       clean              remove files from the build directory
+#       compile            compile a source file into a libtool object
+#       execute            automatically set library path, then run a program
+#       finish             complete the installation of libtool libraries
+#       install            install libraries or executables
+#       link               create a library or an executable
+#       uninstall          remove libraries from an installed directory
+#
+# MODE-ARGS vary depending on the MODE.
+# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
+#
+# When reporting a bug, please describe a test case to reproduce it and
+# include the following information:
+#
+#       host-triplet:	$host
+#       shell:		$SHELL
+#       compiler:		$LTCC
+#       compiler flags:		$LTCFLAGS
+#       linker:		$LD (gnu? $with_gnu_ld)
+#       $progname:		(GNU libtool) 2.2.6
+#       automake:		$automake_version
+#       autoconf:		$autoconf_version
+#
+# Report bugs to <bug-libtool at gnu.org>.
+
+PROGRAM=ltmain.sh
+PACKAGE=libtool
+VERSION=2.2.6
+TIMESTAMP=""
+package_revision=1.3012
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# NLS nuisances: We save the old values to restore during execute mode.
+# Only set LANG and LC_ALL to C if already set.
+# These must not be set unconditionally because not all systems understand
+# e.g. LANG=C (notably SCO).
+lt_user_locale=
+lt_safe_locale=
+for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+do
+  eval "if test \"\${$lt_var+set}\" = set; then
+          save_$lt_var=\$$lt_var
+          $lt_var=C
+	  export $lt_var
+	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
+	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
+	fi"
+done
+
+$lt_unset CDPATH
+
+
+
+
+
+: ${CP="cp -f"}
+: ${ECHO="echo"}
+: ${EGREP="/usr/bin/grep -E"}
+: ${FGREP="/usr/bin/grep -F"}
+: ${GREP="/usr/bin/grep"}
+: ${LN_S="ln -s"}
+: ${MAKE="make"}
+: ${MKDIR="mkdir"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+: ${SED="/opt/local/bin/gsed"}
+: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
+: ${Xsed="$SED -e 1s/^X//"}
+
+# Global variables:
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
+EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
+
+exit_status=$EXIT_SUCCESS
+
+# Make sure IFS has a sensible default
+lt_nl='
+'
+IFS=" 	$lt_nl"
+
+dirname="s,/[^/]*$,,"
+basename="s,^.*/,,"
+
+# func_dirname_and_basename file append nondir_replacement
+# perform func_basename and func_dirname in a single function
+# call:
+#   dirname:  Compute the dirname of FILE.  If nonempty,
+#             add APPEND to the result, otherwise set result
+#             to NONDIR_REPLACEMENT.
+#             value returned in "$func_dirname_result"
+#   basename: Compute filename of FILE.
+#             value retuned in "$func_basename_result"
+# Implementation must be kept synchronized with func_dirname
+# and func_basename. For efficiency, we do not delegate to
+# those functions but instead duplicate the functionality here.
+func_dirname_and_basename ()
+{
+  # Extract subdirectory from the argument.
+  func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
+  if test "X$func_dirname_result" = "X${1}"; then
+    func_dirname_result="${3}"
+  else
+    func_dirname_result="$func_dirname_result${2}"
+  fi
+  func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
+}
+
+# Generated shell functions inserted here.
+
+# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
+# is ksh but when the shell is invoked as "sh" and the current value of
+# the _XPG environment variable is not equal to 1 (one), the special
+# positional parameter $0, within a function call, is the name of the
+# function.
+progpath="$0"
+
+# The name of this program:
+# In the unlikely event $progname began with a '-', it would play havoc with
+# func_echo (imagine progname=-n), so we prepend ./ in that case:
+func_dirname_and_basename "$progpath"
+progname=$func_basename_result
+case $progname in
+  -*) progname=./$progname ;;
+esac
+
+# Make sure we have an absolute path for reexecution:
+case $progpath in
+  [\\/]*|[A-Za-z]:\\*) ;;
+  *[\\/]*)
+     progdir=$func_dirname_result
+     progdir=`cd "$progdir" && pwd`
+     progpath="$progdir/$progname"
+     ;;
+  *)
+     save_IFS="$IFS"
+     IFS=:
+     for progdir in $PATH; do
+       IFS="$save_IFS"
+       test -x "$progdir/$progname" && break
+     done
+     IFS="$save_IFS"
+     test -n "$progdir" || progdir=`pwd`
+     progpath="$progdir/$progname"
+     ;;
+esac
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed="${SED}"' -e 1s/^X//'
+sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\(["`\\]\)/\\\1/g'
+
+# Re-`\' parameter expansions in output of double_quote_subst that were
+# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
+# in input to double_quote_subst, that '$' was protected from expansion.
+# Since each input `\' is now two `\'s, look for any number of runs of
+# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
+bs='\\'
+bs2='\\\\'
+bs4='\\\\\\\\'
+dollar='\$'
+sed_double_backslash="\
+  s/$bs4/&\\
+/g
+  s/^$bs2$dollar/$bs&/
+  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
+  s/\n//g"
+
+# Standard options:
+opt_dry_run=false
+opt_help=false
+opt_quiet=false
+opt_verbose=false
+opt_warning=:
+
+# func_echo arg...
+# Echo program name prefixed message, along with the current mode
+# name if it has been set yet.
+func_echo ()
+{
+    $ECHO "$progname${mode+: }$mode: $*"
+}
+
+# func_verbose arg...
+# Echo program name prefixed message in verbose mode only.
+func_verbose ()
+{
+    $opt_verbose && func_echo ${1+"$@"}
+
+    # A bug in bash halts the script if the last line of a function
+    # fails when set -e is in force, so we need another command to
+    # work around that:
+    :
+}
+
+# func_error arg...
+# Echo program name prefixed message to standard error.
+func_error ()
+{
+    $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
+}
+
+# func_warning arg...
+# Echo program name prefixed warning message to standard error.
+func_warning ()
+{
+    $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
+
+    # bash bug again:
+    :
+}
+
+# func_fatal_error arg...
+# Echo program name prefixed message to standard error, and exit.
+func_fatal_error ()
+{
+    func_error ${1+"$@"}
+    exit $EXIT_FAILURE
+}
+
+# func_fatal_help arg...
+# Echo program name prefixed message to standard error, followed by
+# a help hint, and exit.
+func_fatal_help ()
+{
+    func_error ${1+"$@"}
+    func_fatal_error "$help"
+}
+help="Try \`$progname --help' for more information."  ## default
+
+
+# func_grep expression filename
+# Check whether EXPRESSION matches any line of FILENAME, without output.
+func_grep ()
+{
+    $GREP "$1" "$2" >/dev/null 2>&1
+}
+
+
+# func_mkdir_p directory-path
+# Make sure the entire path to DIRECTORY-PATH is available.
+func_mkdir_p ()
+{
+    my_directory_path="$1"
+    my_dir_list=
+
+    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
+
+      # Protect directory names starting with `-'
+      case $my_directory_path in
+        -*) my_directory_path="./$my_directory_path" ;;
+      esac
+
+      # While some portion of DIR does not yet exist...
+      while test ! -d "$my_directory_path"; do
+        # ...make a list in topmost first order.  Use a colon delimited
+	# list incase some portion of path contains whitespace.
+        my_dir_list="$my_directory_path:$my_dir_list"
+
+        # If the last portion added has no slash in it, the list is done
+        case $my_directory_path in */*) ;; *) break ;; esac
+
+        # ...otherwise throw away the child directory and loop
+        my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"`
+      done
+      my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'`
+
+      save_mkdir_p_IFS="$IFS"; IFS=':'
+      for my_dir in $my_dir_list; do
+	IFS="$save_mkdir_p_IFS"
+        # mkdir can fail with a `File exist' error if two processes
+        # try to create one of the directories concurrently.  Don't
+        # stop in that case!
+        $MKDIR "$my_dir" 2>/dev/null || :
+      done
+      IFS="$save_mkdir_p_IFS"
+
+      # Bail out if we (or some other process) failed to create a directory.
+      test -d "$my_directory_path" || \
+        func_fatal_error "Failed to create \`$1'"
+    fi
+}
+
+
+# func_mktempdir [string]
+# Make a temporary directory that won't clash with other running
+# libtool processes, and avoids race conditions if possible.  If
+# given, STRING is the basename for that directory.
+func_mktempdir ()
+{
+    my_template="${TMPDIR-/tmp}/${1-$progname}"
+
+    if test "$opt_dry_run" = ":"; then
+      # Return a directory name, but don't create it in dry-run mode
+      my_tmpdir="${my_template}-$$"
+    else
+
+      # If mktemp works, use that first and foremost
+      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
+
+      if test ! -d "$my_tmpdir"; then
+        # Failing that, at least try and use $RANDOM to avoid a race
+        my_tmpdir="${my_template}-${RANDOM-0}$$"
+
+        save_mktempdir_umask=`umask`
+        umask 0077
+        $MKDIR "$my_tmpdir"
+        umask $save_mktempdir_umask
+      fi
+
+      # If we're not in dry-run mode, bomb out on failure
+      test -d "$my_tmpdir" || \
+        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
+    fi
+
+    $ECHO "X$my_tmpdir" | $Xsed
+}
+
+
+# func_quote_for_eval arg
+# Aesthetically quote ARG to be evaled later.
+# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
+# is double-quoted, suitable for a subsequent eval, whereas
+# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
+# which are still active within double quotes backslashified.
+func_quote_for_eval ()
+{
+    case $1 in
+      *[\\\`\"\$]*)
+	func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;;
+      *)
+        func_quote_for_eval_unquoted_result="$1" ;;
+    esac
+
+    case $func_quote_for_eval_unquoted_result in
+      # Double-quote args containing shell metacharacters to delay
+      # word splitting, command substitution and and variable
+      # expansion for a subsequent eval.
+      # Many Bourne shells cannot handle close brackets correctly
+      # in scan sets, so we specify it separately.
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
+        ;;
+      *)
+        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
+    esac
+}
+
+
+# func_quote_for_expand arg
+# Aesthetically quote ARG to be evaled later; same as above,
+# but do not quote variable references.
+func_quote_for_expand ()
+{
+    case $1 in
+      *[\\\`\"]*)
+	my_arg=`$ECHO "X$1" | $Xsed \
+	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
+      *)
+        my_arg="$1" ;;
+    esac
+
+    case $my_arg in
+      # Double-quote args containing shell metacharacters to delay
+      # word splitting and command substitution for a subsequent eval.
+      # Many Bourne shells cannot handle close brackets correctly
+      # in scan sets, so we specify it separately.
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+        my_arg="\"$my_arg\""
+        ;;
+    esac
+
+    func_quote_for_expand_result="$my_arg"
+}
+
+
+# func_show_eval cmd [fail_exp]
+# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
+# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.
+func_show_eval ()
+{
+    my_cmd="$1"
+    my_fail_exp="${2-:}"
+
+    ${opt_silent-false} || {
+      func_quote_for_expand "$my_cmd"
+      eval "func_echo $func_quote_for_expand_result"
+    }
+
+    if ${opt_dry_run-false}; then :; else
+      eval "$my_cmd"
+      my_status=$?
+      if test "$my_status" -eq 0; then :; else
+	eval "(exit $my_status); $my_fail_exp"
+      fi
+    fi
+}
+
+
+# func_show_eval_locale cmd [fail_exp]
+# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
+# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.  Use the saved locale for evaluation.
+func_show_eval_locale ()
+{
+    my_cmd="$1"
+    my_fail_exp="${2-:}"
+
+    ${opt_silent-false} || {
+      func_quote_for_expand "$my_cmd"
+      eval "func_echo $func_quote_for_expand_result"
+    }
+
+    if ${opt_dry_run-false}; then :; else
+      eval "$lt_user_locale
+	    $my_cmd"
+      my_status=$?
+      eval "$lt_safe_locale"
+      if test "$my_status" -eq 0; then :; else
+	eval "(exit $my_status); $my_fail_exp"
+      fi
+    fi
+}
+
+
+
+
+
+# func_version
+# Echo version message to standard output and exit.
+func_version ()
+{
+    $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / {
+        s/^# //
+	s/^# *$//
+        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
+        p
+     }' < "$progpath"
+     exit $?
+}
+
+# func_usage
+# Echo short help message to standard output and exit.
+func_usage ()
+{
+    $SED -n '/^# Usage:/,/# -h/ {
+        s/^# //
+	s/^# *$//
+	s/\$progname/'$progname'/
+	p
+    }' < "$progpath"
+    $ECHO
+    $ECHO "run \`$progname --help | more' for full usage"
+    exit $?
+}
+
+# func_help
+# Echo long help message to standard output and exit.
+func_help ()
+{
+    $SED -n '/^# Usage:/,/# Report bugs to/ {
+        s/^# //
+	s/^# *$//
+	s*\$progname*'$progname'*
+	s*\$host*'"$host"'*
+	s*\$SHELL*'"$SHELL"'*
+	s*\$LTCC*'"$LTCC"'*
+	s*\$LTCFLAGS*'"$LTCFLAGS"'*
+	s*\$LD*'"$LD"'*
+	s/\$with_gnu_ld/'"$with_gnu_ld"'/
+	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
+	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
+	p
+     }' < "$progpath"
+    exit $?
+}
+
+# func_missing_arg argname
+# Echo program name prefixed message to standard error and set global
+# exit_cmd.
+func_missing_arg ()
+{
+    func_error "missing argument for $1"
+    exit_cmd=exit
+}
+
+exit_cmd=:
+
+
+
+
+
+# Check that we have a working $ECHO.
+if test "X$1" = X--no-reexec; then
+  # Discard the --no-reexec flag, and continue.
+  shift
+elif test "X$1" = X--fallback-echo; then
+  # Avoid inline document here, it may be left over
+  :
+elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
+  # Yippee, $ECHO works!
+  :
+else
+  # Restart under the correct shell, and then maybe $ECHO will work.
+  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
+fi
+
+if test "X$1" = X--fallback-echo; then
+  # used as fallback echo
+  shift
+  cat <<EOF
+$*
+EOF
+  exit $EXIT_SUCCESS
+fi
+
+magic="%%%MAGIC variable%%%"
+magic_exe="%%%MAGIC EXE variable%%%"
+
+# Global variables.
+# $mode is unset
+nonopt=
+execute_dlfiles=
+preserve_args=
+lo2o="s/\\.lo\$/.${objext}/"
+o2lo="s/\\.${objext}\$/.lo/"
+extracted_archives=
+extracted_serial=0
+
+opt_dry_run=false
+opt_duplicate_deps=false
+opt_silent=false
+opt_debug=:
+
+# If this variable is set in any of the actions, the command in it
+# will be execed at the end.  This prevents here-documents from being
+# left over by shells.
+exec_cmd=
+
+# func_fatal_configuration arg...
+# Echo program name prefixed message to standard error, followed by
+# a configuration failure hint, and exit.
+func_fatal_configuration ()
+{
+    func_error ${1+"$@"}
+    func_error "See the $PACKAGE documentation for more information."
+    func_fatal_error "Fatal configuration error."
+}
+
+
+# func_config
+# Display the configuration for all the tags in this script.
+func_config ()
+{
+    re_begincf='^# ### BEGIN LIBTOOL'
+    re_endcf='^# ### END LIBTOOL'
+
+    # Default configuration.
+    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
+
+    # Now print the configurations for the tags.
+    for tagname in $taglist; do
+      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
+    done
+
+    exit $?
+}
+
+# func_features
+# Display the features supported by this script.
+func_features ()
+{
+    $ECHO "host: $host"
+    if test "$build_libtool_libs" = yes; then
+      $ECHO "enable shared libraries"
+    else
+      $ECHO "disable shared libraries"
+    fi
+    if test "$build_old_libs" = yes; then
+      $ECHO "enable static libraries"
+    else
+      $ECHO "disable static libraries"
+    fi
+
+    exit $?
+}
+
+# func_enable_tag tagname
+# Verify that TAGNAME is valid, and either flag an error and exit, or
+# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
+# variable here.
+func_enable_tag ()
+{
+  # Global variable:
+  tagname="$1"
+
+  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
+  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
+  sed_extractcf="/$re_begincf/,/$re_endcf/p"
+
+  # Validate tagname.
+  case $tagname in
+    *[!-_A-Za-z0-9,/]*)
+      func_fatal_error "invalid tag name: $tagname"
+      ;;
+  esac
+
+  # Don't test for the "default" C tag, as we know it's
+  # there but not specially marked.
+  case $tagname in
+    CC) ;;
+    *)
+      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
+	taglist="$taglist $tagname"
+
+	# Evaluate the configuration.  Be careful to quote the path
+	# and the sed script, to avoid splitting on whitespace, but
+	# also don't use non-portable quotes within backquotes within
+	# quotes we have to do it in 2 steps:
+	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
+	eval "$extractedcf"
+      else
+	func_error "ignoring unknown tag $tagname"
+      fi
+      ;;
+  esac
+}
+
+# Parse options once, thoroughly.  This comes as soon as possible in
+# the script to make things like `libtool --version' happen quickly.
+{
+
+  # Shorthand for --mode=foo, only valid as the first argument
+  case $1 in
+  clean|clea|cle|cl)
+    shift; set dummy --mode clean ${1+"$@"}; shift
+    ;;
+  compile|compil|compi|comp|com|co|c)
+    shift; set dummy --mode compile ${1+"$@"}; shift
+    ;;
+  execute|execut|execu|exec|exe|ex|e)
+    shift; set dummy --mode execute ${1+"$@"}; shift
+    ;;
+  finish|finis|fini|fin|fi|f)
+    shift; set dummy --mode finish ${1+"$@"}; shift
+    ;;
+  install|instal|insta|inst|ins|in|i)
+    shift; set dummy --mode install ${1+"$@"}; shift
+    ;;
+  link|lin|li|l)
+    shift; set dummy --mode link ${1+"$@"}; shift
+    ;;
+  uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
+    shift; set dummy --mode uninstall ${1+"$@"}; shift
+    ;;
+  esac
+
+  # Parse non-mode specific arguments:
+  while test "$#" -gt 0; do
+    opt="$1"
+    shift
+
+    case $opt in
+      --config)		func_config					;;
+
+      --debug)		preserve_args="$preserve_args $opt"
+			func_echo "enabling shell trace mode"
+			opt_debug='set -x'
+			$opt_debug
+			;;
+
+      -dlopen)		test "$#" -eq 0 && func_missing_arg "$opt" && break
+			execute_dlfiles="$execute_dlfiles $1"
+			shift
+			;;
+
+      --dry-run | -n)	opt_dry_run=:					;;
+      --features)       func_features					;;
+      --finish)		mode="finish"					;;
+
+      --mode)		test "$#" -eq 0 && func_missing_arg "$opt" && break
+			case $1 in
+			  # Valid mode arguments:
+			  clean)	;;
+			  compile)	;;
+			  execute)	;;
+			  finish)	;;
+			  install)	;;
+			  link)		;;
+			  relink)	;;
+			  uninstall)	;;
+
+			  # Catch anything else as an error
+			  *) func_error "invalid argument for $opt"
+			     exit_cmd=exit
+			     break
+			     ;;
+		        esac
+
+			mode="$1"
+			shift
+			;;
+
+      --preserve-dup-deps)
+			opt_duplicate_deps=:				;;
+
+      --quiet|--silent)	preserve_args="$preserve_args $opt"
+			opt_silent=:
+			;;
+
+      --verbose| -v)	preserve_args="$preserve_args $opt"
+			opt_silent=false
+			;;
+
+      --tag)		test "$#" -eq 0 && func_missing_arg "$opt" && break
+			preserve_args="$preserve_args $opt $1"
+			func_enable_tag "$1"	# tagname is set here
+			shift
+			;;
+
+      # Separate optargs to long options:
+      -dlopen=*|--mode=*|--tag=*)
+			func_opt_split "$opt"
+			set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
+			shift
+			;;
+
+      -\?|-h)		func_usage					;;
+      --help)		opt_help=:					;;
+      --version)	func_version					;;
+
+      -*)		func_fatal_help "unrecognized option \`$opt'"	;;
+
+      *)		nonopt="$opt"
+			break
+			;;
+    esac
+  done
+
+
+  case $host in
+    *cygwin* | *mingw* | *pw32* | *cegcc*)
+      # don't eliminate duplications in $postdeps and $predeps
+      opt_duplicate_compiler_generated_deps=:
+      ;;
+    *)
+      opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
+      ;;
+  esac
+
+  # Having warned about all mis-specified options, bail out if
+  # anything was wrong.
+  $exit_cmd $EXIT_FAILURE
+}
+
+# func_check_version_match
+# Ensure that we are using m4 macros, and libtool script from the same
+# release of libtool.
+func_check_version_match ()
+{
+  if test "$package_revision" != "$macro_revision"; then
+    if test "$VERSION" != "$macro_version"; then
+      if test -z "$macro_version"; then
+        cat >&2 <<_LT_EOF
+$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
+$progname: definition of this LT_INIT comes from an older release.
+$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
+$progname: and run autoconf again.
+_LT_EOF
+      else
+        cat >&2 <<_LT_EOF
+$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
+$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
+$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
+$progname: and run autoconf again.
+_LT_EOF
+      fi
+    else
+      cat >&2 <<_LT_EOF
+$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
+$progname: but the definition of this LT_INIT comes from revision $macro_revision.
+$progname: You should recreate aclocal.m4 with macros from revision $package_revision
+$progname: of $PACKAGE $VERSION and run autoconf again.
+_LT_EOF
+    fi
+
+    exit $EXIT_MISMATCH
+  fi
+}
+
+
+## ----------- ##
+##    Main.    ##
+## ----------- ##
+
+$opt_help || {
+  # Sanity checks first:
+  func_check_version_match
+
+  if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
+    func_fatal_configuration "not configured to build any kind of library"
+  fi
+
+  test -z "$mode" && func_fatal_error "error: you must specify a MODE."
+
+
+  # Darwin sucks
+  eval std_shrext=\"$shrext_cmds\"
+
+
+  # Only execute mode is allowed to have -dlopen flags.
+  if test -n "$execute_dlfiles" && test "$mode" != execute; then
+    func_error "unrecognized option \`-dlopen'"
+    $ECHO "$help" 1>&2
+    exit $EXIT_FAILURE
+  fi
+
+  # Change the help message to a mode-specific one.
+  generic_help="$help"
+  help="Try \`$progname --help --mode=$mode' for more information."
+}
+
+
+# func_lalib_p file
+# True iff FILE is a libtool `.la' library or `.lo' object file.
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_lalib_p ()
+{
+    test -f "$1" &&
+      $SED -e 4q "$1" 2>/dev/null \
+        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
+}
+
+# func_lalib_unsafe_p file
+# True iff FILE is a libtool `.la' library or `.lo' object file.
+# This function implements the same check as func_lalib_p without
+# resorting to external programs.  To this end, it redirects stdin and
+# closes it afterwards, without saving the original file descriptor.
+# As a safety measure, use it only where a negative result would be
+# fatal anyway.  Works if `file' does not exist.
+func_lalib_unsafe_p ()
+{
+    lalib_p=no
+    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
+	for lalib_p_l in 1 2 3 4
+	do
+	    read lalib_p_line
+	    case "$lalib_p_line" in
+		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
+	    esac
+	done
+	exec 0<&5 5<&-
+    fi
+    test "$lalib_p" = yes
+}
+
+# func_ltwrapper_script_p file
+# True iff FILE is a libtool wrapper script
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_script_p ()
+{
+    func_lalib_p "$1"
+}
+
+# func_ltwrapper_executable_p file
+# True iff FILE is a libtool wrapper executable
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_executable_p ()
+{
+    func_ltwrapper_exec_suffix=
+    case $1 in
+    *.exe) ;;
+    *) func_ltwrapper_exec_suffix=.exe ;;
+    esac
+    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
+}
+
+# func_ltwrapper_scriptname file
+# Assumes file is an ltwrapper_executable
+# uses $file to determine the appropriate filename for a
+# temporary ltwrapper_script.
+func_ltwrapper_scriptname ()
+{
+    func_ltwrapper_scriptname_result=""
+    if func_ltwrapper_executable_p "$1"; then
+	func_dirname_and_basename "$1" "" "."
+	func_stripname '' '.exe' "$func_basename_result"
+	func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
+    fi
+}
+
+# func_ltwrapper_p file
+# True iff FILE is a libtool wrapper script or wrapper executable
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_p ()
+{
+    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
+}
+
+
+# func_execute_cmds commands fail_cmd
+# Execute tilde-delimited COMMANDS.
+# If FAIL_CMD is given, eval that upon failure.
+# FAIL_CMD may read-access the current command in variable CMD!
+func_execute_cmds ()
+{
+    $opt_debug
+    save_ifs=$IFS; IFS='~'
+    for cmd in $1; do
+      IFS=$save_ifs
+      eval cmd=\"$cmd\"
+      func_show_eval "$cmd" "${2-:}"
+    done
+    IFS=$save_ifs
+}
+
+
+# func_source file
+# Source FILE, adding directory component if necessary.
+# Note that it is not necessary on cygwin/mingw to append a dot to
+# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
+# behavior happens only for exec(3), not for open(2)!  Also, sourcing
+# `FILE.' does not work on cygwin managed mounts.
+func_source ()
+{
+    $opt_debug
+    case $1 in
+    */* | *\\*)	. "$1" ;;
+    *)		. "./$1" ;;
+    esac
+}
+
+
+# func_infer_tag arg
+# Infer tagged configuration to use if any are available and
+# if one wasn't chosen via the "--tag" command line option.
+# Only attempt this if the compiler in the base compile
+# command doesn't match the default compiler.
+# arg is usually of the form 'gcc ...'
+func_infer_tag ()
+{
+    $opt_debug
+    if test -n "$available_tags" && test -z "$tagname"; then
+      CC_quoted=
+      for arg in $CC; do
+        func_quote_for_eval "$arg"
+	CC_quoted="$CC_quoted $func_quote_for_eval_result"
+      done
+      case $@ in
+      # Blanks in the command may have been stripped by the calling shell,
+      # but not from the CC environment variable when configure was run.
+      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;;
+      # Blanks at the start of $base_compile will cause this to fail
+      # if we don't check for them as well.
+      *)
+	for z in $available_tags; do
+	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
+	    # Evaluate the configuration.
+	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
+	    CC_quoted=
+	    for arg in $CC; do
+	      # Double-quote args containing other shell metacharacters.
+	      func_quote_for_eval "$arg"
+	      CC_quoted="$CC_quoted $func_quote_for_eval_result"
+	    done
+	    case "$@ " in
+	      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*)
+	      # The compiler in the base compile command matches
+	      # the one in the tagged configuration.
+	      # Assume this is the tagged configuration we want.
+	      tagname=$z
+	      break
+	      ;;
+	    esac
+	  fi
+	done
+	# If $tagname still isn't set, then no tagged configuration
+	# was found and let the user know that the "--tag" command
+	# line option must be used.
+	if test -z "$tagname"; then
+	  func_echo "unable to infer tagged configuration"
+	  func_fatal_error "specify a tag with \`--tag'"
+#	else
+#	  func_verbose "using $tagname tagged configuration"
+	fi
+	;;
+      esac
+    fi
+}
+
+
+
+# func_write_libtool_object output_name pic_name nonpic_name
+# Create a libtool object file (analogous to a ".la" file),
+# but don't create it if we're doing a dry run.
+func_write_libtool_object ()
+{
+    write_libobj=${1}
+    if test "$build_libtool_libs" = yes; then
+      write_lobj=\'${2}\'
+    else
+      write_lobj=none
+    fi
+
+    if test "$build_old_libs" = yes; then
+      write_oldobj=\'${3}\'
+    else
+      write_oldobj=none
+    fi
+
+    $opt_dry_run || {
+      cat >${write_libobj}T <<EOF
+# $write_libobj - a libtool object file
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object=$write_lobj
+
+# Name of the non-PIC object
+non_pic_object=$write_oldobj
+
+EOF
+      $MV "${write_libobj}T" "${write_libobj}"
+    }
+}
+
+# func_mode_compile arg...
+func_mode_compile ()
+{
+    $opt_debug
+    # Get the compilation command and the source file.
+    base_compile=
+    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
+    suppress_opt=yes
+    suppress_output=
+    arg_mode=normal
+    libobj=
+    later=
+    pie_flag=
+
+    for arg
+    do
+      case $arg_mode in
+      arg  )
+	# do not "continue".  Instead, add this to base_compile
+	lastarg="$arg"
+	arg_mode=normal
+	;;
+
+      target )
+	libobj="$arg"
+	arg_mode=normal
+	continue
+	;;
+
+      normal )
+	# Accept any command-line options.
+	case $arg in
+	-o)
+	  test -n "$libobj" && \
+	    func_fatal_error "you cannot specify \`-o' more than once"
+	  arg_mode=target
+	  continue
+	  ;;
+
+	-pie | -fpie | -fPIE)
+          pie_flag="$pie_flag $arg"
+	  continue
+	  ;;
+
+	-shared | -static | -prefer-pic | -prefer-non-pic)
+	  later="$later $arg"
+	  continue
+	  ;;
+
+	-no-suppress)
+	  suppress_opt=no
+	  continue
+	  ;;
+
+	-Xcompiler)
+	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
+	  continue      #  The current "srcfile" will either be retained or
+	  ;;            #  replaced later.  I would guess that would be a bug.
+
+	-Wc,*)
+	  func_stripname '-Wc,' '' "$arg"
+	  args=$func_stripname_result
+	  lastarg=
+	  save_ifs="$IFS"; IFS=','
+	  for arg in $args; do
+	    IFS="$save_ifs"
+	    func_quote_for_eval "$arg"
+	    lastarg="$lastarg $func_quote_for_eval_result"
+	  done
+	  IFS="$save_ifs"
+	  func_stripname ' ' '' "$lastarg"
+	  lastarg=$func_stripname_result
+
+	  # Add the arguments to base_compile.
+	  base_compile="$base_compile $lastarg"
+	  continue
+	  ;;
+
+	*)
+	  # Accept the current argument as the source file.
+	  # The previous "srcfile" becomes the current argument.
+	  #
+	  lastarg="$srcfile"
+	  srcfile="$arg"
+	  ;;
+	esac  #  case $arg
+	;;
+      esac    #  case $arg_mode
+
+      # Aesthetically quote the previous argument.
+      func_quote_for_eval "$lastarg"
+      base_compile="$base_compile $func_quote_for_eval_result"
+    done # for arg
+
+    case $arg_mode in
+    arg)
+      func_fatal_error "you must specify an argument for -Xcompile"
+      ;;
+    target)
+      func_fatal_error "you must specify a target with \`-o'"
+      ;;
+    *)
+      # Get the name of the library object.
+      test -z "$libobj" && {
+	func_basename "$srcfile"
+	libobj="$func_basename_result"
+      }
+      ;;
+    esac
+
+    # Recognize several different file suffixes.
+    # If the user specifies -o file.o, it is replaced with file.lo
+    case $libobj in
+    *.[cCFSifmso] | \
+    *.ada | *.adb | *.ads | *.asm | \
+    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
+    *.[fF][09]? | *.for | *.java | *.obj | *.sx)
+      func_xform "$libobj"
+      libobj=$func_xform_result
+      ;;
+    esac
+
+    case $libobj in
+    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
+    *)
+      func_fatal_error "cannot determine name of library object from \`$libobj'"
+      ;;
+    esac
+
+    func_infer_tag $base_compile
+
+    for arg in $later; do
+      case $arg in
+      -shared)
+	test "$build_libtool_libs" != yes && \
+	  func_fatal_configuration "can not build a shared library"
+	build_old_libs=no
+	continue
+	;;
+
+      -static)
+	build_libtool_libs=no
+	build_old_libs=yes
+	continue
+	;;
+
+      -prefer-pic)
+	pic_mode=yes
+	continue
+	;;
+
+      -prefer-non-pic)
+	pic_mode=no
+	continue
+	;;
+      esac
+    done
+
+    func_quote_for_eval "$libobj"
+    test "X$libobj" != "X$func_quote_for_eval_result" \
+      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
+      && func_warning "libobj name \`$libobj' may not contain shell special characters."
+    func_dirname_and_basename "$obj" "/" ""
+    objname="$func_basename_result"
+    xdir="$func_dirname_result"
+    lobj=${xdir}$objdir/$objname
+
+    test -z "$base_compile" && \
+      func_fatal_help "you must specify a compilation command"
+
+    # Delete any leftover library objects.
+    if test "$build_old_libs" = yes; then
+      removelist="$obj $lobj $libobj ${libobj}T"
+    else
+      removelist="$lobj $libobj ${libobj}T"
+    fi
+
+    # On Cygwin there's no "real" PIC flag so we must build both object types
+    case $host_os in
+    cygwin* | mingw* | pw32* | os2* | cegcc*)
+      pic_mode=default
+      ;;
+    esac
+    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
+      # non-PIC code in shared libraries is not supported
+      pic_mode=default
+    fi
+
+    # Calculate the filename of the output object if compiler does
+    # not support -o with -c
+    if test "$compiler_c_o" = no; then
+      output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
+      lockfile="$output_obj.lock"
+    else
+      output_obj=
+      need_locks=no
+      lockfile=
+    fi
+
+    # Lock this critical section if it is needed
+    # We use this script file to make the link, it avoids creating a new file
+    if test "$need_locks" = yes; then
+      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
+	func_echo "Waiting for $lockfile to be removed"
+	sleep 2
+      done
+    elif test "$need_locks" = warn; then
+      if test -f "$lockfile"; then
+	$ECHO "\
+*** ERROR, $lockfile exists and contains:
+`cat $lockfile 2>/dev/null`
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+	$opt_dry_run || $RM $removelist
+	exit $EXIT_FAILURE
+      fi
+      removelist="$removelist $output_obj"
+      $ECHO "$srcfile" > "$lockfile"
+    fi
+
+    $opt_dry_run || $RM $removelist
+    removelist="$removelist $lockfile"
+    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
+
+    if test -n "$fix_srcfile_path"; then
+      eval srcfile=\"$fix_srcfile_path\"
+    fi
+    func_quote_for_eval "$srcfile"
+    qsrcfile=$func_quote_for_eval_result
+
+    # Only build a PIC object if we are building libtool libraries.
+    if test "$build_libtool_libs" = yes; then
+      # Without this assignment, base_compile gets emptied.
+      fbsd_hideous_sh_bug=$base_compile
+
+      if test "$pic_mode" != no; then
+	command="$base_compile $qsrcfile $pic_flag"
+      else
+	# Don't build PIC code
+	command="$base_compile $qsrcfile"
+      fi
+
+      func_mkdir_p "$xdir$objdir"
+
+      if test -z "$output_obj"; then
+	# Place PIC objects in $objdir
+	command="$command -o $lobj"
+      fi
+
+      func_show_eval_locale "$command"	\
+          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
+
+      if test "$need_locks" = warn &&
+	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+	$ECHO "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+	$opt_dry_run || $RM $removelist
+	exit $EXIT_FAILURE
+      fi
+
+      # Just move the object if needed, then go on to compile the next one
+      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
+	func_show_eval '$MV "$output_obj" "$lobj"' \
+	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
+      fi
+
+      # Allow error messages only from the first compilation.
+      if test "$suppress_opt" = yes; then
+	suppress_output=' >/dev/null 2>&1'
+      fi
+    fi
+
+    # Only build a position-dependent object if we build old libraries.
+    if test "$build_old_libs" = yes; then
+      if test "$pic_mode" != yes; then
+	# Don't build PIC code
+	command="$base_compile $qsrcfile$pie_flag"
+      else
+	command="$base_compile $qsrcfile $pic_flag"
+      fi
+      if test "$compiler_c_o" = yes; then
+	command="$command -o $obj"
+      fi
+
+      # Suppress compiler output if we already did a PIC compilation.
+      command="$command$suppress_output"
+      func_show_eval_locale "$command" \
+        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
+
+      if test "$need_locks" = warn &&
+	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+	$ECHO "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+	$opt_dry_run || $RM $removelist
+	exit $EXIT_FAILURE
+      fi
+
+      # Just move the object if needed
+      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
+	func_show_eval '$MV "$output_obj" "$obj"' \
+	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
+      fi
+    fi
+
+    $opt_dry_run || {
+      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
+
+      # Unlock the critical section if it was locked
+      if test "$need_locks" != no; then
+	removelist=$lockfile
+        $RM "$lockfile"
+      fi
+    }
+
+    exit $EXIT_SUCCESS
+}
+
+$opt_help || {
+test "$mode" = compile && func_mode_compile ${1+"$@"}
+}
+
+func_mode_help ()
+{
+    # We need to display help for each of the modes.
+    case $mode in
+      "")
+        # Generic help is extracted from the usage comments
+        # at the start of this file.
+        func_help
+        ;;
+
+      clean)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
+
+Remove files from the build directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, object or program, all the files associated
+with it are deleted. Otherwise, only FILE itself is deleted using RM."
+        ;;
+
+      compile)
+      $ECHO \
+"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
+
+Compile a source file into a libtool library object.
+
+This mode accepts the following additional options:
+
+  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
+  -no-suppress      do not suppress compiler output for multiple passes
+  -prefer-pic       try to building PIC objects only
+  -prefer-non-pic   try to building non-PIC objects only
+  -shared           do not build a \`.o' file suitable for static linking
+  -static           only build a \`.o' file suitable for static linking
+
+COMPILE-COMMAND is a command to be used in creating a \`standard' object file
+from the given SOURCEFILE.
+
+The output file name is determined by removing the directory component from
+SOURCEFILE, then substituting the C source code suffix \`.c' with the
+library object suffix, \`.lo'."
+        ;;
+
+      execute)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
+
+Automatically set library path, then run a program.
+
+This mode accepts the following additional options:
+
+  -dlopen FILE      add the directory containing FILE to the library path
+
+This mode sets the library path environment variable according to \`-dlopen'
+flags.
+
+If any of the ARGS are libtool executable wrappers, then they are translated
+into their corresponding uninstalled binary, and any of their required library
+directories are added to the library path.
+
+Then, COMMAND is executed, with ARGS as arguments."
+        ;;
+
+      finish)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
+
+Complete the installation of libtool libraries.
+
+Each LIBDIR is a directory that contains libtool libraries.
+
+The commands that this mode executes may require superuser privileges.  Use
+the \`--dry-run' option if you just want to see what would be executed."
+        ;;
+
+      install)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
+
+Install executables or libraries.
+
+INSTALL-COMMAND is the installation command.  The first component should be
+either the \`install' or \`cp' program.
+
+The following components of INSTALL-COMMAND are treated specially:
+
+  -inst-prefix PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
+
+The rest of the components are interpreted as arguments to that command (only
+BSD-compatible install options are recognized)."
+        ;;
+
+      link)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
+
+Link object files or libraries together to form another library, or to
+create an executable program.
+
+LINK-COMMAND is a command using the C compiler that you would use to create
+a program from several object files.
+
+The following components of LINK-COMMAND are treated specially:
+
+  -all-static       do not do any dynamic linking at all
+  -avoid-version    do not add a version suffix if possible
+  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
+  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
+  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
+  -export-symbols SYMFILE
+                    try to export only the symbols listed in SYMFILE
+  -export-symbols-regex REGEX
+                    try to export only the symbols matching REGEX
+  -LLIBDIR          search LIBDIR for required installed libraries
+  -lNAME            OUTPUT-FILE requires the installed library libNAME
+  -module           build a library that can dlopened
+  -no-fast-install  disable the fast-install mode
+  -no-install       link a not-installable executable
+  -no-undefined     declare that a library does not refer to external symbols
+  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
+  -objectlist FILE  Use a list of object files found in FILE to specify objects
+  -precious-files-regex REGEX
+                    don't remove output files matching REGEX
+  -release RELEASE  specify package release information
+  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
+  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
+  -shared           only do dynamic linking of libtool libraries
+  -shrext SUFFIX    override the standard shared library file extension
+  -static           do not do any dynamic linking of uninstalled libtool libraries
+  -static-libtool-libs
+                    do not do any dynamic linking of libtool libraries
+  -version-info CURRENT[:REVISION[:AGE]]
+                    specify library version info [each variable defaults to 0]
+  -weak LIBNAME     declare that the target provides the LIBNAME interface
+
+All other options (arguments beginning with \`-') are ignored.
+
+Every other argument is treated as a filename.  Files ending in \`.la' are
+treated as uninstalled libtool libraries, other files are standard or library
+object files.
+
+If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
+only library objects (\`.lo' files) may be specified, and \`-rpath' is
+required, except when creating a convenience library.
+
+If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
+using \`ar' and \`ranlib', or on Windows using \`lib'.
+
+If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
+is created, otherwise an executable program is created."
+        ;;
+
+      uninstall)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
+
+Remove libraries from an installation directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, all the files associated with it are deleted.
+Otherwise, only FILE itself is deleted using RM."
+        ;;
+
+      *)
+        func_fatal_help "invalid operation mode \`$mode'"
+        ;;
+    esac
+
+    $ECHO
+    $ECHO "Try \`$progname --help' for more information about other modes."
+
+    exit $?
+}
+
+  # Now that we've collected a possible --mode arg, show help if necessary
+  $opt_help && func_mode_help
+
+
+# func_mode_execute arg...
+func_mode_execute ()
+{
+    $opt_debug
+    # The first argument is the command name.
+    cmd="$nonopt"
+    test -z "$cmd" && \
+      func_fatal_help "you must specify a COMMAND"
+
+    # Handle -dlopen flags immediately.
+    for file in $execute_dlfiles; do
+      test -f "$file" \
+	|| func_fatal_help "\`$file' is not a file"
+
+      dir=
+      case $file in
+      *.la)
+	# Check to see that this really is a libtool archive.
+	func_lalib_unsafe_p "$file" \
+	  || func_fatal_help "\`$lib' is not a valid libtool archive"
+
+	# Read the libtool library.
+	dlname=
+	library_names=
+	func_source "$file"
+
+	# Skip this library if it cannot be dlopened.
+	if test -z "$dlname"; then
+	  # Warn if it was a shared library.
+	  test -n "$library_names" && \
+	    func_warning "\`$file' was not linked with \`-export-dynamic'"
+	  continue
+	fi
+
+	func_dirname "$file" "" "."
+	dir="$func_dirname_result"
+
+	if test -f "$dir/$objdir/$dlname"; then
+	  dir="$dir/$objdir"
+	else
+	  if test ! -f "$dir/$dlname"; then
+	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
+	  fi
+	fi
+	;;
+
+      *.lo)
+	# Just add the directory containing the .lo file.
+	func_dirname "$file" "" "."
+	dir="$func_dirname_result"
+	;;
+
+      *)
+	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
+	continue
+	;;
+      esac
+
+      # Get the absolute pathname.
+      absdir=`cd "$dir" && pwd`
+      test -n "$absdir" && dir="$absdir"
+
+      # Now add the directory to shlibpath_var.
+      if eval "test -z \"\$$shlibpath_var\""; then
+	eval "$shlibpath_var=\"\$dir\""
+      else
+	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
+      fi
+    done
+
+    # This variable tells wrapper scripts just to set shlibpath_var
+    # rather than running their programs.
+    libtool_execute_magic="$magic"
+
+    # Check if any of the arguments is a wrapper script.
+    args=
+    for file
+    do
+      case $file in
+      -*) ;;
+      *)
+	# Do a test to see if this is really a libtool program.
+	if func_ltwrapper_script_p "$file"; then
+	  func_source "$file"
+	  # Transform arg to wrapped name.
+	  file="$progdir/$program"
+	elif func_ltwrapper_executable_p "$file"; then
+	  func_ltwrapper_scriptname "$file"
+	  func_source "$func_ltwrapper_scriptname_result"
+	  # Transform arg to wrapped name.
+	  file="$progdir/$program"
+	fi
+	;;
+      esac
+      # Quote arguments (to preserve shell metacharacters).
+      func_quote_for_eval "$file"
+      args="$args $func_quote_for_eval_result"
+    done
+
+    if test "X$opt_dry_run" = Xfalse; then
+      if test -n "$shlibpath_var"; then
+	# Export the shlibpath_var.
+	eval "export $shlibpath_var"
+      fi
+
+      # Restore saved environment variables
+      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+      do
+	eval "if test \"\${save_$lt_var+set}\" = set; then
+                $lt_var=\$save_$lt_var; export $lt_var
+	      else
+		$lt_unset $lt_var
+	      fi"
+      done
+
+      # Now prepare to actually exec the command.
+      exec_cmd="\$cmd$args"
+    else
+      # Display what would be done.
+      if test -n "$shlibpath_var"; then
+	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
+	$ECHO "export $shlibpath_var"
+      fi
+      $ECHO "$cmd$args"
+      exit $EXIT_SUCCESS
+    fi
+}
+
+test "$mode" = execute && func_mode_execute ${1+"$@"}
+
+
+# func_mode_finish arg...
+func_mode_finish ()
+{
+    $opt_debug
+    libdirs="$nonopt"
+    admincmds=
+
+    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
+      for dir
+      do
+	libdirs="$libdirs $dir"
+      done
+
+      for libdir in $libdirs; do
+	if test -n "$finish_cmds"; then
+	  # Do each command in the finish commands.
+	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
+'"$cmd"'"'
+	fi
+	if test -n "$finish_eval"; then
+	  # Do the single finish_eval.
+	  eval cmds=\"$finish_eval\"
+	  $opt_dry_run || eval "$cmds" || admincmds="$admincmds
+       $cmds"
+	fi
+      done
+    fi
+
+    # Exit here if they wanted silent mode.
+    $opt_silent && exit $EXIT_SUCCESS
+
+    $ECHO "X----------------------------------------------------------------------" | $Xsed
+    $ECHO "Libraries have been installed in:"
+    for libdir in $libdirs; do
+      $ECHO "   $libdir"
+    done
+    $ECHO
+    $ECHO "If you ever happen to want to link against installed libraries"
+    $ECHO "in a given directory, LIBDIR, you must either use libtool, and"
+    $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'"
+    $ECHO "flag during linking and do at least one of the following:"
+    if test -n "$shlibpath_var"; then
+      $ECHO "   - add LIBDIR to the \`$shlibpath_var' environment variable"
+      $ECHO "     during execution"
+    fi
+    if test -n "$runpath_var"; then
+      $ECHO "   - add LIBDIR to the \`$runpath_var' environment variable"
+      $ECHO "     during linking"
+    fi
+    if test -n "$hardcode_libdir_flag_spec"; then
+      libdir=LIBDIR
+      eval flag=\"$hardcode_libdir_flag_spec\"
+
+      $ECHO "   - use the \`$flag' linker flag"
+    fi
+    if test -n "$admincmds"; then
+      $ECHO "   - have your system administrator run these commands:$admincmds"
+    fi
+    if test -f /etc/ld.so.conf; then
+      $ECHO "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
+    fi
+    $ECHO
+
+    $ECHO "See any operating system documentation about shared libraries for"
+    case $host in
+      solaris2.[6789]|solaris2.1[0-9])
+        $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual"
+	$ECHO "pages."
+	;;
+      *)
+        $ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
+        ;;
+    esac
+    $ECHO "X----------------------------------------------------------------------" | $Xsed
+    exit $EXIT_SUCCESS
+}
+
+test "$mode" = finish && func_mode_finish ${1+"$@"}
+
+
+# func_mode_install arg...
+func_mode_install ()
+{
+    $opt_debug
+    # There may be an optional sh(1) argument at the beginning of
+    # install_prog (especially on Windows NT).
+    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
+       # Allow the use of GNU shtool's install command.
+       $ECHO "X$nonopt" | $GREP shtool >/dev/null; then
+      # Aesthetically quote it.
+      func_quote_for_eval "$nonopt"
+      install_prog="$func_quote_for_eval_result "
+      arg=$1
+      shift
+    else
+      install_prog=
+      arg=$nonopt
+    fi
+
+    # The real first argument should be the name of the installation program.
+    # Aesthetically quote it.
+    func_quote_for_eval "$arg"
+    install_prog="$install_prog$func_quote_for_eval_result"
+
+    # We need to accept at least all the BSD install flags.
+    dest=
+    files=
+    opts=
+    prev=
+    install_type=
+    isdir=no
+    stripme=
+    for arg
+    do
+      if test -n "$dest"; then
+	files="$files $dest"
+	dest=$arg
+	continue
+      fi
+
+      case $arg in
+      -d) isdir=yes ;;
+      -f)
+	case " $install_prog " in
+	*[\\\ /]cp\ *) ;;
+	*) prev=$arg ;;
+	esac
+	;;
+      -g | -m | -o)
+	prev=$arg
+	;;
+      -s)
+	stripme=" -s"
+	continue
+	;;
+      -*)
+	;;
+      *)
+	# If the previous option needed an argument, then skip it.
+	if test -n "$prev"; then
+	  prev=
+	else
+	  dest=$arg
+	  continue
+	fi
+	;;
+      esac
+
+      # Aesthetically quote the argument.
+      func_quote_for_eval "$arg"
+      install_prog="$install_prog $func_quote_for_eval_result"
+    done
+
+    test -z "$install_prog" && \
+      func_fatal_help "you must specify an install program"
+
+    test -n "$prev" && \
+      func_fatal_help "the \`$prev' option requires an argument"
+
+    if test -z "$files"; then
+      if test -z "$dest"; then
+	func_fatal_help "no file or destination specified"
+      else
+	func_fatal_help "you must specify a destination"
+      fi
+    fi
+
+    # Strip any trailing slash from the destination.
+    func_stripname '' '/' "$dest"
+    dest=$func_stripname_result
+
+    # Check to see that the destination is a directory.
+    test -d "$dest" && isdir=yes
+    if test "$isdir" = yes; then
+      destdir="$dest"
+      destname=
+    else
+      func_dirname_and_basename "$dest" "" "."
+      destdir="$func_dirname_result"
+      destname="$func_basename_result"
+
+      # Not a directory, so check to see that there is only one file specified.
+      set dummy $files; shift
+      test "$#" -gt 1 && \
+	func_fatal_help "\`$dest' is not a directory"
+    fi
+    case $destdir in
+    [\\/]* | [A-Za-z]:[\\/]*) ;;
+    *)
+      for file in $files; do
+	case $file in
+	*.lo) ;;
+	*)
+	  func_fatal_help "\`$destdir' must be an absolute directory name"
+	  ;;
+	esac
+      done
+      ;;
+    esac
+
+    # This variable tells wrapper scripts just to set variables rather
+    # than running their programs.
+    libtool_install_magic="$magic"
+
+    staticlibs=
+    future_libdirs=
+    current_libdirs=
+    for file in $files; do
+
+      # Do each installation.
+      case $file in
+      *.$libext)
+	# Do the static libraries later.
+	staticlibs="$staticlibs $file"
+	;;
+
+      *.la)
+	# Check to see that this really is a libtool archive.
+	func_lalib_unsafe_p "$file" \
+	  || func_fatal_help "\`$file' is not a valid libtool archive"
+
+	library_names=
+	old_library=
+	relink_command=
+	func_source "$file"
+
+	# Add the libdir to current_libdirs if it is the destination.
+	if test "X$destdir" = "X$libdir"; then
+	  case "$current_libdirs " in
+	  *" $libdir "*) ;;
+	  *) current_libdirs="$current_libdirs $libdir" ;;
+	  esac
+	else
+	  # Note the libdir as a future libdir.
+	  case "$future_libdirs " in
+	  *" $libdir "*) ;;
+	  *) future_libdirs="$future_libdirs $libdir" ;;
+	  esac
+	fi
+
+	func_dirname "$file" "/" ""
+	dir="$func_dirname_result"
+	dir="$dir$objdir"
+
+	if test -n "$relink_command"; then
+	  # Determine the prefix the user has applied to our future dir.
+	  inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
+
+	  # Don't allow the user to place us outside of our expected
+	  # location b/c this prevents finding dependent libraries that
+	  # are installed to the same prefix.
+	  # At present, this check doesn't affect windows .dll's that
+	  # are installed into $libdir/../bin (currently, that works fine)
+	  # but it's something to keep an eye on.
+	  test "$inst_prefix_dir" = "$destdir" && \
+	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
+
+	  if test -n "$inst_prefix_dir"; then
+	    # Stick the inst_prefix_dir data into the link command.
+	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
+	  else
+	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
+	  fi
+
+	  func_warning "relinking \`$file'"
+	  func_show_eval "$relink_command" \
+	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
+	fi
+
+	# See the names of the shared library.
+	set dummy $library_names; shift
+	if test -n "$1"; then
+	  realname="$1"
+	  shift
+
+	  srcname="$realname"
+	  test -n "$relink_command" && srcname="$realname"T
+
+	  # Install the shared library and build the symlinks.
+	  func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
+	      'exit $?'
+	  tstripme="$stripme"
+	  case $host_os in
+	  cygwin* | mingw* | pw32* | cegcc*)
+	    case $realname in
+	    *.dll.a)
+	      tstripme=""
+	      ;;
+	    esac
+	    ;;
+	  esac
+	  if test -n "$tstripme" && test -n "$striplib"; then
+	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
+	  fi
+
+	  if test "$#" -gt 0; then
+	    # Delete the old symlinks, and create new ones.
+	    # Try `ln -sf' first, because the `ln' binary might depend on
+	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
+	    # so we also need to try rm && ln -s.
+	    for linkname
+	    do
+	      test "$linkname" != "$realname" \
+		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
+	    done
+	  fi
+
+	  # Do each command in the postinstall commands.
+	  lib="$destdir/$realname"
+	  func_execute_cmds "$postinstall_cmds" 'exit $?'
+	fi
+
+	# Install the pseudo-library for information purposes.
+	func_basename "$file"
+	name="$func_basename_result"
+	instname="$dir/$name"i
+	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
+
+	# Maybe install the static library, too.
+	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
+	;;
+
+      *.lo)
+	# Install (i.e. copy) a libtool object.
+
+	# Figure out destination file name, if it wasn't already specified.
+	if test -n "$destname"; then
+	  destfile="$destdir/$destname"
+	else
+	  func_basename "$file"
+	  destfile="$func_basename_result"
+	  destfile="$destdir/$destfile"
+	fi
+
+	# Deduce the name of the destination old-style object file.
+	case $destfile in
+	*.lo)
+	  func_lo2o "$destfile"
+	  staticdest=$func_lo2o_result
+	  ;;
+	*.$objext)
+	  staticdest="$destfile"
+	  destfile=
+	  ;;
+	*)
+	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
+	  ;;
+	esac
+
+	# Install the libtool object if requested.
+	test -n "$destfile" && \
+	  func_show_eval "$install_prog $file $destfile" 'exit $?'
+
+	# Install the old object if enabled.
+	if test "$build_old_libs" = yes; then
+	  # Deduce the name of the old-style object file.
+	  func_lo2o "$file"
+	  staticobj=$func_lo2o_result
+	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
+	fi
+	exit $EXIT_SUCCESS
+	;;
+
+      *)
+	# Figure out destination file name, if it wasn't already specified.
+	if test -n "$destname"; then
+	  destfile="$destdir/$destname"
+	else
+	  func_basename "$file"
+	  destfile="$func_basename_result"
+	  destfile="$destdir/$destfile"
+	fi
+
+	# If the file is missing, and there is a .exe on the end, strip it
+	# because it is most likely a libtool script we actually want to
+	# install
+	stripped_ext=""
+	case $file in
+	  *.exe)
+	    if test ! -f "$file"; then
+	      func_stripname '' '.exe' "$file"
+	      file=$func_stripname_result
+	      stripped_ext=".exe"
+	    fi
+	    ;;
+	esac
+
+	# Do a test to see if this is really a libtool program.
+	case $host in
+	*cygwin* | *mingw*)
+	    if func_ltwrapper_executable_p "$file"; then
+	      func_ltwrapper_scriptname "$file"
+	      wrapper=$func_ltwrapper_scriptname_result
+	    else
+	      func_stripname '' '.exe' "$file"
+	      wrapper=$func_stripname_result
+	    fi
+	    ;;
+	*)
+	    wrapper=$file
+	    ;;
+	esac
+	if func_ltwrapper_script_p "$wrapper"; then
+	  notinst_deplibs=
+	  relink_command=
+
+	  func_source "$wrapper"
+
+	  # Check the variables that should have been set.
+	  test -z "$generated_by_libtool_version" && \
+	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
+
+	  finalize=yes
+	  for lib in $notinst_deplibs; do
+	    # Check to see that each library is installed.
+	    libdir=
+	    if test -f "$lib"; then
+	      func_source "$lib"
+	    fi
+	    libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
+	    if test -n "$libdir" && test ! -f "$libfile"; then
+	      func_warning "\`$lib' has not been installed in \`$libdir'"
+	      finalize=no
+	    fi
+	  done
+
+	  relink_command=
+	  func_source "$wrapper"
+
+	  outputname=
+	  if test "$fast_install" = no && test -n "$relink_command"; then
+	    $opt_dry_run || {
+	      if test "$finalize" = yes; then
+	        tmpdir=`func_mktempdir`
+		func_basename "$file$stripped_ext"
+		file="$func_basename_result"
+	        outputname="$tmpdir/$file"
+	        # Replace the output file specification.
+	        relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
+
+	        $opt_silent || {
+	          func_quote_for_expand "$relink_command"
+		  eval "func_echo $func_quote_for_expand_result"
+	        }
+	        if eval "$relink_command"; then :
+	          else
+		  func_error "error: relink \`$file' with the above command before installing it"
+		  $opt_dry_run || ${RM}r "$tmpdir"
+		  continue
+	        fi
+	        file="$outputname"
+	      else
+	        func_warning "cannot relink \`$file'"
+	      fi
+	    }
+	  else
+	    # Install the binary that we compiled earlier.
+	    file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
+	  fi
+	fi
+
+	# remove .exe since cygwin /usr/bin/install will append another
+	# one anyway
+	case $install_prog,$host in
+	*/usr/bin/install*,*cygwin*)
+	  case $file:$destfile in
+	  *.exe:*.exe)
+	    # this is ok
+	    ;;
+	  *.exe:*)
+	    destfile=$destfile.exe
+	    ;;
+	  *:*.exe)
+	    func_stripname '' '.exe' "$destfile"
+	    destfile=$func_stripname_result
+	    ;;
+	  esac
+	  ;;
+	esac
+	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
+	$opt_dry_run || if test -n "$outputname"; then
+	  ${RM}r "$tmpdir"
+	fi
+	;;
+      esac
+    done
+
+    for file in $staticlibs; do
+      func_basename "$file"
+      name="$func_basename_result"
+
+      # Set up the ranlib parameters.
+      oldlib="$destdir/$name"
+
+      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
+
+      if test -n "$stripme" && test -n "$old_striplib"; then
+	func_show_eval "$old_striplib $oldlib" 'exit $?'
+      fi
+
+      # Do each command in the postinstall commands.
+      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
+    done
+
+    test -n "$future_libdirs" && \
+      func_warning "remember to run \`$progname --finish$future_libdirs'"
+
+    if test -n "$current_libdirs"; then
+      # Maybe just do a dry run.
+      $opt_dry_run && current_libdirs=" -n$current_libdirs"
+      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
+    else
+      exit $EXIT_SUCCESS
+    fi
+}
+
+test "$mode" = install && func_mode_install ${1+"$@"}
+
+
+# func_generate_dlsyms outputname originator pic_p
+# Extract symbols from dlprefiles and create ${outputname}S.o with
+# a dlpreopen symbol table.
+func_generate_dlsyms ()
+{
+    $opt_debug
+    my_outputname="$1"
+    my_originator="$2"
+    my_pic_p="${3-no}"
+    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
+    my_dlsyms=
+
+    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+      if test -n "$NM" && test -n "$global_symbol_pipe"; then
+	my_dlsyms="${my_outputname}S.c"
+      else
+	func_error "not configured to extract global symbols from dlpreopened files"
+      fi
+    fi
+
+    if test -n "$my_dlsyms"; then
+      case $my_dlsyms in
+      "") ;;
+      *.c)
+	# Discover the nlist of each of the dlfiles.
+	nlist="$output_objdir/${my_outputname}.nm"
+
+	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
+
+	# Parse the name list into a source file.
+	func_verbose "creating $output_objdir/$my_dlsyms"
+
+	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
+/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
+/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
+
+#ifdef __cplusplus
+extern \"C\" {
+#endif
+
+/* External symbol declarations for the compiler. */\
+"
+
+	if test "$dlself" = yes; then
+	  func_verbose "generating symbol list for \`$output'"
+
+	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
+
+	  # Add our own program objects to the symbol list.
+	  progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+	  for progfile in $progfiles; do
+	    func_verbose "extracting global C symbols from \`$progfile'"
+	    $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
+	  done
+
+	  if test -n "$exclude_expsyms"; then
+	    $opt_dry_run || {
+	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
+	      eval '$MV "$nlist"T "$nlist"'
+	    }
+	  fi
+
+	  if test -n "$export_symbols_regex"; then
+	    $opt_dry_run || {
+	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
+	      eval '$MV "$nlist"T "$nlist"'
+	    }
+	  fi
+
+	  # Prepare the list of exported symbols
+	  if test -z "$export_symbols"; then
+	    export_symbols="$output_objdir/$outputname.exp"
+	    $opt_dry_run || {
+	      $RM $export_symbols
+	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+	      case $host in
+	      *cygwin* | *mingw* | *cegcc* )
+                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
+	        ;;
+	      esac
+	    }
+	  else
+	    $opt_dry_run || {
+	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
+	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
+	      eval '$MV "$nlist"T "$nlist"'
+	      case $host in
+	        *cygwin | *mingw* | *cegcc* )
+	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
+	          ;;
+	      esac
+	    }
+	  fi
+	fi
+
+	for dlprefile in $dlprefiles; do
+	  func_verbose "extracting global C symbols from \`$dlprefile'"
+	  func_basename "$dlprefile"
+	  name="$func_basename_result"
+	  $opt_dry_run || {
+	    eval '$ECHO ": $name " >> "$nlist"'
+	    eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
+	  }
+	done
+
+	$opt_dry_run || {
+	  # Make sure we have at least an empty file.
+	  test -f "$nlist" || : > "$nlist"
+
+	  if test -n "$exclude_expsyms"; then
+	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
+	    $MV "$nlist"T "$nlist"
+	  fi
+
+	  # Try sorting and uniquifying the output.
+	  if $GREP -v "^: " < "$nlist" |
+	      if sort -k 3 </dev/null >/dev/null 2>&1; then
+		sort -k 3
+	      else
+		sort +2
+	      fi |
+	      uniq > "$nlist"S; then
+	    :
+	  else
+	    $GREP -v "^: " < "$nlist" > "$nlist"S
+	  fi
+
+	  if test -f "$nlist"S; then
+	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
+	  else
+	    $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms"
+	  fi
+
+	  $ECHO >> "$output_objdir/$my_dlsyms" "\
+
+/* The mapping between symbol names and symbols.  */
+typedef struct {
+  const char *name;
+  void *address;
+} lt_dlsymlist;
+"
+	  case $host in
+	  *cygwin* | *mingw* | *cegcc* )
+	    $ECHO >> "$output_objdir/$my_dlsyms" "\
+/* DATA imports from DLLs on WIN32 con't be const, because
+   runtime relocations are performed -- see ld's documentation
+   on pseudo-relocs.  */"
+	    lt_dlsym_const= ;;
+	  *osf5*)
+	    echo >> "$output_objdir/$my_dlsyms" "\
+/* This system does not cope well with relocations in const data */"
+	    lt_dlsym_const= ;;
+	  *)
+	    lt_dlsym_const=const ;;
+	  esac
+
+	  $ECHO >> "$output_objdir/$my_dlsyms" "\
+extern $lt_dlsym_const lt_dlsymlist
+lt_${my_prefix}_LTX_preloaded_symbols[];
+$lt_dlsym_const lt_dlsymlist
+lt_${my_prefix}_LTX_preloaded_symbols[] =
+{\
+  { \"$my_originator\", (void *) 0 },"
+
+	  case $need_lib_prefix in
+	  no)
+	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
+	    ;;
+	  *)
+	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
+	    ;;
+	  esac
+	  $ECHO >> "$output_objdir/$my_dlsyms" "\
+  {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+  return lt_${my_prefix}_LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif\
+"
+	} # !$opt_dry_run
+
+	pic_flag_for_symtable=
+	case "$compile_command " in
+	*" -static "*) ;;
+	*)
+	  case $host in
+	  # compiling the symbol table file with pic_flag works around
+	  # a FreeBSD bug that causes programs to crash when -lm is
+	  # linked before any other PIC object.  But we must not use
+	  # pic_flag when linking with -static.  The problem exists in
+	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
+	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
+	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
+	  *-*-hpux*)
+	    pic_flag_for_symtable=" $pic_flag"  ;;
+	  *)
+	    if test "X$my_pic_p" != Xno; then
+	      pic_flag_for_symtable=" $pic_flag"
+	    fi
+	    ;;
+	  esac
+	  ;;
+	esac
+	symtab_cflags=
+	for arg in $LTCFLAGS; do
+	  case $arg in
+	  -pie | -fpie | -fPIE) ;;
+	  *) symtab_cflags="$symtab_cflags $arg" ;;
+	  esac
+	done
+
+	# Now compile the dynamic symbol file.
+	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
+
+	# Clean up the generated files.
+	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
+
+	# Transform the symbol file into the correct name.
+	symfileobj="$output_objdir/${my_outputname}S.$objext"
+	case $host in
+	*cygwin* | *mingw* | *cegcc* )
+	  if test -f "$output_objdir/$my_outputname.def"; then
+	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
+	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
+	  else
+	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
+	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
+	  fi
+	  ;;
+	*)
+	  compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
+	  finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
+	  ;;
+	esac
+	;;
+      *)
+	func_fatal_error "unknown suffix for \`$my_dlsyms'"
+	;;
+      esac
+    else
+      # We keep going just in case the user didn't refer to
+      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
+      # really was required.
+
+      # Nullify the symbol file.
+      compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
+      finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
+    fi
+}
+
+# func_win32_libid arg
+# return the library type of file 'arg'
+#
+# Need a lot of goo to handle *both* DLLs and import libs
+# Has to be a shell function in order to 'eat' the argument
+# that is supplied when $file_magic_command is called.
+func_win32_libid ()
+{
+  $opt_debug
+  win32_libid_type="unknown"
+  win32_fileres=`file -L $1 2>/dev/null`
+  case $win32_fileres in
+  *ar\ archive\ import\ library*) # definitely import
+    win32_libid_type="x86 archive import"
+    ;;
+  *ar\ archive*) # could be an import, or static
+    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
+       $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
+      win32_nmres=`eval $NM -f posix -A $1 |
+	$SED -n -e '
+	    1,100{
+		/ I /{
+		    s,.*,import,
+		    p
+		    q
+		}
+	    }'`
+      case $win32_nmres in
+      import*)  win32_libid_type="x86 archive import";;
+      *)        win32_libid_type="x86 archive static";;
+      esac
+    fi
+    ;;
+  *DLL*)
+    win32_libid_type="x86 DLL"
+    ;;
+  *executable*) # but shell scripts are "executable" too...
+    case $win32_fileres in
+    *MS\ Windows\ PE\ Intel*)
+      win32_libid_type="x86 DLL"
+      ;;
+    esac
+    ;;
+  esac
+  $ECHO "$win32_libid_type"
+}
+
+
+
+# func_extract_an_archive dir oldlib
+func_extract_an_archive ()
+{
+    $opt_debug
+    f_ex_an_ar_dir="$1"; shift
+    f_ex_an_ar_oldlib="$1"
+    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?'
+    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
+     :
+    else
+      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
+    fi
+}
+
+
+# func_extract_archives gentop oldlib ...
+func_extract_archives ()
+{
+    $opt_debug
+    my_gentop="$1"; shift
+    my_oldlibs=${1+"$@"}
+    my_oldobjs=""
+    my_xlib=""
+    my_xabs=""
+    my_xdir=""
+
+    for my_xlib in $my_oldlibs; do
+      # Extract the objects.
+      case $my_xlib in
+	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
+	*) my_xabs=`pwd`"/$my_xlib" ;;
+      esac
+      func_basename "$my_xlib"
+      my_xlib="$func_basename_result"
+      my_xlib_u=$my_xlib
+      while :; do
+        case " $extracted_archives " in
+	*" $my_xlib_u "*)
+	  func_arith $extracted_serial + 1
+	  extracted_serial=$func_arith_result
+	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
+	*) break ;;
+	esac
+      done
+      extracted_archives="$extracted_archives $my_xlib_u"
+      my_xdir="$my_gentop/$my_xlib_u"
+
+      func_mkdir_p "$my_xdir"
+
+      case $host in
+      *-darwin*)
+	func_verbose "Extracting $my_xabs"
+	# Do not bother doing anything if just a dry run
+	$opt_dry_run || {
+	  darwin_orig_dir=`pwd`
+	  cd $my_xdir || exit $?
+	  darwin_archive=$my_xabs
+	  darwin_curdir=`pwd`
+	  darwin_base_archive=`basename "$darwin_archive"`
+	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
+	  if test -n "$darwin_arches"; then
+	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
+	    darwin_arch=
+	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
+	    for darwin_arch in  $darwin_arches ; do
+	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
+	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
+	      cd "$darwin_curdir"
+	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
+	    done # $darwin_arches
+            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
+	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
+	    darwin_file=
+	    darwin_files=
+	    for darwin_file in $darwin_filelist; do
+	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
+	      $LIPO -create -output "$darwin_file" $darwin_files
+	    done # $darwin_filelist
+	    $RM -rf unfat-$$
+	    cd "$darwin_orig_dir"
+	  else
+	    cd $darwin_orig_dir
+	    func_extract_an_archive "$my_xdir" "$my_xabs"
+	  fi # $darwin_arches
+	} # !$opt_dry_run
+	;;
+      *)
+        func_extract_an_archive "$my_xdir" "$my_xabs"
+	;;
+      esac
+      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
+    done
+
+    func_extract_archives_result="$my_oldobjs"
+}
+
+
+
+# func_emit_wrapper_part1 [arg=no]
+#
+# Emit the first part of a libtool wrapper script on stdout.
+# For more information, see the description associated with
+# func_emit_wrapper(), below.
+func_emit_wrapper_part1 ()
+{
+	func_emit_wrapper_part1_arg1=no
+	if test -n "$1" ; then
+	  func_emit_wrapper_part1_arg1=$1
+	fi
+
+	$ECHO "\
+#! $SHELL
+
+# $output - temporary wrapper script for $objdir/$outputname
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# The $output program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='${SED} -e 1s/^X//'
+sed_quote_subst='$sed_quote_subst'
+
+# Be Bourne compatible
+if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '\${1+\"\$@\"}'='\"\$@\"'
+  setopt NO_GLOB_SUBST
+else
+  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+relink_command=\"$relink_command\"
+
+# This environment variable determines our operation mode.
+if test \"\$libtool_install_magic\" = \"$magic\"; then
+  # install mode needs the following variables:
+  generated_by_libtool_version='$macro_version'
+  notinst_deplibs='$notinst_deplibs'
+else
+  # When we are sourced in execute mode, \$file and \$ECHO are already set.
+  if test \"\$libtool_execute_magic\" != \"$magic\"; then
+    ECHO=\"$qecho\"
+    file=\"\$0\"
+    # Make sure echo works.
+    if test \"X\$1\" = X--no-reexec; then
+      # Discard the --no-reexec flag, and continue.
+      shift
+    elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then
+      # Yippee, \$ECHO works!
+      :
+    else
+      # Restart under the correct shell, and then maybe \$ECHO will work.
+      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
+    fi
+  fi\
+"
+	$ECHO "\
+
+  # Find the directory that this script lives in.
+  thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
+  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
+
+  # Follow symbolic links until we get to the real thisdir.
+  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
+  while test -n \"\$file\"; do
+    destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
+
+    # If there was a directory component, then change thisdir.
+    if test \"x\$destdir\" != \"x\$file\"; then
+      case \"\$destdir\" in
+      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
+      *) thisdir=\"\$thisdir/\$destdir\" ;;
+      esac
+    fi
+
+    file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
+    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
+  done
+"
+}
+# end: func_emit_wrapper_part1
+
+# func_emit_wrapper_part2 [arg=no]
+#
+# Emit the second part of a libtool wrapper script on stdout.
+# For more information, see the description associated with
+# func_emit_wrapper(), below.
+func_emit_wrapper_part2 ()
+{
+	func_emit_wrapper_part2_arg1=no
+	if test -n "$1" ; then
+	  func_emit_wrapper_part2_arg1=$1
+	fi
+
+	$ECHO "\
+
+  # Usually 'no', except on cygwin/mingw when embedded into
+  # the cwrapper.
+  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1
+  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
+    # special case for '.'
+    if test \"\$thisdir\" = \".\"; then
+      thisdir=\`pwd\`
+    fi
+    # remove .libs from thisdir
+    case \"\$thisdir\" in
+    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;;
+    $objdir )   thisdir=. ;;
+    esac
+  fi
+
+  # Try to get the absolute directory name.
+  absdir=\`cd \"\$thisdir\" && pwd\`
+  test -n \"\$absdir\" && thisdir=\"\$absdir\"
+"
+
+	if test "$fast_install" = yes; then
+	  $ECHO "\
+  program=lt-'$outputname'$exeext
+  progdir=\"\$thisdir/$objdir\"
+
+  if test ! -f \"\$progdir/\$program\" ||
+     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
+       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
+
+    file=\"\$\$-\$program\"
+
+    if test ! -d \"\$progdir\"; then
+      $MKDIR \"\$progdir\"
+    else
+      $RM \"\$progdir/\$file\"
+    fi"
+
+	  $ECHO "\
+
+    # relink executable if necessary
+    if test -n \"\$relink_command\"; then
+      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
+      else
+	$ECHO \"\$relink_command_output\" >&2
+	$RM \"\$progdir/\$file\"
+	exit 1
+      fi
+    fi
+
+    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
+    { $RM \"\$progdir/\$program\";
+      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
+    $RM \"\$progdir/\$file\"
+  fi"
+	else
+	  $ECHO "\
+  program='$outputname'
+  progdir=\"\$thisdir/$objdir\"
+"
+	fi
+
+	$ECHO "\
+
+  if test -f \"\$progdir/\$program\"; then"
+
+	# Export our shlibpath_var if we have one.
+	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+	  $ECHO "\
+    # Add our own library path to $shlibpath_var
+    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
+
+    # Some systems cannot cope with colon-terminated $shlibpath_var
+    # The second colon is a workaround for a bug in BeOS R4 sed
+    $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
+
+    export $shlibpath_var
+"
+	fi
+
+	# fixup the dll searchpath if we need to.
+	if test -n "$dllsearchpath"; then
+	  $ECHO "\
+    # Add the dll search path components to the executable PATH
+    PATH=$dllsearchpath:\$PATH
+"
+	fi
+
+	$ECHO "\
+    if test \"\$libtool_execute_magic\" != \"$magic\"; then
+      # Run the actual program with our arguments.
+"
+	case $host in
+	# Backslashes separate directories on plain windows
+	*-*-mingw | *-*-os2* | *-cegcc*)
+	  $ECHO "\
+      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
+"
+	  ;;
+
+	*)
+	  $ECHO "\
+      exec \"\$progdir/\$program\" \${1+\"\$@\"}
+"
+	  ;;
+	esac
+	$ECHO "\
+      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
+      exit 1
+    fi
+  else
+    # The program doesn't exist.
+    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
+    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
+    $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
+    exit 1
+  fi
+fi\
+"
+}
+# end: func_emit_wrapper_part2
+
+
+# func_emit_wrapper [arg=no]
+#
+# Emit a libtool wrapper script on stdout.
+# Don't directly open a file because we may want to
+# incorporate the script contents within a cygwin/mingw
+# wrapper executable.  Must ONLY be called from within
+# func_mode_link because it depends on a number of variables
+# set therein.
+#
+# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
+# variable will take.  If 'yes', then the emitted script
+# will assume that the directory in which it is stored is
+# the $objdir directory.  This is a cygwin/mingw-specific
+# behavior.
+func_emit_wrapper ()
+{
+	func_emit_wrapper_arg1=no
+	if test -n "$1" ; then
+	  func_emit_wrapper_arg1=$1
+	fi
+
+	# split this up so that func_emit_cwrapperexe_src
+	# can call each part independently.
+	func_emit_wrapper_part1 "${func_emit_wrapper_arg1}"
+	func_emit_wrapper_part2 "${func_emit_wrapper_arg1}"
+}
+
+
+# func_to_host_path arg
+#
+# Convert paths to host format when used with build tools.
+# Intended for use with "native" mingw (where libtool itself
+# is running under the msys shell), or in the following cross-
+# build environments:
+#    $build          $host
+#    mingw (msys)    mingw  [e.g. native]
+#    cygwin          mingw
+#    *nix + wine     mingw
+# where wine is equipped with the `winepath' executable.
+# In the native mingw case, the (msys) shell automatically
+# converts paths for any non-msys applications it launches,
+# but that facility isn't available from inside the cwrapper.
+# Similar accommodations are necessary for $host mingw and
+# $build cygwin.  Calling this function does no harm for other
+# $host/$build combinations not listed above.
+#
+# ARG is the path (on $build) that should be converted to
+# the proper representation for $host. The result is stored
+# in $func_to_host_path_result.
+func_to_host_path ()
+{
+  func_to_host_path_result="$1"
+  if test -n "$1" ; then
+    case $host in
+      *mingw* )
+        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
+        case $build in
+          *mingw* ) # actually, msys
+            # awkward: cmd appends spaces to result
+            lt_sed_strip_trailing_spaces="s/[ ]*\$//"
+            func_to_host_path_tmp1=`( cmd //c echo "$1" |\
+              $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
+            func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
+              $SED -e "$lt_sed_naive_backslashify"`
+            ;;
+          *cygwin* )
+            func_to_host_path_tmp1=`cygpath -w "$1"`
+            func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
+              $SED -e "$lt_sed_naive_backslashify"`
+            ;;
+          * )
+            # Unfortunately, winepath does not exit with a non-zero
+            # error code, so we are forced to check the contents of
+            # stdout. On the other hand, if the command is not
+            # found, the shell will set an exit code of 127 and print
+            # *an error message* to stdout. So we must check for both
+            # error code of zero AND non-empty stdout, which explains
+            # the odd construction:
+            func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
+            if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then
+              func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
+                $SED -e "$lt_sed_naive_backslashify"`
+            else
+              # Allow warning below.
+              func_to_host_path_result=""
+            fi
+            ;;
+        esac
+        if test -z "$func_to_host_path_result" ; then
+          func_error "Could not determine host path corresponding to"
+          func_error "  '$1'"
+          func_error "Continuing, but uninstalled executables may not work."
+          # Fallback:
+          func_to_host_path_result="$1"
+        fi
+        ;;
+    esac
+  fi
+}
+# end: func_to_host_path
+
+# func_to_host_pathlist arg
+#
+# Convert pathlists to host format when used with build tools.
+# See func_to_host_path(), above. This function supports the
+# following $build/$host combinations (but does no harm for
+# combinations not listed here):
+#    $build          $host
+#    mingw (msys)    mingw  [e.g. native]
+#    cygwin          mingw
+#    *nix + wine     mingw
+#
+# Path separators are also converted from $build format to
+# $host format. If ARG begins or ends with a path separator
+# character, it is preserved (but converted to $host format)
+# on output.
+#
+# ARG is a pathlist (on $build) that should be converted to
+# the proper representation on $host. The result is stored
+# in $func_to_host_pathlist_result.
+func_to_host_pathlist ()
+{
+  func_to_host_pathlist_result="$1"
+  if test -n "$1" ; then
+    case $host in
+      *mingw* )
+        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
+        # Remove leading and trailing path separator characters from
+        # ARG. msys behavior is inconsistent here, cygpath turns them
+        # into '.;' and ';.', and winepath ignores them completely.
+        func_to_host_pathlist_tmp2="$1"
+        # Once set for this call, this variable should not be
+        # reassigned. It is used in tha fallback case.
+        func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\
+          $SED -e 's|^:*||' -e 's|:*$||'`
+        case $build in
+          *mingw* ) # Actually, msys.
+            # Awkward: cmd appends spaces to result.
+            lt_sed_strip_trailing_spaces="s/[ ]*\$//"
+            func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\
+              $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
+            func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
+              $SED -e "$lt_sed_naive_backslashify"`
+            ;;
+          *cygwin* )
+            func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"`
+            func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
+              $SED -e "$lt_sed_naive_backslashify"`
+            ;;
+          * )
+            # unfortunately, winepath doesn't convert pathlists
+            func_to_host_pathlist_result=""
+            func_to_host_pathlist_oldIFS=$IFS
+            IFS=:
+            for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do
+              IFS=$func_to_host_pathlist_oldIFS
+              if test -n "$func_to_host_pathlist_f" ; then
+                func_to_host_path "$func_to_host_pathlist_f"
+                if test -n "$func_to_host_path_result" ; then
+                  if test -z "$func_to_host_pathlist_result" ; then
+                    func_to_host_pathlist_result="$func_to_host_path_result"
+                  else
+                    func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result"
+                  fi
+                fi
+              fi
+              IFS=:
+            done
+            IFS=$func_to_host_pathlist_oldIFS
+            ;;
+        esac
+        if test -z "$func_to_host_pathlist_result" ; then
+          func_error "Could not determine the host path(s) corresponding to"
+          func_error "  '$1'"
+          func_error "Continuing, but uninstalled executables may not work."
+          # Fallback. This may break if $1 contains DOS-style drive
+          # specifications. The fix is not to complicate the expression
+          # below, but for the user to provide a working wine installation
+          # with winepath so that path translation in the cross-to-mingw
+          # case works properly.
+          lt_replace_pathsep_nix_to_dos="s|:|;|g"
+          func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\
+            $SED -e "$lt_replace_pathsep_nix_to_dos"`
+        fi
+        # Now, add the leading and trailing path separators back
+        case "$1" in
+          :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result"
+            ;;
+        esac
+        case "$1" in
+          *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;"
+            ;;
+        esac
+        ;;
+    esac
+  fi
+}
+# end: func_to_host_pathlist
+
+# func_emit_cwrapperexe_src
+# emit the source code for a wrapper executable on stdout
+# Must ONLY be called from within func_mode_link because
+# it depends on a number of variable set therein.
+func_emit_cwrapperexe_src ()
+{
+	cat <<EOF
+
+/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
+   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+
+   The $output program cannot be directly executed until all the libtool
+   libraries that it depends on are installed.
+
+   This wrapper executable should never be moved out of the build directory.
+   If it is, it will not operate correctly.
+
+   Currently, it simply execs the wrapper *script* "$SHELL $output",
+   but could eventually absorb all of the scripts functionality and
+   exec $objdir/$outputname directly.
+*/
+EOF
+	    cat <<"EOF"
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef _MSC_VER
+# include <direct.h>
+# include <process.h>
+# include <io.h>
+# define setmode _setmode
+#else
+# include <unistd.h>
+# include <stdint.h>
+# ifdef __CYGWIN__
+#  include <io.h>
+#  define HAVE_SETENV
+#  ifdef __STRICT_ANSI__
+char *realpath (const char *, char *);
+int putenv (char *);
+int setenv (const char *, const char *, int);
+#  endif
+# endif
+#endif
+#include <malloc.h>
+#include <stdarg.h>
+#include <assert.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+#if defined(PATH_MAX)
+# define LT_PATHMAX PATH_MAX
+#elif defined(MAXPATHLEN)
+# define LT_PATHMAX MAXPATHLEN
+#else
+# define LT_PATHMAX 1024
+#endif
+
+#ifndef S_IXOTH
+# define S_IXOTH 0
+#endif
+#ifndef S_IXGRP
+# define S_IXGRP 0
+#endif
+
+#ifdef _MSC_VER
+# define S_IXUSR _S_IEXEC
+# define stat _stat
+# ifndef _INTPTR_T_DEFINED
+#  define intptr_t int
+# endif
+#endif
+
+#ifndef DIR_SEPARATOR
+# define DIR_SEPARATOR '/'
+# define PATH_SEPARATOR ':'
+#endif
+
+#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
+  defined (__OS2__)
+# define HAVE_DOS_BASED_FILE_SYSTEM
+# define FOPEN_WB "wb"
+# ifndef DIR_SEPARATOR_2
+#  define DIR_SEPARATOR_2 '\\'
+# endif
+# ifndef PATH_SEPARATOR_2
+#  define PATH_SEPARATOR_2 ';'
+# endif
+#endif
+
+#ifndef DIR_SEPARATOR_2
+# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
+#else /* DIR_SEPARATOR_2 */
+# define IS_DIR_SEPARATOR(ch) \
+	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
+#endif /* DIR_SEPARATOR_2 */
+
+#ifndef PATH_SEPARATOR_2
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
+#else /* PATH_SEPARATOR_2 */
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
+#endif /* PATH_SEPARATOR_2 */
+
+#ifdef __CYGWIN__
+# define FOPEN_WB "wb"
+#endif
+
+#ifndef FOPEN_WB
+# define FOPEN_WB "w"
+#endif
+#ifndef _O_BINARY
+# define _O_BINARY 0
+#endif
+
+#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
+#define XFREE(stale) do { \
+  if (stale) { free ((void *) stale); stale = 0; } \
+} while (0)
+
+#undef LTWRAPPER_DEBUGPRINTF
+#if defined DEBUGWRAPPER
+# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
+static void
+ltwrapper_debugprintf (const char *fmt, ...)
+{
+    va_list args;
+    va_start (args, fmt);
+    (void) vfprintf (stderr, fmt, args);
+    va_end (args);
+}
+#else
+# define LTWRAPPER_DEBUGPRINTF(args)
+#endif
+
+const char *program_name = NULL;
+
+void *xmalloc (size_t num);
+char *xstrdup (const char *string);
+const char *base_name (const char *name);
+char *find_executable (const char *wrapper);
+char *chase_symlinks (const char *pathspec);
+int make_executable (const char *path);
+int check_executable (const char *path);
+char *strendzap (char *str, const char *pat);
+void lt_fatal (const char *message, ...);
+void lt_setenv (const char *name, const char *value);
+char *lt_extend_str (const char *orig_value, const char *add, int to_end);
+void lt_opt_process_env_set (const char *arg);
+void lt_opt_process_env_prepend (const char *arg);
+void lt_opt_process_env_append (const char *arg);
+int lt_split_name_value (const char *arg, char** name, char** value);
+void lt_update_exe_path (const char *name, const char *value);
+void lt_update_lib_path (const char *name, const char *value);
+
+static const char *script_text_part1 =
+EOF
+
+	    func_emit_wrapper_part1 yes |
+	        $SED -e 's/\([\\"]\)/\\\1/g' \
+	             -e 's/^/  "/' -e 's/$/\\n"/'
+	    echo ";"
+	    cat <<EOF
+
+static const char *script_text_part2 =
+EOF
+	    func_emit_wrapper_part2 yes |
+	        $SED -e 's/\([\\"]\)/\\\1/g' \
+	             -e 's/^/  "/' -e 's/$/\\n"/'
+	    echo ";"
+
+	    cat <<EOF
+const char * MAGIC_EXE = "$magic_exe";
+const char * LIB_PATH_VARNAME = "$shlibpath_var";
+EOF
+
+	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+              func_to_host_pathlist "$temp_rpath"
+	      cat <<EOF
+const char * LIB_PATH_VALUE   = "$func_to_host_pathlist_result";
+EOF
+	    else
+	      cat <<"EOF"
+const char * LIB_PATH_VALUE   = "";
+EOF
+	    fi
+
+	    if test -n "$dllsearchpath"; then
+              func_to_host_pathlist "$dllsearchpath:"
+	      cat <<EOF
+const char * EXE_PATH_VARNAME = "PATH";
+const char * EXE_PATH_VALUE   = "$func_to_host_pathlist_result";
+EOF
+	    else
+	      cat <<"EOF"
+const char * EXE_PATH_VARNAME = "";
+const char * EXE_PATH_VALUE   = "";
+EOF
+	    fi
+
+	    if test "$fast_install" = yes; then
+	      cat <<EOF
+const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
+EOF
+	    else
+	      cat <<EOF
+const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
+EOF
+	    fi
+
+
+	    cat <<"EOF"
+
+#define LTWRAPPER_OPTION_PREFIX         "--lt-"
+#define LTWRAPPER_OPTION_PREFIX_LENGTH  5
+
+static const size_t opt_prefix_len         = LTWRAPPER_OPTION_PREFIX_LENGTH;
+static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
+
+static const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
+
+static const size_t env_set_opt_len     = LTWRAPPER_OPTION_PREFIX_LENGTH + 7;
+static const char *env_set_opt          = LTWRAPPER_OPTION_PREFIX "env-set";
+  /* argument is putenv-style "foo=bar", value of foo is set to bar */
+
+static const size_t env_prepend_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 11;
+static const char *env_prepend_opt      = LTWRAPPER_OPTION_PREFIX "env-prepend";
+  /* argument is putenv-style "foo=bar", new value of foo is bar${foo} */
+
+static const size_t env_append_opt_len  = LTWRAPPER_OPTION_PREFIX_LENGTH + 10;
+static const char *env_append_opt       = LTWRAPPER_OPTION_PREFIX "env-append";
+  /* argument is putenv-style "foo=bar", new value of foo is ${foo}bar */
+
+int
+main (int argc, char *argv[])
+{
+  char **newargz;
+  int  newargc;
+  char *tmp_pathspec;
+  char *actual_cwrapper_path;
+  char *actual_cwrapper_name;
+  char *target_name;
+  char *lt_argv_zero;
+  intptr_t rval = 127;
+
+  int i;
+
+  program_name = (char *) xstrdup (base_name (argv[0]));
+  LTWRAPPER_DEBUGPRINTF (("(main) argv[0]      : %s\n", argv[0]));
+  LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name));
+
+  /* very simple arg parsing; don't want to rely on getopt */
+  for (i = 1; i < argc; i++)
+    {
+      if (strcmp (argv[i], dumpscript_opt) == 0)
+	{
+EOF
+	    case "$host" in
+	      *mingw* | *cygwin* )
+		# make stdout use "unix" line endings
+		echo "          setmode(1,_O_BINARY);"
+		;;
+	      esac
+
+	    cat <<"EOF"
+	  printf ("%s", script_text_part1);
+	  printf ("%s", script_text_part2);
+	  return 0;
+	}
+    }
+
+  newargz = XMALLOC (char *, argc + 1);
+  tmp_pathspec = find_executable (argv[0]);
+  if (tmp_pathspec == NULL)
+    lt_fatal ("Couldn't find %s", argv[0]);
+  LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n",
+			  tmp_pathspec));
+
+  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
+  LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n",
+			  actual_cwrapper_path));
+  XFREE (tmp_pathspec);
+
+  actual_cwrapper_name = xstrdup( base_name (actual_cwrapper_path));
+  strendzap (actual_cwrapper_path, actual_cwrapper_name);
+
+  /* wrapper name transforms */
+  strendzap (actual_cwrapper_name, ".exe");
+  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
+  XFREE (actual_cwrapper_name);
+  actual_cwrapper_name = tmp_pathspec;
+  tmp_pathspec = 0;
+
+  /* target_name transforms -- use actual target program name; might have lt- prefix */
+  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
+  strendzap (target_name, ".exe");
+  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
+  XFREE (target_name);
+  target_name = tmp_pathspec;
+  tmp_pathspec = 0;
+
+  LTWRAPPER_DEBUGPRINTF (("(main) libtool target name: %s\n",
+			  target_name));
+EOF
+
+	    cat <<EOF
+  newargz[0] =
+    XMALLOC (char, (strlen (actual_cwrapper_path) +
+		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
+  strcpy (newargz[0], actual_cwrapper_path);
+  strcat (newargz[0], "$objdir");
+  strcat (newargz[0], "/");
+EOF
+
+	    cat <<"EOF"
+  /* stop here, and copy so we don't have to do this twice */
+  tmp_pathspec = xstrdup (newargz[0]);
+
+  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
+  strcat (newargz[0], actual_cwrapper_name);
+
+  /* DO want the lt- prefix here if it exists, so use target_name */
+  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
+  XFREE (tmp_pathspec);
+  tmp_pathspec = NULL;
+EOF
+
+	    case $host_os in
+	      mingw*)
+	    cat <<"EOF"
+  {
+    char* p;
+    while ((p = strchr (newargz[0], '\\')) != NULL)
+      {
+	*p = '/';
+      }
+    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
+      {
+	*p = '/';
+      }
+  }
+EOF
+	    ;;
+	    esac
+
+	    cat <<"EOF"
+  XFREE (target_name);
+  XFREE (actual_cwrapper_path);
+  XFREE (actual_cwrapper_name);
+
+  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
+  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
+  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
+  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
+
+  newargc=0;
+  for (i = 1; i < argc; i++)
+    {
+      if (strncmp (argv[i], env_set_opt, env_set_opt_len) == 0)
+        {
+          if (argv[i][env_set_opt_len] == '=')
+            {
+              const char *p = argv[i] + env_set_opt_len + 1;
+              lt_opt_process_env_set (p);
+            }
+          else if (argv[i][env_set_opt_len] == '\0' && i + 1 < argc)
+            {
+              lt_opt_process_env_set (argv[++i]); /* don't copy */
+            }
+          else
+            lt_fatal ("%s missing required argument", env_set_opt);
+          continue;
+        }
+      if (strncmp (argv[i], env_prepend_opt, env_prepend_opt_len) == 0)
+        {
+          if (argv[i][env_prepend_opt_len] == '=')
+            {
+              const char *p = argv[i] + env_prepend_opt_len + 1;
+              lt_opt_process_env_prepend (p);
+            }
+          else if (argv[i][env_prepend_opt_len] == '\0' && i + 1 < argc)
+            {
+              lt_opt_process_env_prepend (argv[++i]); /* don't copy */
+            }
+          else
+            lt_fatal ("%s missing required argument", env_prepend_opt);
+          continue;
+        }
+      if (strncmp (argv[i], env_append_opt, env_append_opt_len) == 0)
+        {
+          if (argv[i][env_append_opt_len] == '=')
+            {
+              const char *p = argv[i] + env_append_opt_len + 1;
+              lt_opt_process_env_append (p);
+            }
+          else if (argv[i][env_append_opt_len] == '\0' && i + 1 < argc)
+            {
+              lt_opt_process_env_append (argv[++i]); /* don't copy */
+            }
+          else
+            lt_fatal ("%s missing required argument", env_append_opt);
+          continue;
+        }
+      if (strncmp (argv[i], ltwrapper_option_prefix, opt_prefix_len) == 0)
+        {
+          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
+             namespace, but it is not one of the ones we know about and
+             have already dealt with, above (inluding dump-script), then
+             report an error. Otherwise, targets might begin to believe
+             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
+             namespace. The first time any user complains about this, we'll
+             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
+             or a configure.ac-settable value.
+           */
+          lt_fatal ("Unrecognized option in %s namespace: '%s'",
+                    ltwrapper_option_prefix, argv[i]);
+        }
+      /* otherwise ... */
+      newargz[++newargc] = xstrdup (argv[i]);
+    }
+  newargz[++newargc] = NULL;
+
+  LTWRAPPER_DEBUGPRINTF     (("(main) lt_argv_zero : %s\n", (lt_argv_zero ? lt_argv_zero : "<NULL>")));
+  for (i = 0; i < newargc; i++)
+    {
+      LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d]   : %s\n", i, (newargz[i] ? newargz[i] : "<NULL>")));
+    }
+
+EOF
+
+	    case $host_os in
+	      mingw*)
+		cat <<"EOF"
+  /* execv doesn't actually work on mingw as expected on unix */
+  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
+  if (rval == -1)
+    {
+      /* failed to start process */
+      LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno));
+      return 127;
+    }
+  return rval;
+EOF
+		;;
+	      *)
+		cat <<"EOF"
+  execv (lt_argv_zero, newargz);
+  return rval; /* =127, but avoids unused variable warning */
+EOF
+		;;
+	    esac
+
+	    cat <<"EOF"
+}
+
+void *
+xmalloc (size_t num)
+{
+  void *p = (void *) malloc (num);
+  if (!p)
+    lt_fatal ("Memory exhausted");
+
+  return p;
+}
+
+char *
+xstrdup (const char *string)
+{
+  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
+			  string) : NULL;
+}
+
+const char *
+base_name (const char *name)
+{
+  const char *base;
+
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+  /* Skip over the disk name in MSDOS pathnames. */
+  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
+    name += 2;
+#endif
+
+  for (base = name; *name; name++)
+    if (IS_DIR_SEPARATOR (*name))
+      base = name + 1;
+  return base;
+}
+
+int
+check_executable (const char *path)
+{
+  struct stat st;
+
+  LTWRAPPER_DEBUGPRINTF (("(check_executable)  : %s\n",
+			  path ? (*path ? path : "EMPTY!") : "NULL!"));
+  if ((!path) || (!*path))
+    return 0;
+
+  if ((stat (path, &st) >= 0)
+      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
+    return 1;
+  else
+    return 0;
+}
+
+int
+make_executable (const char *path)
+{
+  int rval = 0;
+  struct stat st;
+
+  LTWRAPPER_DEBUGPRINTF (("(make_executable)   : %s\n",
+			  path ? (*path ? path : "EMPTY!") : "NULL!"));
+  if ((!path) || (!*path))
+    return 0;
+
+  if (stat (path, &st) >= 0)
+    {
+      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
+    }
+  return rval;
+}
+
+/* Searches for the full path of the wrapper.  Returns
+   newly allocated full path name if found, NULL otherwise
+   Does not chase symlinks, even on platforms that support them.
+*/
+char *
+find_executable (const char *wrapper)
+{
+  int has_slash = 0;
+  const char *p;
+  const char *p_next;
+  /* static buffer for getcwd */
+  char tmp[LT_PATHMAX + 1];
+  int tmp_len;
+  char *concat_name;
+
+  LTWRAPPER_DEBUGPRINTF (("(find_executable)   : %s\n",
+			  wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"));
+
+  if ((wrapper == NULL) || (*wrapper == '\0'))
+    return NULL;
+
+  /* Absolute path? */
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
+    {
+      concat_name = xstrdup (wrapper);
+      if (check_executable (concat_name))
+	return concat_name;
+      XFREE (concat_name);
+    }
+  else
+    {
+#endif
+      if (IS_DIR_SEPARATOR (wrapper[0]))
+	{
+	  concat_name = xstrdup (wrapper);
+	  if (check_executable (concat_name))
+	    return concat_name;
+	  XFREE (concat_name);
+	}
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+    }
+#endif
+
+  for (p = wrapper; *p; p++)
+    if (*p == '/')
+      {
+	has_slash = 1;
+	break;
+      }
+  if (!has_slash)
+    {
+      /* no slashes; search PATH */
+      const char *path = getenv ("PATH");
+      if (path != NULL)
+	{
+	  for (p = path; *p; p = p_next)
+	    {
+	      const char *q;
+	      size_t p_len;
+	      for (q = p; *q; q++)
+		if (IS_PATH_SEPARATOR (*q))
+		  break;
+	      p_len = q - p;
+	      p_next = (*q == '\0' ? q : q + 1);
+	      if (p_len == 0)
+		{
+		  /* empty path: current directory */
+		  if (getcwd (tmp, LT_PATHMAX) == NULL)
+		    lt_fatal ("getcwd failed");
+		  tmp_len = strlen (tmp);
+		  concat_name =
+		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
+		  memcpy (concat_name, tmp, tmp_len);
+		  concat_name[tmp_len] = '/';
+		  strcpy (concat_name + tmp_len + 1, wrapper);
+		}
+	      else
+		{
+		  concat_name =
+		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
+		  memcpy (concat_name, p, p_len);
+		  concat_name[p_len] = '/';
+		  strcpy (concat_name + p_len + 1, wrapper);
+		}
+	      if (check_executable (concat_name))
+		return concat_name;
+	      XFREE (concat_name);
+	    }
+	}
+      /* not found in PATH; assume curdir */
+    }
+  /* Relative path | not found in path: prepend cwd */
+  if (getcwd (tmp, LT_PATHMAX) == NULL)
+    lt_fatal ("getcwd failed");
+  tmp_len = strlen (tmp);
+  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
+  memcpy (concat_name, tmp, tmp_len);
+  concat_name[tmp_len] = '/';
+  strcpy (concat_name + tmp_len + 1, wrapper);
+
+  if (check_executable (concat_name))
+    return concat_name;
+  XFREE (concat_name);
+  return NULL;
+}
+
+char *
+chase_symlinks (const char *pathspec)
+{
+#ifndef S_ISLNK
+  return xstrdup (pathspec);
+#else
+  char buf[LT_PATHMAX];
+  struct stat s;
+  char *tmp_pathspec = xstrdup (pathspec);
+  char *p;
+  int has_symlinks = 0;
+  while (strlen (tmp_pathspec) && !has_symlinks)
+    {
+      LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n",
+			      tmp_pathspec));
+      if (lstat (tmp_pathspec, &s) == 0)
+	{
+	  if (S_ISLNK (s.st_mode) != 0)
+	    {
+	      has_symlinks = 1;
+	      break;
+	    }
+
+	  /* search backwards for last DIR_SEPARATOR */
+	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
+	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
+	    p--;
+	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
+	    {
+	      /* no more DIR_SEPARATORS left */
+	      break;
+	    }
+	  *p = '\0';
+	}
+      else
+	{
+	  char *errstr = strerror (errno);
+	  lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
+	}
+    }
+  XFREE (tmp_pathspec);
+
+  if (!has_symlinks)
+    {
+      return xstrdup (pathspec);
+    }
+
+  tmp_pathspec = realpath (pathspec, buf);
+  if (tmp_pathspec == 0)
+    {
+      lt_fatal ("Could not follow symlinks for %s", pathspec);
+    }
+  return xstrdup (tmp_pathspec);
+#endif
+}
+
+char *
+strendzap (char *str, const char *pat)
+{
+  size_t len, patlen;
+
+  assert (str != NULL);
+  assert (pat != NULL);
+
+  len = strlen (str);
+  patlen = strlen (pat);
+
+  if (patlen <= len)
+    {
+      str += len - patlen;
+      if (strcmp (str, pat) == 0)
+	*str = '\0';
+    }
+  return str;
+}
+
+static void
+lt_error_core (int exit_status, const char *mode,
+	       const char *message, va_list ap)
+{
+  fprintf (stderr, "%s: %s: ", program_name, mode);
+  vfprintf (stderr, message, ap);
+  fprintf (stderr, ".\n");
+
+  if (exit_status >= 0)
+    exit (exit_status);
+}
+
+void
+lt_fatal (const char *message, ...)
+{
+  va_list ap;
+  va_start (ap, message);
+  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
+  va_end (ap);
+}
+
+void
+lt_setenv (const char *name, const char *value)
+{
+  LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n",
+                          (name ? name : "<NULL>"),
+                          (value ? value : "<NULL>")));
+  {
+#ifdef HAVE_SETENV
+    /* always make a copy, for consistency with !HAVE_SETENV */
+    char *str = xstrdup (value);
+    setenv (name, str, 1);
+#else
+    int len = strlen (name) + 1 + strlen (value) + 1;
+    char *str = XMALLOC (char, len);
+    sprintf (str, "%s=%s", name, value);
+    if (putenv (str) != EXIT_SUCCESS)
+      {
+        XFREE (str);
+      }
+#endif
+  }
+}
+
+char *
+lt_extend_str (const char *orig_value, const char *add, int to_end)
+{
+  char *new_value;
+  if (orig_value && *orig_value)
+    {
+      int orig_value_len = strlen (orig_value);
+      int add_len = strlen (add);
+      new_value = XMALLOC (char, add_len + orig_value_len + 1);
+      if (to_end)
+        {
+          strcpy (new_value, orig_value);
+          strcpy (new_value + orig_value_len, add);
+        }
+      else
+        {
+          strcpy (new_value, add);
+          strcpy (new_value + add_len, orig_value);
+        }
+    }
+  else
+    {
+      new_value = xstrdup (add);
+    }
+  return new_value;
+}
+
+int
+lt_split_name_value (const char *arg, char** name, char** value)
+{
+  const char *p;
+  int len;
+  if (!arg || !*arg)
+    return 1;
+
+  p = strchr (arg, (int)'=');
+
+  if (!p)
+    return 1;
+
+  *value = xstrdup (++p);
+
+  len = strlen (arg) - strlen (*value);
+  *name = XMALLOC (char, len);
+  strncpy (*name, arg, len-1);
+  (*name)[len - 1] = '\0';
+
+  return 0;
+}
+
+void
+lt_opt_process_env_set (const char *arg)
+{
+  char *name = NULL;
+  char *value = NULL;
+
+  if (lt_split_name_value (arg, &name, &value) != 0)
+    {
+      XFREE (name);
+      XFREE (value);
+      lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg);
+    }
+
+  lt_setenv (name, value);
+  XFREE (name);
+  XFREE (value);
+}
+
+void
+lt_opt_process_env_prepend (const char *arg)
+{
+  char *name = NULL;
+  char *value = NULL;
+  char *new_value = NULL;
+
+  if (lt_split_name_value (arg, &name, &value) != 0)
+    {
+      XFREE (name);
+      XFREE (value);
+      lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg);
+    }
+
+  new_value = lt_extend_str (getenv (name), value, 0);
+  lt_setenv (name, new_value);
+  XFREE (new_value);
+  XFREE (name);
+  XFREE (value);
+}
+
+void
+lt_opt_process_env_append (const char *arg)
+{
+  char *name = NULL;
+  char *value = NULL;
+  char *new_value = NULL;
+
+  if (lt_split_name_value (arg, &name, &value) != 0)
+    {
+      XFREE (name);
+      XFREE (value);
+      lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg);
+    }
+
+  new_value = lt_extend_str (getenv (name), value, 1);
+  lt_setenv (name, new_value);
+  XFREE (new_value);
+  XFREE (name);
+  XFREE (value);
+}
+
+void
+lt_update_exe_path (const char *name, const char *value)
+{
+  LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
+                          (name ? name : "<NULL>"),
+                          (value ? value : "<NULL>")));
+
+  if (name && *name && value && *value)
+    {
+      char *new_value = lt_extend_str (getenv (name), value, 0);
+      /* some systems can't cope with a ':'-terminated path #' */
+      int len = strlen (new_value);
+      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
+        {
+          new_value[len-1] = '\0';
+        }
+      lt_setenv (name, new_value);
+      XFREE (new_value);
+    }
+}
+
+void
+lt_update_lib_path (const char *name, const char *value)
+{
+  LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
+                          (name ? name : "<NULL>"),
+                          (value ? value : "<NULL>")));
+
+  if (name && *name && value && *value)
+    {
+      char *new_value = lt_extend_str (getenv (name), value, 0);
+      lt_setenv (name, new_value);
+      XFREE (new_value);
+    }
+}
+
+
+EOF
+}
+# end: func_emit_cwrapperexe_src
+
+# func_mode_link arg...
+func_mode_link ()
+{
+    $opt_debug
+    case $host in
+    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+      # It is impossible to link a dll without this setting, and
+      # we shouldn't force the makefile maintainer to figure out
+      # which system we are compiling for in order to pass an extra
+      # flag for every libtool invocation.
+      # allow_undefined=no
+
+      # FIXME: Unfortunately, there are problems with the above when trying
+      # to make a dll which has undefined symbols, in which case not
+      # even a static library is built.  For now, we need to specify
+      # -no-undefined on the libtool link line when we can be certain
+      # that all symbols are satisfied, otherwise we get a static library.
+      allow_undefined=yes
+      ;;
+    *)
+      allow_undefined=yes
+      ;;
+    esac
+    libtool_args=$nonopt
+    base_compile="$nonopt $@"
+    compile_command=$nonopt
+    finalize_command=$nonopt
+
+    compile_rpath=
+    finalize_rpath=
+    compile_shlibpath=
+    finalize_shlibpath=
+    convenience=
+    old_convenience=
+    deplibs=
+    old_deplibs=
+    compiler_flags=
+    linker_flags=
+    dllsearchpath=
+    lib_search_path=`pwd`
+    inst_prefix_dir=
+    new_inherited_linker_flags=
+
+    avoid_version=no
+    dlfiles=
+    dlprefiles=
+    dlself=no
+    export_dynamic=no
+    export_symbols=
+    export_symbols_regex=
+    generated=
+    libobjs=
+    ltlibs=
+    module=no
+    no_install=no
+    objs=
+    non_pic_objects=
+    precious_files_regex=
+    prefer_static_libs=no
+    preload=no
+    prev=
+    prevarg=
+    release=
+    rpath=
+    xrpath=
+    perm_rpath=
+    temp_rpath=
+    thread_safe=no
+    vinfo=
+    vinfo_number=no
+    weak_libs=
+    single_module="${wl}-single_module"
+    func_infer_tag $base_compile
+
+    # We need to know -static, to get the right output filenames.
+    for arg
+    do
+      case $arg in
+      -shared)
+	test "$build_libtool_libs" != yes && \
+	  func_fatal_configuration "can not build a shared library"
+	build_old_libs=no
+	break
+	;;
+      -all-static | -static | -static-libtool-libs)
+	case $arg in
+	-all-static)
+	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
+	    func_warning "complete static linking is impossible in this configuration"
+	  fi
+	  if test -n "$link_static_flag"; then
+	    dlopen_self=$dlopen_self_static
+	  fi
+	  prefer_static_libs=yes
+	  ;;
+	-static)
+	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
+	    dlopen_self=$dlopen_self_static
+	  fi
+	  prefer_static_libs=built
+	  ;;
+	-static-libtool-libs)
+	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
+	    dlopen_self=$dlopen_self_static
+	  fi
+	  prefer_static_libs=yes
+	  ;;
+	esac
+	build_libtool_libs=no
+	build_old_libs=yes
+	break
+	;;
+      esac
+    done
+
+    # See if our shared archives depend on static archives.
+    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
+
+    # Go through the arguments, transforming them on the way.
+    while test "$#" -gt 0; do
+      arg="$1"
+      shift
+      func_quote_for_eval "$arg"
+      qarg=$func_quote_for_eval_unquoted_result
+      func_append libtool_args " $func_quote_for_eval_result"
+
+      # If the previous option needs an argument, assign it.
+      if test -n "$prev"; then
+	case $prev in
+	output)
+	  func_append compile_command " @OUTPUT@"
+	  func_append finalize_command " @OUTPUT@"
+	  ;;
+	esac
+
+	case $prev in
+	dlfiles|dlprefiles)
+	  if test "$preload" = no; then
+	    # Add the symbol object into the linking commands.
+	    func_append compile_command " @SYMFILE@"
+	    func_append finalize_command " @SYMFILE@"
+	    preload=yes
+	  fi
+	  case $arg in
+	  *.la | *.lo) ;;  # We handle these cases below.
+	  force)
+	    if test "$dlself" = no; then
+	      dlself=needless
+	      export_dynamic=yes
+	    fi
+	    prev=
+	    continue
+	    ;;
+	  self)
+	    if test "$prev" = dlprefiles; then
+	      dlself=yes
+	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
+	      dlself=yes
+	    else
+	      dlself=needless
+	      export_dynamic=yes
+	    fi
+	    prev=
+	    continue
+	    ;;
+	  *)
+	    if test "$prev" = dlfiles; then
+	      dlfiles="$dlfiles $arg"
+	    else
+	      dlprefiles="$dlprefiles $arg"
+	    fi
+	    prev=
+	    continue
+	    ;;
+	  esac
+	  ;;
+	expsyms)
+	  export_symbols="$arg"
+	  test -f "$arg" \
+	    || func_fatal_error "symbol file \`$arg' does not exist"
+	  prev=
+	  continue
+	  ;;
+	expsyms_regex)
+	  export_symbols_regex="$arg"
+	  prev=
+	  continue
+	  ;;
+	framework)
+	  case $host in
+	    *-*-darwin*)
+	      case "$deplibs " in
+		*" $qarg.ltframework "*) ;;
+		*) deplibs="$deplibs $qarg.ltframework" # this is fixed later
+		   ;;
+	      esac
+	      ;;
+	  esac
+	  prev=
+	  continue
+	  ;;
+	inst_prefix)
+	  inst_prefix_dir="$arg"
+	  prev=
+	  continue
+	  ;;
+	objectlist)
+	  if test -f "$arg"; then
+	    save_arg=$arg
+	    moreargs=
+	    for fil in `cat "$save_arg"`
+	    do
+#	      moreargs="$moreargs $fil"
+	      arg=$fil
+	      # A libtool-controlled object.
+
+	      # Check to see that this really is a libtool object.
+	      if func_lalib_unsafe_p "$arg"; then
+		pic_object=
+		non_pic_object=
+
+		# Read the .lo file
+		func_source "$arg"
+
+		if test -z "$pic_object" ||
+		   test -z "$non_pic_object" ||
+		   test "$pic_object" = none &&
+		   test "$non_pic_object" = none; then
+		  func_fatal_error "cannot find name of object for \`$arg'"
+		fi
+
+		# Extract subdirectory from the argument.
+		func_dirname "$arg" "/" ""
+		xdir="$func_dirname_result"
+
+		if test "$pic_object" != none; then
+		  # Prepend the subdirectory the object is found in.
+		  pic_object="$xdir$pic_object"
+
+		  if test "$prev" = dlfiles; then
+		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+		      dlfiles="$dlfiles $pic_object"
+		      prev=
+		      continue
+		    else
+		      # If libtool objects are unsupported, then we need to preload.
+		      prev=dlprefiles
+		    fi
+		  fi
+
+		  # CHECK ME:  I think I busted this.  -Ossama
+		  if test "$prev" = dlprefiles; then
+		    # Preload the old-style object.
+		    dlprefiles="$dlprefiles $pic_object"
+		    prev=
+		  fi
+
+		  # A PIC object.
+		  func_append libobjs " $pic_object"
+		  arg="$pic_object"
+		fi
+
+		# Non-PIC object.
+		if test "$non_pic_object" != none; then
+		  # Prepend the subdirectory the object is found in.
+		  non_pic_object="$xdir$non_pic_object"
+
+		  # A standard non-PIC object
+		  func_append non_pic_objects " $non_pic_object"
+		  if test -z "$pic_object" || test "$pic_object" = none ; then
+		    arg="$non_pic_object"
+		  fi
+		else
+		  # If the PIC object exists, use it instead.
+		  # $xdir was prepended to $pic_object above.
+		  non_pic_object="$pic_object"
+		  func_append non_pic_objects " $non_pic_object"
+		fi
+	      else
+		# Only an error if not doing a dry-run.
+		if $opt_dry_run; then
+		  # Extract subdirectory from the argument.
+		  func_dirname "$arg" "/" ""
+		  xdir="$func_dirname_result"
+
+		  func_lo2o "$arg"
+		  pic_object=$xdir$objdir/$func_lo2o_result
+		  non_pic_object=$xdir$func_lo2o_result
+		  func_append libobjs " $pic_object"
+		  func_append non_pic_objects " $non_pic_object"
+	        else
+		  func_fatal_error "\`$arg' is not a valid libtool object"
+		fi
+	      fi
+	    done
+	  else
+	    func_fatal_error "link input file \`$arg' does not exist"
+	  fi
+	  arg=$save_arg
+	  prev=
+	  continue
+	  ;;
+	precious_regex)
+	  precious_files_regex="$arg"
+	  prev=
+	  continue
+	  ;;
+	release)
+	  release="-$arg"
+	  prev=
+	  continue
+	  ;;
+	rpath | xrpath)
+	  # We need an absolute path.
+	  case $arg in
+	  [\\/]* | [A-Za-z]:[\\/]*) ;;
+	  *)
+	    func_fatal_error "only absolute run-paths are allowed"
+	    ;;
+	  esac
+	  if test "$prev" = rpath; then
+	    case "$rpath " in
+	    *" $arg "*) ;;
+	    *) rpath="$rpath $arg" ;;
+	    esac
+	  else
+	    case "$xrpath " in
+	    *" $arg "*) ;;
+	    *) xrpath="$xrpath $arg" ;;
+	    esac
+	  fi
+	  prev=
+	  continue
+	  ;;
+	shrext)
+	  shrext_cmds="$arg"
+	  prev=
+	  continue
+	  ;;
+	weak)
+	  weak_libs="$weak_libs $arg"
+	  prev=
+	  continue
+	  ;;
+	xcclinker)
+	  linker_flags="$linker_flags $qarg"
+	  compiler_flags="$compiler_flags $qarg"
+	  prev=
+	  func_append compile_command " $qarg"
+	  func_append finalize_command " $qarg"
+	  continue
+	  ;;
+	xcompiler)
+	  compiler_flags="$compiler_flags $qarg"
+	  prev=
+	  func_append compile_command " $qarg"
+	  func_append finalize_command " $qarg"
+	  continue
+	  ;;
+	xlinker)
+	  linker_flags="$linker_flags $qarg"
+	  compiler_flags="$compiler_flags $wl$qarg"
+	  prev=
+	  func_append compile_command " $wl$qarg"
+	  func_append finalize_command " $wl$qarg"
+	  continue
+	  ;;
+	*)
+	  eval "$prev=\"\$arg\""
+	  prev=
+	  continue
+	  ;;
+	esac
+      fi # test -n "$prev"
+
+      prevarg="$arg"
+
+      case $arg in
+      -all-static)
+	if test -n "$link_static_flag"; then
+	  # See comment for -static flag below, for more details.
+	  func_append compile_command " $link_static_flag"
+	  func_append finalize_command " $link_static_flag"
+	fi
+	continue
+	;;
+
+      -allow-undefined)
+	# FIXME: remove this flag sometime in the future.
+	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
+	;;
+
+      -avoid-version)
+	avoid_version=yes
+	continue
+	;;
+
+      -dlopen)
+	prev=dlfiles
+	continue
+	;;
+
+      -dlpreopen)
+	prev=dlprefiles
+	continue
+	;;
+
+      -export-dynamic)
+	export_dynamic=yes
+	continue
+	;;
+
+      -export-symbols | -export-symbols-regex)
+	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+	  func_fatal_error "more than one -exported-symbols argument is not allowed"
+	fi
+	if test "X$arg" = "X-export-symbols"; then
+	  prev=expsyms
+	else
+	  prev=expsyms_regex
+	fi
+	continue
+	;;
+
+      -framework)
+	prev=framework
+	continue
+	;;
+
+      -inst-prefix-dir)
+	prev=inst_prefix
+	continue
+	;;
+
+      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
+      # so, if we see these flags be careful not to treat them like -L
+      -L[A-Z][A-Z]*:*)
+	case $with_gcc/$host in
+	no/*-*-irix* | /*-*-irix*)
+	  func_append compile_command " $arg"
+	  func_append finalize_command " $arg"
+	  ;;
+	esac
+	continue
+	;;
+
+      -L*)
+	func_stripname '-L' '' "$arg"
+	dir=$func_stripname_result
+	if test -z "$dir"; then
+	  if test "$#" -gt 0; then
+	    func_fatal_error "require no space between \`-L' and \`$1'"
+	  else
+	    func_fatal_error "need path for \`-L' option"
+	  fi
+	fi
+	# We need an absolute path.
+	case $dir in
+	[\\/]* | [A-Za-z]:[\\/]*) ;;
+	*)
+	  absdir=`cd "$dir" && pwd`
+	  test -z "$absdir" && \
+	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
+	  dir="$absdir"
+	  ;;
+	esac
+	case "$deplibs " in
+	*" -L$dir "*) ;;
+	*)
+	  deplibs="$deplibs -L$dir"
+	  lib_search_path="$lib_search_path $dir"
+	  ;;
+	esac
+	case $host in
+	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+	  testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'`
+	  case :$dllsearchpath: in
+	  *":$dir:"*) ;;
+	  ::) dllsearchpath=$dir;;
+	  *) dllsearchpath="$dllsearchpath:$dir";;
+	  esac
+	  case :$dllsearchpath: in
+	  *":$testbindir:"*) ;;
+	  ::) dllsearchpath=$testbindir;;
+	  *) dllsearchpath="$dllsearchpath:$testbindir";;
+	  esac
+	  ;;
+	esac
+	continue
+	;;
+
+      -l*)
+	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
+	  case $host in
+	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*)
+	    # These systems don't actually have a C or math library (as such)
+	    continue
+	    ;;
+	  *-*-os2*)
+	    # These systems don't actually have a C library (as such)
+	    test "X$arg" = "X-lc" && continue
+	    ;;
+	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	    # Do not include libc due to us having libc/libc_r.
+	    test "X$arg" = "X-lc" && continue
+	    ;;
+	  *-*-rhapsody* | *-*-darwin1.[012])
+	    # Rhapsody C and math libraries are in the System framework
+	    deplibs="$deplibs System.ltframework"
+	    continue
+	    ;;
+	  *-*-sco3.2v5* | *-*-sco5v6*)
+	    # Causes problems with __ctype
+	    test "X$arg" = "X-lc" && continue
+	    ;;
+	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+	    # Compiler inserts libc in the correct place for threads to work
+	    test "X$arg" = "X-lc" && continue
+	    ;;
+	  esac
+	elif test "X$arg" = "X-lc_r"; then
+	 case $host in
+	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	   # Do not include libc_r directly, use -pthread flag.
+	   continue
+	   ;;
+	 esac
+	fi
+	deplibs="$deplibs $arg"
+	continue
+	;;
+
+      -module)
+	module=yes
+	continue
+	;;
+
+      # Tru64 UNIX uses -model [arg] to determine the layout of C++
+      # classes, name mangling, and exception handling.
+      # Darwin uses the -arch flag to determine output architecture.
+      -model|-arch|-isysroot)
+	compiler_flags="$compiler_flags $arg"
+	func_append compile_command " $arg"
+	func_append finalize_command " $arg"
+	prev=xcompiler
+	continue
+	;;
+
+      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
+	compiler_flags="$compiler_flags $arg"
+	func_append compile_command " $arg"
+	func_append finalize_command " $arg"
+	case "$new_inherited_linker_flags " in
+	    *" $arg "*) ;;
+	    * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
+	esac
+	continue
+	;;
+
+      -multi_module)
+	single_module="${wl}-multi_module"
+	continue
+	;;
+
+      -no-fast-install)
+	fast_install=no
+	continue
+	;;
+
+      -no-install)
+	case $host in
+	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
+	  # The PATH hackery in wrapper scripts is required on Windows
+	  # and Darwin in order for the loader to find any dlls it needs.
+	  func_warning "\`-no-install' is ignored for $host"
+	  func_warning "assuming \`-no-fast-install' instead"
+	  fast_install=no
+	  ;;
+	*) no_install=yes ;;
+	esac
+	continue
+	;;
+
+      -no-undefined)
+	allow_undefined=no
+	continue
+	;;
+
+      -objectlist)
+	prev=objectlist
+	continue
+	;;
+
+      -o) prev=output ;;
+
+      -precious-files-regex)
+	prev=precious_regex
+	continue
+	;;
+
+      -release)
+	prev=release
+	continue
+	;;
+
+      -rpath)
+	prev=rpath
+	continue
+	;;
+
+      -R)
+	prev=xrpath
+	continue
+	;;
+
+      -R*)
+	func_stripname '-R' '' "$arg"
+	dir=$func_stripname_result
+	# We need an absolute path.
+	case $dir in
+	[\\/]* | [A-Za-z]:[\\/]*) ;;
+	*)
+	  func_fatal_error "only absolute run-paths are allowed"
+	  ;;
+	esac
+	case "$xrpath " in
+	*" $dir "*) ;;
+	*) xrpath="$xrpath $dir" ;;
+	esac
+	continue
+	;;
+
+      -shared)
+	# The effects of -shared are defined in a previous loop.
+	continue
+	;;
+
+      -shrext)
+	prev=shrext
+	continue
+	;;
+
+      -static | -static-libtool-libs)
+	# The effects of -static are defined in a previous loop.
+	# We used to do the same as -all-static on platforms that
+	# didn't have a PIC flag, but the assumption that the effects
+	# would be equivalent was wrong.  It would break on at least
+	# Digital Unix and AIX.
+	continue
+	;;
+
+      -thread-safe)
+	thread_safe=yes
+	continue
+	;;
+
+      -version-info)
+	prev=vinfo
+	continue
+	;;
+
+      -version-number)
+	prev=vinfo
+	vinfo_number=yes
+	continue
+	;;
+
+      -weak)
+        prev=weak
+	continue
+	;;
+
+      -Wc,*)
+	func_stripname '-Wc,' '' "$arg"
+	args=$func_stripname_result
+	arg=
+	save_ifs="$IFS"; IFS=','
+	for flag in $args; do
+	  IFS="$save_ifs"
+          func_quote_for_eval "$flag"
+	  arg="$arg $wl$func_quote_for_eval_result"
+	  compiler_flags="$compiler_flags $func_quote_for_eval_result"
+	done
+	IFS="$save_ifs"
+	func_stripname ' ' '' "$arg"
+	arg=$func_stripname_result
+	;;
+
+      -Wl,*)
+	func_stripname '-Wl,' '' "$arg"
+	args=$func_stripname_result
+	arg=
+	save_ifs="$IFS"; IFS=','
+	for flag in $args; do
+	  IFS="$save_ifs"
+          func_quote_for_eval "$flag"
+	  arg="$arg $wl$func_quote_for_eval_result"
+	  compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
+	  linker_flags="$linker_flags $func_quote_for_eval_result"
+	done
+	IFS="$save_ifs"
+	func_stripname ' ' '' "$arg"
+	arg=$func_stripname_result
+	;;
+
+      -Xcompiler)
+	prev=xcompiler
+	continue
+	;;
+
+      -Xlinker)
+	prev=xlinker
+	continue
+	;;
+
+      -XCClinker)
+	prev=xcclinker
+	continue
+	;;
+
+      # -msg_* for osf cc
+      -msg_*)
+	func_quote_for_eval "$arg"
+	arg="$func_quote_for_eval_result"
+	;;
+
+      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
+      # -r[0-9][0-9]* specifies the processor on the SGI compiler
+      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
+      # +DA*, +DD* enable 64-bit mode on the HP compiler
+      # -q* pass through compiler args for the IBM compiler
+      # -m*, -t[45]*, -txscale* pass through architecture-specific
+      # compiler args for GCC
+      # -F/path gives path to uninstalled frameworks, gcc on darwin
+      # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
+      # @file GCC response files
+      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
+      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
+        func_quote_for_eval "$arg"
+	arg="$func_quote_for_eval_result"
+        func_append compile_command " $arg"
+        func_append finalize_command " $arg"
+        compiler_flags="$compiler_flags $arg"
+        continue
+        ;;
+
+      # Some other compiler flag.
+      -* | +*)
+        func_quote_for_eval "$arg"
+	arg="$func_quote_for_eval_result"
+	;;
+
+      *.$objext)
+	# A standard object.
+	objs="$objs $arg"
+	;;
+
+      *.lo)
+	# A libtool-controlled object.
+
+	# Check to see that this really is a libtool object.
+	if func_lalib_unsafe_p "$arg"; then
+	  pic_object=
+	  non_pic_object=
+
+	  # Read the .lo file
+	  func_source "$arg"
+
+	  if test -z "$pic_object" ||
+	     test -z "$non_pic_object" ||
+	     test "$pic_object" = none &&
+	     test "$non_pic_object" = none; then
+	    func_fatal_error "cannot find name of object for \`$arg'"
+	  fi
+
+	  # Extract subdirectory from the argument.
+	  func_dirname "$arg" "/" ""
+	  xdir="$func_dirname_result"
+
+	  if test "$pic_object" != none; then
+	    # Prepend the subdirectory the object is found in.
+	    pic_object="$xdir$pic_object"
+
+	    if test "$prev" = dlfiles; then
+	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+		dlfiles="$dlfiles $pic_object"
+		prev=
+		continue
+	      else
+		# If libtool objects are unsupported, then we need to preload.
+		prev=dlprefiles
+	      fi
+	    fi
+
+	    # CHECK ME:  I think I busted this.  -Ossama
+	    if test "$prev" = dlprefiles; then
+	      # Preload the old-style object.
+	      dlprefiles="$dlprefiles $pic_object"
+	      prev=
+	    fi
+
+	    # A PIC object.
+	    func_append libobjs " $pic_object"
+	    arg="$pic_object"
+	  fi
+
+	  # Non-PIC object.
+	  if test "$non_pic_object" != none; then
+	    # Prepend the subdirectory the object is found in.
+	    non_pic_object="$xdir$non_pic_object"
+
+	    # A standard non-PIC object
+	    func_append non_pic_objects " $non_pic_object"
+	    if test -z "$pic_object" || test "$pic_object" = none ; then
+	      arg="$non_pic_object"
+	    fi
+	  else
+	    # If the PIC object exists, use it instead.
+	    # $xdir was prepended to $pic_object above.
+	    non_pic_object="$pic_object"
+	    func_append non_pic_objects " $non_pic_object"
+	  fi
+	else
+	  # Only an error if not doing a dry-run.
+	  if $opt_dry_run; then
+	    # Extract subdirectory from the argument.
+	    func_dirname "$arg" "/" ""
+	    xdir="$func_dirname_result"
+
+	    func_lo2o "$arg"
+	    pic_object=$xdir$objdir/$func_lo2o_result
+	    non_pic_object=$xdir$func_lo2o_result
+	    func_append libobjs " $pic_object"
+	    func_append non_pic_objects " $non_pic_object"
+	  else
+	    func_fatal_error "\`$arg' is not a valid libtool object"
+	  fi
+	fi
+	;;
+
+      *.$libext)
+	# An archive.
+	deplibs="$deplibs $arg"
+	old_deplibs="$old_deplibs $arg"
+	continue
+	;;
+
+      *.la)
+	# A libtool-controlled library.
+
+	if test "$prev" = dlfiles; then
+	  # This library was specified with -dlopen.
+	  dlfiles="$dlfiles $arg"
+	  prev=
+	elif test "$prev" = dlprefiles; then
+	  # The library was specified with -dlpreopen.
+	  dlprefiles="$dlprefiles $arg"
+	  prev=
+	else
+	  deplibs="$deplibs $arg"
+	fi
+	continue
+	;;
+
+      # Some other compiler argument.
+      *)
+	# Unknown arguments in both finalize_command and compile_command need
+	# to be aesthetically quoted because they are evaled later.
+	func_quote_for_eval "$arg"
+	arg="$func_quote_for_eval_result"
+	;;
+      esac # arg
+
+      # Now actually substitute the argument into the commands.
+      if test -n "$arg"; then
+	func_append compile_command " $arg"
+	func_append finalize_command " $arg"
+      fi
+    done # argument parsing loop
+
+    test -n "$prev" && \
+      func_fatal_help "the \`$prevarg' option requires an argument"
+
+    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
+      eval arg=\"$export_dynamic_flag_spec\"
+      func_append compile_command " $arg"
+      func_append finalize_command " $arg"
+    fi
+
+    oldlibs=
+    # calculate the name of the file, without its directory
+    func_basename "$output"
+    outputname="$func_basename_result"
+    libobjs_save="$libobjs"
+
+    if test -n "$shlibpath_var"; then
+      # get the directories listed in $shlibpath_var
+      eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
+    else
+      shlib_search_path=
+    fi
+    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
+    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
+
+    func_dirname "$output" "/" ""
+    output_objdir="$func_dirname_result$objdir"
+    # Create the object directory.
+    func_mkdir_p "$output_objdir"
+
+    # Determine the type of output
+    case $output in
+    "")
+      func_fatal_help "you must specify an output file"
+      ;;
+    *.$libext) linkmode=oldlib ;;
+    *.lo | *.$objext) linkmode=obj ;;
+    *.la) linkmode=lib ;;
+    *) linkmode=prog ;; # Anything else should be a program.
+    esac
+
+    specialdeplibs=
+
+    libs=
+    # Find all interdependent deplibs by searching for libraries
+    # that are linked more than once (e.g. -la -lb -la)
+    for deplib in $deplibs; do
+      if $opt_duplicate_deps ; then
+	case "$libs " in
+	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+	esac
+      fi
+      libs="$libs $deplib"
+    done
+
+    if test "$linkmode" = lib; then
+      libs="$predeps $libs $compiler_lib_search_path $postdeps"
+
+      # Compute libraries that are listed more than once in $predeps
+      # $postdeps and mark them as special (i.e., whose duplicates are
+      # not to be eliminated).
+      pre_post_deps=
+      if $opt_duplicate_compiler_generated_deps; then
+	for pre_post_dep in $predeps $postdeps; do
+	  case "$pre_post_deps " in
+	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
+	  esac
+	  pre_post_deps="$pre_post_deps $pre_post_dep"
+	done
+      fi
+      pre_post_deps=
+    fi
+
+    deplibs=
+    newdependency_libs=
+    newlib_search_path=
+    need_relink=no # whether we're linking any uninstalled libtool libraries
+    notinst_deplibs= # not-installed libtool libraries
+    notinst_path= # paths that contain not-installed libtool libraries
+
+    case $linkmode in
+    lib)
+	passes="conv dlpreopen link"
+	for file in $dlfiles $dlprefiles; do
+	  case $file in
+	  *.la) ;;
+	  *)
+	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
+	    ;;
+	  esac
+	done
+	;;
+    prog)
+	compile_deplibs=
+	finalize_deplibs=
+	alldeplibs=no
+	newdlfiles=
+	newdlprefiles=
+	passes="conv scan dlopen dlpreopen link"
+	;;
+    *)  passes="conv"
+	;;
+    esac
+
+    for pass in $passes; do
+      # The preopen pass in lib mode reverses $deplibs; put it back here
+      # so that -L comes before libs that need it for instance...
+      if test "$linkmode,$pass" = "lib,link"; then
+	## FIXME: Find the place where the list is rebuilt in the wrong
+	##        order, and fix it there properly
+        tmp_deplibs=
+	for deplib in $deplibs; do
+	  tmp_deplibs="$deplib $tmp_deplibs"
+	done
+	deplibs="$tmp_deplibs"
+      fi
+
+      if test "$linkmode,$pass" = "lib,link" ||
+	 test "$linkmode,$pass" = "prog,scan"; then
+	libs="$deplibs"
+	deplibs=
+      fi
+      if test "$linkmode" = prog; then
+	case $pass in
+	dlopen) libs="$dlfiles" ;;
+	dlpreopen) libs="$dlprefiles" ;;
+	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
+	esac
+      fi
+      if test "$linkmode,$pass" = "lib,dlpreopen"; then
+	# Collect and forward deplibs of preopened libtool libs
+	for lib in $dlprefiles; do
+	  # Ignore non-libtool-libs
+	  dependency_libs=
+	  case $lib in
+	  *.la)	func_source "$lib" ;;
+	  esac
+
+	  # Collect preopened libtool deplibs, except any this library
+	  # has declared as weak libs
+	  for deplib in $dependency_libs; do
+            deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"`
+	    case " $weak_libs " in
+	    *" $deplib_base "*) ;;
+	    *) deplibs="$deplibs $deplib" ;;
+	    esac
+	  done
+	done
+	libs="$dlprefiles"
+      fi
+      if test "$pass" = dlopen; then
+	# Collect dlpreopened libraries
+	save_deplibs="$deplibs"
+	deplibs=
+      fi
+
+      for deplib in $libs; do
+	lib=
+	found=no
+	case $deplib in
+	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
+	  if test "$linkmode,$pass" = "prog,link"; then
+	    compile_deplibs="$deplib $compile_deplibs"
+	    finalize_deplibs="$deplib $finalize_deplibs"
+	  else
+	    compiler_flags="$compiler_flags $deplib"
+	    if test "$linkmode" = lib ; then
+		case "$new_inherited_linker_flags " in
+		    *" $deplib "*) ;;
+		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
+		esac
+	    fi
+	  fi
+	  continue
+	  ;;
+	-l*)
+	  if test "$linkmode" != lib && test "$linkmode" != prog; then
+	    func_warning "\`-l' is ignored for archives/objects"
+	    continue
+	  fi
+	  func_stripname '-l' '' "$deplib"
+	  name=$func_stripname_result
+	  if test "$linkmode" = lib; then
+	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
+	  else
+	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
+	  fi
+	  for searchdir in $searchdirs; do
+	    for search_ext in .la $std_shrext .so .a; do
+	      # Search the libtool library
+	      lib="$searchdir/lib${name}${search_ext}"
+	      if test -f "$lib"; then
+		if test "$search_ext" = ".la"; then
+		  found=yes
+		else
+		  found=no
+		fi
+		break 2
+	      fi
+	    done
+	  done
+	  if test "$found" != yes; then
+	    # deplib doesn't seem to be a libtool library
+	    if test "$linkmode,$pass" = "prog,link"; then
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    else
+	      deplibs="$deplib $deplibs"
+	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+	    fi
+	    continue
+	  else # deplib is a libtool library
+	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
+	    # We need to do some special things here, and not later.
+	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	      case " $predeps $postdeps " in
+	      *" $deplib "*)
+		if func_lalib_p "$lib"; then
+		  library_names=
+		  old_library=
+		  func_source "$lib"
+		  for l in $old_library $library_names; do
+		    ll="$l"
+		  done
+		  if test "X$ll" = "X$old_library" ; then # only static version available
+		    found=no
+		    func_dirname "$lib" "" "."
+		    ladir="$func_dirname_result"
+		    lib=$ladir/$old_library
+		    if test "$linkmode,$pass" = "prog,link"; then
+		      compile_deplibs="$deplib $compile_deplibs"
+		      finalize_deplibs="$deplib $finalize_deplibs"
+		    else
+		      deplibs="$deplib $deplibs"
+		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+		    fi
+		    continue
+		  fi
+		fi
+		;;
+	      *) ;;
+	      esac
+	    fi
+	  fi
+	  ;; # -l
+	*.ltframework)
+	  if test "$linkmode,$pass" = "prog,link"; then
+	    compile_deplibs="$deplib $compile_deplibs"
+	    finalize_deplibs="$deplib $finalize_deplibs"
+	  else
+	    deplibs="$deplib $deplibs"
+	    if test "$linkmode" = lib ; then
+		case "$new_inherited_linker_flags " in
+		    *" $deplib "*) ;;
+		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
+		esac
+	    fi
+	  fi
+	  continue
+	  ;;
+	-L*)
+	  case $linkmode in
+	  lib)
+	    deplibs="$deplib $deplibs"
+	    test "$pass" = conv && continue
+	    newdependency_libs="$deplib $newdependency_libs"
+	    func_stripname '-L' '' "$deplib"
+	    newlib_search_path="$newlib_search_path $func_stripname_result"
+	    ;;
+	  prog)
+	    if test "$pass" = conv; then
+	      deplibs="$deplib $deplibs"
+	      continue
+	    fi
+	    if test "$pass" = scan; then
+	      deplibs="$deplib $deplibs"
+	    else
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    fi
+	    func_stripname '-L' '' "$deplib"
+	    newlib_search_path="$newlib_search_path $func_stripname_result"
+	    ;;
+	  *)
+	    func_warning "\`-L' is ignored for archives/objects"
+	    ;;
+	  esac # linkmode
+	  continue
+	  ;; # -L
+	-R*)
+	  if test "$pass" = link; then
+	    func_stripname '-R' '' "$deplib"
+	    dir=$func_stripname_result
+	    # Make sure the xrpath contains only unique directories.
+	    case "$xrpath " in
+	    *" $dir "*) ;;
+	    *) xrpath="$xrpath $dir" ;;
+	    esac
+	  fi
+	  deplibs="$deplib $deplibs"
+	  continue
+	  ;;
+	*.la) lib="$deplib" ;;
+	*.$libext)
+	  if test "$pass" = conv; then
+	    deplibs="$deplib $deplibs"
+	    continue
+	  fi
+	  case $linkmode in
+	  lib)
+	    # Linking convenience modules into shared libraries is allowed,
+	    # but linking other static libraries is non-portable.
+	    case " $dlpreconveniencelibs " in
+	    *" $deplib "*) ;;
+	    *)
+	      valid_a_lib=no
+	      case $deplibs_check_method in
+		match_pattern*)
+		  set dummy $deplibs_check_method; shift
+		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+		  if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \
+		    | $EGREP "$match_pattern_regex" > /dev/null; then
+		    valid_a_lib=yes
+		  fi
+		;;
+		pass_all)
+		  valid_a_lib=yes
+		;;
+	      esac
+	      if test "$valid_a_lib" != yes; then
+		$ECHO
+		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
+		$ECHO "*** I have the capability to make that library automatically link in when"
+		$ECHO "*** you link to this library.  But I can only do this if you have a"
+		$ECHO "*** shared version of the library, which you do not appear to have"
+		$ECHO "*** because the file extensions .$libext of this argument makes me believe"
+		$ECHO "*** that it is just a static archive that I should not use here."
+	      else
+		$ECHO
+		$ECHO "*** Warning: Linking the shared library $output against the"
+		$ECHO "*** static library $deplib is not portable!"
+		deplibs="$deplib $deplibs"
+	      fi
+	      ;;
+	    esac
+	    continue
+	    ;;
+	  prog)
+	    if test "$pass" != link; then
+	      deplibs="$deplib $deplibs"
+	    else
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    fi
+	    continue
+	    ;;
+	  esac # linkmode
+	  ;; # *.$libext
+	*.lo | *.$objext)
+	  if test "$pass" = conv; then
+	    deplibs="$deplib $deplibs"
+	  elif test "$linkmode" = prog; then
+	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+	      # If there is no dlopen support or we're linking statically,
+	      # we need to preload.
+	      newdlprefiles="$newdlprefiles $deplib"
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    else
+	      newdlfiles="$newdlfiles $deplib"
+	    fi
+	  fi
+	  continue
+	  ;;
+	%DEPLIBS%)
+	  alldeplibs=yes
+	  continue
+	  ;;
+	esac # case $deplib
+
+	if test "$found" = yes || test -f "$lib"; then :
+	else
+	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
+	fi
+
+	# Check to see that this really is a libtool archive.
+	func_lalib_unsafe_p "$lib" \
+	  || func_fatal_error "\`$lib' is not a valid libtool archive"
+
+	func_dirname "$lib" "" "."
+	ladir="$func_dirname_result"
+
+	dlname=
+	dlopen=
+	dlpreopen=
+	libdir=
+	library_names=
+	old_library=
+	inherited_linker_flags=
+	# If the library was installed with an old release of libtool,
+	# it will not redefine variables installed, or shouldnotlink
+	installed=yes
+	shouldnotlink=no
+	avoidtemprpath=
+
+
+	# Read the .la file
+	func_source "$lib"
+
+	# Convert "-framework foo" to "foo.ltframework"
+	if test -n "$inherited_linker_flags"; then
+	  tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'`
+	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
+	    case " $new_inherited_linker_flags " in
+	      *" $tmp_inherited_linker_flag "*) ;;
+	      *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
+	    esac
+	  done
+	fi
+	dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	if test "$linkmode,$pass" = "lib,link" ||
+	   test "$linkmode,$pass" = "prog,scan" ||
+	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
+	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
+	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
+	fi
+
+	if test "$pass" = conv; then
+	  # Only check for convenience libraries
+	  deplibs="$lib $deplibs"
+	  if test -z "$libdir"; then
+	    if test -z "$old_library"; then
+	      func_fatal_error "cannot find name of link library for \`$lib'"
+	    fi
+	    # It is a libtool convenience library, so add in its objects.
+	    convenience="$convenience $ladir/$objdir/$old_library"
+	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
+	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
+	    func_fatal_error "\`$lib' is not a convenience library"
+	  fi
+	  tmp_libs=
+	  for deplib in $dependency_libs; do
+	    deplibs="$deplib $deplibs"
+	    if $opt_duplicate_deps ; then
+	      case "$tmp_libs " in
+	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+	      esac
+	    fi
+	    tmp_libs="$tmp_libs $deplib"
+	  done
+	  continue
+	fi # $pass = conv
+
+
+	# Get the name of the library we link against.
+	linklib=
+	for l in $old_library $library_names; do
+	  linklib="$l"
+	done
+	if test -z "$linklib"; then
+	  func_fatal_error "cannot find name of link library for \`$lib'"
+	fi
+
+	# This library was specified with -dlopen.
+	if test "$pass" = dlopen; then
+	  if test -z "$libdir"; then
+	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
+	  fi
+	  if test -z "$dlname" ||
+	     test "$dlopen_support" != yes ||
+	     test "$build_libtool_libs" = no; then
+	    # If there is no dlname, no dlopen support or we're linking
+	    # statically, we need to preload.  We also need to preload any
+	    # dependent libraries so libltdl's deplib preloader doesn't
+	    # bomb out in the load deplibs phase.
+	    dlprefiles="$dlprefiles $lib $dependency_libs"
+	  else
+	    newdlfiles="$newdlfiles $lib"
+	  fi
+	  continue
+	fi # $pass = dlopen
+
+	# We need an absolute path.
+	case $ladir in
+	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
+	*)
+	  abs_ladir=`cd "$ladir" && pwd`
+	  if test -z "$abs_ladir"; then
+	    func_warning "cannot determine absolute directory name of \`$ladir'"
+	    func_warning "passing it literally to the linker, although it might fail"
+	    abs_ladir="$ladir"
+	  fi
+	  ;;
+	esac
+	func_basename "$lib"
+	laname="$func_basename_result"
+
+	# Find the relevant object directory and library name.
+	if test "X$installed" = Xyes; then
+	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+	    func_warning "library \`$lib' was moved."
+	    dir="$ladir"
+	    absdir="$abs_ladir"
+	    libdir="$abs_ladir"
+	  else
+	    dir="$libdir"
+	    absdir="$libdir"
+	  fi
+	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
+	else
+	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+	    dir="$ladir"
+	    absdir="$abs_ladir"
+	    # Remove this search path later
+	    notinst_path="$notinst_path $abs_ladir"
+	  else
+	    dir="$ladir/$objdir"
+	    absdir="$abs_ladir/$objdir"
+	    # Remove this search path later
+	    notinst_path="$notinst_path $abs_ladir"
+	  fi
+	fi # $installed = yes
+	func_stripname 'lib' '.la' "$laname"
+	name=$func_stripname_result
+
+	# This library was specified with -dlpreopen.
+	if test "$pass" = dlpreopen; then
+	  if test -z "$libdir" && test "$linkmode" = prog; then
+	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
+	  fi
+	  # Prefer using a static library (so that no silly _DYNAMIC symbols
+	  # are required to link).
+	  if test -n "$old_library"; then
+	    newdlprefiles="$newdlprefiles $dir/$old_library"
+	    # Keep a list of preopened convenience libraries to check
+	    # that they are being used correctly in the link pass.
+	    test -z "$libdir" && \
+		dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
+	  # Otherwise, use the dlname, so that lt_dlopen finds it.
+	  elif test -n "$dlname"; then
+	    newdlprefiles="$newdlprefiles $dir/$dlname"
+	  else
+	    newdlprefiles="$newdlprefiles $dir/$linklib"
+	  fi
+	fi # $pass = dlpreopen
+
+	if test -z "$libdir"; then
+	  # Link the convenience library
+	  if test "$linkmode" = lib; then
+	    deplibs="$dir/$old_library $deplibs"
+	  elif test "$linkmode,$pass" = "prog,link"; then
+	    compile_deplibs="$dir/$old_library $compile_deplibs"
+	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
+	  else
+	    deplibs="$lib $deplibs" # used for prog,scan pass
+	  fi
+	  continue
+	fi
+
+
+	if test "$linkmode" = prog && test "$pass" != link; then
+	  newlib_search_path="$newlib_search_path $ladir"
+	  deplibs="$lib $deplibs"
+
+	  linkalldeplibs=no
+	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
+	     test "$build_libtool_libs" = no; then
+	    linkalldeplibs=yes
+	  fi
+
+	  tmp_libs=
+	  for deplib in $dependency_libs; do
+	    case $deplib in
+	    -L*) func_stripname '-L' '' "$deplib"
+	         newlib_search_path="$newlib_search_path $func_stripname_result"
+		 ;;
+	    esac
+	    # Need to link against all dependency_libs?
+	    if test "$linkalldeplibs" = yes; then
+	      deplibs="$deplib $deplibs"
+	    else
+	      # Need to hardcode shared library paths
+	      # or/and link against static libraries
+	      newdependency_libs="$deplib $newdependency_libs"
+	    fi
+	    if $opt_duplicate_deps ; then
+	      case "$tmp_libs " in
+	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+	      esac
+	    fi
+	    tmp_libs="$tmp_libs $deplib"
+	  done # for deplib
+	  continue
+	fi # $linkmode = prog...
+
+	if test "$linkmode,$pass" = "prog,link"; then
+	  if test -n "$library_names" &&
+	     { { test "$prefer_static_libs" = no ||
+	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
+	       test -z "$old_library"; }; then
+	    # We need to hardcode the library path
+	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
+	      # Make sure the rpath contains only unique directories.
+	      case "$temp_rpath:" in
+	      *"$absdir:"*) ;;
+	      *) temp_rpath="$temp_rpath$absdir:" ;;
+	      esac
+	    fi
+
+	    # Hardcode the library path.
+	    # Skip directories that are in the system default run-time
+	    # search path.
+	    case " $sys_lib_dlsearch_path " in
+	    *" $absdir "*) ;;
+	    *)
+	      case "$compile_rpath " in
+	      *" $absdir "*) ;;
+	      *) compile_rpath="$compile_rpath $absdir"
+	      esac
+	      ;;
+	    esac
+	    case " $sys_lib_dlsearch_path " in
+	    *" $libdir "*) ;;
+	    *)
+	      case "$finalize_rpath " in
+	      *" $libdir "*) ;;
+	      *) finalize_rpath="$finalize_rpath $libdir"
+	      esac
+	      ;;
+	    esac
+	  fi # $linkmode,$pass = prog,link...
+
+	  if test "$alldeplibs" = yes &&
+	     { test "$deplibs_check_method" = pass_all ||
+	       { test "$build_libtool_libs" = yes &&
+		 test -n "$library_names"; }; }; then
+	    # We only need to search for static libraries
+	    continue
+	  fi
+	fi
+
+	link_static=no # Whether the deplib will be linked statically
+	use_static_libs=$prefer_static_libs
+	if test "$use_static_libs" = built && test "$installed" = yes; then
+	  use_static_libs=no
+	fi
+	if test -n "$library_names" &&
+	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
+	  case $host in
+	  *cygwin* | *mingw* | *cegcc*)
+	      # No point in relinking DLLs because paths are not encoded
+	      notinst_deplibs="$notinst_deplibs $lib"
+	      need_relink=no
+	    ;;
+	  *)
+	    if test "$installed" = no; then
+	      notinst_deplibs="$notinst_deplibs $lib"
+	      need_relink=yes
+	    fi
+	    ;;
+	  esac
+	  # This is a shared library
+
+	  # Warn about portability, can't link against -module's on some
+	  # systems (darwin).  Don't bleat about dlopened modules though!
+	  dlopenmodule=""
+	  for dlpremoduletest in $dlprefiles; do
+	    if test "X$dlpremoduletest" = "X$lib"; then
+	      dlopenmodule="$dlpremoduletest"
+	      break
+	    fi
+	  done
+	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
+	    $ECHO
+	    if test "$linkmode" = prog; then
+	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
+	    else
+	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
+	    fi
+	    $ECHO "*** $linklib is not portable!"
+	  fi
+	  if test "$linkmode" = lib &&
+	     test "$hardcode_into_libs" = yes; then
+	    # Hardcode the library path.
+	    # Skip directories that are in the system default run-time
+	    # search path.
+	    case " $sys_lib_dlsearch_path " in
+	    *" $absdir "*) ;;
+	    *)
+	      case "$compile_rpath " in
+	      *" $absdir "*) ;;
+	      *) compile_rpath="$compile_rpath $absdir"
+	      esac
+	      ;;
+	    esac
+	    case " $sys_lib_dlsearch_path " in
+	    *" $libdir "*) ;;
+	    *)
+	      case "$finalize_rpath " in
+	      *" $libdir "*) ;;
+	      *) finalize_rpath="$finalize_rpath $libdir"
+	      esac
+	      ;;
+	    esac
+	  fi
+
+	  if test -n "$old_archive_from_expsyms_cmds"; then
+	    # figure out the soname
+	    set dummy $library_names
+	    shift
+	    realname="$1"
+	    shift
+	    libname=`eval "\\$ECHO \"$libname_spec\""`
+	    # use dlname if we got it. it's perfectly good, no?
+	    if test -n "$dlname"; then
+	      soname="$dlname"
+	    elif test -n "$soname_spec"; then
+	      # bleh windows
+	      case $host in
+	      *cygwin* | mingw* | *cegcc*)
+	        func_arith $current - $age
+		major=$func_arith_result
+		versuffix="-$major"
+		;;
+	      esac
+	      eval soname=\"$soname_spec\"
+	    else
+	      soname="$realname"
+	    fi
+
+	    # Make a new name for the extract_expsyms_cmds to use
+	    soroot="$soname"
+	    func_basename "$soroot"
+	    soname="$func_basename_result"
+	    func_stripname 'lib' '.dll' "$soname"
+	    newlib=libimp-$func_stripname_result.a
+
+	    # If the library has no export list, then create one now
+	    if test -f "$output_objdir/$soname-def"; then :
+	    else
+	      func_verbose "extracting exported symbol list from \`$soname'"
+	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
+	    fi
+
+	    # Create $newlib
+	    if test -f "$output_objdir/$newlib"; then :; else
+	      func_verbose "generating import library for \`$soname'"
+	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
+	    fi
+	    # make sure the library variables are pointing to the new library
+	    dir=$output_objdir
+	    linklib=$newlib
+	  fi # test -n "$old_archive_from_expsyms_cmds"
+
+	  if test "$linkmode" = prog || test "$mode" != relink; then
+	    add_shlibpath=
+	    add_dir=
+	    add=
+	    lib_linked=yes
+	    case $hardcode_action in
+	    immediate | unsupported)
+	      if test "$hardcode_direct" = no; then
+		add="$dir/$linklib"
+		case $host in
+		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
+		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
+		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
+		    *-*-unixware7*) add_dir="-L$dir" ;;
+		  *-*-darwin* )
+		    # if the lib is a (non-dlopened) module then we can not
+		    # link against it, someone is ignoring the earlier warnings
+		    if /usr/bin/file -L $add 2> /dev/null |
+			 $GREP ": [^:]* bundle" >/dev/null ; then
+		      if test "X$dlopenmodule" != "X$lib"; then
+			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
+			if test -z "$old_library" ; then
+			  $ECHO
+			  $ECHO "*** And there doesn't seem to be a static archive available"
+			  $ECHO "*** The link will probably fail, sorry"
+			else
+			  add="$dir/$old_library"
+			fi
+		      elif test -n "$old_library"; then
+			add="$dir/$old_library"
+		      fi
+		    fi
+		esac
+	      elif test "$hardcode_minus_L" = no; then
+		case $host in
+		*-*-sunos*) add_shlibpath="$dir" ;;
+		esac
+		add_dir="-L$dir"
+		add="-l$name"
+	      elif test "$hardcode_shlibpath_var" = no; then
+		add_shlibpath="$dir"
+		add="-l$name"
+	      else
+		lib_linked=no
+	      fi
+	      ;;
+	    relink)
+	      if test "$hardcode_direct" = yes &&
+	         test "$hardcode_direct_absolute" = no; then
+		add="$dir/$linklib"
+	      elif test "$hardcode_minus_L" = yes; then
+		add_dir="-L$dir"
+		# Try looking first in the location we're being installed to.
+		if test -n "$inst_prefix_dir"; then
+		  case $libdir in
+		    [\\/]*)
+		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
+		      ;;
+		  esac
+		fi
+		add="-l$name"
+	      elif test "$hardcode_shlibpath_var" = yes; then
+		add_shlibpath="$dir"
+		add="-l$name"
+	      else
+		lib_linked=no
+	      fi
+	      ;;
+	    *) lib_linked=no ;;
+	    esac
+
+	    if test "$lib_linked" != yes; then
+	      func_fatal_configuration "unsupported hardcode properties"
+	    fi
+
+	    if test -n "$add_shlibpath"; then
+	      case :$compile_shlibpath: in
+	      *":$add_shlibpath:"*) ;;
+	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
+	      esac
+	    fi
+	    if test "$linkmode" = prog; then
+	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
+	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
+	    else
+	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
+	      test -n "$add" && deplibs="$add $deplibs"
+	      if test "$hardcode_direct" != yes &&
+		 test "$hardcode_minus_L" != yes &&
+		 test "$hardcode_shlibpath_var" = yes; then
+		case :$finalize_shlibpath: in
+		*":$libdir:"*) ;;
+		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
+		esac
+	      fi
+	    fi
+	  fi
+
+	  if test "$linkmode" = prog || test "$mode" = relink; then
+	    add_shlibpath=
+	    add_dir=
+	    add=
+	    # Finalize command for both is simple: just hardcode it.
+	    if test "$hardcode_direct" = yes &&
+	       test "$hardcode_direct_absolute" = no; then
+	      add="$libdir/$linklib"
+	    elif test "$hardcode_minus_L" = yes; then
+	      add_dir="-L$libdir"
+	      add="-l$name"
+	    elif test "$hardcode_shlibpath_var" = yes; then
+	      case :$finalize_shlibpath: in
+	      *":$libdir:"*) ;;
+	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
+	      esac
+	      add="-l$name"
+	    elif test "$hardcode_automatic" = yes; then
+	      if test -n "$inst_prefix_dir" &&
+		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
+		add="$inst_prefix_dir$libdir/$linklib"
+	      else
+		add="$libdir/$linklib"
+	      fi
+	    else
+	      # We cannot seem to hardcode it, guess we'll fake it.
+	      add_dir="-L$libdir"
+	      # Try looking first in the location we're being installed to.
+	      if test -n "$inst_prefix_dir"; then
+		case $libdir in
+		  [\\/]*)
+		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
+		    ;;
+		esac
+	      fi
+	      add="-l$name"
+	    fi
+
+	    if test "$linkmode" = prog; then
+	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
+	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
+	    else
+	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
+	      test -n "$add" && deplibs="$add $deplibs"
+	    fi
+	  fi
+	elif test "$linkmode" = prog; then
+	  # Here we assume that one of hardcode_direct or hardcode_minus_L
+	  # is not unsupported.  This is valid on all known static and
+	  # shared platforms.
+	  if test "$hardcode_direct" != unsupported; then
+	    test -n "$old_library" && linklib="$old_library"
+	    compile_deplibs="$dir/$linklib $compile_deplibs"
+	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
+	  else
+	    compile_deplibs="-l$name -L$dir $compile_deplibs"
+	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
+	  fi
+	elif test "$build_libtool_libs" = yes; then
+	  # Not a shared library
+	  if test "$deplibs_check_method" != pass_all; then
+	    # We're trying link a shared library against a static one
+	    # but the system doesn't support it.
+
+	    # Just print a warning and add the library to dependency_libs so
+	    # that the program can be linked against the static library.
+	    $ECHO
+	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
+	    $ECHO "*** I have the capability to make that library automatically link in when"
+	    $ECHO "*** you link to this library.  But I can only do this if you have a"
+	    $ECHO "*** shared version of the library, which you do not appear to have."
+	    if test "$module" = yes; then
+	      $ECHO "*** But as you try to build a module library, libtool will still create "
+	      $ECHO "*** a static module, that should work as long as the dlopening application"
+	      $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime."
+	      if test -z "$global_symbol_pipe"; then
+		$ECHO
+		$ECHO "*** However, this would only work if libtool was able to extract symbol"
+		$ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
+		$ECHO "*** not find such a program.  So, this module is probably useless."
+		$ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
+	      fi
+	      if test "$build_old_libs" = no; then
+		build_libtool_libs=module
+		build_old_libs=yes
+	      else
+		build_libtool_libs=no
+	      fi
+	    fi
+	  else
+	    deplibs="$dir/$old_library $deplibs"
+	    link_static=yes
+	  fi
+	fi # link shared/static library?
+
+	if test "$linkmode" = lib; then
+	  if test -n "$dependency_libs" &&
+	     { test "$hardcode_into_libs" != yes ||
+	       test "$build_old_libs" = yes ||
+	       test "$link_static" = yes; }; then
+	    # Extract -R from dependency_libs
+	    temp_deplibs=
+	    for libdir in $dependency_libs; do
+	      case $libdir in
+	      -R*) func_stripname '-R' '' "$libdir"
+	           temp_xrpath=$func_stripname_result
+		   case " $xrpath " in
+		   *" $temp_xrpath "*) ;;
+		   *) xrpath="$xrpath $temp_xrpath";;
+		   esac;;
+	      *) temp_deplibs="$temp_deplibs $libdir";;
+	      esac
+	    done
+	    dependency_libs="$temp_deplibs"
+	  fi
+
+	  newlib_search_path="$newlib_search_path $absdir"
+	  # Link against this library
+	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
+	  # ... and its dependency_libs
+	  tmp_libs=
+	  for deplib in $dependency_libs; do
+	    newdependency_libs="$deplib $newdependency_libs"
+	    if $opt_duplicate_deps ; then
+	      case "$tmp_libs " in
+	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+	      esac
+	    fi
+	    tmp_libs="$tmp_libs $deplib"
+	  done
+
+	  if test "$link_all_deplibs" != no; then
+	    # Add the search paths of all dependency libraries
+	    for deplib in $dependency_libs; do
+	      case $deplib in
+	      -L*) path="$deplib" ;;
+	      *.la)
+	        func_dirname "$deplib" "" "."
+		dir="$func_dirname_result"
+		# We need an absolute path.
+		case $dir in
+		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
+		*)
+		  absdir=`cd "$dir" && pwd`
+		  if test -z "$absdir"; then
+		    func_warning "cannot determine absolute directory name of \`$dir'"
+		    absdir="$dir"
+		  fi
+		  ;;
+		esac
+		if $GREP "^installed=no" $deplib > /dev/null; then
+		case $host in
+		*-*-darwin*)
+		  depdepl=
+		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
+		  if test -n "$deplibrary_names" ; then
+		    for tmp in $deplibrary_names ; do
+		      depdepl=$tmp
+		    done
+		    if test -f "$absdir/$objdir/$depdepl" ; then
+		      depdepl="$absdir/$objdir/$depdepl"
+		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
+                      if test -z "$darwin_install_name"; then
+                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
+                      fi
+		      compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
+		      linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
+		      path=
+		    fi
+		  fi
+		  ;;
+		*)
+		  path="-L$absdir/$objdir"
+		  ;;
+		esac
+		else
+		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+		  test -z "$libdir" && \
+		    func_fatal_error "\`$deplib' is not a valid libtool archive"
+		  test "$absdir" != "$libdir" && \
+		    func_warning "\`$deplib' seems to be moved"
+
+		  path="-L$absdir"
+		fi
+		;;
+	      esac
+	      case " $deplibs " in
+	      *" $path "*) ;;
+	      *) deplibs="$path $deplibs" ;;
+	      esac
+	    done
+	  fi # link_all_deplibs != no
+	fi # linkmode = lib
+      done # for deplib in $libs
+      if test "$pass" = link; then
+	if test "$linkmode" = "prog"; then
+	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
+	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
+	else
+	  compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	fi
+      fi
+      dependency_libs="$newdependency_libs"
+      if test "$pass" = dlpreopen; then
+	# Link the dlpreopened libraries before other libraries
+	for deplib in $save_deplibs; do
+	  deplibs="$deplib $deplibs"
+	done
+      fi
+      if test "$pass" != dlopen; then
+	if test "$pass" != conv; then
+	  # Make sure lib_search_path contains only unique directories.
+	  lib_search_path=
+	  for dir in $newlib_search_path; do
+	    case "$lib_search_path " in
+	    *" $dir "*) ;;
+	    *) lib_search_path="$lib_search_path $dir" ;;
+	    esac
+	  done
+	  newlib_search_path=
+	fi
+
+	if test "$linkmode,$pass" != "prog,link"; then
+	  vars="deplibs"
+	else
+	  vars="compile_deplibs finalize_deplibs"
+	fi
+	for var in $vars dependency_libs; do
+	  # Add libraries to $var in reverse order
+	  eval tmp_libs=\"\$$var\"
+	  new_libs=
+	  for deplib in $tmp_libs; do
+	    # FIXME: Pedantically, this is the right thing to do, so
+	    #        that some nasty dependency loop isn't accidentally
+	    #        broken:
+	    #new_libs="$deplib $new_libs"
+	    # Pragmatically, this seems to cause very few problems in
+	    # practice:
+	    case $deplib in
+	    -L*) new_libs="$deplib $new_libs" ;;
+	    -R*) ;;
+	    *)
+	      # And here is the reason: when a library appears more
+	      # than once as an explicit dependence of a library, or
+	      # is implicitly linked in more than once by the
+	      # compiler, it is considered special, and multiple
+	      # occurrences thereof are not removed.  Compare this
+	      # with having the same library being listed as a
+	      # dependency of multiple other libraries: in this case,
+	      # we know (pedantically, we assume) the library does not
+	      # need to be listed more than once, so we keep only the
+	      # last copy.  This is not always right, but it is rare
+	      # enough that we require users that really mean to play
+	      # such unportable linking tricks to link the library
+	      # using -Wl,-lname, so that libtool does not consider it
+	      # for duplicate removal.
+	      case " $specialdeplibs " in
+	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
+	      *)
+		case " $new_libs " in
+		*" $deplib "*) ;;
+		*) new_libs="$deplib $new_libs" ;;
+		esac
+		;;
+	      esac
+	      ;;
+	    esac
+	  done
+	  tmp_libs=
+	  for deplib in $new_libs; do
+	    case $deplib in
+	    -L*)
+	      case " $tmp_libs " in
+	      *" $deplib "*) ;;
+	      *) tmp_libs="$tmp_libs $deplib" ;;
+	      esac
+	      ;;
+	    *) tmp_libs="$tmp_libs $deplib" ;;
+	    esac
+	  done
+	  eval $var=\"$tmp_libs\"
+	done # for var
+      fi
+      # Last step: remove runtime libs from dependency_libs
+      # (they stay in deplibs)
+      tmp_libs=
+      for i in $dependency_libs ; do
+	case " $predeps $postdeps $compiler_lib_search_path " in
+	*" $i "*)
+	  i=""
+	  ;;
+	esac
+	if test -n "$i" ; then
+	  tmp_libs="$tmp_libs $i"
+	fi
+      done
+      dependency_libs=$tmp_libs
+    done # for pass
+    if test "$linkmode" = prog; then
+      dlfiles="$newdlfiles"
+    fi
+    if test "$linkmode" = prog || test "$linkmode" = lib; then
+      dlprefiles="$newdlprefiles"
+    fi
+
+    case $linkmode in
+    oldlib)
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+	func_warning "\`-dlopen' is ignored for archives"
+      fi
+
+      case " $deplibs" in
+      *\ -l* | *\ -L*)
+	func_warning "\`-l' and \`-L' are ignored for archives" ;;
+      esac
+
+      test -n "$rpath" && \
+	func_warning "\`-rpath' is ignored for archives"
+
+      test -n "$xrpath" && \
+	func_warning "\`-R' is ignored for archives"
+
+      test -n "$vinfo" && \
+	func_warning "\`-version-info/-version-number' is ignored for archives"
+
+      test -n "$release" && \
+	func_warning "\`-release' is ignored for archives"
+
+      test -n "$export_symbols$export_symbols_regex" && \
+	func_warning "\`-export-symbols' is ignored for archives"
+
+      # Now set the variables for building old libraries.
+      build_libtool_libs=no
+      oldlibs="$output"
+      objs="$objs$old_deplibs"
+      ;;
+
+    lib)
+      # Make sure we only generate libraries of the form `libNAME.la'.
+      case $outputname in
+      lib*)
+	func_stripname 'lib' '.la' "$outputname"
+	name=$func_stripname_result
+	eval shared_ext=\"$shrext_cmds\"
+	eval libname=\"$libname_spec\"
+	;;
+      *)
+	test "$module" = no && \
+	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
+
+	if test "$need_lib_prefix" != no; then
+	  # Add the "lib" prefix for modules if required
+	  func_stripname '' '.la' "$outputname"
+	  name=$func_stripname_result
+	  eval shared_ext=\"$shrext_cmds\"
+	  eval libname=\"$libname_spec\"
+	else
+	  func_stripname '' '.la' "$outputname"
+	  libname=$func_stripname_result
+	fi
+	;;
+      esac
+
+      if test -n "$objs"; then
+	if test "$deplibs_check_method" != pass_all; then
+	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
+	else
+	  $ECHO
+	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
+	  $ECHO "*** objects $objs is not portable!"
+	  libobjs="$libobjs $objs"
+	fi
+      fi
+
+      test "$dlself" != no && \
+	func_warning "\`-dlopen self' is ignored for libtool libraries"
+
+      set dummy $rpath
+      shift
+      test "$#" -gt 1 && \
+	func_warning "ignoring multiple \`-rpath's for a libtool library"
+
+      install_libdir="$1"
+
+      oldlibs=
+      if test -z "$rpath"; then
+	if test "$build_libtool_libs" = yes; then
+	  # Building a libtool convenience library.
+	  # Some compilers have problems with a `.al' extension so
+	  # convenience libraries should have the same extension an
+	  # archive normally would.
+	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
+	  build_libtool_libs=convenience
+	  build_old_libs=yes
+	fi
+
+	test -n "$vinfo" && \
+	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
+
+	test -n "$release" && \
+	  func_warning "\`-release' is ignored for convenience libraries"
+      else
+
+	# Parse the version information argument.
+	save_ifs="$IFS"; IFS=':'
+	set dummy $vinfo 0 0 0
+	shift
+	IFS="$save_ifs"
+
+	test -n "$7" && \
+	  func_fatal_help "too many parameters to \`-version-info'"
+
+	# convert absolute version numbers to libtool ages
+	# this retains compatibility with .la files and attempts
+	# to make the code below a bit more comprehensible
+
+	case $vinfo_number in
+	yes)
+	  number_major="$1"
+	  number_minor="$2"
+	  number_revision="$3"
+	  #
+	  # There are really only two kinds -- those that
+	  # use the current revision as the major version
+	  # and those that subtract age and use age as
+	  # a minor version.  But, then there is irix
+	  # which has an extra 1 added just for fun
+	  #
+	  case $version_type in
+	  darwin|linux|osf|windows|none)
+	    func_arith $number_major + $number_minor
+	    current=$func_arith_result
+	    age="$number_minor"
+	    revision="$number_revision"
+	    ;;
+	  freebsd-aout|freebsd-elf|sunos)
+	    current="$number_major"
+	    revision="$number_minor"
+	    age="0"
+	    ;;
+	  irix|nonstopux)
+	    func_arith $number_major + $number_minor
+	    current=$func_arith_result
+	    age="$number_minor"
+	    revision="$number_minor"
+	    lt_irix_increment=no
+	    ;;
+	  esac
+	  ;;
+	no)
+	  current="$1"
+	  revision="$2"
+	  age="$3"
+	  ;;
+	esac
+
+	# Check that each of the things are valid numbers.
+	case $current in
+	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+	*)
+	  func_error "CURRENT \`$current' must be a nonnegative integer"
+	  func_fatal_error "\`$vinfo' is not valid version information"
+	  ;;
+	esac
+
+	case $revision in
+	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+	*)
+	  func_error "REVISION \`$revision' must be a nonnegative integer"
+	  func_fatal_error "\`$vinfo' is not valid version information"
+	  ;;
+	esac
+
+	case $age in
+	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+	*)
+	  func_error "AGE \`$age' must be a nonnegative integer"
+	  func_fatal_error "\`$vinfo' is not valid version information"
+	  ;;
+	esac
+
+	if test "$age" -gt "$current"; then
+	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
+	  func_fatal_error "\`$vinfo' is not valid version information"
+	fi
+
+	# Calculate the version variables.
+	major=
+	versuffix=
+	verstring=
+	case $version_type in
+	none) ;;
+
+	darwin)
+	  # Like Linux, but with the current version available in
+	  # verstring for coding it into the library header
+	  func_arith $current - $age
+	  major=.$func_arith_result
+	  versuffix="$major.$age.$revision"
+	  # Darwin ld doesn't like 0 for these options...
+	  func_arith $current + 1
+	  minor_current=$func_arith_result
+	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
+	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+	  ;;
+
+	freebsd-aout)
+	  major=".$current"
+	  versuffix=".$current.$revision";
+	  ;;
+
+	freebsd-elf)
+	  major=".$current"
+	  versuffix=".$current"
+	  ;;
+
+	irix | nonstopux)
+	  if test "X$lt_irix_increment" = "Xno"; then
+	    func_arith $current - $age
+	  else
+	    func_arith $current - $age + 1
+	  fi
+	  major=$func_arith_result
+
+	  case $version_type in
+	    nonstopux) verstring_prefix=nonstopux ;;
+	    *)         verstring_prefix=sgi ;;
+	  esac
+	  verstring="$verstring_prefix$major.$revision"
+
+	  # Add in all the interfaces that we are compatible with.
+	  loop=$revision
+	  while test "$loop" -ne 0; do
+	    func_arith $revision - $loop
+	    iface=$func_arith_result
+	    func_arith $loop - 1
+	    loop=$func_arith_result
+	    verstring="$verstring_prefix$major.$iface:$verstring"
+	  done
+
+	  # Before this point, $major must not contain `.'.
+	  major=.$major
+	  versuffix="$major.$revision"
+	  ;;
+
+	linux)
+	  func_arith $current - $age
+	  major=.$func_arith_result
+	  versuffix="$major.$age.$revision"
+	  ;;
+
+	osf)
+	  func_arith $current - $age
+	  major=.$func_arith_result
+	  versuffix=".$current.$age.$revision"
+	  verstring="$current.$age.$revision"
+
+	  # Add in all the interfaces that we are compatible with.
+	  loop=$age
+	  while test "$loop" -ne 0; do
+	    func_arith $current - $loop
+	    iface=$func_arith_result
+	    func_arith $loop - 1
+	    loop=$func_arith_result
+	    verstring="$verstring:${iface}.0"
+	  done
+
+	  # Make executables depend on our current version.
+	  verstring="$verstring:${current}.0"
+	  ;;
+
+	qnx)
+	  major=".$current"
+	  versuffix=".$current"
+	  ;;
+
+	sunos)
+	  major=".$current"
+	  versuffix=".$current.$revision"
+	  ;;
+
+	windows)
+	  # Use '-' rather than '.', since we only want one
+	  # extension on DOS 8.3 filesystems.
+	  func_arith $current - $age
+	  major=$func_arith_result
+	  versuffix="-$major"
+	  ;;
+
+	*)
+	  func_fatal_configuration "unknown library version type \`$version_type'"
+	  ;;
+	esac
+
+	# Clear the version info if we defaulted, and they specified a release.
+	if test -z "$vinfo" && test -n "$release"; then
+	  major=
+	  case $version_type in
+	  darwin)
+	    # we can't check for "0.0" in archive_cmds due to quoting
+	    # problems, so we reset it completely
+	    verstring=
+	    ;;
+	  *)
+	    verstring="0.0"
+	    ;;
+	  esac
+	  if test "$need_version" = no; then
+	    versuffix=
+	  else
+	    versuffix=".0.0"
+	  fi
+	fi
+
+	# Remove version info from name if versioning should be avoided
+	if test "$avoid_version" = yes && test "$need_version" = no; then
+	  major=
+	  versuffix=
+	  verstring=""
+	fi
+
+	# Check to see if the archive will have undefined symbols.
+	if test "$allow_undefined" = yes; then
+	  if test "$allow_undefined_flag" = unsupported; then
+	    func_warning "undefined symbols not allowed in $host shared libraries"
+	    build_libtool_libs=no
+	    build_old_libs=yes
+	  fi
+	else
+	  # Don't allow undefined symbols.
+	  allow_undefined_flag="$no_undefined_flag"
+	fi
+
+      fi
+
+      func_generate_dlsyms "$libname" "$libname" "yes"
+      libobjs="$libobjs $symfileobj"
+      test "X$libobjs" = "X " && libobjs=
+
+      if test "$mode" != relink; then
+	# Remove our outputs, but don't remove object files since they
+	# may have been created when compiling PIC objects.
+	removelist=
+	tempremovelist=`$ECHO "$output_objdir/*"`
+	for p in $tempremovelist; do
+	  case $p in
+	    *.$objext | *.gcno)
+	       ;;
+	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
+	       if test "X$precious_files_regex" != "X"; then
+		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
+		 then
+		   continue
+		 fi
+	       fi
+	       removelist="$removelist $p"
+	       ;;
+	    *) ;;
+	  esac
+	done
+	test -n "$removelist" && \
+	  func_show_eval "${RM}r \$removelist"
+      fi
+
+      # Now set the variables for building old libraries.
+      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
+	oldlibs="$oldlibs $output_objdir/$libname.$libext"
+
+	# Transform .lo files to .o files.
+	oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
+      fi
+
+      # Eliminate all temporary directories.
+      #for path in $notinst_path; do
+      #	lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"`
+      #	deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"`
+      #	dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"`
+      #done
+
+      if test -n "$xrpath"; then
+	# If the user specified any rpath flags, then add them.
+	temp_xrpath=
+	for libdir in $xrpath; do
+	  temp_xrpath="$temp_xrpath -R$libdir"
+	  case "$finalize_rpath " in
+	  *" $libdir "*) ;;
+	  *) finalize_rpath="$finalize_rpath $libdir" ;;
+	  esac
+	done
+	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
+	  dependency_libs="$temp_xrpath $dependency_libs"
+	fi
+      fi
+
+      # Make sure dlfiles contains only unique files that won't be dlpreopened
+      old_dlfiles="$dlfiles"
+      dlfiles=
+      for lib in $old_dlfiles; do
+	case " $dlprefiles $dlfiles " in
+	*" $lib "*) ;;
+	*) dlfiles="$dlfiles $lib" ;;
+	esac
+      done
+
+      # Make sure dlprefiles contains only unique files
+      old_dlprefiles="$dlprefiles"
+      dlprefiles=
+      for lib in $old_dlprefiles; do
+	case "$dlprefiles " in
+	*" $lib "*) ;;
+	*) dlprefiles="$dlprefiles $lib" ;;
+	esac
+      done
+
+      if test "$build_libtool_libs" = yes; then
+	if test -n "$rpath"; then
+	  case $host in
+	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*)
+	    # these systems don't actually have a c library (as such)!
+	    ;;
+	  *-*-rhapsody* | *-*-darwin1.[012])
+	    # Rhapsody C library is in the System framework
+	    deplibs="$deplibs System.ltframework"
+	    ;;
+	  *-*-netbsd*)
+	    # Don't link with libc until the a.out ld.so is fixed.
+	    ;;
+	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	    # Do not include libc due to us having libc/libc_r.
+	    ;;
+	  *-*-sco3.2v5* | *-*-sco5v6*)
+	    # Causes problems with __ctype
+	    ;;
+	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+	    # Compiler inserts libc in the correct place for threads to work
+	    ;;
+	  *)
+	    # Add libc to deplibs on all other systems if necessary.
+	    if test "$build_libtool_need_lc" = "yes"; then
+	      deplibs="$deplibs -lc"
+	    fi
+	    ;;
+	  esac
+	fi
+
+	# Transform deplibs into only deplibs that can be linked in shared.
+	name_save=$name
+	libname_save=$libname
+	release_save=$release
+	versuffix_save=$versuffix
+	major_save=$major
+	# I'm not sure if I'm treating the release correctly.  I think
+	# release should show up in the -l (ie -lgmp5) so we don't want to
+	# add it in twice.  Is that correct?
+	release=""
+	versuffix=""
+	major=""
+	newdeplibs=
+	droppeddeps=no
+	case $deplibs_check_method in
+	pass_all)
+	  # Don't check for shared/static.  Everything works.
+	  # This might be a little naive.  We might want to check
+	  # whether the library exists or not.  But this is on
+	  # osf3 & osf4 and I'm not really sure... Just
+	  # implementing what was already the behavior.
+	  newdeplibs=$deplibs
+	  ;;
+	test_compile)
+	  # This code stresses the "libraries are programs" paradigm to its
+	  # limits. Maybe even breaks it.  We compile a program, linking it
+	  # against the deplibs as a proxy for the library.  Then we can check
+	  # whether they linked in statically or dynamically with ldd.
+	  $opt_dry_run || $RM conftest.c
+	  cat > conftest.c <<EOF
+	  int main() { return 0; }
+EOF
+	  $opt_dry_run || $RM conftest
+	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
+	    ldd_output=`ldd conftest`
+	    for i in $deplibs; do
+	      case $i in
+	      -l*)
+		func_stripname -l '' "$i"
+		name=$func_stripname_result
+		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		  case " $predeps $postdeps " in
+		  *" $i "*)
+		    newdeplibs="$newdeplibs $i"
+		    i=""
+		    ;;
+		  esac
+		fi
+		if test -n "$i" ; then
+		  libname=`eval "\\$ECHO \"$libname_spec\""`
+		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
+		  set dummy $deplib_matches; shift
+		  deplib_match=$1
+		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+		    newdeplibs="$newdeplibs $i"
+		  else
+		    droppeddeps=yes
+		    $ECHO
+		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
+		    $ECHO "*** I have the capability to make that library automatically link in when"
+		    $ECHO "*** you link to this library.  But I can only do this if you have a"
+		    $ECHO "*** shared version of the library, which I believe you do not have"
+		    $ECHO "*** because a test_compile did reveal that the linker did not use it for"
+		    $ECHO "*** its dynamic dependency list that programs get resolved with at runtime."
+		  fi
+		fi
+		;;
+	      *)
+		newdeplibs="$newdeplibs $i"
+		;;
+	      esac
+	    done
+	  else
+	    # Error occurred in the first compile.  Let's try to salvage
+	    # the situation: Compile a separate program for each library.
+	    for i in $deplibs; do
+	      case $i in
+	      -l*)
+		func_stripname -l '' "$i"
+		name=$func_stripname_result
+		$opt_dry_run || $RM conftest
+		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
+		  ldd_output=`ldd conftest`
+		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		    case " $predeps $postdeps " in
+		    *" $i "*)
+		      newdeplibs="$newdeplibs $i"
+		      i=""
+		      ;;
+		    esac
+		  fi
+		  if test -n "$i" ; then
+		    libname=`eval "\\$ECHO \"$libname_spec\""`
+		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
+		    set dummy $deplib_matches; shift
+		    deplib_match=$1
+		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+		      newdeplibs="$newdeplibs $i"
+		    else
+		      droppeddeps=yes
+		      $ECHO
+		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
+		      $ECHO "*** I have the capability to make that library automatically link in when"
+		      $ECHO "*** you link to this library.  But I can only do this if you have a"
+		      $ECHO "*** shared version of the library, which you do not appear to have"
+		      $ECHO "*** because a test_compile did reveal that the linker did not use this one"
+		      $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime."
+		    fi
+		  fi
+		else
+		  droppeddeps=yes
+		  $ECHO
+		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
+		  $ECHO "*** make it link in!  You will probably need to install it or some"
+		  $ECHO "*** library that it depends on before this library will be fully"
+		  $ECHO "*** functional.  Installing it before continuing would be even better."
+		fi
+		;;
+	      *)
+		newdeplibs="$newdeplibs $i"
+		;;
+	      esac
+	    done
+	  fi
+	  ;;
+	file_magic*)
+	  set dummy $deplibs_check_method; shift
+	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+	  for a_deplib in $deplibs; do
+	    case $a_deplib in
+	    -l*)
+	      func_stripname -l '' "$a_deplib"
+	      name=$func_stripname_result
+	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		case " $predeps $postdeps " in
+		*" $a_deplib "*)
+		  newdeplibs="$newdeplibs $a_deplib"
+		  a_deplib=""
+		  ;;
+		esac
+	      fi
+	      if test -n "$a_deplib" ; then
+		libname=`eval "\\$ECHO \"$libname_spec\""`
+		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+		  for potent_lib in $potential_libs; do
+		      # Follow soft links.
+		      if ls -lLd "$potent_lib" 2>/dev/null |
+			 $GREP " -> " >/dev/null; then
+			continue
+		      fi
+		      # The statement above tries to avoid entering an
+		      # endless loop below, in case of cyclic links.
+		      # We might still enter an endless loop, since a link
+		      # loop can be closed while we follow links,
+		      # but so what?
+		      potlib="$potent_lib"
+		      while test -h "$potlib" 2>/dev/null; do
+			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
+			case $potliblink in
+			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
+			*) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
+			esac
+		      done
+		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
+			 $SED -e 10q |
+			 $EGREP "$file_magic_regex" > /dev/null; then
+			newdeplibs="$newdeplibs $a_deplib"
+			a_deplib=""
+			break 2
+		      fi
+		  done
+		done
+	      fi
+	      if test -n "$a_deplib" ; then
+		droppeddeps=yes
+		$ECHO
+		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
+		$ECHO "*** I have the capability to make that library automatically link in when"
+		$ECHO "*** you link to this library.  But I can only do this if you have a"
+		$ECHO "*** shared version of the library, which you do not appear to have"
+		$ECHO "*** because I did check the linker path looking for a file starting"
+		if test -z "$potlib" ; then
+		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
+		else
+		  $ECHO "*** with $libname and none of the candidates passed a file format test"
+		  $ECHO "*** using a file magic. Last file checked: $potlib"
+		fi
+	      fi
+	      ;;
+	    *)
+	      # Add a -L argument.
+	      newdeplibs="$newdeplibs $a_deplib"
+	      ;;
+	    esac
+	  done # Gone through all deplibs.
+	  ;;
+	match_pattern*)
+	  set dummy $deplibs_check_method; shift
+	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+	  for a_deplib in $deplibs; do
+	    case $a_deplib in
+	    -l*)
+	      func_stripname -l '' "$a_deplib"
+	      name=$func_stripname_result
+	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		case " $predeps $postdeps " in
+		*" $a_deplib "*)
+		  newdeplibs="$newdeplibs $a_deplib"
+		  a_deplib=""
+		  ;;
+		esac
+	      fi
+	      if test -n "$a_deplib" ; then
+		libname=`eval "\\$ECHO \"$libname_spec\""`
+		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+		  for potent_lib in $potential_libs; do
+		    potlib="$potent_lib" # see symlink-check above in file_magic test
+		    if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \
+		       $EGREP "$match_pattern_regex" > /dev/null; then
+		      newdeplibs="$newdeplibs $a_deplib"
+		      a_deplib=""
+		      break 2
+		    fi
+		  done
+		done
+	      fi
+	      if test -n "$a_deplib" ; then
+		droppeddeps=yes
+		$ECHO
+		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
+		$ECHO "*** I have the capability to make that library automatically link in when"
+		$ECHO "*** you link to this library.  But I can only do this if you have a"
+		$ECHO "*** shared version of the library, which you do not appear to have"
+		$ECHO "*** because I did check the linker path looking for a file starting"
+		if test -z "$potlib" ; then
+		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
+		else
+		  $ECHO "*** with $libname and none of the candidates passed a file format test"
+		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
+		fi
+	      fi
+	      ;;
+	    *)
+	      # Add a -L argument.
+	      newdeplibs="$newdeplibs $a_deplib"
+	      ;;
+	    esac
+	  done # Gone through all deplibs.
+	  ;;
+	none | unknown | *)
+	  newdeplibs=""
+	  tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \
+	      -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'`
+	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	    for i in $predeps $postdeps ; do
+	      # can't use Xsed below, because $i might contain '/'
+	      tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"`
+	    done
+	  fi
+	  if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[	 ]//g' |
+	     $GREP . >/dev/null; then
+	    $ECHO
+	    if test "X$deplibs_check_method" = "Xnone"; then
+	      $ECHO "*** Warning: inter-library dependencies are not supported in this platform."
+	    else
+	      $ECHO "*** Warning: inter-library dependencies are not known to be supported."
+	    fi
+	    $ECHO "*** All declared inter-library dependencies are being dropped."
+	    droppeddeps=yes
+	  fi
+	  ;;
+	esac
+	versuffix=$versuffix_save
+	major=$major_save
+	release=$release_save
+	libname=$libname_save
+	name=$name_save
+
+	case $host in
+	*-*-rhapsody* | *-*-darwin1.[012])
+	  # On Rhapsody replace the C library with the System framework
+	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
+	  ;;
+	esac
+
+	if test "$droppeddeps" = yes; then
+	  if test "$module" = yes; then
+	    $ECHO
+	    $ECHO "*** Warning: libtool could not satisfy all declared inter-library"
+	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
+	    $ECHO "*** a static module, that should work as long as the dlopening"
+	    $ECHO "*** application is linked with the -dlopen flag."
+	    if test -z "$global_symbol_pipe"; then
+	      $ECHO
+	      $ECHO "*** However, this would only work if libtool was able to extract symbol"
+	      $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
+	      $ECHO "*** not find such a program.  So, this module is probably useless."
+	      $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
+	    fi
+	    if test "$build_old_libs" = no; then
+	      oldlibs="$output_objdir/$libname.$libext"
+	      build_libtool_libs=module
+	      build_old_libs=yes
+	    else
+	      build_libtool_libs=no
+	    fi
+	  else
+	    $ECHO "*** The inter-library dependencies that have been dropped here will be"
+	    $ECHO "*** automatically added whenever a program is linked with this library"
+	    $ECHO "*** or is declared to -dlopen it."
+
+	    if test "$allow_undefined" = no; then
+	      $ECHO
+	      $ECHO "*** Since this library must not contain undefined symbols,"
+	      $ECHO "*** because either the platform does not support them or"
+	      $ECHO "*** it was explicitly requested with -no-undefined,"
+	      $ECHO "*** libtool will only create a static version of it."
+	      if test "$build_old_libs" = no; then
+		oldlibs="$output_objdir/$libname.$libext"
+		build_libtool_libs=module
+		build_old_libs=yes
+	      else
+		build_libtool_libs=no
+	      fi
+	    fi
+	  fi
+	fi
+	# Done checking deplibs!
+	deplibs=$newdeplibs
+      fi
+      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
+      case $host in
+	*-*-darwin*)
+	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	  new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	  deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	  ;;
+      esac
+
+      # move library search paths that coincide with paths to not yet
+      # installed libraries to the beginning of the library search list
+      new_libs=
+      for path in $notinst_path; do
+	case " $new_libs " in
+	*" -L$path/$objdir "*) ;;
+	*)
+	  case " $deplibs " in
+	  *" -L$path/$objdir "*)
+	    new_libs="$new_libs -L$path/$objdir" ;;
+	  esac
+	  ;;
+	esac
+      done
+      for deplib in $deplibs; do
+	case $deplib in
+	-L*)
+	  case " $new_libs " in
+	  *" $deplib "*) ;;
+	  *) new_libs="$new_libs $deplib" ;;
+	  esac
+	  ;;
+	*) new_libs="$new_libs $deplib" ;;
+	esac
+      done
+      deplibs="$new_libs"
+
+      # All the library-specific variables (install_libdir is set above).
+      library_names=
+      old_library=
+      dlname=
+
+      # Test again, we may have decided not to build it any more
+      if test "$build_libtool_libs" = yes; then
+	if test "$hardcode_into_libs" = yes; then
+	  # Hardcode the library paths
+	  hardcode_libdirs=
+	  dep_rpath=
+	  rpath="$finalize_rpath"
+	  test "$mode" != relink && rpath="$compile_rpath$rpath"
+	  for libdir in $rpath; do
+	    if test -n "$hardcode_libdir_flag_spec"; then
+	      if test -n "$hardcode_libdir_separator"; then
+		if test -z "$hardcode_libdirs"; then
+		  hardcode_libdirs="$libdir"
+		else
+		  # Just accumulate the unique libdirs.
+		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+		    ;;
+		  *)
+		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+		    ;;
+		  esac
+		fi
+	      else
+		eval flag=\"$hardcode_libdir_flag_spec\"
+		dep_rpath="$dep_rpath $flag"
+	      fi
+	    elif test -n "$runpath_var"; then
+	      case "$perm_rpath " in
+	      *" $libdir "*) ;;
+	      *) perm_rpath="$perm_rpath $libdir" ;;
+	      esac
+	    fi
+	  done
+	  # Substitute the hardcoded libdirs into the rpath.
+	  if test -n "$hardcode_libdir_separator" &&
+	     test -n "$hardcode_libdirs"; then
+	    libdir="$hardcode_libdirs"
+	    if test -n "$hardcode_libdir_flag_spec_ld"; then
+	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
+	    else
+	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
+	    fi
+	  fi
+	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
+	    # We should set the runpath_var.
+	    rpath=
+	    for dir in $perm_rpath; do
+	      rpath="$rpath$dir:"
+	    done
+	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
+	  fi
+	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
+	fi
+
+	shlibpath="$finalize_shlibpath"
+	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
+	if test -n "$shlibpath"; then
+	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
+	fi
+
+	# Get the real and link names of the library.
+	eval shared_ext=\"$shrext_cmds\"
+	eval library_names=\"$library_names_spec\"
+	set dummy $library_names
+	shift
+	realname="$1"
+	shift
+
+	if test -n "$soname_spec"; then
+	  eval soname=\"$soname_spec\"
+	else
+	  soname="$realname"
+	fi
+	if test -z "$dlname"; then
+	  dlname=$soname
+	fi
+
+	lib="$output_objdir/$realname"
+	linknames=
+	for link
+	do
+	  linknames="$linknames $link"
+	done
+
+	# Use standard objects if they are pic
+	test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+	test "X$libobjs" = "X " && libobjs=
+
+	delfiles=
+	if test -n "$export_symbols" && test -n "$include_expsyms"; then
+	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
+	  export_symbols="$output_objdir/$libname.uexp"
+	  delfiles="$delfiles $export_symbols"
+	fi
+
+	orig_export_symbols=
+	case $host_os in
+	cygwin* | mingw* | cegcc*)
+	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
+	    # exporting using user supplied symfile
+	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
+	      # and it's NOT already a .def file. Must figure out
+	      # which of the given symbols are data symbols and tag
+	      # them as such. So, trigger use of export_symbols_cmds.
+	      # export_symbols gets reassigned inside the "prepare
+	      # the list of exported symbols" if statement, so the
+	      # include_expsyms logic still works.
+	      orig_export_symbols="$export_symbols"
+	      export_symbols=
+	      always_export_symbols=yes
+	    fi
+	  fi
+	  ;;
+	esac
+
+	# Prepare the list of exported symbols
+	if test -z "$export_symbols"; then
+	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
+	    func_verbose "generating symbol list for \`$libname.la'"
+	    export_symbols="$output_objdir/$libname.exp"
+	    $opt_dry_run || $RM $export_symbols
+	    cmds=$export_symbols_cmds
+	    save_ifs="$IFS"; IFS='~'
+	    for cmd in $cmds; do
+	      IFS="$save_ifs"
+	      eval cmd=\"$cmd\"
+	      func_len " $cmd"
+	      len=$func_len_result
+	      if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+		func_show_eval "$cmd" 'exit $?'
+		skipped_export=false
+	      else
+		# The command line is too long to execute in one step.
+		func_verbose "using reloadable object file for export list..."
+		skipped_export=:
+		# Break out early, otherwise skipped_export may be
+		# set to false by a later but shorter cmd.
+		break
+	      fi
+	    done
+	    IFS="$save_ifs"
+	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
+	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
+	    fi
+	  fi
+	fi
+
+	if test -n "$export_symbols" && test -n "$include_expsyms"; then
+	  tmp_export_symbols="$export_symbols"
+	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+	  $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
+	fi
+
+	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
+	  # The given exports_symbols file has to be filtered, so filter it.
+	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
+	  # 's' commands which not all seds can handle. GNU sed should be fine
+	  # though. Also, the filter scales superlinearly with the number of
+	  # global variables. join(1) would be nice here, but unfortunately
+	  # isn't a blessed tool.
+	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
+	  delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
+	  export_symbols=$output_objdir/$libname.def
+	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
+	fi
+
+	tmp_deplibs=
+	for test_deplib in $deplibs; do
+	  case " $convenience " in
+	  *" $test_deplib "*) ;;
+	  *)
+	    tmp_deplibs="$tmp_deplibs $test_deplib"
+	    ;;
+	  esac
+	done
+	deplibs="$tmp_deplibs"
+
+	if test -n "$convenience"; then
+	  if test -n "$whole_archive_flag_spec" &&
+	    test "$compiler_needs_object" = yes &&
+	    test -z "$libobjs"; then
+	    # extract the archives, so we have objects to list.
+	    # TODO: could optimize this to just extract one archive.
+	    whole_archive_flag_spec=
+	  fi
+	  if test -n "$whole_archive_flag_spec"; then
+	    save_libobjs=$libobjs
+	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+	    test "X$libobjs" = "X " && libobjs=
+	  else
+	    gentop="$output_objdir/${outputname}x"
+	    generated="$generated $gentop"
+
+	    func_extract_archives $gentop $convenience
+	    libobjs="$libobjs $func_extract_archives_result"
+	    test "X$libobjs" = "X " && libobjs=
+	  fi
+	fi
+
+	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
+	  eval flag=\"$thread_safe_flag_spec\"
+	  linker_flags="$linker_flags $flag"
+	fi
+
+	# Make a backup of the uninstalled library when relinking
+	if test "$mode" = relink; then
+	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
+	fi
+
+	# Do each of the archive commands.
+	if test "$module" = yes && test -n "$module_cmds" ; then
+	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+	    eval test_cmds=\"$module_expsym_cmds\"
+	    cmds=$module_expsym_cmds
+	  else
+	    eval test_cmds=\"$module_cmds\"
+	    cmds=$module_cmds
+	  fi
+	else
+	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+	    eval test_cmds=\"$archive_expsym_cmds\"
+	    cmds=$archive_expsym_cmds
+	  else
+	    eval test_cmds=\"$archive_cmds\"
+	    cmds=$archive_cmds
+	  fi
+	fi
+
+	if test "X$skipped_export" != "X:" &&
+	   func_len " $test_cmds" &&
+	   len=$func_len_result &&
+	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+	  :
+	else
+	  # The command line is too long to link in one step, link piecewise
+	  # or, if using GNU ld and skipped_export is not :, use a linker
+	  # script.
+
+	  # Save the value of $output and $libobjs because we want to
+	  # use them later.  If we have whole_archive_flag_spec, we
+	  # want to use save_libobjs as it was before
+	  # whole_archive_flag_spec was expanded, because we can't
+	  # assume the linker understands whole_archive_flag_spec.
+	  # This may have to be revisited, in case too many
+	  # convenience libraries get linked in and end up exceeding
+	  # the spec.
+	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
+	    save_libobjs=$libobjs
+	  fi
+	  save_output=$output
+	  output_la=`$ECHO "X$output" | $Xsed -e "$basename"`
+
+	  # Clear the reloadable object creation command queue and
+	  # initialize k to one.
+	  test_cmds=
+	  concat_cmds=
+	  objlist=
+	  last_robj=
+	  k=1
+
+	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
+	    output=${output_objdir}/${output_la}.lnkscript
+	    func_verbose "creating GNU ld script: $output"
+	    $ECHO 'INPUT (' > $output
+	    for obj in $save_libobjs
+	    do
+	      $ECHO "$obj" >> $output
+	    done
+	    $ECHO ')' >> $output
+	    delfiles="$delfiles $output"
+	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
+	    output=${output_objdir}/${output_la}.lnk
+	    func_verbose "creating linker input file list: $output"
+	    : > $output
+	    set x $save_libobjs
+	    shift
+	    firstobj=
+	    if test "$compiler_needs_object" = yes; then
+	      firstobj="$1 "
+	      shift
+	    fi
+	    for obj
+	    do
+	      $ECHO "$obj" >> $output
+	    done
+	    delfiles="$delfiles $output"
+	    output=$firstobj\"$file_list_spec$output\"
+	  else
+	    if test -n "$save_libobjs"; then
+	      func_verbose "creating reloadable object files..."
+	      output=$output_objdir/$output_la-${k}.$objext
+	      eval test_cmds=\"$reload_cmds\"
+	      func_len " $test_cmds"
+	      len0=$func_len_result
+	      len=$len0
+
+	      # Loop over the list of objects to be linked.
+	      for obj in $save_libobjs
+	      do
+		func_len " $obj"
+		func_arith $len + $func_len_result
+		len=$func_arith_result
+		if test "X$objlist" = X ||
+		   test "$len" -lt "$max_cmd_len"; then
+		  func_append objlist " $obj"
+		else
+		  # The command $test_cmds is almost too long, add a
+		  # command to the queue.
+		  if test "$k" -eq 1 ; then
+		    # The first file doesn't have a previous command to add.
+		    eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
+		  else
+		    # All subsequent reloadable object files will link in
+		    # the last one created.
+		    eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\"
+		  fi
+		  last_robj=$output_objdir/$output_la-${k}.$objext
+		  func_arith $k + 1
+		  k=$func_arith_result
+		  output=$output_objdir/$output_la-${k}.$objext
+		  objlist=$obj
+		  func_len " $last_robj"
+		  func_arith $len0 + $func_len_result
+		  len=$func_arith_result
+		fi
+	      done
+	      # Handle the remaining objects by creating one last
+	      # reloadable object file.  All subsequent reloadable object
+	      # files will link in the last one created.
+	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+	      eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
+	      if test -n "$last_robj"; then
+	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
+	      fi
+	      delfiles="$delfiles $output"
+
+	    else
+	      output=
+	    fi
+
+	    if ${skipped_export-false}; then
+	      func_verbose "generating symbol list for \`$libname.la'"
+	      export_symbols="$output_objdir/$libname.exp"
+	      $opt_dry_run || $RM $export_symbols
+	      libobjs=$output
+	      # Append the command to create the export file.
+	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
+	      if test -n "$last_robj"; then
+		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
+	      fi
+	    fi
+
+	    test -n "$save_libobjs" &&
+	      func_verbose "creating a temporary reloadable object file: $output"
+
+	    # Loop through the commands generated above and execute them.
+	    save_ifs="$IFS"; IFS='~'
+	    for cmd in $concat_cmds; do
+	      IFS="$save_ifs"
+	      $opt_silent || {
+		  func_quote_for_expand "$cmd"
+		  eval "func_echo $func_quote_for_expand_result"
+	      }
+	      $opt_dry_run || eval "$cmd" || {
+		lt_exit=$?
+
+		# Restore the uninstalled library and exit
+		if test "$mode" = relink; then
+		  ( cd "$output_objdir" && \
+		    $RM "${realname}T" && \
+		    $MV "${realname}U" "$realname" )
+		fi
+
+		exit $lt_exit
+	      }
+	    done
+	    IFS="$save_ifs"
+
+	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
+	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
+	    fi
+	  fi
+
+          if ${skipped_export-false}; then
+	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
+	      tmp_export_symbols="$export_symbols"
+	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+	      $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
+	    fi
+
+	    if test -n "$orig_export_symbols"; then
+	      # The given exports_symbols file has to be filtered, so filter it.
+	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
+	      # 's' commands which not all seds can handle. GNU sed should be fine
+	      # though. Also, the filter scales superlinearly with the number of
+	      # global variables. join(1) would be nice here, but unfortunately
+	      # isn't a blessed tool.
+	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
+	      delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
+	      export_symbols=$output_objdir/$libname.def
+	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
+	    fi
+	  fi
+
+	  libobjs=$output
+	  # Restore the value of output.
+	  output=$save_output
+
+	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
+	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+	    test "X$libobjs" = "X " && libobjs=
+	  fi
+	  # Expand the library linking commands again to reset the
+	  # value of $libobjs for piecewise linking.
+
+	  # Do each of the archive commands.
+	  if test "$module" = yes && test -n "$module_cmds" ; then
+	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+	      cmds=$module_expsym_cmds
+	    else
+	      cmds=$module_cmds
+	    fi
+	  else
+	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+	      cmds=$archive_expsym_cmds
+	    else
+	      cmds=$archive_cmds
+	    fi
+	  fi
+	fi
+
+	if test -n "$delfiles"; then
+	  # Append the command to remove temporary files to $cmds.
+	  eval cmds=\"\$cmds~\$RM $delfiles\"
+	fi
+
+	# Add any objects from preloaded convenience libraries
+	if test -n "$dlprefiles"; then
+	  gentop="$output_objdir/${outputname}x"
+	  generated="$generated $gentop"
+
+	  func_extract_archives $gentop $dlprefiles
+	  libobjs="$libobjs $func_extract_archives_result"
+	  test "X$libobjs" = "X " && libobjs=
+	fi
+
+	save_ifs="$IFS"; IFS='~'
+	for cmd in $cmds; do
+	  IFS="$save_ifs"
+	  eval cmd=\"$cmd\"
+	  $opt_silent || {
+	    func_quote_for_expand "$cmd"
+	    eval "func_echo $func_quote_for_expand_result"
+	  }
+	  $opt_dry_run || eval "$cmd" || {
+	    lt_exit=$?
+
+	    # Restore the uninstalled library and exit
+	    if test "$mode" = relink; then
+	      ( cd "$output_objdir" && \
+	        $RM "${realname}T" && \
+		$MV "${realname}U" "$realname" )
+	    fi
+
+	    exit $lt_exit
+	  }
+	done
+	IFS="$save_ifs"
+
+	# Restore the uninstalled library and exit
+	if test "$mode" = relink; then
+	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
+
+	  if test -n "$convenience"; then
+	    if test -z "$whole_archive_flag_spec"; then
+	      func_show_eval '${RM}r "$gentop"'
+	    fi
+	  fi
+
+	  exit $EXIT_SUCCESS
+	fi
+
+	# Create links to the real library.
+	for linkname in $linknames; do
+	  if test "$realname" != "$linkname"; then
+	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
+	  fi
+	done
+
+	# If -module or -export-dynamic was specified, set the dlname.
+	if test "$module" = yes || test "$export_dynamic" = yes; then
+	  # On all known operating systems, these are identical.
+	  dlname="$soname"
+	fi
+      fi
+      ;;
+
+    obj)
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+	func_warning "\`-dlopen' is ignored for objects"
+      fi
+
+      case " $deplibs" in
+      *\ -l* | *\ -L*)
+	func_warning "\`-l' and \`-L' are ignored for objects" ;;
+      esac
+
+      test -n "$rpath" && \
+	func_warning "\`-rpath' is ignored for objects"
+
+      test -n "$xrpath" && \
+	func_warning "\`-R' is ignored for objects"
+
+      test -n "$vinfo" && \
+	func_warning "\`-version-info' is ignored for objects"
+
+      test -n "$release" && \
+	func_warning "\`-release' is ignored for objects"
+
+      case $output in
+      *.lo)
+	test -n "$objs$old_deplibs" && \
+	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
+
+	libobj=$output
+	func_lo2o "$libobj"
+	obj=$func_lo2o_result
+	;;
+      *)
+	libobj=
+	obj="$output"
+	;;
+      esac
+
+      # Delete the old objects.
+      $opt_dry_run || $RM $obj $libobj
+
+      # Objects from convenience libraries.  This assumes
+      # single-version convenience libraries.  Whenever we create
+      # different ones for PIC/non-PIC, this we'll have to duplicate
+      # the extraction.
+      reload_conv_objs=
+      gentop=
+      # reload_cmds runs $LD directly, so let us get rid of
+      # -Wl from whole_archive_flag_spec and hope we can get by with
+      # turning comma into space..
+      wl=
+
+      if test -n "$convenience"; then
+	if test -n "$whole_archive_flag_spec"; then
+	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
+	  reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
+	else
+	  gentop="$output_objdir/${obj}x"
+	  generated="$generated $gentop"
+
+	  func_extract_archives $gentop $convenience
+	  reload_conv_objs="$reload_objs $func_extract_archives_result"
+	fi
+      fi
+
+      # Create the old-style object.
+      reload_objs="$objs$old_deplibs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
+
+      output="$obj"
+      func_execute_cmds "$reload_cmds" 'exit $?'
+
+      # Exit if we aren't doing a library object file.
+      if test -z "$libobj"; then
+	if test -n "$gentop"; then
+	  func_show_eval '${RM}r "$gentop"'
+	fi
+
+	exit $EXIT_SUCCESS
+      fi
+
+      if test "$build_libtool_libs" != yes; then
+	if test -n "$gentop"; then
+	  func_show_eval '${RM}r "$gentop"'
+	fi
+
+	# Create an invalid libtool object if no PIC, so that we don't
+	# accidentally link it into a program.
+	# $show "echo timestamp > $libobj"
+	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
+	exit $EXIT_SUCCESS
+      fi
+
+      if test -n "$pic_flag" || test "$pic_mode" != default; then
+	# Only do commands if we really have different PIC objects.
+	reload_objs="$libobjs $reload_conv_objs"
+	output="$libobj"
+	func_execute_cmds "$reload_cmds" 'exit $?'
+      fi
+
+      if test -n "$gentop"; then
+	func_show_eval '${RM}r "$gentop"'
+      fi
+
+      exit $EXIT_SUCCESS
+      ;;
+
+    prog)
+      case $host in
+	*cygwin*) func_stripname '' '.exe' "$output"
+	          output=$func_stripname_result.exe;;
+      esac
+      test -n "$vinfo" && \
+	func_warning "\`-version-info' is ignored for programs"
+
+      test -n "$release" && \
+	func_warning "\`-release' is ignored for programs"
+
+      test "$preload" = yes \
+        && test "$dlopen_support" = unknown \
+	&& test "$dlopen_self" = unknown \
+	&& test "$dlopen_self_static" = unknown && \
+	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
+
+      case $host in
+      *-*-rhapsody* | *-*-darwin1.[012])
+	# On Rhapsody replace the C library is the System framework
+	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
+	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
+	;;
+      esac
+
+      case $host in
+      *-*-darwin*)
+	# Don't allow lazy linking, it breaks C++ global constructors
+	# But is supposedly fixed on 10.4 or later (yay!).
+	if test "$tagname" = CXX ; then
+	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
+	    10.[0123])
+	      compile_command="$compile_command ${wl}-bind_at_load"
+	      finalize_command="$finalize_command ${wl}-bind_at_load"
+	    ;;
+	  esac
+	fi
+	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
+	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	;;
+      esac
+
+
+      # move library search paths that coincide with paths to not yet
+      # installed libraries to the beginning of the library search list
+      new_libs=
+      for path in $notinst_path; do
+	case " $new_libs " in
+	*" -L$path/$objdir "*) ;;
+	*)
+	  case " $compile_deplibs " in
+	  *" -L$path/$objdir "*)
+	    new_libs="$new_libs -L$path/$objdir" ;;
+	  esac
+	  ;;
+	esac
+      done
+      for deplib in $compile_deplibs; do
+	case $deplib in
+	-L*)
+	  case " $new_libs " in
+	  *" $deplib "*) ;;
+	  *) new_libs="$new_libs $deplib" ;;
+	  esac
+	  ;;
+	*) new_libs="$new_libs $deplib" ;;
+	esac
+      done
+      compile_deplibs="$new_libs"
+
+
+      compile_command="$compile_command $compile_deplibs"
+      finalize_command="$finalize_command $finalize_deplibs"
+
+      if test -n "$rpath$xrpath"; then
+	# If the user specified any rpath flags, then add them.
+	for libdir in $rpath $xrpath; do
+	  # This is the magic to use -rpath.
+	  case "$finalize_rpath " in
+	  *" $libdir "*) ;;
+	  *) finalize_rpath="$finalize_rpath $libdir" ;;
+	  esac
+	done
+      fi
+
+      # Now hardcode the library paths
+      rpath=
+      hardcode_libdirs=
+      for libdir in $compile_rpath $finalize_rpath; do
+	if test -n "$hardcode_libdir_flag_spec"; then
+	  if test -n "$hardcode_libdir_separator"; then
+	    if test -z "$hardcode_libdirs"; then
+	      hardcode_libdirs="$libdir"
+	    else
+	      # Just accumulate the unique libdirs.
+	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+		;;
+	      *)
+		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+		;;
+	      esac
+	    fi
+	  else
+	    eval flag=\"$hardcode_libdir_flag_spec\"
+	    rpath="$rpath $flag"
+	  fi
+	elif test -n "$runpath_var"; then
+	  case "$perm_rpath " in
+	  *" $libdir "*) ;;
+	  *) perm_rpath="$perm_rpath $libdir" ;;
+	  esac
+	fi
+	case $host in
+	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
+	  case :$dllsearchpath: in
+	  *":$libdir:"*) ;;
+	  ::) dllsearchpath=$libdir;;
+	  *) dllsearchpath="$dllsearchpath:$libdir";;
+	  esac
+	  case :$dllsearchpath: in
+	  *":$testbindir:"*) ;;
+	  ::) dllsearchpath=$testbindir;;
+	  *) dllsearchpath="$dllsearchpath:$testbindir";;
+	  esac
+	  ;;
+	esac
+      done
+      # Substitute the hardcoded libdirs into the rpath.
+      if test -n "$hardcode_libdir_separator" &&
+	 test -n "$hardcode_libdirs"; then
+	libdir="$hardcode_libdirs"
+	eval rpath=\" $hardcode_libdir_flag_spec\"
+      fi
+      compile_rpath="$rpath"
+
+      rpath=
+      hardcode_libdirs=
+      for libdir in $finalize_rpath; do
+	if test -n "$hardcode_libdir_flag_spec"; then
+	  if test -n "$hardcode_libdir_separator"; then
+	    if test -z "$hardcode_libdirs"; then
+	      hardcode_libdirs="$libdir"
+	    else
+	      # Just accumulate the unique libdirs.
+	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+		;;
+	      *)
+		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+		;;
+	      esac
+	    fi
+	  else
+	    eval flag=\"$hardcode_libdir_flag_spec\"
+	    rpath="$rpath $flag"
+	  fi
+	elif test -n "$runpath_var"; then
+	  case "$finalize_perm_rpath " in
+	  *" $libdir "*) ;;
+	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
+	  esac
+	fi
+      done
+      # Substitute the hardcoded libdirs into the rpath.
+      if test -n "$hardcode_libdir_separator" &&
+	 test -n "$hardcode_libdirs"; then
+	libdir="$hardcode_libdirs"
+	eval rpath=\" $hardcode_libdir_flag_spec\"
+      fi
+      finalize_rpath="$rpath"
+
+      if test -n "$libobjs" && test "$build_old_libs" = yes; then
+	# Transform all the library objects into standard objects.
+	compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+	finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+      fi
+
+      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
+
+      # template prelinking step
+      if test -n "$prelink_cmds"; then
+	func_execute_cmds "$prelink_cmds" 'exit $?'
+      fi
+
+      wrappers_required=yes
+      case $host in
+      *cygwin* | *mingw* )
+        if test "$build_libtool_libs" != yes; then
+          wrappers_required=no
+        fi
+        ;;
+      *cegcc)
+        # Disable wrappers for cegcc, we are cross compiling anyway.
+        wrappers_required=no
+        ;;
+      *)
+        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
+          wrappers_required=no
+        fi
+        ;;
+      esac
+      if test "$wrappers_required" = no; then
+	# Replace the output file specification.
+	compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+	link_command="$compile_command$compile_rpath"
+
+	# We have no uninstalled library dependencies, so finalize right now.
+	exit_status=0
+	func_show_eval "$link_command" 'exit_status=$?'
+
+	# Delete the generated files.
+	if test -f "$output_objdir/${outputname}S.${objext}"; then
+	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
+	fi
+
+	exit $exit_status
+      fi
+
+      if test -n "$compile_shlibpath$finalize_shlibpath"; then
+	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
+      fi
+      if test -n "$finalize_shlibpath"; then
+	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
+      fi
+
+      compile_var=
+      finalize_var=
+      if test -n "$runpath_var"; then
+	if test -n "$perm_rpath"; then
+	  # We should set the runpath_var.
+	  rpath=
+	  for dir in $perm_rpath; do
+	    rpath="$rpath$dir:"
+	  done
+	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
+	fi
+	if test -n "$finalize_perm_rpath"; then
+	  # We should set the runpath_var.
+	  rpath=
+	  for dir in $finalize_perm_rpath; do
+	    rpath="$rpath$dir:"
+	  done
+	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
+	fi
+      fi
+
+      if test "$no_install" = yes; then
+	# We don't need to create a wrapper script.
+	link_command="$compile_var$compile_command$compile_rpath"
+	# Replace the output file specification.
+	link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+	# Delete the old output file.
+	$opt_dry_run || $RM $output
+	# Link the executable and exit
+	func_show_eval "$link_command" 'exit $?'
+	exit $EXIT_SUCCESS
+      fi
+
+      if test "$hardcode_action" = relink; then
+	# Fast installation is not supported
+	link_command="$compile_var$compile_command$compile_rpath"
+	relink_command="$finalize_var$finalize_command$finalize_rpath"
+
+	func_warning "this platform does not like uninstalled shared libraries"
+	func_warning "\`$output' will be relinked during installation"
+      else
+	if test "$fast_install" != no; then
+	  link_command="$finalize_var$compile_command$finalize_rpath"
+	  if test "$fast_install" = yes; then
+	    relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
+	  else
+	    # fast_install is set to needless
+	    relink_command=
+	  fi
+	else
+	  link_command="$compile_var$compile_command$compile_rpath"
+	  relink_command="$finalize_var$finalize_command$finalize_rpath"
+	fi
+      fi
+
+      # Replace the output file specification.
+      link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
+
+      # Delete the old output files.
+      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
+
+      func_show_eval "$link_command" 'exit $?'
+
+      # Now create the wrapper script.
+      func_verbose "creating $output"
+
+      # Quote the relink command for shipping.
+      if test -n "$relink_command"; then
+	# Preserve any variables that may affect compiler behavior
+	for var in $variables_saved_for_relink; do
+	  if eval test -z \"\${$var+set}\"; then
+	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
+	  elif eval var_value=\$$var; test -z "$var_value"; then
+	    relink_command="$var=; export $var; $relink_command"
+	  else
+	    func_quote_for_eval "$var_value"
+	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
+	  fi
+	done
+	relink_command="(cd `pwd`; $relink_command)"
+	relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+      fi
+
+      # Quote $ECHO for shipping.
+      if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then
+	case $progpath in
+	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
+	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
+	esac
+	qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"`
+      else
+	qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"`
+      fi
+
+      # Only actually do things if not in dry run mode.
+      $opt_dry_run || {
+	# win32 will think the script is a binary if it has
+	# a .exe suffix, so we strip it off here.
+	case $output in
+	  *.exe) func_stripname '' '.exe' "$output"
+	         output=$func_stripname_result ;;
+	esac
+	# test for cygwin because mv fails w/o .exe extensions
+	case $host in
+	  *cygwin*)
+	    exeext=.exe
+	    func_stripname '' '.exe' "$outputname"
+	    outputname=$func_stripname_result ;;
+	  *) exeext= ;;
+	esac
+	case $host in
+	  *cygwin* | *mingw* )
+	    func_dirname_and_basename "$output" "" "."
+	    output_name=$func_basename_result
+	    output_path=$func_dirname_result
+	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
+	    cwrapper="$output_path/$output_name.exe"
+	    $RM $cwrappersource $cwrapper
+	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
+
+	    func_emit_cwrapperexe_src > $cwrappersource
+
+	    # The wrapper executable is built using the $host compiler,
+	    # because it contains $host paths and files. If cross-
+	    # compiling, it, like the target executable, must be
+	    # executed on the $host or under an emulation environment.
+	    $opt_dry_run || {
+	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
+	      $STRIP $cwrapper
+	    }
+
+	    # Now, create the wrapper script for func_source use:
+	    func_ltwrapper_scriptname $cwrapper
+	    $RM $func_ltwrapper_scriptname_result
+	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
+	    $opt_dry_run || {
+	      # note: this script will not be executed, so do not chmod.
+	      if test "x$build" = "x$host" ; then
+		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
+	      else
+		func_emit_wrapper no > $func_ltwrapper_scriptname_result
+	      fi
+	    }
+	  ;;
+	  * )
+	    $RM $output
+	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
+
+	    func_emit_wrapper no > $output
+	    chmod +x $output
+	  ;;
+	esac
+      }
+      exit $EXIT_SUCCESS
+      ;;
+    esac
+
+    # See if we need to build an old-fashioned archive.
+    for oldlib in $oldlibs; do
+
+      if test "$build_libtool_libs" = convenience; then
+	oldobjs="$libobjs_save $symfileobj"
+	addlibs="$convenience"
+	build_libtool_libs=no
+      else
+	if test "$build_libtool_libs" = module; then
+	  oldobjs="$libobjs_save"
+	  build_libtool_libs=no
+	else
+	  oldobjs="$old_deplibs $non_pic_objects"
+	  if test "$preload" = yes && test -f "$symfileobj"; then
+	    oldobjs="$oldobjs $symfileobj"
+	  fi
+	fi
+	addlibs="$old_convenience"
+      fi
+
+      if test -n "$addlibs"; then
+	gentop="$output_objdir/${outputname}x"
+	generated="$generated $gentop"
+
+	func_extract_archives $gentop $addlibs
+	oldobjs="$oldobjs $func_extract_archives_result"
+      fi
+
+      # Do each command in the archive commands.
+      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
+	cmds=$old_archive_from_new_cmds
+      else
+
+	# Add any objects from preloaded convenience libraries
+	if test -n "$dlprefiles"; then
+	  gentop="$output_objdir/${outputname}x"
+	  generated="$generated $gentop"
+
+	  func_extract_archives $gentop $dlprefiles
+	  oldobjs="$oldobjs $func_extract_archives_result"
+	fi
+
+	# POSIX demands no paths to be encoded in archives.  We have
+	# to avoid creating archives with duplicate basenames if we
+	# might have to extract them afterwards, e.g., when creating a
+	# static archive out of a convenience library, or when linking
+	# the entirety of a libtool archive into another (currently
+	# not supported by libtool).
+	if (for obj in $oldobjs
+	    do
+	      func_basename "$obj"
+	      $ECHO "$func_basename_result"
+	    done | sort | sort -uc >/dev/null 2>&1); then
+	  :
+	else
+	  $ECHO "copying selected object files to avoid basename conflicts..."
+	  gentop="$output_objdir/${outputname}x"
+	  generated="$generated $gentop"
+	  func_mkdir_p "$gentop"
+	  save_oldobjs=$oldobjs
+	  oldobjs=
+	  counter=1
+	  for obj in $save_oldobjs
+	  do
+	    func_basename "$obj"
+	    objbase="$func_basename_result"
+	    case " $oldobjs " in
+	    " ") oldobjs=$obj ;;
+	    *[\ /]"$objbase "*)
+	      while :; do
+		# Make sure we don't pick an alternate name that also
+		# overlaps.
+		newobj=lt$counter-$objbase
+		func_arith $counter + 1
+		counter=$func_arith_result
+		case " $oldobjs " in
+		*[\ /]"$newobj "*) ;;
+		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
+		esac
+	      done
+	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
+	      oldobjs="$oldobjs $gentop/$newobj"
+	      ;;
+	    *) oldobjs="$oldobjs $obj" ;;
+	    esac
+	  done
+	fi
+	eval cmds=\"$old_archive_cmds\"
+
+	func_len " $cmds"
+	len=$func_len_result
+	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+	  cmds=$old_archive_cmds
+	else
+	  # the command line is too long to link in one step, link in parts
+	  func_verbose "using piecewise archive linking..."
+	  save_RANLIB=$RANLIB
+	  RANLIB=:
+	  objlist=
+	  concat_cmds=
+	  save_oldobjs=$oldobjs
+	  oldobjs=
+	  # Is there a better way of finding the last object in the list?
+	  for obj in $save_oldobjs
+	  do
+	    last_oldobj=$obj
+	  done
+	  eval test_cmds=\"$old_archive_cmds\"
+	  func_len " $test_cmds"
+	  len0=$func_len_result
+	  len=$len0
+	  for obj in $save_oldobjs
+	  do
+	    func_len " $obj"
+	    func_arith $len + $func_len_result
+	    len=$func_arith_result
+	    func_append objlist " $obj"
+	    if test "$len" -lt "$max_cmd_len"; then
+	      :
+	    else
+	      # the above command should be used before it gets too long
+	      oldobjs=$objlist
+	      if test "$obj" = "$last_oldobj" ; then
+		RANLIB=$save_RANLIB
+	      fi
+	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
+	      objlist=
+	      len=$len0
+	    fi
+	  done
+	  RANLIB=$save_RANLIB
+	  oldobjs=$objlist
+	  if test "X$oldobjs" = "X" ; then
+	    eval cmds=\"\$concat_cmds\"
+	  else
+	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
+	  fi
+	fi
+      fi
+      func_execute_cmds "$cmds" 'exit $?'
+    done
+
+    test -n "$generated" && \
+      func_show_eval "${RM}r$generated"
+
+    # Now create the libtool archive.
+    case $output in
+    *.la)
+      old_library=
+      test "$build_old_libs" = yes && old_library="$libname.$libext"
+      func_verbose "creating $output"
+
+      # Preserve any variables that may affect compiler behavior
+      for var in $variables_saved_for_relink; do
+	if eval test -z \"\${$var+set}\"; then
+	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
+	elif eval var_value=\$$var; test -z "$var_value"; then
+	  relink_command="$var=; export $var; $relink_command"
+	else
+	  func_quote_for_eval "$var_value"
+	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
+	fi
+      done
+      # Quote the link command for shipping.
+      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
+      relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+      if test "$hardcode_automatic" = yes ; then
+	relink_command=
+      fi
+
+      # Only create the output if not a dry run.
+      $opt_dry_run || {
+	for installed in no yes; do
+	  if test "$installed" = yes; then
+	    if test -z "$install_libdir"; then
+	      break
+	    fi
+	    output="$output_objdir/$outputname"i
+	    # Replace all uninstalled libtool libraries with the installed ones
+	    newdependency_libs=
+	    for deplib in $dependency_libs; do
+	      case $deplib in
+	      *.la)
+		func_basename "$deplib"
+		name="$func_basename_result"
+		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+		test -z "$libdir" && \
+		  func_fatal_error "\`$deplib' is not a valid libtool archive"
+		newdependency_libs="$newdependency_libs $libdir/$name"
+		;;
+	      *) newdependency_libs="$newdependency_libs $deplib" ;;
+	      esac
+	    done
+	    dependency_libs="$newdependency_libs"
+	    newdlfiles=
+
+	    for lib in $dlfiles; do
+	      case $lib in
+	      *.la)
+	        func_basename "$lib"
+		name="$func_basename_result"
+		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+		test -z "$libdir" && \
+		  func_fatal_error "\`$lib' is not a valid libtool archive"
+		newdlfiles="$newdlfiles $libdir/$name"
+		;;
+	      *) newdlfiles="$newdlfiles $lib" ;;
+	      esac
+	    done
+	    dlfiles="$newdlfiles"
+	    newdlprefiles=
+	    for lib in $dlprefiles; do
+	      case $lib in
+	      *.la)
+		# Only pass preopened files to the pseudo-archive (for
+		# eventual linking with the app. that links it) if we
+		# didn't already link the preopened objects directly into
+		# the library:
+		func_basename "$lib"
+		name="$func_basename_result"
+		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+		test -z "$libdir" && \
+		  func_fatal_error "\`$lib' is not a valid libtool archive"
+		newdlprefiles="$newdlprefiles $libdir/$name"
+		;;
+	      esac
+	    done
+	    dlprefiles="$newdlprefiles"
+	  else
+	    newdlfiles=
+	    for lib in $dlfiles; do
+	      case $lib in
+		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+		*) abs=`pwd`"/$lib" ;;
+	      esac
+	      newdlfiles="$newdlfiles $abs"
+	    done
+	    dlfiles="$newdlfiles"
+	    newdlprefiles=
+	    for lib in $dlprefiles; do
+	      case $lib in
+		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+		*) abs=`pwd`"/$lib" ;;
+	      esac
+	      newdlprefiles="$newdlprefiles $abs"
+	    done
+	    dlprefiles="$newdlprefiles"
+	  fi
+	  $RM $output
+	  # place dlname in correct position for cygwin
+	  tdlname=$dlname
+	  case $host,$output,$installed,$module,$dlname in
+	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
+	  esac
+	  $ECHO > $output "\
+# $outputname - a libtool library file
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# The name that we can dlopen(3).
+dlname='$tdlname'
+
+# Names of this library.
+library_names='$library_names'
+
+# The name of the static archive.
+old_library='$old_library'
+
+# Linker flags that can not go in dependency_libs.
+inherited_linker_flags='$new_inherited_linker_flags'
+
+# Libraries that this one depends upon.
+dependency_libs='$dependency_libs'
+
+# Names of additional weak libraries provided by this library
+weak_library_names='$weak_libs'
+
+# Version information for $libname.
+current=$current
+age=$age
+revision=$revision
+
+# Is this an already installed library?
+installed=$installed
+
+# Should we warn about portability when linking against -modules?
+shouldnotlink=$module
+
+# Files to dlopen/dlpreopen
+dlopen='$dlfiles'
+dlpreopen='$dlprefiles'
+
+# Directory that this library needs to be installed in:
+libdir='$install_libdir'"
+	  if test "$installed" = no && test "$need_relink" = yes; then
+	    $ECHO >> $output "\
+relink_command=\"$relink_command\""
+	  fi
+	done
+      }
+
+      # Do a symbolic link so that the libtool archive can be found in
+      # LD_LIBRARY_PATH before the program is installed.
+      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
+      ;;
+    esac
+    exit $EXIT_SUCCESS
+}
+
+{ test "$mode" = link || test "$mode" = relink; } &&
+    func_mode_link ${1+"$@"}
+
+
+# func_mode_uninstall arg...
+func_mode_uninstall ()
+{
+    $opt_debug
+    RM="$nonopt"
+    files=
+    rmforce=
+    exit_status=0
+
+    # This variable tells wrapper scripts just to set variables rather
+    # than running their programs.
+    libtool_install_magic="$magic"
+
+    for arg
+    do
+      case $arg in
+      -f) RM="$RM $arg"; rmforce=yes ;;
+      -*) RM="$RM $arg" ;;
+      *) files="$files $arg" ;;
+      esac
+    done
+
+    test -z "$RM" && \
+      func_fatal_help "you must specify an RM program"
+
+    rmdirs=
+
+    origobjdir="$objdir"
+    for file in $files; do
+      func_dirname "$file" "" "."
+      dir="$func_dirname_result"
+      if test "X$dir" = X.; then
+	objdir="$origobjdir"
+      else
+	objdir="$dir/$origobjdir"
+      fi
+      func_basename "$file"
+      name="$func_basename_result"
+      test "$mode" = uninstall && objdir="$dir"
+
+      # Remember objdir for removal later, being careful to avoid duplicates
+      if test "$mode" = clean; then
+	case " $rmdirs " in
+	  *" $objdir "*) ;;
+	  *) rmdirs="$rmdirs $objdir" ;;
+	esac
+      fi
+
+      # Don't error if the file doesn't exist and rm -f was used.
+      if { test -L "$file"; } >/dev/null 2>&1 ||
+	 { test -h "$file"; } >/dev/null 2>&1 ||
+	 test -f "$file"; then
+	:
+      elif test -d "$file"; then
+	exit_status=1
+	continue
+      elif test "$rmforce" = yes; then
+	continue
+      fi
+
+      rmfiles="$file"
+
+      case $name in
+      *.la)
+	# Possibly a libtool archive, so verify it.
+	if func_lalib_p "$file"; then
+	  func_source $dir/$name
+
+	  # Delete the libtool libraries and symlinks.
+	  for n in $library_names; do
+	    rmfiles="$rmfiles $objdir/$n"
+	  done
+	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
+
+	  case "$mode" in
+	  clean)
+	    case "  $library_names " in
+	    # "  " in the beginning catches empty $dlname
+	    *" $dlname "*) ;;
+	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
+	    esac
+	    test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
+	    ;;
+	  uninstall)
+	    if test -n "$library_names"; then
+	      # Do each command in the postuninstall commands.
+	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+	    fi
+
+	    if test -n "$old_library"; then
+	      # Do each command in the old_postuninstall commands.
+	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+	    fi
+	    # FIXME: should reinstall the best remaining shared library.
+	    ;;
+	  esac
+	fi
+	;;
+
+      *.lo)
+	# Possibly a libtool object, so verify it.
+	if func_lalib_p "$file"; then
+
+	  # Read the .lo file
+	  func_source $dir/$name
+
+	  # Add PIC object to the list of files to remove.
+	  if test -n "$pic_object" &&
+	     test "$pic_object" != none; then
+	    rmfiles="$rmfiles $dir/$pic_object"
+	  fi
+
+	  # Add non-PIC object to the list of files to remove.
+	  if test -n "$non_pic_object" &&
+	     test "$non_pic_object" != none; then
+	    rmfiles="$rmfiles $dir/$non_pic_object"
+	  fi
+	fi
+	;;
+
+      *)
+	if test "$mode" = clean ; then
+	  noexename=$name
+	  case $file in
+	  *.exe)
+	    func_stripname '' '.exe' "$file"
+	    file=$func_stripname_result
+	    func_stripname '' '.exe' "$name"
+	    noexename=$func_stripname_result
+	    # $file with .exe has already been added to rmfiles,
+	    # add $file without .exe
+	    rmfiles="$rmfiles $file"
+	    ;;
+	  esac
+	  # Do a test to see if this is a libtool program.
+	  if func_ltwrapper_p "$file"; then
+	    if func_ltwrapper_executable_p "$file"; then
+	      func_ltwrapper_scriptname "$file"
+	      relink_command=
+	      func_source $func_ltwrapper_scriptname_result
+	      rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
+	    else
+	      relink_command=
+	      func_source $dir/$noexename
+	    fi
+
+	    # note $name still contains .exe if it was in $file originally
+	    # as does the version of $file that was added into $rmfiles
+	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
+	    if test "$fast_install" = yes && test -n "$relink_command"; then
+	      rmfiles="$rmfiles $objdir/lt-$name"
+	    fi
+	    if test "X$noexename" != "X$name" ; then
+	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
+	    fi
+	  fi
+	fi
+	;;
+      esac
+      func_show_eval "$RM $rmfiles" 'exit_status=1'
+    done
+    objdir="$origobjdir"
+
+    # Try to remove the ${objdir}s in the directories where we deleted files
+    for dir in $rmdirs; do
+      if test -d "$dir"; then
+	func_show_eval "rmdir $dir >/dev/null 2>&1"
+      fi
+    done
+
+    exit $exit_status
+}
+
+{ test "$mode" = uninstall || test "$mode" = clean; } &&
+    func_mode_uninstall ${1+"$@"}
+
+test -z "$mode" && {
+  help="$generic_help"
+  func_fatal_help "you must specify a MODE"
+}
+
+test -z "$exec_cmd" && \
+  func_fatal_help "invalid operation mode \`$mode'"
+
+if test -n "$exec_cmd"; then
+  eval exec "$exec_cmd"
+  exit $EXIT_FAILURE
+fi
+
+exit $exit_status
+
+
+# The TAGs below are defined such that we never get into a situation
+# in which we disable both kinds of libraries.  Given conflicting
+# choices, we go for a static library, that is the most portable,
+# since we can't tell whether shared libraries were disabled because
+# the user asked for that or because the platform doesn't support
+# them.  This is particularly important on AIX, because we don't
+# support having both static and shared libraries enabled at the same
+# time on that platform, so we default to a shared-only configuration.
+# If a disable-shared tag is given, we'll fallback to a static-only
+# configuration.  But we'll never go from static-only to shared-only.
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
+build_libtool_libs=no
+build_old_libs=yes
+# ### END LIBTOOL TAG CONFIG: disable-shared
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-static
+build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
+# ### END LIBTOOL TAG CONFIG: disable-static
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation:2
+# End:
+# vi:sw=2
+

-- 
idjc packaging



More information about the pkg-multimedia-commits mailing list