]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Fix installer deps
authorDavid Woodhouse <dwmw2@infradead.org>
Mon, 29 Mar 2021 16:44:21 +0000 (17:44 +0100)
committerDavid Woodhouse <dwmw2@infradead.org>
Mon, 29 Mar 2021 21:49:45 +0000 (22:49 +0100)
Just including .openconnect.exe.d from the main Makefile means it always
has to be up to date. Which means we always have to *build* openconnect,
even if it was just invoked for 'make clean'. That's bogus.

So shift the DLL dependency tracking out into its own Makefile, to be
invoked recursively. Much as I hate recursive make in the general case,
this is one of the few cases where it makes sense.

The automatic dependencies weren't working very well anyway, as it was
happy to 'discover' openconnect.exe and libopenconnect-5.dll in the MinGW
sysroot instead of using the locally built ones, *and* libtool messes up
the filenames so you can't just depend on .libs/openconnect.exe anyway.

Fix up $(DISTCLEANFILES) to be a bit more complete while we're at it.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Makefile.am
Makefile.dlldeps [new file with mode: 0644]

index b51981452ba57b2f2821bb5e8875251b73b1a1bc..eb05a86e27ba15e9ad18b65c2b75259be328ac33 100644 (file)
@@ -140,7 +140,7 @@ EXTRA_DIST = AUTHORS version.sh COPYING.LGPL openconnect.ico $(lib_srcs_openssl)
 EXTRA_DIST += $(shell cd "$(top_srcdir)" && \
                git ls-tree HEAD -r --name-only -- android/ java/ trojans/ bash/ 2>/dev/null)
 
-DISTCLEANFILES = $(pkgconfig_DATA)
+DISTCLEANFILES = $(pkgconfig_DATA) version.c
 
 pkglibexec_SCRIPTS = trojans/csd-post.sh trojans/csd-wrapper.sh trojans/tncc-wrapper.py \
        trojans/hipreport.sh trojans/hipreport-android.sh trojans/tncc-emulate.py
@@ -245,43 +245,22 @@ po/$(PACKAGE).pot: $(POTFILES) version.sh
 ACLOCAL_AMFLAGS = -I m4
 
 if BUILD_NSIS
-# Automatically find DLL dependencies, transitively.
-#
-# Each .d file is auto-generated on demand when Make tries to include
-# it. It is generated by a pattern rule from the corresponding DLL
-# binary, either in the local .libs directory or in the MinGw sys-root
-# which ought to be $(bindir).
-#
-# The Makefile snippet in each generated file adds the full DLL
-# pathname to $(DLLS), adds the .d file itself to the dependencies of
-# file-list.txt, and then includes more .d files for each other DLL
-# that this DLL links to.
-#
-# Because we use -include, we just skip any DLLs we can't find, which
-# will mostly be Windows system runtime stuff like kernel32.dll.
-#
-# The result, after manually -including the top-level .openconnect.exe.d,
-# is that we have a full transitive list of required non-system DLLs
-# in the $(DLLS) variable. Which will contain duplicates, hence the
-# use of $(sort) when writing it out to file-list.txt.
-.%.d: .libs/% Makefile
-       ( echo "DLLS += $<" ; \
-         echo "file-list.txt: $@" ; \
-       mingw-objdump -p "$<" | sed -n '/DLL Name:/{s%^.*DLL Name: %-include .%;s/$$/.d/;p}' | tr A-Z a-z ) > $@
-
-.%.d: $(bindir)/% Makefile
-       ( echo "DLLS += $<" ; \
-         echo "file-list.txt: $@" ; \
-       mingw-objdump -p "$<" | sed -n '/DLL Name:/{s%^.*DLL Name: %-include .%;s/$$/.d/;p}' | tr A-Z a-z ) > $@
-
--include .openconnect.exe.d
+DISTCLEANFILES += .*.dll.d .*.exe.d file-list*.txt instfiles.nsh uninstfiles.nsh vpnc-script-win.js openconnect.nsi openconnect-installer.exe
 
 if OPENCONNECT_WINTUN
--include .wintun.dll.d
+WINTUN_DLL = .libs/wintun.dll
+DISTCLEANFILES += $(WINTUN_DLL)
 endif
 
-file-list.txt: Makefile tap-windows-9.21.2.exe vpnc-script-win.js
-       for dll in $(sort $(DLLS)); do echo "$${dll}"; done > $@
+export V AM_DEFAULT_VERBOSITY bindir OBJDUMP
+
+# This Makefile has no rules to create these, just uses them to track
+# dependencies on file-list.txt if it already exists.
+-include .openconnect.exe.d
+-include .wintun.dll.d
+
+file-list.txt: Makefile.dlldeps openconnect$(EXEEXT) libopenconnect.la $(WINTUN_DLL)
+       @$(MAKE) --no-print-directory -f $< $@
 
 # OpenVPN TAP driver for Windows Vista/2003 and newer
 # (see https://community.openvpn.net/openvpn/wiki/GettingTapWindows)
@@ -317,17 +296,17 @@ file-list-%.txt: %
 # Rather than trying to get clever in NSIS and iterate over lists,
 # just emit raw snippets to be included separately in the install
 # and uninstall sections.
