[Openvpn-devel,v2] Fix building with --enable-async-push in FreeBSD

Message ID 20200312030323.19293-1-lstipakov@gmail.com
State Superseded
Headers show
Series
  • [Openvpn-devel,v2] Fix building with --enable-async-push in FreeBSD
Related show

Commit Message

Lev Stipakov March 12, 2020, 3:03 a.m.
This option can be used in FreedBSD with devel/libinotify
installed.

Detect presence of libinotify and link with its _LIBS variable.

Trac #1256

Signed-off-by: Lev Stipakov <lstipakov@gmail.com>
---
 
 v2: use PKG_CHECK_MODULES instead of hardcoded -linotify

 configure.ac            | 9 +++++++++
 src/openvpn/Makefile.am | 3 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

Comments

Gert Doering March 14, 2020, 12:35 p.m. | #1
Hi,

On Thu, Mar 12, 2020 at 05:03:23AM +0200, Lev Stipakov wrote:
> This option can be used in FreedBSD with devel/libinotify
> installed.
> 
> Detect presence of libinotify and link with its _LIBS variable.
> 
> Trac #1256
> 
> Signed-off-by: Lev Stipakov <lstipakov@gmail.com>

Doesn't want to work for me...

FreeBSD 11.3 here, with "libinotify-20180201_1" installed, which
brings in /usr/local/include/sys/inotify.h

Running configure like this (out of tree):

../openvpn/configure LZO_CFLAGS=-I/usr/local/include LZO_LIBS="-L/usr/local/lib -llzo2" --enable-async-push

ends in...

checking whether the compiler accepts -Wno-unused-parameter... yes
checking whether the compiler accepts -Wall... yes
checking sys/inotify.h usability... no
checking sys/inotify.h presence... no
checking for sys/inotify.h... no
configure: error: inotify.h not found.

which is not exactly surprising, given that it wants to find this
header *before* pkg_config tells it where to look...


if test "${enable_async_push}" = "yes"; then
        AC_CHECK_HEADERS(
                [sys/inotify.h],
                AC_DEFINE([ENABLE_ASYNC_PUSH], [1], [Enable async push]),
                AC_MSG_ERROR([inotify.h not found.])
        )
        case "$host" in
                *-*-freebsd*)
                        PKG_CHECK_MODULES(
                                [OPTIONAL_INOTIFY],
                                [libinotify]
                        )
                ;;
        esac
fi


so unless you happen to have "-I/usr/local/include" in your CFLAGS
at this point, it will still fail.

gert

Patch

diff --git a/configure.ac b/configure.ac
index a47ef3e7..085e7b69 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1344,6 +1344,14 @@  if test "${enable_async_push}" = "yes"; then
 		AC_DEFINE([ENABLE_ASYNC_PUSH], [1], [Enable async push]),
 		AC_MSG_ERROR([inotify.h not found.])
 	)
+	case "$host" in
+		*-*-freebsd*)
+			PKG_CHECK_MODULES(
+				[OPTIONAL_INOTIFY],
+				[libinotify]
+			)
+		;;
+	esac
 fi
 
 CONFIGURE_DEFINES="`set | grep '^enable_.*=' ; set | grep '^with_.*='`"
@@ -1370,6 +1378,7 @@  AC_SUBST([OPTIONAL_LZ4_LIBS])
 AC_SUBST([OPTIONAL_SYSTEMD_LIBS])
 AC_SUBST([OPTIONAL_PKCS11_HELPER_CFLAGS])
 AC_SUBST([OPTIONAL_PKCS11_HELPER_LIBS])
+AC_SUBST([OPTIONAL_INOTIFY_LIBS])
 
 AC_SUBST([PLUGIN_AUTH_PAM_CFLAGS])
 AC_SUBST([PLUGIN_AUTH_PAM_LIBS])
diff --git a/src/openvpn/Makefile.am b/src/openvpn/Makefile.am
index 2ea47cda..b924014d 100644
--- a/src/openvpn/Makefile.am
+++ b/src/openvpn/Makefile.am
@@ -137,7 +137,8 @@  openvpn_LDADD = \
 	$(OPTIONAL_CRYPTO_LIBS) \
 	$(OPTIONAL_SELINUX_LIBS) \
 	$(OPTIONAL_SYSTEMD_LIBS) \
-	$(OPTIONAL_DL_LIBS)
+	$(OPTIONAL_DL_LIBS) \
+	$(OPTIONAL_INOTIFY_LIBS)
 if WIN32
 openvpn_SOURCES += openvpn_win32_resources.rc block_dns.c block_dns.h ring_buffer.c ring_buffer.h
 openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lfwpuclnt -lrpcrt4 -lncrypt -lsetupapi