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.)
This commit is contained in:
Ozkan Sezer 2020-12-22 17:00:00 +03:00
parent 15abab9cf8
commit 087de97b56
1 changed files with 35 additions and 27 deletions

View File

@ -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 | \ esd_micro_version=`$ESD_CONFIG $esd_config_args --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
if test "x$enable_esdtest" = "xyes" ; then if test "x$enable_esdtest" = "xyes" ; then
AC_LANG_PUSH([C])
ac_save_CFLAGS="$CFLAGS" ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS" ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $ESD_CFLAGS" CFLAGS="$CFLAGS $ESD_CFLAGS"
@ -60,35 +61,16 @@ dnl
AC_TRY_RUN([ AC_TRY_RUN([
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <esd.h> #include <esd.h>
char* int main (void)
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 major, minor, micro; 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 */ if (sscanf("$min_esd_version", "%d.%d.%d", &major, &minor, &micro) != 3) {
tmp_version = my_strdup("$min_esd_version");
if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
printf("%s, bad version string\n", "$min_esd_version"); printf("%s, bad version string\n", "$min_esd_version");
exit(1); exit(1);
} }
@ -110,10 +92,10 @@ int main ()
return 1; 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" CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS" LIBS="$ac_save_LIBS"
AC_LANG_POP([C])
fi fi
fi fi
if test "x$no_esd" = x ; then if test "x$no_esd" = x ; then
@ -133,6 +115,7 @@ int main ()
echo "*** Could not run ESD test program, checking why..." echo "*** Could not run ESD test program, checking why..."
CFLAGS="$CFLAGS $ESD_CFLAGS" CFLAGS="$CFLAGS $ESD_CFLAGS"
LIBS="$LIBS $ESD_LIBS" LIBS="$LIBS $ESD_LIBS"
AC_LANG_PUSH([C])
AC_TRY_LINK([ AC_TRY_LINK([
#include <stdio.h> #include <stdio.h>
#include <esd.h> #include <esd.h>
@ -152,6 +135,7 @@ int main ()
echo "*** may want to edit the esd-config script: $ESD_CONFIG" ]) echo "*** may want to edit the esd-config script: $ESD_CONFIG" ])
CFLAGS="$ac_save_CFLAGS" CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS" LIBS="$ac_save_LIBS"
AC_LANG_POP([C])
fi fi
fi fi
ESD_CFLAGS="" ESD_CFLAGS=""
@ -162,3 +146,27 @@ int main ()
AC_SUBST(ESD_LIBS) AC_SUBST(ESD_LIBS)
rm -f conf.esdtest 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
)
])