Commit 087de97b5646538cc477495cc285659cf0be1550

Ozkan Sezer 2020-12-22T17:00:00

acinclude/esd.m4: update from mainstream esound tree, - revise for better compatibility with new autoconf, - remove HP/UX 9 (%@#!) support from it, - replace system("touch conf.esdtest") with fopen/fclose in the test code (see, e.g. glib-2.0.m4 -- sdl.m4 does the same.)

diff --git a/acinclude/esd.m4 b/acinclude/esd.m4
index 979d1b8..9627e0b 100644
--- a/acinclude/esd.m4
+++ b/acinclude/esd.m4
@@ -8,7 +8,7 @@ dnl AM_PATH_ESD([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
 dnl Test for ESD, and define ESD_CFLAGS and ESD_LIBS
 dnl
 AC_DEFUN([AM_PATH_ESD],
-[dnl 
+[dnl
 dnl Get the cflags and libraries from the esd-config script
 dnl
 AC_ARG_WITH(esd-prefix,[  --with-esd-prefix=PFX   Prefix where ESD is installed (optional)],
@@ -48,6 +48,7 @@ AC_ARG_ENABLE(esdtest, [  --disable-esdtest       Do not try to compile and run 
     esd_micro_version=`$ESD_CONFIG $esd_config_args --version | \
            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
     if test "x$enable_esdtest" = "xyes" ; then
+      AC_LANG_PUSH([C])
       ac_save_CFLAGS="$CFLAGS"
       ac_save_LIBS="$LIBS"
       CFLAGS="$CFLAGS $ESD_CFLAGS"
@@ -60,35 +61,16 @@ dnl
       AC_TRY_RUN([
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <esd.h>
 
-char*
-my_strdup (char *str)
-{
-  char *new_str;
-  
-  if (str)
-    {
-      new_str = malloc ((strlen (str) + 1) * sizeof(char));
-      strcpy (new_str, str);
-    }
-  else
-    new_str = NULL;
-  
-  return new_str;
-}
-
-int main ()
+int main (void)
 {
   int major, minor, micro;
-  char *tmp_version;
+  FILE *fp = fopen("conf.esdtest", "w");
 
-  system ("touch conf.esdtest");
+  if (fp) fclose(fp);
 
-  /* HP/UX 9 (%@#!) writes to sscanf strings */
-  tmp_version = my_strdup("$min_esd_version");
-  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
+  if (sscanf("$min_esd_version", "%d.%d.%d", &major, &minor, &micro) != 3) {
      printf("%s, bad version string\n", "$min_esd_version");
      exit(1);
    }
@@ -110,15 +92,15 @@ int main ()
       return 1;
     }
 }
-
-],, no_esd=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
+], [], [no_esd=yes], [echo $ac_n "cross compiling; assumed OK... $ac_c"])
        CFLAGS="$ac_save_CFLAGS"
        LIBS="$ac_save_LIBS"
+       AC_LANG_POP([C])
      fi
   fi
   if test "x$no_esd" = x ; then
      AC_MSG_RESULT(yes)
-     ifelse([$2], , :, [$2])     
+     ifelse([$2], , :, [$2])
   else
      AC_MSG_RESULT(no)
      if test "$ESD_CONFIG" = "no" ; then
@@ -133,6 +115,7 @@ int main ()
           echo "*** Could not run ESD test program, checking why..."
           CFLAGS="$CFLAGS $ESD_CFLAGS"
           LIBS="$LIBS $ESD_LIBS"
+          AC_LANG_PUSH([C])
           AC_TRY_LINK([
 #include <stdio.h>
 #include <esd.h>
@@ -152,6 +135,7 @@ int main ()
           echo "*** may want to edit the esd-config script: $ESD_CONFIG" ])
           CFLAGS="$ac_save_CFLAGS"
           LIBS="$ac_save_LIBS"
+          AC_LANG_POP([C])
        fi
      fi
      ESD_CFLAGS=""
@@ -162,3 +146,27 @@ int main ()
   AC_SUBST(ESD_LIBS)
   rm -f conf.esdtest
 ])
+
+dnl AM_ESD_SUPPORTS_MULTIPLE_RECORD([ACTION-IF-SUPPORTS [, ACTION-IF-NOT-SUPPORTS]])
+dnl Test, whether esd supports multiple recording clients (version >=0.2.21)
+dnl
+AC_DEFUN([AM_ESD_SUPPORTS_MULTIPLE_RECORD],
+[dnl
+  AC_MSG_NOTICE([whether installed esd version supports multiple recording clients])
+  ac_save_ESD_CFLAGS="$ESD_CFLAGS"
+  ac_save_ESD_LIBS="$ESD_LIBS"
+  AM_PATH_ESD(0.2.21,
+    ifelse([$1], , [
+      AM_CONDITIONAL(ESD_SUPPORTS_MULTIPLE_RECORD, true)
+      AC_DEFINE(ESD_SUPPORTS_MULTIPLE_RECORD, 1,
+	[Define if you have esound with support of multiple recording clients.])],
+    [$1]),
+    ifelse([$2], , [AM_CONDITIONAL(ESD_SUPPORTS_MULTIPLE_RECORD, false)], [$2])
+    if test "x$ac_save_ESD_CFLAGS" != x ; then
+       ESD_CFLAGS="$ac_save_ESD_CFLAGS"
+    fi
+    if test "x$ac_save_ESD_LIBS" != x ; then
+       ESD_LIBS="$ac_save_ESD_LIBS"
+    fi
+  )
+])