+AM_CONDITIONAL(PDCLIB, [test x$HAVE_PDCLIB = xyes])
+
+AC_SUBST(PDCLIB_INCLUDES)
+AC_SUBST(PDCLIB_LIBS_M0)
+AC_SUBST(PDCLIB_LIBS_M3)
+AC_SUBST(HAVE_PDCLIB)
+
+if test "x$HAVE_ARM_CC" = "xyes"; then
+ save_CC="$CC"
+ save_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+ CC="$ARM_CC"
+ CFLAGS="-mthumb -mcpu=cortex-m0"
+ LIBS="-ffreestanding -nostdlib"
+ AC_LANG_PUSH([C])
+
+ AC_MSG_CHECKING([if ]$ARM_CC[ supports cortex-m0])
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int i;])],
+ [HAVE_ARM_M0_CC=yes],
+ [HAVE_ARM_M0_CC=no])
+ AC_MSG_RESULT([$HAVE_ARM_M0_CC])
+
+ CFLAGS="-mthumb -mcpu=cortex-m3"
+ AC_MSG_CHECKING([if ]$ARM_CC[ supports cortex-m3])
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int i;])],
+ [HAVE_ARM_M3_CC=yes],
+ [HAVE_ARM_M3_CC=no])
+ AC_MSG_RESULT([$HAVE_ARM_M3_CC])
+
+ if test x$HAVE_PDCLIB != xyes; then
+ AC_CHECK_LIB(pdclib-cortex-m0,memcpy,
+ [],
+ [HAVE_ARM_M0_CC=no])
+
+ AC_CHECK_LIB(pdclib-cortex-m3,memcpy,
+ [],
+ [HAVE_ARM_M3_CC=no])
+ fi
+
+ AC_LANG_POP([C])
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+ CC="$save_CC"
+else
+ HAVE_ARM_M3_CC=no
+ HAVE_ARM_M0_CC=no
+fi
+AC_SUBST(HAVE_ARM_M3_CC)
+AC_SUBST(HAVE_ARM_M0_CC)
+
+if test "x$HAVE_ARM_M3_CC" = "xno"; then
+ AC_MSG_WARN([No cortex-m3 arm compiler found, STM32L binaries will not be built])
+fi
+
+if test "x$HAVE_ARM_M0_CC" = "xno"; then
+ AC_MSG_WARN([No cortex-m0 arm compiler found, LPC11U14 binaries will not be built])
+fi
+
+#
+# Configure AVR compiler
+#
+
+AC_ARG_WITH([avr-cc],
+ [AS_HELP_STRING([--with-avr-cc],
+ [Name of AVR C compiler])],
+ [],
+ [with_avr_cc=auto])
+
+if test "x$with_avr_cc" != "xno"; then
+ if test "x$with_avr_cc" = "xauto"; then
+ with_avr_cc="avr-gcc"
+ AC_CHECK_PROG([HAVE_AVR_CC],[$with_avr_cc], yes, no)
+ else
+ HAVE_AVR_CC=yes
+ fi
+else
+ HAVE_AVR_CC=no
+fi
+
+AC_ARG_WITH([avr-objcopy],
+ [AS_HELP_STRING([--with-avr-objcopy],
+ [Name of AVR objcopy])],
+ [],
+ [with_avr_objcopy=auto])
+
+if test "x$with_avr_objcopy" != "xno"; then
+ if test "x$with_avr_objcopy" = "xauto"; then
+ with_avr_objcopy="avr-objcopy"
+ AC_CHECK_PROG([HAVE_AVR_OBJCOPY],[$with_avr_objcopy], yes, no)
+ else
+ HAVE_AVR_OBJCOPY=yes
+ fi
+else
+ HAVE_AVR_OBJCOPY=no
+fi
+
+if test "x$HAVE_AVR_CC" = "xno" -o "x$HAVE_AVR_OBJCOPY" = "xno"; then
+ AC_MSG_WARN([AVR compiler and objcopy not found, atmel binaries will not be built])
+ HAVE_AVR_CC=no
+else
+ save_CC="$CC"
+ save_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+
+ CC="$with_avr_cc"
+ CFLAGS="-mmcu=attiny85"
+ AC_LANG_PUSH([C])
+ AC_MSG_CHECKING([if ]$with_avr_cc[ can link programs])
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
+ [AVR_LINK=yes],
+ [AVR_LINK=no])
+ AC_MSG_RESULT([$AVR_LINK])
+ AC_LANG_POP([C])
+
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+ CC="$save_CC"
+
+ if test "x$AVR_LINK" = xyes; then
+ AVR_CC=$with_avr_cc
+ AVR_OBJCOPY=$with_avr_objcopy
+ else
+ HAVE_AVR_CC=no;
+ fi
+fi
+
+AC_SUBST(AVR_CC)
+AC_SUBST(AVR_OBJCOPY)
+AC_SUBST(HAVE_AVR_CC)
+