Fix runtime libraries find and installation
authorAndre Heinecke <aheinecke@intevation.de>
Tue, 22 Sep 2015 13:51:09 +0000 (15:51 +0200)
committerAndre Heinecke <aheinecke@intevation.de>
Tue, 22 Sep 2015 13:51:09 +0000 (15:51 +0200)
* m4/gpg4win.m4(GPG4WIN_RUNTIME_LIBRARY): New. Helper for runtime
  libraries. Searches more locations.
* configure.ac: Use above and add libwinpthread-1.dll dependency
* src/inst-gpg4win.nsi: Install libwinpthread-1.dll. Move runtime
  libs from pub to top level install dir.
* src/uninst-gpg4win.nsi: Uninstall runtime libs from their
  new location.

--
This also fixes the problem that libraries were not reported as
missing when no other missing tools were found missing.

configure.ac
m4/gpg4win.m4
src/inst-gpg4win.nsi
src/uninst-gpg4win.nsi

index f6a2b81..2bef226 100644 (file)
@@ -257,55 +257,10 @@ for i in DLLTOOL MAKE UNZIP TAR MKDIR CP RM STOW MAKENSIS ZCAT TEXI2DVI \
    fi
 done
 
-# GpgOL and GpgEx need the runtime libaries
-# The default path should probably be more generic
-changequote(,)dnl
-gcc_major_minor=$($CC --version \
-                  | awk 'NR==1 {split($NF,a,"."); print a[1] "." a[2]}')
-changequote([,])dnl
-
-libgcc_dll=no
-AC_ARG_WITH([libgcc_s_sjlj-1-dll],
-           AC_HELP_STRING([--with-libgcc_s_sjlj-1-dll=FILE],
-                          [use the libgcc_s_sjlj-1 DLL]),
-           [libgcc_dll=$withval])
-
-if test "$libgcc_dll" = "no"; then
-  file="/usr/lib/gcc/$host/$gcc_major_minor/libgcc_s_sjlj-1.dll"
-  if test -r "$file"; then
-    libgcc_dll="$file"
-  fi
-fi
-if test "$libgcc_dll" = "no"; then
-  missing_opt_tools="libgcc_s_sjlj-1.dll $missing_opt_tools"
-else
-  if test -r "$libgcc_dll"; then
-    cp $libgcc_dll src/libgcc_s_sjlj-1.dll-x
-  else
-    missing_opt_tools="libgcc_s_sjlj-1.dll $missing_opt_tools"
-  fi
-fi
-
-libstdcpp_dll=no
-AC_ARG_WITH([libstdc++-6-dll],
-           AC_HELP_STRING([--with-libstdc++-6-dll=FILE],
-                          [use the libstd++-6 DLL]),
-           [libstdcpp_dll=$withval])
-if test "$libstdcpp_dll" = "no"; then
-  file="/usr/lib/gcc/$host/$gcc_major_minor/libstdc++-6.dll"
-  if test -r "$file"; then
-    libstdcpp_dll="$file"
-  fi
-fi
-if test "$libstdcpp_dll" = "no"; then
-  missing_opt_tools="libstdc++-6.dll $missing_opt_tools"
-else
-  if test -r "$libstdcpp_dll"; then
-    cp $libstdcpp_dll src/libstdc++-6.dll-x
-  else
-    missing_opt_tools="libstdc++-6.dll $missing_opt_tools"
- fi
-fi
+# Additional runtime libraries from mingw.
+GPG4WIN_RUNTIME_LIBRARY(libgcc_s_sjlj-1)
+GPG4WIN_RUNTIME_LIBRARY(libstdc++-6)
+GPG4WIN_RUNTIME_LIBRARY(libwinpthread-1)
 
 AC_CHECK_PROGS(GLIB_GENMARSHAL, glib-genmarshal)
 AC_CHECK_PROGS(GLIB_COMPILE_SCHEMAS, glib-compile-schemas)
index 7aa451b..279e2d6 100644 (file)
@@ -726,3 +726,39 @@ AC_DEFUN([GPG4WIN_BPKG_BINSRC],
           [$4])
 ])
 
+# Add a runtime library argument 1 should be the dll
+# name without the .dll suffix
+AC_DEFUN([GPG4WIN_RUNTIME_LIBRARY],
+[
+    dll_path="no"
+    AC_ARG_WITH([$1],
+    AS_HELP_STRING([--with-$1-dll[=FILE]],
+                   [include FILE as runtime dependency for the installer.]),
+                   [dll_path=$withval])
+
+    if test "$dll_path" = "no"; then
+        changequote(,)
+        gcc_major_minor=$($CC --version \
+                          | awk 'NR==1 {split($NF,a,"."); print a[1] "." a[2]}')
+        changequote([,])
+        guesses="/usr/lib/gcc/$host/$gcc_major_minor/$1.dll
+                 /usr/$host/lib/$1.dll
+                 /usr/lib/gcc/$host/${gcc_major_minor}-win32/$1.dll"
+
+        for file in $guesses; do
+            if test -r "$file"; then
+                dll_path="$file"
+                break
+            fi
+        done
+    fi
+
+    if test "$dll_path" = "no"; then
+        AC_MSG_ERROR(can not find the runtime library $1.dll in the default locations.
+                     Use the --with-$1 option to set the path directly.
+        )
+    fi
+    AC_MSG_NOTICE(Using $dll_path to provide $1)
+    $CP "$dll_path" src/$1.dll-x
+    $STRIP src/$1.dll-x
+])
index 81c6e05..0e63295 100644 (file)
@@ -86,12 +86,12 @@ Section "-gpg4win" SEC_gpg4win
   File "${BUILD_DIR}/md5sum.exe"
   File "${BUILD_DIR}/mkportable.exe"
 
-  SetOutPath "$INSTDIR\pub"
   # Install the mingw32 runtime libraries.  They are stored in the
   # build directory with a different suffix, so that makensis does not
-  # list sumbol names.
+  # list symbol names.
   File /oname=libstdc++-6.dll     "${BUILD_DIR}/libstdc++-6.dll-x"
   File /oname=libgcc_s_sjlj-1.dll "${BUILD_DIR}/libgcc_s_sjlj-1.dll-x"
+  File /oname=libwinpthread-1.dll "${BUILD_DIR}/libwinpthread-1.dll-x"
 
 !endif
 
index 82b93af..ba54fd4 100644 (file)
@@ -36,9 +36,10 @@ Section "-un.gpg4win"
   Delete "$INSTDIR\md5sum.exe"
   Delete "$INSTDIR\mkportable.exe"
 
-  # Delete the runtime libarries
-  Delete "$INSTDIR\pub\libstdc++-6.dll"
-  Delete "$INSTDIR\pub\libgcc_s_sjlj-1.dll"
+  # Delete the runtime libaries
+  Delete "$INSTDIR\libstdc++-6.dll"
+  Delete "$INSTDIR\libgcc_s_sjlj-1.dll"
+  Delete "$INSTDIR\libwinpthread-1.dll"
 
   # Delete standard stuff.
   Delete "$INSTDIR\share\gpg4win\README.*.txt"