From 0bd1b82d3a7901db924b9d81181196a3673391ca Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Mon, 28 Aug 2023 17:44:53 +0100 Subject: [PATCH] Move libgen.h out of IPC conditional code since it is not related directly to IPC; adjust IPC configuration so that IPC support is auto-disabled if the relevant header files or library functions are missing. --- Makefile.am | 2 +- configure.ac | 12 +++++++++++- src/include/config-aux.h | 5 ----- src/include/config.h.in | 9 +++++++++ src/pv/cursor.c | 4 +++- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Makefile.am b/Makefile.am index fd95255..594efbb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to produce Makefile.in -AUTOMAKE_OPTIONS = subdir-objects no-dependencies +AUTOMAKE_OPTIONS = subdir-objects SUBDIRS = po diff --git a/configure.ac b/configure.ac index 2201a15..6b4e96a 100644 --- a/configure.ac +++ b/configure.ac @@ -24,6 +24,7 @@ AC_CHECK_FUNCS([fpathconf sysconf posix_memalign posix_fadvise]) AC_CHECK_HEADERS([limits.h]) AC_CHECK_HEADERS([wctype.h]) AC_CHECK_HEADERS([termios.h]) +AC_CHECK_HEADERS([libgen.h]) AC_CHECK_HEADERS([sys/ioctl.h]) AC_CHECK_HEADERS([libintl.h locale.h]) AH_BOTTOM([#include "config-aux.h"]) @@ -78,7 +79,16 @@ yes ], [LIBS="$LIBS -lc128"]) if test "$IPC_SUPPORT" = "yes"; then - AC_CHECK_HEADERS([sys/ipc.h sys/param.h libgen.h]) + AC_CHECK_HEADERS([sys/ipc.h], [], [IPC_SUPPORT=no]) + AC_CHECK_HEADERS([sys/msg.h], [], [IPC_SUPPORT=no]) + AC_CHECK_HEADERS([sys/param.h]) + if test "$IPC_SUPPORT" = "yes"; then + AC_CHECK_FUNCS([msgget], [], [IPC_SUPPORT=no]) + fi +fi + +if test "$IPC_SUPPORT" = "yes"; then + AC_DEFINE([HAVE_IPC], [1], [IPC support enabled]) fi if test "$SPLICE_SUPPORT" = "yes"; then diff --git a/src/include/config-aux.h b/src/include/config-aux.h index 1971c42..96b9763 100644 --- a/src/include/config-aux.h +++ b/src/include/config-aux.h @@ -22,11 +22,6 @@ # define N_(String) (String) #endif -#undef HAVE_IPC -#ifdef HAVE_SYS_IPC_H -#define HAVE_IPC 1 -#endif - #undef CURSOR_ANSWERBACK_BYTE_BY_BYTE #ifndef _AIX #define CURSOR_ANSWERBACK_BYTE_BY_BYTE 1 diff --git a/src/include/config.h.in b/src/include/config.h.in index d7b8f2c..112b538 100644 --- a/src/include/config.h.in +++ b/src/include/config.h.in @@ -43,6 +43,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H +/* IPC support enabled */ +#undef HAVE_IPC + /* Define to 1 if you have the header file. */ #undef HAVE_LIBGEN_H @@ -61,6 +64,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_MINIX_CONFIG_H +/* Define to 1 if you have the `msgget' function. */ +#undef HAVE_MSGGET + /* Define to 1 if you have the `posix_fadvise' function. */ #undef HAVE_POSIX_FADVISE @@ -100,6 +106,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_IPC_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_MSG_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PARAM_H diff --git a/src/pv/cursor.c b/src/pv/cursor.c index 6d0e3a2..84f2a13 100644 --- a/src/pv/cursor.c +++ b/src/pv/cursor.c @@ -35,10 +35,12 @@ #ifdef HAVE_SYS_PARAM_H #include #endif +#endif /* HAVE_IPC */ + +/* for basename() */ #ifdef HAVE_LIBGEN_H #include #endif -#endif /* HAVE_IPC */ /*