From e04281104f8174ee1dc9d23e64682de703582e1c Mon Sep 17 00:00:00 2001
From: joerg_wunsch <joerg_wunsch@81a1dc3b-b13d-400b-aceb-764788c761c2>
Date: Fri, 11 Aug 2006 16:00:12 +0000
Subject: [PATCH] * configure.ac (AC_CHECK_LIB([usb]): implement a private
 LIBUSB macro to add this library to, to prevent it from being automatically
 linked to all binaries.  This should fix the Win32 build of loaddrv. *
 Makefile.am (avrdude_LDADD): add LIBUSB here.

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@602 81a1dc3b-b13d-400b-aceb-764788c761c2
---
 ChangeLog    | 8 ++++++++
 Makefile.am  | 2 ++
 configure.ac | 5 ++++-
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 52b1d0f5..be0a9a30 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-08-11 Joerg Wunsch <j@uriah.heep.sax.de>
+
+	* configure.ac (AC_CHECK_LIB([usb]): implement a private LIBUSB
+	macro to add this library to, to prevent it from being
+	automatically linked to all binaries.  This should fix the Win32
+	build of loaddrv.
+	* Makefile.am (avrdude_LDADD): add LIBUSB here.
+
 2006-08-10 Eric B. Weddington <eweddington@cso.atmel.com>
 
     Contributed by Bob Paddock <graceindustries@gmail.com>
diff --git a/Makefile.am b/Makefile.am
index 73912bc0..6d807f6f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -47,6 +47,8 @@ avrdude_CPPFLAGS = -DCONFIG_DIR=\"$(sysconfdir)\"
 
 avrdude_CFLAGS   = @ENABLE_WARNINGS@  
 
+avrdude_LDADD  = @LIBUSB@
+
 bin_PROGRAMS = avrdude
 
 avrdude_SOURCES = \
diff --git a/configure.ac b/configure.ac
index 1b3344ea..6145959a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -46,7 +46,10 @@ AC_CHECK_LIB([ncurses], [tputs])
 AC_CHECK_LIB([readline], [readline])
 # usb_get_string_simple is only available in recent enough
 # versions of libusb, so use that as a decision base.
-AC_CHECK_LIB([usb], [usb_get_string_simple])
+AC_CHECK_LIB([usb], [usb_get_string_simple],
+		    [LIBUSB=-lusb],
+		    [LIBUSB=])
+AC_SUBST(LIBUSB, $LIBUSB)
 
 # Checks for header files.
 AC_HEADER_STDC