From 53adf494c74149181be7f3846faad95f59ed11b1 Mon Sep 17 00:00:00 2001 From: Marios Paouris Date: Thu, 22 Feb 2024 12:03:01 +0200 Subject: [PATCH] MinGW build improvements - Decoupled wintun and vpnc-script-win.js from building installer. - Added required dependencies for downloading wintun and vpnc-script-win.js. - Install wintun, vpnc-script-win.js and list-system-keys by default. - Added configure option to disable building installer (doesn't work in msys/mingw builds, can also speedup build when no installer required). Signed-off-by: Marios Paouris --- Makefile.am | 21 +++++++++++++++++- configure.ac | 62 ++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 70 insertions(+), 13 deletions(-) diff --git a/Makefile.am b/Makefile.am index 4ce076e0..ce08613f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,6 +18,8 @@ endif lib_LTLIBRARIES = libopenconnect.la sbin_PROGRAMS = openconnect man8_MANS = openconnect.8 +bin_PROGRAMS := +sbin_SCRIPTS := noinst_PROGRAMS := AM_CFLAGS = @WFLAGS@ @@ -34,6 +36,7 @@ openconnect_LDADD = libopenconnect.la $(SSL_LIBS) $(LIBXML2_LIBS) \ if OPENCONNECT_WIN32 openconnect_SOURCES += openconnect.rc +sbin_SCRIPTS += vpnc-script-win.js endif library_srcs = ssl.c http.c textbuf.c http-auth.c auth-common.c \ auth-html.c library.c compat.c lzs.c mainloop.c script.c \ @@ -167,7 +170,16 @@ endif endif if OPENCONNECT_SYSTEM_KEYS +if OPENCONNECT_WIN32 +#install list-system-keys on Windows +bin_PROGRAMS += list-system-keys +else +#Don't install list-system-keys +#It breaks the Linux COPR builds since the native RPM doesn't list it as +#one of the files that are expected to be installed. +#see commit 17887b53e171ec7223340092dc042298a29defb0 noinst_PROGRAMS += list-system-keys +endif #OPENCONNECT_WIN32 list_system_keys_SOURCES = list-system-keys.c list_system_keys_CFLAGS = $(GNUTLS_CFLAGS) list_system_keys_LDADD = $(GNUTLS_LIBS) @@ -388,13 +400,18 @@ DISTCLEANFILES += .*.dll.d .*.exe.d file-list*.txt instfiles.nsh uninstfiles.nsh #EXTRA_DLLDIRS := $(OPENCONNECT_GUI_DIR)/bin $(libdir)/qt5/plugins/platforms $(libdir)/qt5/plugins/styles DLL_EXECUTABLES := openconnect$(EXEEXT) $(EXTRA_EXECUTABLES) +endif if OPENCONNECT_WINTUN WINTUN_DLL = .libs/wintun.dll DISTCLEANFILES += $(WINTUN_DLL) +sbin_SCRIPTS += .libs/wintun.dll +if BUILD_NSIS DLL_EXECUTABLES += wintun.dll endif +endif +if BUILD_NSIS if OPENCONNECT_SYSTEM_KEYS DLL_EXECUTABLES += list-system-keys$(EXEEXT) endif @@ -417,6 +434,7 @@ export V AM_DEFAULT_VERBOSITY bindir libdir OBJDUMP DLL_EXECUTABLES EXTRA_DLLDIR file-list.txt: Makefile.dlldeps openconnect$(EXEEXT) libopenconnect.la $(WINTUN_DLL) @$(MAKE) --no-print-directory -f $< $@ +endif #BUILD_NSIS # Wintun Layer 3 TUN driver for Windows 7 and newer # (see https://wintun.net) @@ -437,6 +455,7 @@ vpnc-script-win.js: jq -r '.[0] | "// This script matches the version found at " + (.web_url | sub("/commit/"; "/blob/")) + "/vpnc-script-win.js\n// Updated on " + .authored_date[:10] + " by " + .author_name + " <" + .author_email + "> (\"" + .title + "\")\n//"' > $@ curl https://gitlab.com/openconnect/vpnc-scripts/raw/master/vpnc-script-win.js >> $@ +if BUILD_NSIS # Let make find the file in VPATH file-list-%.txt: % echo $< > $@ @@ -484,4 +503,4 @@ openconnect-installer-$(INSTALLER_SUFFIX).exe: openconnect.nsi instfiles.nsh uni $(AM_V_MAKENSIS) $(MAKENSIS) $< ln -f "$$(grep -E '^OutFile' openconnect.nsi | cut -f2 -d\")" $@ -endif +endif #BUILD_NSIS diff --git a/configure.ac b/configure.ac index 54afa25a..8ba1a45f 100644 --- a/configure.ac +++ b/configure.ac @@ -72,7 +72,15 @@ case $host_os in system_pcsc_libs="-lwinscard" system_pcsc_cflags= AC_CHECK_TOOL([WINDRES], [windres], []) - AC_CHECK_TOOL([MAKENSIS], [makensis], []) + + AC_ARG_ENABLE([nsis-installer], + AS_HELP_STRING([--disable-nsis-installer], [Do not build an NSIS installer]), + [USE_NSIS=$enableval], [USE_NSIS=yes]) + + if test "$USE_NSIS" = "yes"; then + AC_CHECK_TOOL([MAKENSIS], [makensis], []) + fi + default_browser=open case $host_cpu in @@ -114,19 +122,34 @@ case $host_os in ;; esac AM_CONDITIONAL(OPENCONNECT_WIN32, [ test "$have_win" = "yes" ]) -build_nsis=no -if test "${MAKENSIS}" != ""; then + +if test "$have_win" = "yes"; then + #required for vpnc-script-win.js and wintun AC_CHECK_PROG(have_curl, curl, yes) - if test "${have_curl}" = "yes"; then - build_nsis=yes - if test "${wintun_arch}" != ""; then - AC_CHECK_PROG(have_unzip, unzip, yes) - if test "${have_unzip}" != "yes"; then - wintun_arch= - fi + AC_CHECK_PROG(have_unzip, unzip, yes) + AC_CHECK_PROG(have_jq, jq, yes) + + if test "${wintun_arch}" != ""; then + if test "${have_curl}" != "yes"; then + wintun_arch= + else + if test "${have_unzip}" != "yes"; then + wintun_arch= + fi fi fi fi + +build_nsis=no +if test "$MAKENSIS" != ""; then + #disable NSIS build if we cannot extract wintun + if test "${wintun_arch}" != ""; then + build_nsis=yes + else + AC_MSG_WARN([Disabling NSIS installer since wintun cannot be included]) + fi +fi + AM_CONDITIONAL(BUILD_NSIS, [ test "$build_nsis" = "yes" ]) AM_CONDITIONAL(OPENCONNECT_WINTUN, [ test "${wintun_arch}" != "" ]) @@ -160,6 +183,17 @@ if test "$with_vpnc_script" = "yes" || test "$with_vpnc_script" = ""; then AC_MSG_CHECKING([for vpnc-script in standard locations]) if test "$have_win" = "yes"; then with_vpnc_script=vpnc-script-win.js + + #downloading and amending vpnc-script-win.js depends on curl and jq. Disable it if they are missing, which *should* cause configure to stop + + if test "${have_curl}" != "yes"; then + with_vpnc_script=no + else + if test "${have_jq}" != "yes"; then + with_vpnc_script=no + fi + fi + AC_MSG_RESULT([${with_vpnc_script}]) else for with_vpnc_script in /usr/local/share/vpnc-scripts/vpnc-script /usr/local/sbin/vpnc-script /usr/share/vpnc-scripts/vpnc-script /usr/sbin/vpnc-script /etc/vpnc/vpnc-script; do if test -x "$with_vpnc_script"; then @@ -185,7 +219,8 @@ if test "$with_vpnc_script" = "yes" || test "$with_vpnc_script" = ""; then AC_MSG_RESULT([${with_vpnc_script}]) fi fi -elif test "$with_vpnc_script" = "no"; then +fi +if test "$with_vpnc_script" = "no"; then AC_MSG_ERROR(You cannot disable vpnc-script. OpenConnect will not function correctly without it. See https://www.infradead.org/openconnect/vpnc-script.html) @@ -1500,7 +1535,10 @@ SUMMARY([DSA tests], [$enable_dsa_tests]) SUMMARY([PPP tests], [$enable_ppp_tests]) SUMMARY([Flask tests], [$have_python36_flask]) SUMMARY([Insecure debugging], [$insecure_debugging]) -SUMMARY([NSIS installer], [$build_nsis]) +if test "$have_win" = "yes"; then + SUMMARY([NSIS installer], [$build_nsis]) + SUMMARY([wintun architecture], [$wintun_arch]) +fi SUMMARY([External browser], [${with_external_browser}]) SUMMARY([VPNC script], [${with_vpnc_script}]) -- 2.50.1