diff --git a/lib/Makefile.m32 b/lib/Makefile.m32
index d0ac77b1058213a46ea55e78d760f97db2024b44..2b23a40eee6c587d7a42ef32e42d9972d16789a4 100644
--- a/lib/Makefile.m32
+++ b/lib/Makefile.m32
@@ -54,9 +54,14 @@ ifndef LIBCARES_PATH
 LIBCARES_PATH = $(PROOT)/ares
 endif
 
-# Edit the var below to set to your architecture or set environment var.
+# Set environment var ARCH to your architecture to override autodetection.
 ifndef ARCH
-ARCH = w32
+TARGET	:= $(shell $(CC) -dumpmachine)
+ifeq ($(findstring x86_64,$(TARGET)),x86_64)
+ARCH	= w64
+else
+ARCH	= w32
+endif
 endif
 
 CC	= $(CROSSPREFIX)gcc
diff --git a/src/Makefile.m32 b/src/Makefile.m32
index ac1c0b8353929d678ea2fb2ea21ef0ca86785111..5cacade5719212a9e0d3778305ec791311fbb800 100644
--- a/src/Makefile.m32
+++ b/src/Makefile.m32
@@ -66,9 +66,14 @@ ifndef LIBCARES_PATH
 LIBCARES_PATH = $(PROOT)/ares
 endif
 
-# Edit the var below to set to your architecture or set environment var.
+# Set environment var ARCH to your architecture to override autodetection.
 ifndef ARCH
-ARCH = w32
+TARGET  := $(shell $(CC) -dumpmachine)
+ifeq ($(findstring x86_64,$(TARGET)),x86_64)
+ARCH    = w64
+else
+ARCH    = w32
+endif
 endif
 
 CC	= $(CROSSPREFIX)gcc