aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac19
-rw-r--r--src/Makefile.am24
2 files changed, 18 insertions, 25 deletions
diff --git a/configure.ac b/configure.ac
index a5abdfd3..968e381b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -999,19 +999,29 @@ fi
if test $build_ft2232_libftdi = yes -o $build_usb_blaster_libftdi = yes -o \
$build_openjtag_ftdi = yes; then
- # We assume: the package is preinstalled in the proper place
- # these present as 2 libraries..
- LIBS="$LIBS -lftdi -lusb"
+
+ # we can have libftdi or libftdi1, so check it and use the latest one
+ PKG_CHECK_MODULES([LIBFTDI], [libftdi1], [use_libftdi=yes], [use_libftdi=no])
+ if test $use_libftdi = no; then
+ PKG_CHECK_MODULES([LIBFTDI], [libftdi], [use_libftdi=yes], [use_libftdi=no])
+ fi
+ if test $use_libftdi = no; then
+ AC_MSG_ERROR([The libftdi driver is not present on your system.])
+ fi
+
#
# Try to build a small program.
AC_MSG_CHECKING([Build & Link with libftdi...])
LDFLAGS_SAVE=$LDFLAGS
CFLAGS_SAVE=$CFLAGS
+ LIBS_SAVE=$LIBS
_LDFLAGS=`eval echo $LDFLAGS`
_CFLAGS=`eval echo $CFLAGS`
+ _LIBS=`eval echo $LIBS`
LDFLAGS=$_LDFLAGS
- CFLAGS=$_CFLAGS
+ CFLAGS="$_CFLAGS $LIBFTDI_CFLAGS"
+ LIBS="$_LIBS $LIBFTDI_LIBS"
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
@@ -1075,6 +1085,7 @@ enum ftdi_chip_type x = TYPE_232H;
# Restore the 'unexpanded ldflags'
LDFLAGS=$LDFLAGS_SAVE
CFLAGS=$CFLAGS_SAVE
+ LIBS=$LIBS_SAVE
fi
PKG_CHECK_MODULES([LIBUSB1], [libusb-1.0], [
diff --git a/src/Makefile.am b/src/Makefile.am
index 3413ba95..48af21d4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -52,7 +52,7 @@ libopenocd_la_CPPFLAGS += -DGITVERSION=\"`cd $(top_srcdir) && git describe`\"
endif
# add default CPPFLAGS
-libopenocd_la_CPPFLAGS += $(AM_CPPFLAGS) $(CPPFLAGS)
+libopenocd_la_CPPFLAGS += $(AM_CPPFLAGS) $(CPPFLAGS) $(LIBFTDI_CFLAGS)
# the library search path.
libopenocd_la_LDFLAGS = $(all_libraries)
@@ -63,25 +63,6 @@ else
MINGWLDADD =
endif
-if FT2232_LIBFTDI
-FTDI2232LIB = -lftdi -lusb
-else
-if PRESTO_LIBFTDI
-FTDI2232LIB = -lftdi -lusb
-else
-FTDI2232LIB =
-endif
-endif
-
-LIBUSB =
-if USE_LIBUSB1
-LIBUSB += $(LIBUSB1_LIBS)
-endif
-
-if USE_LIBUSB0
-LIBUSB += $(LIBUSB0_LIBS)
-endif
-
libopenocd_la_LIBADD = \
$(top_builddir)/src/xsvf/libxsvf.la \
$(top_builddir)/src/svf/libsvf.la \
@@ -93,7 +74,8 @@ libopenocd_la_LIBADD = \
$(top_builddir)/src/server/libserver.la \
$(top_builddir)/src/rtos/librtos.la \
$(top_builddir)/src/helper/libhelper.la \
- $(FTDI2232LIB) $(MINGWLDADD) $(LIBUSB)
+ $(LIBFTDI_LIBS) $(MINGWLDADD) \
+ $(LIBUSB1_LIBS) $(LIBUSB0_LIBS)
STARTUP_TCL_SRCS = \
$(srcdir)/helper/startup.tcl \