-instfiles.nsh: file-list.txt file-list-vpnc-script-win.js.txt file-list-tap-windows-9.21.2.exe.txt
-       sed 's%\(.*\)%File "\1"%' $^ | tee $@
+instfiles.nsh: file-list.txt file-list-vpnc-script-win.js.txt file-list-$(TAPDRIVER).txt
+       $(AM_V_GEN) cat $^ | while read FILE; do echo "File \"$${FILE}\"" ; done > $@
 
-uninstfiles.nsh: file-list.txt file-list-vpnc-script-win.js.txt file-list-tap-windows-9.21.2.exe.txt
-       sed 's%.*/\(.*\)%Delete /rebootok "$$INSTDIR\\\\\1"%' $^ > $@
+uninstfiles.nsh: file-list.txt file-list-vpnc-script-win.js.txt file-list-$(TAPDRIVER).txt
+       $(AM_V_GEN) cat $^ | while read FILE; do echo "Delete /rebootok \"\$$INSTDIR\\\\$${FILE##*/}\"" ; done > $@
 
 # Theoretically makensis can define symbols with the -D command line
 # option and much of this could just be done that way, but I couldn't
 # get it to work and life's too short.
 openconnect.nsi: version.c
-       VERSION=$$(cut -f2 -d\" version.c); \
+       $(AM_V_GEN) VERSION=$$(cut -f2 -d\" version.c); \
        PROD_VERSION=$$(echo "$$VERSION" | perl -ne 'm|v(\d+)\.(\d+)(?:\.git\.\|\-)?(\d+)?(?:-g.+\|.*)|; print "$$1.$$2." . ($$3 or "0") . ".0"'); \
        if egrep -q '^#define OPENCONNECT_GNUTLS' config.h; then \
            TLS_LIBRARY=GnuTLS; \
@@ -341,7 +320,12 @@ openconnect.nsi: version.c
          echo "VIAddVersionKey Comments \"OpenConnect multi-protocol VPN client for Windows (command-line version, built with $$TLS_LIBRARY). For more information, visit http://www.infradead.org/openconnect/\""; \
          echo "!include $(srcdir)/openconnect.nsi.in" ) > $@
 
-openconnect-installer.exe: openconnect.nsi instfiles.nsh uninstfiles.nsh $(srcdir)/openconnect.nsi.in openconnect$(EXEEXT) libopenconnect.la html-recursive tap-windows-9.21.2.exe vpnc-script-win.js
-       $(MAKENSIS) $<
+AM_V_MAKENSIS = $(am__v_MAKENSIS_$(V))
+am__v_MAKENSIS_ = $(am__v_MAKENSIS_$(AM_DEFAULT_VERBOSITY))
+am__v_MAKENSIS_0 = @echo "  MAKENSIS   " $@;
+am__v_MAKENSIS_1 =
+
+openconnect-installer.exe: openconnect.nsi instfiles.nsh uninstfiles.nsh $(srcdir)/openconnect.nsi.in html-recursive
+       $(AM_V_MAKENSIS) $(MAKENSIS) $<
 
 endif
diff --git a/Makefile.dlldeps b/Makefile.dlldeps
new file mode 100644 (file)
index 0000000..dbc821f
--- /dev/null
@@ -0,0 +1,49 @@
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Automatically find DLL dependencies, transitively.
+#
+# Copyright © 2021 David Woodhouse <dwmw2@infradead.org>
+#
+# Each .d file is auto-generated on demand when make tries to include
+# it. It is generated by a pattern rule from the corresponding DLL
+# binary, either in the local .libs directory or in the MinGw sys-root
+# which ought to be $(bindir).
+#
+# The Makefile snippet in each generated file adds the full DLL
+# pathname to $(DLLS), adds the .d file itself to the dependencies of
+# file-list.txt, and then includes more .d files for each other DLL
+# that this DLL links to.
+#
+# Because we use -include, we just skip any DLLs we can't find, which
+# will mostly be Windows system runtime stuff like kernel32.dll.
+#
+# The result, after manually -including the top-level .openconnect.exe.d,
+# is that we have a full transitive list of required non-system DLLs
+# in the $(DLLS) variable. Which will contain duplicates, hence the
+# use of $(sort) when writing it out to file-list.txt.
+
+AM_V_LISTDLLS = $(am__v_LISTDLLS_$(V))
+am__v_LISTDLLS_ = $(am__v_LISTDLLS_$(AM_DEFAULT_VERBOSITY))
+am__v_LISTDLLS_0 = @echo "  LISTDLLS" $<;
+am__v_LISTDLLS_1 =
+
+LISTDLLS_CMD = $(AM_V_LISTDLLS) \
+       ( echo "DLLS += $<" ;  echo "file-list.txt: $@" ; \
+         $(OBJDUMP) -p "$<" | sed -n '/DLL Name:/{s%^.*DLL Name: %-include .%;s/$$/.d/;p}' | tr A-Z a-z ) > $@
+
+.%.d: .libs/%
+       $(LISTDLLS_CMD)
+
+.%.d: $(bindir)/%
+       $(LISTDLLS_CMD)
+
+-include .openconnect.exe.d
+-include .wintun.dll.d
+
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 =
+
+file-list.txt:
+       $(AM_V_GEN) for dll in $(sort $(DLLS)); do echo "$${dll}"; done > $@