From: Andre Noll <maan@tuebingen.mpg.de>
Date: Sun, 24 Aug 2014 22:00:51 +0000 (+0200)
Subject: build: Convert libao detection to new macros.
X-Git-Tag: v0.5.5~44^2~5
X-Git-Url: https://git.tue.mpg.de/?a=commitdiff_plain;h=5597f7555575ba0cf1955b102403f04fa1115c10;p=paraslash.git

build: Convert libao detection to new macros.

Splits the old check into two checks for pthread and libao.
---

diff --git a/Makefile.in b/Makefile.in
index 39d5b23b..d8c6ed83 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -44,6 +44,7 @@ ogg_cppflags := @ogg_cppflags@
 mad_cppflags := @mad_cppflags@
 faad_cppflags := @faad_cppflags@
 curses_cppflags := @curses_cppflags@
+pthread_cppflags := @pthread_cppflags@
 ao_cppflags := @ao_cppflags@
 flac_cppflags := @flac_cppflags@
 samplerate_cppflags := @samplerate_cppflags@
@@ -61,6 +62,7 @@ mad_ldflags := @mad_ldflags@
 flac_ldflags := @flac_ldflags@
 oss_ldflags := @oss_ldflags@
 alsa_ldflags := @alsa_ldflags@
+pthread_ldflags := @pthread_ldflags@
 ao_ldflags := @ao_ldflags@
 readline_ldflags := @readline_ldflags@
 samplerate_ldflags := @samplerate_ldflags@
diff --git a/Makefile.real b/Makefile.real
index 94a0865e..55d9e18c 100644
--- a/Makefile.real
+++ b/Makefile.real
@@ -196,7 +196,6 @@ $(object_dir)/flac%.o $(dep_dir)/flac%.d: CPPFLAGS += $(flac_cppflags)
 $(object_dir)/mp3_afh.o $(dep_dir)/mp3_afh.d: CPPFLAGS += $(id3tag_cppflags)
 $(object_dir)/crypt.o $(dep_dir)/crypt.d: CPPFLAGS += $(openssl_cppflags)
 $(object_dir)/gcrypt.o $(dep_dir)/gcrypt.d: CPPFLAGS += $(gcrypt_cppflags)
-$(object_dir)/ao_write.o $(dep_dir)/ao_write.d: CPPFLAGS += $(ao_cppflags)
 $(object_dir)/alsa%.o $(dep_dir)/alsa%.d: CPPFLAGS += $(alsa_cppflags)
 
 $(object_dir)/interactive.o $(dep_dir)/interactive.d \
@@ -205,6 +204,9 @@ $(object_dir)/interactive.o $(dep_dir)/interactive.d \
 $(object_dir)/resample_filter.o $(dep_dir)/resample_filter.d \
 : CPPFLAGS += $(samplerate_cppflags)
 
+$(object_dir)/ao_write.o $(dep_dir)/ao_write.d \
+: CPPFLAGS += $(ao_cppflags) $(pthread_cppflags)
+
 $(object_dir)/mp3dec_filter.o $(dep_dir)/mp3dec_filter.d \
 : CPPFLAGS += $(mad_cppflags)
 
@@ -265,7 +267,8 @@ $(dep_dir)/%.d: %.c error2.h | $(dep_dir)
 		-e "s@ \([a-zA-Z0-9_]\{1,\}\.completion.h\)@ $(cmdlist_dir)/\1@g" > $@
 
 para_recv para_afh para_play para_server: LDFLAGS += $(id3tag_ldflags)
-para_write para_play para_audiod: LDFLAGS += $(ao_ldflags) $(core_audio_ldflags)
+para_write para_play para_audiod \
+: LDFLAGS += $(ao_ldflags) $(pthread_ldflags) $(core_audio_ldflags)
 para_client para_audioc para_play : LDFLAGS += $(readline_ldflags)
 para_server: LDFLAGS += $(osl_ldflags)
 para_gui: LDFLAGS += $(curses_ldflags)
