All UNIX platforms we care about have openpty() in the libutil library. Use of pty.h must also be made conditional, excluding Win32. Reviewed-by: Pavel Hrdina <phrdina@xxxxxxxxxx> Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx> --- build-aux/syntax-check.mk | 3 +++ configure.ac | 4 ++++ src/util/Makefile.inc.am | 1 + src/util/virfile.c | 14 +++++++++++++- 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index 1fd11093d8..687a4ef368 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -2342,3 +2342,6 @@ exclude_file_name_regexp--sc_prohibit_strcmp = \ exclude_file_name_regexp--sc_prohibit_backslash_alignment = \ ^build-aux/syntax-check\.mk$$ + +exclude_file_name_regexp--sc_prohibit_always_true_header_tests = \ + ^src/util/virfile\.c$$ diff --git a/configure.ac b/configure.ac index 8837928358..b28ed4a6dc 100644 --- a/configure.ac +++ b/configure.ac @@ -383,10 +383,13 @@ dnl Availability of various common headers (non-fatal if missing). AC_CHECK_HEADERS([\ ifaddrs.h \ libtasn1.h \ + util.h \ + libutil.h \ linux/magic.h \ mntent.h \ net/ethernet.h \ netinet/tcp.h \ + pty.h \ pwd.h \ stdarg.h \ syslog.h \ @@ -430,6 +433,7 @@ dnl header could be found. AM_CONDITIONAL([HAVE_LIBTASN1], [test "x$ac_cv_header_libtasn1_h" = "xyes"]) AC_CHECK_LIB([intl],[gettext],[]) +AC_CHECK_LIB([util],[openpty],[]) dnl diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am index dfa8347853..23de4a6375 100644 --- a/src/util/Makefile.inc.am +++ b/src/util/Makefile.inc.am @@ -282,6 +282,7 @@ libvirt_util_la_CFLAGS = \ $(NULL) libvirt_util_la_LIBADD = \ -lm \ + $(OPENPTY_LIBS) \ $(CAPNG_LIBS) \ $(YAJL_LIBS) \ $(LIBNL_LIBS) \ diff --git a/src/util/virfile.c b/src/util/virfile.c index 6eaabf5371..8bd03f8176 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -27,7 +27,19 @@ #include <passfd.h> #include <fcntl.h> -#include <pty.h> +#include <termios.h> +#ifdef HAVE_PTY_H +/* Linux openpty */ +# include <pty.h> +#endif /* !HAVE_PTY_H */ +#ifdef HAVE_UTIL_H +/* macOS openpty */ +# include <util.h> +#endif /* !HAVE_LIBUTIL_H */ +#ifdef HAVE_LIBUTIL_H +/* FreeBSD openpty */ +# include <libutil.h> +#endif /* !HAVE_LIBUTIL_H */ #include <sys/stat.h> #include <sys/types.h> #include <sys/socket.h> -- 2.24.1