if USE_NLS
SUBDIRS += po
endif
+if BUILD_NSIS
+noinst_DATA = openconnect-installer.exe
+endif
lib_LTLIBRARIES = libopenconnect.la
sbin_PROGRAMS = openconnect
pkgconfig_DATA = openconnect.pc
-EXTRA_DIST = AUTHORS version.sh COPYING.LGPL openconnect.ico $(lib_srcs_openssl) $(lib_srcs_gnutls)
+EXTRA_DIST = AUTHORS version.sh COPYING.LGPL openconnect.ico $(lib_srcs_openssl) $(lib_srcs_gnutls) openconnect.nsi.in
EXTRA_DIST += $(shell cd "$(top_srcdir)" && \
git ls-tree HEAD -r --name-only -- android/ java/ trojans/ bash/ 2>/dev/null)
-o $@ $(POTFILES)
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
+# dll-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 dll-list.txt.
+.%.d: .libs/% Makefile
+ ( echo "DLLS += $<" ; \
+ echo "dll-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 "dll-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
+
+dll-list.txt: Makefile
+ for dll in $(sort $(DLLS)); do echo "$${dll}"; done > $@
+
+# 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: dll-list.txt
+ sed 's%\(.*\)%File "\1"%' $< | tee $@
+
+uninstfiles.nsh: dll-list.txt
+ sed 's%.*/\(.*\)%Delete /rebootok "$$INSTDIR\\\\\1"%' $< > $@
+
+# 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); \
+ PROD_VERSION=$$(echo "$$VERSION" | perl -ne 'm|v(\d+)\.(\d+)(?:\-(\d+)-g.+)|; print "$$1.$$2." . ($$3 or "0") . ".0"'); \
+ if egrep -q '^#define OPENCONNECT_GNUTLS' config.h; then \
+ TLS_LIBRARY=GnuTLS; \
+ elif egrep -q '^#define OPENCONNECT_OPENSSL' config.h; then \
+ TLS_LIBRARY=OpenSSL; \
+ else \
+ TLS_LIBRARY="Unknown TLS library"; \
+ fi; \
+ ( echo "VIProductVersion \"$$PROD_VERSION\""; \
+ echo "VIAddVersionKey ProductVersion \"$$VERSION\""; \
+ 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
+ $(MAKENSIS) $<
+
+endif
system_pcsc_libs="-lwinscard"
system_pcsc_cflags=
AC_CHECK_TOOL([WINDRES], [windres], [])
+ AC_CHECK_TOOL([MAKENSIS], [makensis], [])
;;
*darwin*)
system_pcsc_libs="-Wl,-framework -Wl,PCSC"
;;
esac
AM_CONDITIONAL(OPENCONNECT_WIN32, [ test "$have_win" = "yes" ])
+build_nsis=no
+if test "${MAKENSIS}" != ""; then
+ build_nsis=yes
+fi
+AM_CONDITIONAL(BUILD_NSIS, [ test "$build_nsis" = "yes" ])
AC_ARG_WITH([vpnc-script],
[AS_HELP_STRING([--with-vpnc-script],
SUMMARY([Unit tests], [$have_cwrap])
SUMMARY([Net namespace tests], [$have_netns])
SUMMARY([Insecure debugging], [$insecure_debugging])
+SUMMARY([NSIS installer], [$build_nsis])
if test "$ssl_library" = "OpenSSL"; then
AC_MSG_WARN([[
--- /dev/null
+#!Nsis Installer Command Script
+#
+# This is an NSIS Installer Command Script generated automatically
+# by the Fedora nsiswrapper program. For more information see:
+#
+# http://fedoraproject.org/wiki/MinGW
+#
+# To build an installer from the script you would normally do:
+#
+# makensis this_script
+#
+# which will generate the output file 'openconnect-installer.exe' which is a Windows
+# installer containing your program.
+
+Name "OpenConnect"
+OutFile "openconnect-installer.exe"
+InstallDir "$ProgramFiles\OpenConnect"
+InstallDirRegKey HKLM SOFTWARE\OpenConnect "Install_Dir"
+
+ShowInstDetails hide
+ShowUninstDetails hide
+
+SetCompressor /FINAL lzma
+
+VIAddVersionKey ProductName "OpenConnect"
+
+XPStyle on
+
+!include "x64.nsh"
+
+Function .onInit
+ ${If} ${RunningX64}
+ SetRegView 64
+ StrCpy $INSTDIR "$ProgramFiles64\OpenConnect"
+ ${EndIf}
+FunctionEnd
+
+
+Page components
+Page directory
+Page instfiles
+
+ComponentText "Select which optional components you want to install."
+
+DirText "Please select the installation folder."
+
+Section "OpenConnect"
+ SectionIn RO
+
+ SetOutPath "$INSTDIR"
+ !include instfiles.nsh
+SectionEnd
+
+Section "Start Menu Shortcuts"
+ CreateDirectory "$SMPROGRAMS\OpenConnect"
+ CreateShortCut "$SMPROGRAMS\OpenConnect\Uninstall OpenConnect.lnk" "$INSTDIR\Uninstall OpenConnect.exe" "" "$INSTDIR\Uninstall OpenConnect.exe" 0
+ CreateShortCut "$SMPROGRAMS\OpenConnect\openconnect.exe.lnk" "$INSTDIR\.\openconnect.exe" "" "$INSTDIR\.\openconnect.exe" 0
+SectionEnd
+
+Section "Desktop Icons"
+ CreateShortCut "$DESKTOP\openconnect.exe.lnk" "$INSTDIR\.\openconnect.exe" "" "$INSTDIR\.\openconnect.exe" 0
+SectionEnd
+
+Section "Uninstall"
+ Delete /rebootok "$DESKTOP\openconnect.exe.lnk"
+ Delete /rebootok "$SMPROGRAMS\OpenConnect\openconnect.exe.lnk"
+ Delete /rebootok "$SMPROGRAMS\OpenConnect\Uninstall OpenConnect.lnk"
+ RMDir "$SMPROGRAMS\OpenConnect"
+
+ !include uninstfiles.nsh
+ Delete /rebootok "$INSTDIR\Uninstall OpenConnect.exe"
+ RMDir "$INSTDIR"
+SectionEnd
+
+Section -post
+ WriteUninstaller "$INSTDIR\Uninstall OpenConnect.exe"
+SectionEnd