diff --git a/configure.ac b/configure.ac
index 80fff1e0..ac4192f2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -385,58 +385,23 @@ 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
-OLD_CPPFLAGS="$CPPFLAGS"
-OLD_LDFLAGS="$LDFLAGS"
-OLD_LIBS="$LIBS"
-
-have_ao="yes"
-AC_ARG_WITH(ao_headers, [AS_HELP_STRING(--with-ao-headers=dir,
-	[look for ao/ao.h also in dir])])
-if test -n "$with_ao_headers"; then
-	ao_cppflags="-I$with_ao_headers"
-	CPPFLAGS="$CPPFLAGS $ao_cppflags"
-fi
-AC_ARG_WITH(ao_libs, [AS_HELP_STRING(--with-ao-libs=dir,
-	[look for libao also in dir])])
-if test -n "$with_ao_libs"; then
-	ao_libs="-L$with_ao_libs"
-	LDFLAGS="$LDFLAGS $ao_libs"
-fi
-msg="no libao support for para_audiod/para_write"
-AC_CHECK_HEADERS([ao/ao.h], [
-	], [
-	have_ao="no"
-	AC_MSG_WARN([ao.h not found, $msg])
-])
-if test "$have_ao" = "yes"; then
-	AC_CHECK_LIB([ao], [ao_initialize], [], [
-		have_ao="no"
-		AC_MSG_WARN([ao lib not found or not working, $msg])
-	])
-fi
-if test "$have_ao" = "yes"; then
-	AC_CHECK_HEADERS([pthread.h], [
-		], [
-		have_ao="no"
-		AC_MSG_WARN([pthread.h not found, $msg])
-	])
-fi
-if test "$have_ao" = "yes"; then
-	AC_CHECK_LIB([pthread], [pthread_create], [], [
-		have_ao="no"
-		AC_MSG_WARN([pthread lib not found or not working, $msg])
-	])
-fi
-if test "$have_ao" = "yes"; then
-	AC_SUBST(ao_cppflags)
-	ao_ldflags="$ao_libs -lao -lpthread"
-	AC_SUBST(ao_ldflags)
-fi
-
-CPPFLAGS="$OLD_CPPFLAGS"
-LDFLAGS="$OLD_LDFLAGS"
-LIBS="$OLD_LIBS"
+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
 OLD_CPPFLAGS="$CPPFLAGS"
 OLD_LDFLAGS="$LDFLAGS"
@@ -734,10 +699,10 @@ if test -n "$CRYPTOLIB"; then
 		audiod_errlist_objs="$audiod_errlist_objs alsa_write"
 		audiod_cmdline_objs="$audiod_cmdline_objs alsa_write"
 	fi
-	if test "$have_ao" = "yes"; then
+	NEED_AO_OBJECTS && {
 		audiod_errlist_objs="$audiod_errlist_objs ao_write"
 		audiod_cmdline_objs="$audiod_cmdline_objs ao_write"
-	fi
+	}
 	if test "$have_samplerate" = "yes"; then
 		audiod_errlist_objs="$audiod_errlist_objs resample_filter check_wav"
 		audiod_cmdline_objs="$audiod_cmdline_objs resample_filter"
@@ -1081,10 +1046,10 @@ if test $HAVE_ALSA = yes; then
 	play_errlist_objs="$play_errlist_objs alsa_write"
 	play_cmdline_objs="$play_cmdline_objs alsa_write"
 fi
-if test "$have_ao" = "yes"; then
+NEED_AO_OBJECTS && {
 	play_errlist_objs="$play_errlist_objs ao_write"
 	play_cmdline_objs="$play_cmdline_objs ao_write"
-fi
+}
 if test "$have_readline" = "yes"; then
 	play_errlist_objs="$play_errlist_objs interactive"
 fi
@@ -1125,12 +1090,12 @@ if test "$have_core_audio" = "yes"; then
 	writers="$writers osx"
 	default_writer="OSX_WRITE"
 fi
-if test "$have_ao" = "yes"; then
+NEED_AO_OBJECTS && {
 	write_errlist_objs="$write_errlist_objs ao_write"
 	write_cmdline_objs="$write_cmdline_objs ao_write"
 	writers="$writers ao"
 	default_writer="AO_WRITE"
-fi
+}
 if test "$have_oss" = "yes"; then
 	write_errlist_objs="$write_errlist_objs oss_write"
 	write_cmdline_objs="$write_cmdline_objs oss_write"