From cb943f5534fd30d7883c22c351db2688a95619b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st>
Date: Sat, 19 Nov 2011 15:19:22 +0100
Subject: [PATCH] =?UTF-8?q?Cygwin/mingw32=20improvements=20contributed=20b?=
 =?UTF-8?q?y=20Martin=20Storsj=C3=B6:=20*=20configure.ac:=20Setup=20instal?=
 =?UTF-8?q?lation=20of=20dll=20files=20in=20$bindir.=20(IF=5FDLL,=20LIBNET?=
 =?UTF-8?q?TLE=5FFILE=5FSRC,=20LIBHOGWEED=5FFILE=5FSRC):=20New=20substitut?=
 =?UTF-8?q?ions.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* config.make.in (LIBNETTLE_FILE_SRC): Substitute new autoconf
variable.
(LIBHOGWEED_FILE_SRC): Likewise.

* Makefile.in (install-dll-nettle, uninstall-dll-nettle): New
target for installing the dll file in $bindir.
(install-shared-nettle): Conditionally
depend on install-dll-nettle. Use LIBNETTLE_FILE_SRC.
(uninstall-shared-nettle): Conditionally depend on
install-dll-nettle.
(various hogweed targets): Analogous changes.

Rev: nettle/ChangeLog:1.230
Rev: nettle/Makefile.in:1.41
Rev: nettle/config.make.in:1.4
Rev: nettle/configure.ac:1.47
---
 ChangeLog      | 18 +++++++++++++++++-
 Makefile.in    | 26 ++++++++++++++++++++------
 config.make.in |  2 ++
 configure.ac   | 14 ++++++++++++++
 4 files changed, 53 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f9511296..bbbb4e7d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,22 @@
 2011-11-19  Niels M�ller  <nisse@lysator.liu.se>
 
-	From Martin Storsj�:
+	Cygwin/mingw32 improvements contributed by Martin Storsj�:
+	* configure.ac: Setup installation of dll files in $bindir.
+	(IF_DLL, LIBNETTLE_FILE_SRC, LIBHOGWEED_FILE_SRC): New
+	substitutions.
+
+	* config.make.in (LIBNETTLE_FILE_SRC): Substitute new autoconf
+	variable.
+	(LIBHOGWEED_FILE_SRC): Likewise.
+
+	* Makefile.in (install-dll-nettle, uninstall-dll-nettle): New
+	target for installing the dll file in $bindir.
+	(install-shared-nettle): Conditionally
+	depend on install-dll-nettle. Use LIBNETTLE_FILE_SRC.
+	(uninstall-shared-nettle): Conditionally depend on
+	install-dll-nettle.
+	(various hogweed targets): Analogous changes.
+
 	* configure.ac: Unify shared lib setup for cygwin and mingw.
 
 2011-10-31  Niels M�ller  <nisse@lysator.liu.se>
diff --git a/Makefile.in b/Makefile.in
index 27f076a7..a954f7fe 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -285,17 +285,25 @@ install-static: $(LIBTARGETS)
 	  $(INSTALL_DATA) $$f $(DESTDIR)$(libdir) ; \
 	done
 
-install-shared-nettle: $(LIBNETTLE_FORLINK)
+install-dll-nettle:
+	$(MKDIR_P) $(DESTDIR)$(bindir)
+	$(INSTALL_DATA) $(LIBNETTLE_FORLINK) $(DESTDIR)$(bindir)/$(LIBNETTLE_FORLINK)
+
+install-shared-nettle: $(LIBNETTLE_FORLINK) @IF_DLL@ install-dll-nettle
 	$(MKDIR_P) $(DESTDIR)$(libdir)
