+CRYPTOLIB="$enable_cryptolib"
+case "$enable_cryptolib" in
+"openssl")
+ test $HAVE_OPENSSL = no && AC_MSG_ERROR(openssl not found)
+ crypto_ldflags="$openssl_ldflags"
+ ;;
+"gcrypt")
+ test $HAVE_GCRYPT = no && AC_MSG_ERROR(gcrypt not found)
+ crypto_ldflags="$gcrypt_ldflags"
+ ;;
+"")
+ crypto_ldflags=
+ if test $HAVE_GCRYPT = yes; then
+ CRYPTOLIB=gcrypt
+ crypto_ldflags="$gcrypt_ldflags"
+ fi
+ if test $HAVE_OPENSSL = yes; then
+ CRYPTOLIB=openssl
+ crypto_ldflags="$openssl_ldflags"
+ fi
+ ;;
+*)
+ AC_MSG_ERROR([invalid value "$enable_cryptolib" for --enable-cryptolib])
+ ;;
+esac
+AC_SUBST(crypto_ldflags)
+########################################################################## iconv
+STASH_FLAGS
+LIBS=
+AC_SEARCH_LIBS([libiconv_open], [iconv],
+ [iconv_ldflags="$LIBS"],
+ []
+)
+AC_SUBST(iconv_ldflags)
+AC_MSG_CHECKING([whether iconv needs const char ** cast])
+AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ #include <iconv.h>
+ ],[
+ size_t iconv(iconv_t cd, const char **inbuf,
+ size_t *inbytesleft, char **outbuf,
+ size_t *outbytesleft);
+ ])
+],
+ [cast='(const char **)'; msg=yes],
+ [cast=; msg=no]
+)
+AC_DEFINE_UNQUOTED(ICONV_CAST, $cast, [cast for second arg to iconv()])
+AC_MSG_RESULT($msg)
+UNSTASH_FLAGS
+########################################################################### ucred
+AC_CHECK_TYPE([struct ucred], [
+ AC_DEFINE(HAVE_UCRED, 1, define to 1 you have struct ucred)
+], [], [
+ #include <sys/types.h>
+ #include <sys/socket.h>
+])
+################################################################### FNM_EXTMATCH
+AC_MSG_CHECKING(for extended wildcard pattern matching)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ #include <fnmatch.h>
+]], [[
+ unsigned n = FNM_EXTMATCH;
+]])], [have_fnm_extmatch=yes], [have_fnm_extmatch=no])
+AC_MSG_RESULT($have_fnm_extmatch)
+if test $have_fnm_extmatch = yes; then
+ AC_DEFINE(HAVE_FNM_EXTMATCH, 1, define to 1 if FNM_EXTMATCH is defined)
+fi
+########################################################################### curses
+STASH_FLAGS
+LIB_ARG_WITH([curses], [])
+HAVE_CURSES=yes
+AC_CHECK_HEADER(curses.h, [], [HAVE_CURSES=no])
+AC_SEARCH_LIBS([initscr], [ncursesw curses], [], [HAVE_CURSES=no])
+curses_ldflags="$curses_ldflags $LIBS"
+LIB_SUBST_FLAGS(curses)
+UNSTASH_FLAGS
+########################################################################### ip_mreqn
+AC_CHECK_TYPE([struct ip_mreqn], [
+ AC_DEFINE(HAVE_IP_MREQN, 1, define to 1 if you have struct ip_mreqn)
+], [], [
+ #include <netdb.h>
+ #include <net/if.h>
+])
+########################################################################### ogg
+STASH_FLAGS
+LIB_ARG_WITH([ogg], [-logg])
+HAVE_OGG=yes
+AC_CHECK_HEADERS([ogg/ogg.h], [], [HAVE_OGG=no])
+AC_CHECK_LIB([ogg], [ogg_stream_init], [], [HAVE_OGG=no])
+AC_CHECK_LIB([ogg], [ogg_stream_flush_fill], [
+ AC_DEFINE(HAVE_OGG_STREAM_FLUSH_FILL, 1, [libogg >= 1.3.0])])
+LIB_SUBST_FLAGS(ogg)
+UNSTASH_FLAGS
+######################################################################### vorbis
+STASH_FLAGS
+LIB_ARG_WITH([vorbis], [-lvorbis -lvorbisfile])
+HAVE_VORBIS=yes
+AC_CHECK_HEADERS([vorbis/codec.h], [], [HAVE_VORBIS=no])
+AC_CHECK_LIB([vorbis], [vorbis_info_init], [], [HAVE_VORBIS=no])
+LIB_SUBST_FLAGS(vorbis)
+UNSTASH_FLAGS
+######################################################################### speex
+STASH_FLAGS
+LIB_ARG_WITH([speex], [-lspeex])
+HAVE_SPEEX=yes
+AC_CHECK_HEADERS([speex/speex.h], [], [HAVE_SPEEX=no])
+AC_CHECK_LIB([speex], [speex_decoder_init], [], [HAVE_SPEEX=no])
+LIB_SUBST_FLAGS(speex)
+UNSTASH_FLAGS
+######################################################################### opus
+STASH_FLAGS
+LIB_ARG_WITH([opus], [-lopus])
+HAVE_OPUS=yes
+AC_CHECK_HEADERS([opus/opus.h], [], [HAVE_OPUS=no])
+AC_CHECK_LIB([opus], [opus_multistream_decode], [], [HAVE_OPUS=no])
+LIB_SUBST_FLAGS(opus)
+UNSTASH_FLAGS
+########################################################################### flac
+STASH_FLAGS
+LIB_ARG_WITH([flac], [-lFLAC -lm])
+HAVE_FLAC=yes
+AC_CHECK_HEADER(FLAC/stream_decoder.h, [], HAVE_FLAC=no)
+AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_init_file], [], HAVE_FLAC=no)
+LIB_SUBST_FLAGS(flac)
+UNSTASH_FLAGS
+
+# some helper functions for codecs which use the ogg container format
+AC_DEFUN([NEED_OGG_OBJECTS], [{
+ test "$HAVE_OGG" = 'yes' -a \( \
+ "$HAVE_VORBIS" = 'yes' \
+ -o "$HAVE_SPEEX" = 'yes' \
+ -o "$HAVE_OPUS" = 'yes' \
+ -o "$HAVE_FLAC" = 'yes' \
+ \)
+}])
+AC_DEFUN([NEED_VORBIS_OBJECTS], [{
+ test "$HAVE_OGG" = 'yes' -a "$HAVE_VORBIS" = 'yes'
+}])
+AC_DEFUN([NEED_SPEEX_OBJECTS], [{
+ test "$HAVE_OGG" = 'yes' -a "$HAVE_SPEEX" = 'yes'
+}])
+AC_DEFUN([NEED_OPUS_OBJECTS], [{
+ test "$HAVE_OGG" = 'yes' -a "$HAVE_OPUS" = 'yes'
+}])
+AC_DEFUN([NEED_FLAC_OBJECTS], [{
+ test "$HAVE_OGG" = 'yes' -a "$HAVE_FLAC" = 'yes'
+}])
+########################################################################### faad
+STASH_FLAGS
+LIB_ARG_WITH([faad], [-lfaad -lmp4ff])
+HAVE_FAAD=yes
+AC_CHECK_HEADER(neaacdec.h, [], HAVE_FAAD=no)
+AC_CHECK_HEADER(mp4ff.h, [], HAVE_FAAD=no)
+AC_CHECK_LIB([faad], [NeAACDecOpen], [], HAVE_FAAD=no)
+AC_CHECK_LIB([mp4ff], [mp4ff_meta_get_artist], [], HAVE_FAAD=no)
+LIB_SUBST_FLAGS(faad)
+UNSTASH_FLAGS
+########################################################################### mad
+STASH_FLAGS
+LIB_ARG_WITH([mad], [-lmad])
+HAVE_MAD=yes
+AC_CHECK_HEADER(mad.h, [], HAVE_MAD=no)
+AC_CHECK_LIB([mad], [mad_stream_init], [], HAVE_MAD=no)
+LIB_SUBST_FLAGS(mad)
+UNSTASH_FLAGS
+###################################################################### libid3tag
+STASH_FLAGS
+LIB_ARG_WITH([id3tag], [-lid3tag -lz])
+HAVE_ID3TAG=yes
+AC_CHECK_HEADER(id3tag.h, [], HAVE_ID3TAG=no)
+AC_CHECK_LIB([id3tag], [id3_file_fdopen], [], HAVE_ID3TAG=no)
+LIB_SUBST_FLAGS(id3tag)
+UNSTASH_FLAGS
+########################################################################### oss
+STASH_FLAGS
+LIB_ARG_WITH([oss], [])
+AC_CHECK_HEADER(sys/soundcard.h, [HAVE_OSS=yes], [HAVE_OSS=no])
+AC_CHECK_LIB(ossaudio, _oss_ioctl, [oss_ldflags="$oss_ldflags -lossaudio"], [])
+LIB_SUBST_FLAGS(oss)
+UNSTASH_FLAGS
+########################################################################### alsa
+STASH_FLAGS
+LIB_ARG_WITH([alsa], [-lasound])
+HAVE_ALSA=yes
+AC_CHECK_HEADER(alsa/asoundlib.h, [], HAVE_ALSA=no)
+AC_CHECK_LIB([asound], [snd_pcm_open], [], HAVE_ALSA=no)
+LIB_SUBST_FLAGS(alsa)
+UNSTASH_FLAGS
+######################################################################### pthread
+STASH_FLAGS
+LIB_ARG_WITH([pthread], [-lpthread])
+HAVE_PTHREAD=yes
+AC_CHECK_HEADER(pthread.h, [], HAVE_PTHREAD=no)
+AC_CHECK_LIB([pthread], [pthread_create], [], HAVE_PTHREAD=no)
+LIB_SUBST_FLAGS(pthread)
+UNSTASH_FLAGS
+########################################################################### libao
+STASH_FLAGS
+LIB_ARG_WITH([ao], [-lao])
+HAVE_AO=yes
+AC_CHECK_HEADER(ao/ao.h, [], HAVE_AO=no)
+AC_CHECK_LIB([ao], [ao_initialize], [], HAVE_AO=no)
+LIB_SUBST_FLAGS(ao)
+UNSTASH_FLAGS
+AC_DEFUN([NEED_AO_OBJECTS], [{ test $HAVE_AO = yes -a $HAVE_PTHREAD = yes; }])
+######################################################################## readline
+STASH_FLAGS
+AC_SEARCH_LIBS([tgetent], [tinfo curses terminfo termcap])
+LIB_ARG_WITH([readline], [-lreadline $LIBS])
+HAVE_READLINE=yes
+AC_CHECK_HEADER([readline/readline.h], [], [HAVE_READLINE=no])
+AC_CHECK_LIB([readline], [rl_free_keymap], [], HAVE_READLINE=no)
+AC_CHECK_DECL(
+ [rl_free_keymap],
+ [AC_DEFINE(RL_FREE_KEYMAP_DECLARED, 1, readline >= 6.3)],
+ [],
+ [
+ #include <stdio.h>
+ #include <readline/readline.h>
+ ]
+)
+LIB_SUBST_FLAGS(readline)
+UNSTASH_FLAGS
+############################################################# libsamplerate
+STASH_FLAGS
+LIB_ARG_WITH([samplerate], [-lsamplerate])
+HAVE_SAMPLERATE=yes
+AC_CHECK_HEADER(samplerate.h, [], HAVE_SAMPLERATE=no)
+AC_CHECK_LIB([samplerate], [src_process], [], HAVE_SAMPLERATE=no)
+LIB_SUBST_FLAGS(samplerate)
+UNSTASH_FLAGS
+######################################################################### server
+if test -n "$CRYPTOLIB" && test $HAVE_OSL = yes && test -n "$BISON" && \
+ test -n "$FLEX"; then
+ build_server="yes"