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

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

Commit Message

Lev Stipakov March 14, 2020, 5:29 a.m.
This option can be used in FreedBSD with devel/libinotify
installed.

Detect presence of libinotify with pkgconf and use its word
to compile and link.

Signed-off-by: Lev Stipakov <lstipakov@gmail.com>
---

 v4: remove unneeded commas in configure.ac
 
 v3: use _CFLAGS from pkgconf to get include dir

 v2: use _LIBS from pkgcong instead of hardcoded -linotify

 configure.ac            | 26 +++++++++++++++++++++-----
 src/openvpn/Makefile.am |  4 +++-
 2 files changed, 24 insertions(+), 6 deletions(-)

Comments

Gert Doering March 15, 2020, 9:14 p.m. | #1
Acked-by: Gert Doering <gert@greenie.muc.de>

Your patch has been applied to the master branch.  

Tested on FreeBSD 11.3 with libinotify installed and 12.0 without (fails
if called with "--enable-async-patch", works nicely otherwise).  From
"staring at patch" I assume no changes for other platforms, so I did not
test there.

commit f31b344177eded16279ef8c0caebcd4864b206b6
Author: Lev Stipakov
Date:   Sat Mar 14 07:29:06 2020 +0200

     Fix building with --enable-async-push in FreeBSD

     Signed-off-by: Lev Stipakov <lstipakov@gmail.com>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Message-Id: <20200314052906.28095-1-lstipakov@gmail.com>
     URL: https://www.mail-archive.com/search?l=mid&q=20200314052906.28095-1-lstipakov@gmail.com
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering
Gert Doering March 15, 2020, 9:16 p.m. | #2
Acked-by: Gert Doering <gert@greenie.muc.de>

Your patch has been applied to the master branch.  

Tested on FreeBSD 11.3 with libinotify installed and 12.0 without (fails
if called with "--enable-async-patch", works nicely otherwise).  From
"staring at patch" I assume no changes for other platforms, so I did not
test there.

Re-sending with a new commit ID - I noticed, after sending out the mail,
that the "Trac: ###" got lost from v4.  So I re-added, and this is the
right commit ID now.

commit e1eb630df1b3ef5df88afd51003fbec40e5d6d67
Author: Lev Stipakov
Date:   Sat Mar 14 07:29:06 2020 +0200

     Fix building with --enable-async-push in FreeBSD

     Signed-off-by: Lev Stipakov <lstipakov@gmail.com>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Message-Id: <20200314052906.28095-1-lstipakov@gmail.com>
     URL: https://www.mail-archive.com/search?l=mid&q=20200314052906.28095-1-lstipakov@gmail.com
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering
Gert Doering March 16, 2020, 8:04 a.m. | #3
Hi,

and yet another mail for this patch - Lev asked for this to be merged
to release/2.4 as well, which I've done.  Context is unchanged, so
it merges nicely.  Tested on FreeBSD 11.3, works.

commit 8484f37a62ce4f1b8efe7644c6ddb28819c4f8ae (HEAD -> release/2.4)

gert

On Sun, Mar 15, 2020 at 10:16:28PM +0100, Gert Doering wrote:
> Acked-by: Gert Doering <gert@greenie.muc.de>
> 
> Your patch has been applied to the master branch.  
> 
> Tested on FreeBSD 11.3 with libinotify installed and 12.0 without (fails
> if called with "--enable-async-patch", works nicely otherwise).  From
> "staring at patch" I assume no changes for other platforms, so I did not
> test there.
> 
> Re-sending with a new commit ID - I noticed, after sending out the mail,
> that the "Trac: ###" got lost from v4.  So I re-added, and this is the
> right commit ID now.
> 
> commit e1eb630df1b3ef5df88afd51003fbec40e5d6d67
> Author: Lev Stipakov
> Date:   Sat Mar 14 07:29:06 2020 +0200
> 
>      Fix building with --enable-async-push in FreeBSD
> 
>      Signed-off-by: Lev Stipakov <lstipakov@gmail.com>
>      Acked-by: Gert Doering <gert@greenie.muc.de>
>      Message-Id: <20200314052906.28095-1-lstipakov@gmail.com>
>      URL: https://www.mail-archive.com/search?l=mid&q=20200314052906.28095-1-lstipakov@gmail.com
>      Signed-off-by: Gert Doering <gert@greenie.muc.de>
> 
> 
> --
> kind regards,
> 
> Gert Doering
> 
> 
> 
> _______________________________________________
> Openvpn-devel mailing list
> Openvpn-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openvpn-devel
>

Patch

diff --git a/configure.ac b/configure.ac
index a47ef3e7..fcec7389 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1339,11 +1339,25 @@  if test "${enable_plugin_auth_pam}" = "yes"; then
 fi
 
 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],
+				[
+					AC_DEFINE([HAVE_SYS_INOTIFY_H])
+					AC_DEFINE([ENABLE_ASYNC_PUSH], [1], [Enable async push])
+				]
+			)
+		;;
+		*)
+			AC_CHECK_HEADERS(
+				[sys/inotify.h],
+				AC_DEFINE([ENABLE_ASYNC_PUSH], [1], [Enable async push]),
+				AC_MSG_ERROR([inotify.h not found.])
+			)
+		;;
+	esac
 fi
 
 CONFIGURE_DEFINES="`set | grep '^enable_.*=' ; set | grep '^with_.*='`"
@@ -1370,6 +1384,8 @@  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_CFLAGS])
+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..f0e0ad23 100644
--- a/src/openvpn/Makefile.am
+++ b/src/openvpn/Makefile.am
@@ -28,6 +28,7 @@  AM_CFLAGS = \
 	$(OPTIONAL_LZO_CFLAGS) \
 	$(OPTIONAL_LZ4_CFLAGS) \
 	$(OPTIONAL_PKCS11_HELPER_CFLAGS) \
+	$(OPTIONAL_INOTIFY_CFLAGS) \
 	-DPLUGIN_LIBDIR=\"${plugindir}\"
 
 if WIN32
@@ -137,7 +138,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