-	$(INSTALL_DATA) $(LIBNETTLE_FORLINK) $(DESTDIR)$(libdir)/$(LIBNETTLE_FILE)
+	$(INSTALL_DATA) $(LIBNETTLE_FILE_SRC) $(DESTDIR)$(libdir)/$(LIBNETTLE_FILE)
 	[ -z "$(LIBNETTLE_SONAME)" ] \
                 || (cd $(DESTDIR)$(libdir) \
 		&& ln -sf $(LIBNETTLE_FILE) $(LIBNETTLE_SONAME) \
 		&& ln -sf $(LIBNETTLE_FILE) $(LIBNETTLE_FORLINK))
 
-install-shared-hogweed: $(LIBHOGWEED_FORLINK)
+install-dll-hogweed:
+	$(MKDIR_P) $(DESTDIR)$(bindir)
+	$(INSTALL_DATA) $(LIBHOGWEED_FORLINK) $(DESTDIR)$(bindir)/$(LIBHOGWEED_FORLINK)
+
+install-shared-hogweed: $(LIBHOGWEED_FORLINK) @IF_DLL@ install-dll-hogweed
 	$(MKDIR_P) $(DESTDIR)$(libdir)
-	$(INSTALL_DATA) $(LIBHOGWEED_FORLINK) $(DESTDIR)$(libdir)/$(LIBHOGWEED_FILE)
+	$(INSTALL_DATA) $(LIBHOGWEED_FILE_SRC) $(DESTDIR)$(libdir)/$(LIBHOGWEED_FILE)
 	[ -z "$(LIBHOGWEED_SONAME)" ] \
                 || (cd $(DESTDIR)$(libdir) \
 		&& ln -sf $(LIBHOGWEED_FILE) $(LIBHOGWEED_SONAME) \
@@ -356,12 +364,18 @@ uninstall-info:
 # FIXME: Leaves the links around
 uninstall-shared: uninstall-shared-nettle @IF_HOGWEED@ uninstall-shared-hogweed
 
-uninstall-shared-nettle:
+uninstall-dll-nettle:
+	rm -f $(DESTDIR)$(bindir)/$(LIBNETTLE_FORLINK)
+
+uninstall-shared-nettle: @IF_DLL@ uninstall-dll-nettle
 	rm -f $(DESTDIR)$(libdir)/$(LIBNETTLE_FILE)
 	[ -z "$(LIBNETTLE_SONAME)" ] \
 		|| rm -f $(LIBNETTLE_SONAME) $(LIBNETTLE_FORLINK)
 
-uninstall-shared-hogweed:
+uninstall-dll-hogweed:
+	rm -f $(DESTDIR)$(bindir)/$(LIBHOGWEED_FORLINK)
+
+uninstall-shared-hogweed: @IF_DLL@ uninstall-dll-hogweed
 	rm -f $(DESTDIR)$(libdir)/$(LIBHOGWEED_FILE)
 	[ -z "$(LIBHOGWEED_SONAME)" ] \
 		|| rm -f $(LIBHOGWEED_SONAME) $(LIBHOGWEED_FORLINK)
diff --git a/config.make.in b/config.make.in
index 152b42e5..3caa460b 100644
--- a/config.make.in
+++ b/config.make.in
@@ -30,6 +30,7 @@ LIBNETTLE_MAJOR = @LIBNETTLE_MAJOR@
 LIBNETTLE_MINOR = @LIBNETTLE_MINOR@
 LIBNETTLE_SONAME = @LIBNETTLE_SONAME@
 LIBNETTLE_FILE = @LIBNETTLE_FILE@
+LIBNETTLE_FILE_SRC = @LIBNETTLE_FILE_SRC@
 LIBNETTLE_FORLINK = @LIBNETTLE_FORLINK@
 LIBNETTLE_LIBS = @LIBNETTLE_LIBS@
 LIBNETTLE_LINK = @LIBNETTLE_LINK@
@@ -38,6 +39,7 @@ LIBHOGWEED_MAJOR = @LIBHOGWEED_MAJOR@
 LIBHOGWEED_MINOR = @LIBHOGWEED_MINOR@
 LIBHOGWEED_SONAME = @LIBHOGWEED_SONAME@
 LIBHOGWEED_FILE = @LIBHOGWEED_FILE@
+LIBHOGWEED_FILE_SRC = @LIBHOGWEED_FILE_SRC@
 LIBHOGWEED_FORLINK = @LIBHOGWEED_FORLINK@
 LIBHOGWEED_LIBS = @LIBHOGWEED_LIBS@
 LIBHOGWEED_LINK = @LIBHOGWEED_LINK@
diff --git a/configure.ac b/configure.ac
index 4510c819..5f2ab76e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -252,8 +252,16 @@ LSH_CCPIC
 
 SHLIBCFLAGS="$CCPIC"
 
+IF_DLL='#'
+LIBNETTLE_FILE_SRC='$(LIBNETTLE_FORLINK)'
+LIBHOGWEED_FILE_SRC='$(LIBHOGWEED_FORLINK)'
+
 case "$host_os" in
   mingw32*|cygwin*)
