build: Convert alsa detection to new macros.
[paraslash.git] / configure.ac
index 32189513d02f29953c46d9fd4eccb6bd9f978560..80fff1e016f690fe55814ee2d5c21e3b60383269 100644 (file)
@@ -299,6 +299,14 @@ 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], [{
@@ -306,6 +314,7 @@ AC_DEFUN([NEED_OGG_OBJECTS], [{
                 "$HAVE_VORBIS" = 'yes' \
                -o "$HAVE_SPEEX" = 'yes' \
                -o "$HAVE_OPUS" = 'yes' \
+               -o "$HAVE_FLAC" = 'yes' \
        \)
 }])
 AC_DEFUN([NEED_VORBIS_OBJECTS], [{
@@ -317,139 +326,33 @@ AC_DEFUN([NEED_SPEEX_OBJECTS], [{
 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
-have_faad=yes
-OLD_CPPFLAGS="$CPPFLAGS"
-OLD_LDFLAGS="$LDFLAGS"
-OLD_LIBS="$LIBS"
-AC_ARG_WITH(faad_headers, [AS_HELP_STRING(--with-faad-headers=dir,
-       [look for neaacdec.h also in dir])])
-if test -n "$with_faad_headers"; then
-       faad_cppflags="-I$with_faad_headers"
-       CPPFLAGS="$CPPFLAGS $faad_cppflags"
-fi
-AC_ARG_WITH(faad_libs, [AS_HELP_STRING(--with-faad-libs=dir,
-       [look for libfaad also in dir])])
-if test -n "$with_faad_libs"; then
-       faad_libs="-L$with_faad_libs"
-       LDFLAGS="$LDFLAGS $faad_libs"
-fi
-AC_CHECK_HEADER(neaacdec.h, [], have_faad=no)
-AC_CHECK_LIB([faad], [NeAACDecOpen], [], have_faad=no)
-if test "$have_faad" = "yes"; then
-       AC_DEFINE(HAVE_FAAD, 1, define to 1 if you want to build the aacdec filter)
-       AC_SUBST(faad_cppflags)
-       faad_ldflags="$faad_libs -lfaad"
-       AC_SUBST(faad_ldflags)
-fi
-CPPFLAGS="$OLD_CPPFLAGS"
-LDFLAGS="$OLD_LDFLAGS"
-LIBS="$OLD_LIBS"
+STASH_FLAGS
+LIB_ARG_WITH([faad], [-lfaad])
+HAVE_FAAD=yes
+AC_CHECK_HEADER(neaacdec.h, [], HAVE_FAAD=no)
+AC_CHECK_LIB([faad], [NeAACDecOpen], [], HAVE_FAAD=no)
+LIB_SUBST_FLAGS(faad)
+UNSTASH_FLAGS
 ########################################################################### mad
-have_mad="yes"
-OLD_CPPFLAGS="$CPPFLAGS"
-OLD_LDFLAGS="$LDFLAGS"
-OLD_LIBS="$LIBS"
-
-AC_ARG_WITH(mad_headers, [AS_HELP_STRING(--with-mad-headers=dir,
-       [look for mad.h also in dir])])
-if test -n "$with_mad_headers"; then
-       mad_cppflags="-I$with_mad_headers"
-       CPPFLAGS="$CPPFLAGS $mad_cppflags"
-fi
-AC_ARG_WITH(mad_libs, [AS_HELP_STRING(--with-mad-libs=dir,
-       [look for libmad also in dir])])
-if test -n "$with_mad_libs"; then
-       mad_libs="-L$with_mad_libs"
-       LDFLAGS="$LDFLAGS $mad_libs"
-fi
-AC_CHECK_HEADERS([mad.h], [], [
-       have_mad="no"
-])
-AC_CHECK_LIB([mad], [mad_stream_init], [], [
-       have_mad="no"
-])
-if test "$have_mad" = "yes"; then
-       AC_DEFINE(HAVE_MAD, 1, define to 1 if you want to build the mp3dec filter)
-       AC_SUBST(mad_cppflags)
-       mad_ldflags="$mad_libs -lmad"
-       AC_SUBST(mad_ldflags)
-else
-       AC_MSG_WARN([no mp3dec support in para_audiod/para_filter])
-fi
-CPPFLAGS="$OLD_CPPFLAGS"
-LDFLAGS="$OLD_LDFLAGS"
-LIBS="$OLD_LIBS"
+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
-OLD_CPPFLAGS="$CPPFLAGS"
-OLD_LDFLAGS="$LDFLAGS"
-OLD_LIBS="$LIBS"
-
-have_libid3tag="yes"
-AC_ARG_WITH(id3tag_headers, [AS_HELP_STRING(--with-id3tag-headers=dir,
-       [look for id3tag header files also in dir])])
-if test -n "$with_id3tag_headers"; then
-       id3tag_cppflags="-I$with_id3tag_headers"
-       CPPFLAGS="$CPPFLAGS $id3tag_cppflags"
-fi
-AC_ARG_WITH(id3tag_libs, [AS_HELP_STRING(--with-id3tag-libs=dir,
-       [look for id3tag libs also in dir])])
-if test -n "$with_id3tag_libs"; then
-       id3tag_libs="-L$with_id3tag_libs"
-       LDFLAGS="$LDFLAGS $id3tag_libs"
-fi
-
-AC_MSG_CHECKING(for libid3tag)
-AC_LINK_IFELSE([AC_LANG_PROGRAM([[
-       #include <id3tag.h>
-]], [[
-       struct id3_tag t = {.flags = 0};
-]])],[],[have_libid3tag=no])
-AC_MSG_RESULT($have_libid3tag)
-
-if test ${have_libid3tag} = yes; then
-       AC_DEFINE(HAVE_LIBID3TAG, 1, define to 1 you have libid3tag)
-       AC_SUBST(id3tag_cppflags)
-       AC_SUBST(id3tag_ldflags, "$id3tag_libs -lid3tag -lz")
-fi
-CPPFLAGS="$OLD_CPPFLAGS"
-LDFLAGS="$OLD_LDFLAGS"
-LIBS="$OLD_LIBS"
-########################################################################### flac
-OLD_CPPFLAGS="$CPPFLAGS"
-OLD_LDFLAGS="$LDFLAGS"
-OLD_LIBS="$LIBS"
-
-have_flac="yes"
-AC_ARG_WITH(flac_headers, [AS_HELP_STRING(--with-flac-headers=dir,
-       [look for flac headers also in dir])])
-if test -n "$with_flac_headers"; then
-       flac_cppflags="-I$with_flac_headers"
-       CPPFLAGS="$CPPFLAGS $flac_cppflags"
-fi
-AC_ARG_WITH(flac_libs, [AS_HELP_STRING(--with-flac-libs=dir,
-       [look for flac libs also in dir])])
-if test -n "$with_flac_libs"; then
-       flac_libs="-L$with_flac_libs"
-       LDFLAGS="$LDFLAGS $flac_libs"
-fi
-AC_CHECK_HEADER(FLAC/stream_decoder.h, [], have_flac=no)
-AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_init_file], [], [
-       # nope, try again with -logg
-       AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_init_file], [],
-               have_flac=no, -lm -logg)
-       ], -lm)
-if test "$have_flac" = "yes"; then
-       AC_DEFINE(HAVE_FLAC, 1, define to 1 if you want to build the flacdec filter)
-       AC_SUBST(flac_cppflags)
-       flac_ldflags="$flac_libs -lFLAC"
-       AC_SUBST(flac_ldflags)
-else
-       AC_MSG_WARN([no flac support in para_audiod/para_filter/para_afh/para_server])
-fi
-CPPFLAGS="$OLD_CPPFLAGS"
-LDFLAGS="$OLD_LDFLAGS"
-LIBS="$OLD_LIBS"
+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
 OLD_CPPFLAGS="$CPPFLAGS"
 OLD_LDFLAGS="$LDFLAGS"
@@ -475,38 +378,13 @@ LDFLAGS="$OLD_LDFLAGS"
 LIBS="$OLD_LIBS"
 
 ########################################################################### alsa
-OLD_CPPFLAGS="$CPPFLAGS"
-OLD_LDFLAGS="$LDFLAGS"
-OLD_LIBS="$LIBS"
-
-msg="=> no alsa support for para_audiod/para_write"
-if test "$OSTYPE" != "Linux"; then
-       have_alsa="no"
-else
-       have_alsa="yes"
-fi
-if test "$have_alsa" = "yes"; then
-       AC_CHECK_HEADERS([alsa/asoundlib.h], [], [
-               have_alsa="no"
-               AC_MSG_WARN([no alsa/asoundlib $msg])
-       ])
-fi
-
-if test "$have_alsa" = "yes"; then
-       AC_CHECK_LIB([asound], [snd_pcm_open], [], [
-               have_alsa="no"
-               AC_MSG_WARN([no libasound $msg])
-       ])
-fi
-
-if test "$have_alsa" = "yes"; then
-       alsa_ldflags="-lasound"
-       AC_SUBST(alsa_ldflags)
-fi
-
-CPPFLAGS="$OLD_CPPFLAGS"
-LDFLAGS="$OLD_LDFLAGS"
-LIBS="$OLD_LIBS"
+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
 ########################################################################### libao
 OLD_CPPFLAGS="$CPPFLAGS"
 OLD_LDFLAGS="$LDFLAGS"
@@ -714,12 +592,8 @@ if test -n "$CRYPTOLIB" && test $HAVE_OSL = yes; then
        NEED_VORBIS_OBJECTS() && server_errlist_objs="$server_errlist_objs ogg_afh"
        NEED_SPEEX_OBJECTS() && server_errlist_objs="$server_errlist_objs spx_afh spx_common"
        NEED_OPUS_OBJECTS() && server_errlist_objs="$server_errlist_objs opus_afh opus_common"
-       if test "$have_faad" = "yes"; then
-               server_errlist_objs="$server_errlist_objs aac_afh aac_common"
-       fi
-       if test "$have_flac" = "yes"; then
-               server_errlist_objs="$server_errlist_objs flac_afh"
-       fi
+       NEED_FLAC_OBJECTS && server_errlist_objs="$server_errlist_objs flac_afh"
+       test $HAVE_FAAD = yes && server_errlist_objs="$server_errlist_objs aac_afh aac_common"
        server_objs="add_cmdline($server_cmdline_objs) $server_errlist_objs"
        AC_SUBST(server_objs, add_dot_o($server_objs))
        AC_DEFINE_UNQUOTED(INIT_SERVER_ERRLISTS,
@@ -839,24 +713,24 @@ if test -n "$CRYPTOLIB"; then
                audiod_errlist_objs="$audiod_errlist_objs opusdec_filter opus_common"
                audiod_audio_formats="$audiod_audio_formats opus"
        }
-       if test "$have_faad" = "yes"; then
+       NEED_FLAC_OBJECTS && {
+               audiod_errlist_objs="$audiod_errlist_objs flacdec_filter"
+               audiod_audio_formats="$audiod_audio_formats flac"
+       }
+       if test $HAVE_FAAD = yes; then
                audiod_errlist_objs="$audiod_errlist_objs aacdec_filter aac_common"
                audiod_audio_formats="$audiod_audio_formats aac"
        fi
-       if test "$have_mad" = "yes"; then
+       if test $HAVE_MAD = yes; then
                audiod_audio_formats="$audiod_audio_formats mp3"
                audiod_cmdline_objs="$audiod_cmdline_objs mp3dec_filter"
                audiod_errlist_objs="$audiod_errlist_objs mp3dec_filter"
        fi
-       if test "$have_flac" = "yes"; then
-               audiod_errlist_objs="$audiod_errlist_objs flacdec_filter"
-               audiod_audio_formats="$audiod_audio_formats flac"
-       fi
        if test "$have_oss" = "yes"; then
                audiod_errlist_objs="$audiod_errlist_objs oss_write"
                audiod_cmdline_objs="$audiod_cmdline_objs oss_write"
        fi
-       if test "$have_alsa" = "yes"; then
+       if test $HAVE_ALSA = yes; then
                audiod_errlist_objs="$audiod_errlist_objs alsa_write"
                audiod_cmdline_objs="$audiod_cmdline_objs alsa_write"
        fi
@@ -882,7 +756,7 @@ else
        build_audiod="no"
 fi
 ########################################################################### fade
-if test "$have_oss" = "yes" -o "$have_alsa" = "yes"; then
+if test "$have_oss" = "yes" -o $HAVE_ALSA = yes; then
        build_fade="yes"
        executables="$executables fade"
        fade_cmdline_objs="fade"
@@ -892,7 +766,7 @@ if test "$have_oss" = "yes" -o "$have_alsa" = "yes"; then
                mixers="${mixers}oss "
                default_mixer="OSS_MIX"
        fi
-       if test "$have_alsa" = "yes"; then
+       if test $HAVE_ALSA = yes; then
                fade_errlist_objs="$fade_errlist_objs alsa_mix"
                mixers="${mixers}alsa "
                default_mixer="ALSA_MIX"
@@ -1007,19 +881,19 @@ NEED_OPUS_OBJECTS && {
        filters="$filters opusdec"
        filter_errlist_objs="$filter_errlist_objs opusdec_filter opus_common"
 }
-if test "$have_faad" = "yes"; then
+NEED_FLAC_OBJECTS && {
+       filter_errlist_objs="$filter_errlist_objs flacdec_filter"
+       filters="$filters flacdec"
+}
+if test $HAVE_FAAD = yes; then
        filter_errlist_objs="$filter_errlist_objs aacdec_filter aac_common"
        filters="$filters aacdec"
 fi
-if test "$have_mad" = "yes"; then
+if test $HAVE_MAD = yes; then
        filter_cmdline_objs="$filter_cmdline_objs mp3dec_filter"
        filter_errlist_objs="$filter_errlist_objs mp3dec_filter"
        filters="$filters mp3dec"
 fi
-if test "$have_flac" = "yes"; then
-       filter_errlist_objs="$filter_errlist_objs flacdec_filter"
-       filters="$filters flacdec"
-fi
 if test "$have_samplerate" = "yes"; then
        filter_errlist_objs="$filter_errlist_objs resample_filter check_wav"
        filter_cmdline_objs="$filter_cmdline_objs resample_filter"
@@ -1074,13 +948,11 @@ NEED_OGG_OBJECTS && recv_errlist_objs="$recv_errlist_objs ogg_afh_common"
 NEED_VORBIS_OBJECTS && recv_errlist_objs="$recv_errlist_objs ogg_afh"
 NEED_SPEEX_OBJECTS && recv_errlist_objs="$recv_errlist_objs spx_afh spx_common"
 NEED_OPUS_OBJECTS && recv_errlist_objs="$recv_errlist_objs opus_afh opus_common"
+NEED_FLAC_OBJECTS && recv_errlist_objs="$recv_errlist_objs flac_afh"
 
-if test "$have_faad" = "yes"; then
+if test $HAVE_FAAD = yes; then
        recv_errlist_objs="$recv_errlist_objs aac_afh aac_common"
 fi
-if test "$have_flac" = "yes"; then
-       recv_errlist_objs="$recv_errlist_objs flac_afh"
-fi
 recv_objs="add_cmdline($recv_cmdline_objs) $recv_errlist_objs"
 AC_SUBST(receivers, "http dccp udp afh")
 AC_SUBST(recv_objs, add_dot_o($recv_objs))
@@ -1114,13 +986,13 @@ NEED_OPUS_OBJECTS && {
        afh_errlist_objs="$afh_errlist_objs opus_afh opus_common"
        audio_format_handlers="$audio_format_handlers opus"
 }
-if test "$have_faad" = "yes"; then
-       afh_errlist_objs="$afh_errlist_objs aac_common aac_afh"
-       audio_format_handlers="$audio_format_handlers aac"
-fi
-if test "$have_flac" = "yes"; then
+NEED_FLAC_OBJECTS && {
        afh_errlist_objs="$afh_errlist_objs flac_afh"
        audio_format_handlers="$audio_format_handlers flac"
+}
+if test $HAVE_FAAD = yes; then
+       afh_errlist_objs="$afh_errlist_objs aac_common aac_afh"
+       audio_format_handlers="$audio_format_handlers aac"
 fi
 
 afh_objs="add_cmdline($afh_cmdline_objs) $afh_errlist_objs"
@@ -1191,21 +1063,21 @@ NEED_OPUS_OBJECTS &&
                opus_afh
                opus_common
        "
-if test "$have_faad" = "yes"; then
+NEED_FLAC_OBJECTS && {
+       play_errlist_objs="$play_errlist_objs flacdec_filter flac_afh"
+}
+if test $HAVE_FAAD = yes; then
        play_errlist_objs="$play_errlist_objs aacdec_filter aac_afh aac_common"
 fi
-if test "$have_mad" = "yes"; then
+if test $HAVE_MAD = yes; then
        play_cmdline_objs="$play_cmdline_objs mp3dec_filter"
        play_errlist_objs="$play_errlist_objs mp3dec_filter"
 fi
-if test "$have_flac" = "yes"; then
-       play_errlist_objs="$play_errlist_objs flacdec_filter flac_afh"
-fi
 if test "$have_oss" = "yes"; then
        play_errlist_objs="$play_errlist_objs oss_write"
        play_cmdline_objs="$play_cmdline_objs oss_write"
 fi
-if test "$have_alsa" = "yes"; then
+if test $HAVE_ALSA = yes; then
        play_errlist_objs="$play_errlist_objs alsa_write"
        play_cmdline_objs="$play_cmdline_objs alsa_write"
 fi
@@ -1265,7 +1137,7 @@ if test "$have_oss" = "yes"; then
        writers="$writers oss"
        default_writer="OSS_WRITE"
 fi
-if test "$have_alsa" = "yes"; then
+if test $HAVE_ALSA = yes; then
        write_errlist_objs="$write_errlist_objs alsa_write"
        write_cmdline_objs="$write_cmdline_objs alsa_write"
        writers="$writers alsa"
@@ -1389,7 +1261,7 @@ crypto lib: ${CRYPTOLIB:-[none]}
 unix socket credentials: $have_ucred
 readline (interactive CLIs): $have_readline
 audio formats handlers: $audio_format_handlers
-id3 version2 support: $have_libid3tag
+id3 version 2 support: $HAVE_ID3TAG
 filters: $filters
 writers: $writers