Skip to contentSkip to conversation

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

PATCH Superseded Lev Stipakov 2 participants 9 messages Mar 12, 2020 – Mar 16, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix building with --enable-async-push in FreeBSD

This option can be used in FreedBSD with devel/libinotify installed, however it requires linkage with -linotify.

Trac #1256

---
 configure.ac            | 4 ++++
 src/openvpn/Makefile.am | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)
configure.ac +4 -0
index a47ef3e7..d3a4158a 100644
@@ -1344,6 +1344,9 @@ 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*) OPTIONAL_INOTIFY_LIBS="-linotify";;
+	esac
 fi
 
 CONFIGURE_DEFINES="`set | grep '^enable_.*=' ; set | grep '^with_.*='`"
@@ -1370,6 +1373,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])
src/openvpn/Makefile.am +2 -1
index 2ea47cda..b924014d 100644
@@ -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
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/1 Fix building with --enable-async-push in FreeBSD

This option can be used in FreedBSD with devel/libinotify installed.

Detect presence of libinotify and link with its _LIBS variable.

Trac #1256

---

v2: use PKG_CHECK_MODULES instead of hardcoded -linotify

 configure.ac            | 9 +++++++++
 src/openvpn/Makefile.am | 3 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)
configure.ac +9 -0
index a47ef3e7..085e7b69 100644
@@ -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])
src/openvpn/Makefile.am +2 -1
index 2ea47cda..b924014d 100644
@@ -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
Signature · 1 line
2.17.1
#2 lore raw

Hi,

Quoted 8 lines · Lev Stipakov

This option can be used in FreedBSD with devel/libinotify installed.

Detect presence of libinotify and link with its _LIBS variable.

Trac #1256

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

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...
#3 lore raw

PATCH v3 1/1 Fix building with --enable-async-push in FreeBSD

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.

---

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(-)
configure.ac +21 -5
index a47ef3e7..4a86089b 100644
@@ -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])
src/openvpn/Makefile.am +3 -1
index 2ea47cda..f0e0ad23 100644
@@ -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
Signature · 1 line
2.17.1
#4 lore raw

Hi,

Quoted 6 lines · Lev Stipakov

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.

Quoted 6 lines

---

v3: use _CFLAGS from pkgconf to get include dir

v2: use _LIBS from pkgcong instead of hardcoded -linotify

We're getting close :-) - but something is still funny. In the output, I now have...

checking for OPTIONAL_INOTIFY... yes
../openvpn/configure: ,: not found
checking for CMOCKA... yes

... which is caused by these lines in configure:

------- snip ----------
$as_echo "#define HAVE_SYS_INOTIFY_H 1" >>confdefs.h
,

$as_echo "#define ENABLE_ASYNC_PUSH 1" >>confdefs.h ------- snip ----------

so yes, there's a single line with a "," on it... autoconf 2.69_3

It compiles and links fine, with inotify, but I think we should do a v4 and get rid of the Comma.

thanks,

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...
#5 lore raw

PATCH v4 1/1 Fix building with --enable-async-push in FreeBSD

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.

---

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(-)
configure.ac +21 -5
index a47ef3e7..fcec7389 100644
@@ -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])
src/openvpn/Makefile.am +3 -1
index 2ea47cda..f0e0ad23 100644
@@ -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
Signature · 1 line
2.17.1
Acked-by on v4 1/1
#6 lore raw

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 <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/search?l=mid&[email protected]...
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

Acked-by on v4 1/1
#7 lore raw
In reply to Lev Stipakov

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 <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/search?l=mid&[email protected]...
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#8 lore raw

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

Quoted 38 lines · Gert Doering

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 <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/search?l=mid&[email protected]...
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...