+    # The actual DLLs, e.g. libnettle-$major-$minor.dll, are normally
+    # installed into the bin dir (or more exactly $libdir/../bin, for
+    # automake), while libnettle.dll.a, which is a stub file for
+    # linking to the DLL, is installed into the lib dir.
     case "$host_os" in
       mingw32*)
         LIBNETTLE_FORLINK='libnettle-$(LIBNETTLE_MAJOR)-$(LIBNETTLE_MINOR).dll'
@@ -266,13 +274,16 @@ case "$host_os" in
     esac
     LIBNETTLE_SONAME=''
     LIBNETTLE_FILE='libnettle.dll.a'
+    LIBNETTLE_FILE_SRC='$(LIBNETTLE_FILE)'
     LIBNETTLE_LINK='$(CC) $(LDFLAGS) -shared -Wl,--out-implib=$(LIBNETTLE_FILE) -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--whole-archive'
     LIBNETTLE_LIBS='-Wl,--no-whole-archive $(LIBS)'
 
     LIBHOGWEED_SONAME=''
     LIBHOGWEED_FILE='libhogweed.dll.a'
+    LIBHOGWEED_FILE_SRC='$(LIBHOGWEED_FILE)'
     LIBHOGWEED_LINK='$(CC) $(LDFLAGS) -shared -Wl,--out-implib=$(LIBHOGWEED_FILE) -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--whole-archive'
     LIBHOGWEED_LIBS='-Wl,--no-whole-archive $(LIBS) libnettle.dll.a'
+    IF_DLL=''
     ;;
   darwin*)
     LIBNETTLE_FORLINK=libnettle.dylib
@@ -442,6 +453,7 @@ AC_SUBST(LIBNETTLE_MINOR)
 AC_SUBST(LIBNETTLE_FORLINK)
 AC_SUBST(LIBNETTLE_SONAME)
 AC_SUBST(LIBNETTLE_FILE)
+AC_SUBST(LIBNETTLE_FILE_SRC)
 AC_SUBST(LIBNETTLE_LINK)
 AC_SUBST(LIBNETTLE_LIBS)
 
@@ -450,6 +462,7 @@ AC_SUBST(LIBHOGWEED_MINOR)
 AC_SUBST(LIBHOGWEED_FORLINK)
 AC_SUBST(LIBHOGWEED_SONAME)
 AC_SUBST(LIBHOGWEED_FILE)
+AC_SUBST(LIBHOGWEED_FILE_SRC)
 AC_SUBST(LIBHOGWEED_LINK)
 AC_SUBST(LIBHOGWEED_LIBS)
 
@@ -538,6 +551,7 @@ fi
 
 AC_SUBST(IF_HOGWEED)
 AC_SUBST(IF_SHARED)
+AC_SUBST(IF_DLL)
 
 OPENSSL_LIBFLAGS=''
 
-- 
GitLab