From d7de263402aabe916fc77b5ee1d2f33dcd781f2b Mon Sep 17 00:00:00 2001
From: joerg_wunsch <joerg_wunsch@81a1dc3b-b13d-400b-aceb-764788c761c2>
Date: Sun, 24 Sep 2006 13:35:40 +0000
Subject: [PATCH] Submitted by Thomas Fischl (initially):

Add the CoreFoundation and IOKit framework linker flags on MacOS X
when configuring for USB support.

patch #4685: Libusb on MacOS X: detection and additional includes

Thanks to Matthias Ringwald for testing the reworked patch.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@666 81a1dc3b-b13d-400b-aceb-764788c761c2
---
 ChangeLog    |  7 +++++++
 configure.ac | 22 ++++++++++++++--------
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6e5da182..4d9d591f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-09-24 Joerg Wunsch <j@uriah.heep.sax.de>
+
+	Submitted by Thomas Fischl (initially):
+	* configure.ac: Add the CoreFoundation and IOKit framework
+	linker flags on MacOS X when configuring for USB support.
+	patch #4685: Libusb on MacOS X: detection and additional includes
+
 2006-09-20 Joerg Wunsch <j@uriah.heep.sax.de>
 
 	* avr910.c: As there is a lot of ambiguity about the AVR910
diff --git a/configure.ac b/configure.ac
index 5f57d0b6..29896ca1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,14 +44,20 @@ AM_PROG_LEX
 AC_CHECK_LIB([termcap], [tputs])
 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],
-		    [LIBUSB=-lusb
-		    AC_DEFINE([HAVE_LIBUSB],
-		              [1],
-			      [Define to 1 if libusb is available.])],
-		    [LIBUSB=])
+AH_TEMPLATE([HAVE_LIBUSB],
+            [Define if USB support is enabled via libusb])
+AC_CHECK_LIB([usb], [usb_get_string_simple], [have_libusb=yes])
+if test x$have_libusb = xyes; then
+   case $target in
+       *-*-darwin*)
+               LIBUSB="-lusb -framework CoreFoundation -framework IOKit"
+               ;;
+       *)
+               LIBUSB="-lusb"
+               ;;
+   esac
+   AC_DEFINE([HAVE_LIBUSB])
+fi
 AC_SUBST(LIBUSB, $LIBUSB)
 
 # Checks for header files.