Browse Source

Prepare configure for runtime backend selection

Do not select one MIDI backend against the other(s). Detect all
available MIDI backends (for now, ALSA and OSS only) and enable
them all. Provide the user with options to disable some backends,
but make sure that at least one backend is available and enabled.

The OSS backend is considered to be always available, since it has
no compile-time dependency.
develop
Damien Goutte-Gattat 8 years ago
parent
commit
73672aae85
  1. 2
      Makefile.am
  2. 76
      configure.ac

2
Makefile.am

@ -3,5 +3,3 @@ SUBDIRS = lib src man
ACLOCAL_AMFLAGS = -I m4 --install
dist_doc_DATA = AUTHORS COPYING README
AM_DISTCHECK_CONFIGURE_FLAGS = --with-alsa

76
configure.ac

@ -18,30 +18,58 @@ AC_PROG_INSTALL
dnl Check for some non-ubiquitous functions
ICP_CHECK_NOTCH_FUNCS
dnl Choice of MIDI backend
midi_backend=
midi_default_port=
AC_ARG_WITH([alsa],
[AS_HELP_STRING([--with-alsa],
[use ALSA MIDI backend])],
[AS_IF([test "x$with_alsa" = xyes], [midi_backend=alsa])])
AC_ARG_WITH([oss],
[AS_HELP_STRING([--with-oss],
[use OSS MIDI backend])],
[AS_IF([test "x$with_oss" = xyes], [midi_backend=oss])])
dnl Check for MIDI backends
AM_PATH_ALSA([1.0.0], [alsa_available=yes], [alsa_available=no])
oss_available=yes
dnl Select MIDI backends to enable
AC_ARG_ENABLE([alsa],
[AS_HELP_STRING([--enable-alsa],
[Enable ALSA MIDI backend (default=auto)])],
[], [])
AC_ARG_ENABLE([oss],
[AS_HELP_STRING([--enable-oss],
[Enable OSS MIDI backend (default=yes)])])
dnl Now decide which backends to use
midi_backends=
AS_IF([test "x$alsa_available" = xyes],
[AS_IF([test "x$enable_alsa" != xno],
[use_alsa=yes],
[use_alsa=no
CFLAGS="$alsa_save_CFLAGS"
LDFLAGS="$alsa_save_LDFLAGS"
LIBS="$alsa_save_LIBS"])],
[use_alsa=no
AS_IF([test "x$enable_alsa" = xyes],
[AC_MSG_ERROR([ALSA backend requested but not available.])])])
AS_IF([test "x$oss_available" = xyes],
[AS_IF([test "x$enable_oss" != xno],
[use_oss=yes],
[use_oss=no])],
[use_oss=no
AS_IF([test "x$enable_oss" = xyes],
[AC_MSG_ERROR([OSS backend requested but not available.])])])
dnl Backend(s) selected, now act accordingly
AS_IF([test "x$use_alsa" = xyes],
[AS_IF([test -z "$midi_backends"],
[midi_backends="alsa"], [midi_backends="$midi_backends alsa"])
AC_DEFINE([HAVE_ALSA], [1],
[Whether ALSA MIDI backend is available.])
midi_default_port=hw:1,0,0])
AS_IF([test "x$use_oss" = xyes],
[AS_IF([test -z "$midi_backends"],
[midi_backends="oss"], [midi_backends="$midi_backends oss"])
AC_DEFINE([HAVE_OSS], [1],
[Whether OSS MIDI backend is available.])
midi_default_port=/dev/midi00])
dnl At least one backend must be available and enabled
AS_IF([test -z "$midi_backends"],
[AC_MSG_ERROR([No MIDI backend enabled.])])
dnl Check for selected backend
AS_CASE(["x$midi_backend"],
[xalsa],
[AM_PATH_ALSA([1.0.0],
[AC_DEFINE([USE_ALSA_MIDI_API], [1],
[Define wether to use the ALSA MIDI API.])
midi_default_port="hw:1,0,0"])],
[xoss],
[AC_DEFINE([USE_OSS_MIDI_API], [1],
[Define whether to use the OSS MIDI API.])
midi_default_port="/dev/midi00"],
[AC_MSG_ERROR([No MIDI backend selected.])])
AC_DEFINE_UNQUOTED([DEFAULT_MIDI_PORT], ["$midi_default_port"],
[Default MIDI port to use.])
AC_SUBST([DEFAULT_MIDI_PORT], [$midi_default_port])
@ -59,6 +87,6 @@ Configuration complete
Prefix: '${prefix}'
Compiler: '${CC} ${CFLAGS} ${CPPFLAGS}'
MIDI backend: '${midi_backend}'
MIDI backends: '${midi_backends}'
"

Loading…
Cancel
Save