fixed Makefile variables for cross-compilation

When configured for a different host, the variables CC, AR and
RANLIB have not been set correctly. With this fix, tinydtls can
be compiled for another platform when it is configured as a
submodule of an automake-enabled project.

For example, when the dtls branch of libcoap[1] can be cross-compiled
for the raspberry pi as follows:

  ./configure --with-host=arm-linux-gnueabihf --disable-shared

Note that cross-compilation does not yet work without automake as the
m4 macro AM_PROG_AR depends on automake.

[1] https://github.com/obgm/libcoap/tree/dtls

Change-Id: If23080dc7754a48434e7ac787c0bddda1dd9530b
diff --git a/Makefile.in b/Makefile.in
index bec7c8c..932919c 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -22,6 +22,9 @@
 SHELL = /bin/sh
 MKDIR = mkdir
 ETAGS = @ETAGS@
+CC=@CC@
+AR=@AR@
+RANLIB=@RANLIB@
 
 prefix = @prefix@
 exec_prefix = @exec_prefix@
@@ -76,7 +79,7 @@
 
 $(LIB):	$(OBJECTS)
 	$(AR) $(ARFLAGS) $@ $^ 
-	ranlib $@
+	$(RANLIB) $@
 
 clean:
 	@rm -f $(PROGRAM) main.o $(LIB) $(OBJECTS)
diff --git a/aes/Makefile.in b/aes/Makefile.in
index 7c9f6ef..f6b5880 100644
--- a/aes/Makefile.in
+++ b/aes/Makefile.in
@@ -20,6 +20,7 @@
 @SET_MAKE@
 SHELL = /bin/sh
 MKDIR = mkdir
+CC=@CC@
 
 abs_builddir = @abs_builddir@
 top_builddir = @top_builddir@
diff --git a/configure.ac b/configure.ac
index 8ec4d50..757de17 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,6 +26,7 @@
 AC_PROG_MAKE_SET
 AC_PROG_CC
 AC_PROG_RANLIB
+m4_ifdef([AM_PROG_AR], [AM_PROG_AR], [AR=ar])
 
 AC_C_BIGENDIAN
 
@@ -81,6 +82,7 @@
 AC_SUBST(NDEBUG)
 AC_SUBST(DTLS_ECC)
 AC_SUBST(DTLS_PSK)
+AC_SUBST(AR)
 
 # Checks for header files.
 AC_CHECK_HEADERS([assert.h arpa/inet.h fcntl.h inttypes.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h strings.h sys/param.h sys/socket.h unistd.h])
diff --git a/ecc/Makefile.in b/ecc/Makefile.in
index ebf8231..9bd71fd 100644
--- a/ecc/Makefile.in
+++ b/ecc/Makefile.in
@@ -21,6 +21,7 @@
 @SET_MAKE@
 SHELL = /bin/sh
 MKDIR = mkdir
+CC=@CC@
 
 abs_builddir = @abs_builddir@
 top_builddir = @top_builddir@
diff --git a/sha2/Makefile.in b/sha2/Makefile.in
index 9f19314..f7ec138 100644
--- a/sha2/Makefile.in
+++ b/sha2/Makefile.in
@@ -20,6 +20,7 @@
 @SET_MAKE@
 SHELL = /bin/sh
 MKDIR = mkdir
+CC=@CC@
 
 abs_builddir = @abs_builddir@
 top_builddir = @top_builddir@
diff --git a/tests/Makefile.in b/tests/Makefile.in
index a8a2ed0..a2e68b6 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -20,6 +20,7 @@
 @SET_MAKE@
 SHELL = /bin/sh
 MKDIR = mkdir
+CC=@CC@
 
 abs_builddir = @abs_builddir@
 top_builddir = @top_builddir@