mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Generate baudrate switch cases based on detection
Support a single source of baud rate configuration as discussed in https://github.com/tio/tio/issues/45 . To do so, autogeneration of the switch cases which do the baud rate option value check and configuration/conversion in tty_configure() is introduced via a single macro. Just to be safe, this change also enables configure detection of all baud rates, including the ones previously assumed supported by most/all systems (POSIX).
This commit is contained in:
parent
ab4c4fb151
commit
c8a677e3d9
2 changed files with 22 additions and 70 deletions
14
configure.ac
14
configure.ac
|
|
@ -30,14 +30,11 @@ AM_CONDITIONAL([ENABLE_BASH_COMPLETION],[test "x$with_bash_completion_dir" != "x
|
|||
AC_DEFUN(
|
||||
[TIO_CHECK_BAUDRATE],
|
||||
[
|
||||
tio_have_decl=0
|
||||
AS_IF([test $1 -le 38400],
|
||||
# Baud rates up to 38400 are defined by POSIX,
|
||||
# so we don't have to check for them.
|
||||
[tio_have_decl=1],
|
||||
[AC_CHECK_DECLS([B$1], [tio_have_decl=1], [], [[#include <termios.h>]])]
|
||||
AC_CHECK_DECL([B$1], [tio_have_decl=1], [tio_have_decl=0], [[#include <termios.h>]])
|
||||
AS_IF([test $tio_have_decl = 1], [
|
||||
AC_SUBST([BAUDRATES], ["$BAUDRATES $1"])
|
||||
AC_SUBST([BAUDRATE_CASES], ["$BAUDRATE_CASES case $1: baudrate = B$1; break;"])]
|
||||
)
|
||||
AS_IF([test $tio_have_decl = 1], [AC_SUBST([BAUDRATES], ["$BAUDRATES $1"])])
|
||||
]
|
||||
)
|
||||
|
||||
|
|
@ -49,6 +46,7 @@ AC_DEFUN(
|
|||
|
||||
# Check for available terminal I/O speeds
|
||||
BAUDRATES=
|
||||
BAUDRATE_CASES=
|
||||
TIO_CHECK_BAUDRATES(
|
||||
0,
|
||||
50,
|
||||
|
|
@ -83,6 +81,8 @@ TIO_CHECK_BAUDRATES(
|
|||
4000000
|
||||
)
|
||||
|
||||
AC_DEFINE_UNQUOTED([AUTOCONF_BAUDRATE_CASES],[$BAUDRATE_CASES],[Switch cases for detected baud rates])
|
||||
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_CONFIG_FILES([src/Makefile])
|
||||
AC_CONFIG_FILES([src/bash-completion/tio])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue