Fix:

error: implicitly declaring library function 'memcmp' with type 'int (const void *, const void *, unsigned long)' [-Werror,-Wimplicit-function-declaration]

error: implicitly declaring library function 'strcpy' with type 'char *(char *, const char *)' [-Werror,-Wimplicit-function-declaration]

These problems in the configure script seem to stem from misuse of autoconf
features. Something about the way the checks for libusb are written prevents
autoconf from being able to determine later that the headers and functions
exist so move the checks for headers and functions before the libusb check.

https://github.com/dfu-programmer/dfu-programmer/issues/61


Fix:

error: implicitly declaring library function 'malloc' with type 'void *(unsigned long)' [-Werror,-Wimplicit-function-declaration]

Upstream has already fixed this problem by moving the code that uses malloc
from atmel.c to intel_hex.c which already includes <stdlib.h>.

https://github.com/dfu-programmer/dfu-programmer/commit/26d96f2195312bdb1dbe5af673acea900eda4318
--- configure.ac.orig
+++ configure.ac
@@ -13,6 +13,17 @@ AM_MAINTAINER_MODE
 # Checks for programs.
 AC_PROG_CC

+# Checks for header files.
+AC_HEADER_STDC
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_TYPE_SIZE_T
+
+# Checks for library functions.
+AC_FUNC_MALLOC
+AC_FUNC_MEMCMP
+
 # Checks for libusb - from sane-backends configuration

 dnl Enable libusb-1.0, if available
@@ -64,17 +75,6 @@ if test "$HAVE_USB" = "yes"; then
 fi


-# Checks for header files.
-AC_HEADER_STDC
-
-# Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-AC_TYPE_SIZE_T
-
-# Checks for library functions.
-AC_FUNC_MALLOC
-AC_FUNC_MEMCMP
-#AC_CHECK_FUNC([memset], :, [AC_CHECK_LIB([libc], [libc])])

 AC_CONFIG_FILES(fedora/dfu-programmer.spec Makefile docs/Makefile src/Makefile)
 AC_OUTPUT
--- src/atmel.c.orig	2014-08-01 05:54:25.000000000 -0500
+++ src/atmel.c	2020-12-10 21:36:44.000000000 -0600
@@ -21,6 +21,7 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <stdint.h>
+#include <stdlib.h>
 #include <string.h>
 #include <stddef.h>
 #include <errno.h>
