diff --git a/examples/Makefile.in b/examples/Makefile.in
index a3b07905e0dbaade694816fdf2bf5fefcb657f13..211600ed71640246a65f54e71cc3f2e521f6bd98 100644
--- a/examples/Makefile.in
+++ b/examples/Makefile.in
@@ -75,7 +75,8 @@ $(TARGETS) : io.$(OBJEXT) ../libnettle.a
 
 check: $(TS_ALL)
 	LD_LIBRARY_PATH=../.lib srcdir="$(srcdir)" \
-	  "$(srcdir)"/run-tests $(TS_ALL)
+	  EMULATOR="$(EMULATOR)" EXEEXT="$(EXEEXT)" \
+          "$(srcdir)"/run-tests $(TS_ALL)
 
 Makefile: $(srcdir)/Makefile.in ../config.status
 	cd .. && $(SHELL) ./config.status examples/$@
diff --git a/examples/rsa-encrypt-test b/examples/rsa-encrypt-test
index 08b7a44700b4cbc38576eac0141a7e30172d6e65..ff935fb0abdc331686895602b3a94fad5b5abe7f 100755
--- a/examples/rsa-encrypt-test
+++ b/examples/rsa-encrypt-test
@@ -6,13 +6,13 @@ fi
 
 data="$srcdir/nettle-benchmark.c"
 
-if [ -x rsa-encrypt ] ; then
-  if ./rsa-encrypt -r rsa-decrypt testkey.pub < "$data" > testciphertext ; then
+if [ -x rsa-encrypt$EXEEXT ] ; then
+  if $EMULATOR ./rsa-encrypt -r rsa-decrypt$EXEEXT testkey.pub < "$data" > testciphertext ; then
     :
   else
     exit 1
   fi
-  if ./rsa-decrypt testkey < testciphertext > testcleartext ; then
+  if $EMULATOR ./rsa-decrypt testkey < testciphertext > testcleartext ; then
     :
   else
     exit 1
diff --git a/examples/rsa-sign-test b/examples/rsa-sign-test
index 16212269fe5ff0e04b7896830b7c44ee840860db..99d90dfcf023721e72b4755a2b8d7103f5b632c9 100755
--- a/examples/rsa-sign-test
+++ b/examples/rsa-sign-test
@@ -6,8 +6,8 @@ fi
 
 data="$srcdir/nettle-benchmark.c"
 
-if [ -x rsa-sign ] ; then
-  if ./rsa-sign testkey < "$data" > testsignature ; then
+if [ -x rsa-sign$EXEEXT ] ; then
+  if $EMULATOR ./rsa-sign testkey < "$data" > testsignature ; then
     exit 0;
   else
     exit 1
diff --git a/examples/rsa-verify-test b/examples/rsa-verify-test
index 765b61f5d71c23d0e40858960e6dcf98d165a167..13c143cb3f4cfe892540fc81aa41324777dabb99 100755
--- a/examples/rsa-verify-test
+++ b/examples/rsa-verify-test
@@ -6,21 +6,21 @@ fi
 
 data="$srcdir/nettle-benchmark.c"
 
-if [ -x rsa-verify ] ; then
-  ./rsa-sign testkey < "$data" > testsignature \
-    && ./rsa-verify testkey.pub testsignature < "$data" \
+if [ -x rsa-verify$EXEEXT ] ; then
+  $EMULATOR ./rsa-sign testkey < "$data" > testsignature \
+    && $EMULATOR ./rsa-verify testkey.pub testsignature < "$data" \
     || exit 1;
   
   # Try modifying the data
   sed s/128/129/ < "$data" >testdata
 
-  if ./rsa-verify testkey.pub testsignature < testdata 2>/dev/null; then
+  if $EMULATOR ./rsa-verify testkey.pub testsignature < testdata 2>/dev/null; then
     exit 1
   fi
   
   # Try modifying the signature
   sed s/1/2/ <testsignature > testsignature2
-  if ./rsa-verify testkey.pub testsignature2 < "$data" 2>/dev/null; then
+  if $EMULATOR ./rsa-verify testkey.pub testsignature2 < "$data" 2>/dev/null; then
     exit 1;
   fi
   exit 0
diff --git a/examples/setup-env b/examples/setup-env
index 7588d6f88b19986051621334d463d9daf63a1979..3ebef2c8b7d5b673c96d88d64103df180b0edeae 100755
--- a/examples/setup-env
+++ b/examples/setup-env
@@ -2,6 +2,6 @@
 
 set -e
 
-if [ -x rsa-keygen ] ; then
-  ./rsa-keygen -r rsa-decrypt -o testkey || exit 1
+if [ -x rsa-keygen$EXEEXT ] ; then
+  $EMULATOR ./rsa-keygen -r rsa-decrypt$EXEEXT -o testkey || exit 1
 fi
diff --git a/examples/teardown-env b/examples/teardown-env
index ce1a157bdb6994fc892b09a1d50d4a27940a2476..496c8cc5255245d5f63b3ac9a1acc799f6966e8a 100755
--- a/examples/teardown-env
+++ b/examples/teardown-env
@@ -1,6 +1,7 @@
 #! /bin/sh
 
-rm -rf testkey testkey.pub testsignature testsignature2 testdata \
+rm -rf testkey testkey.pub testsignature testsignature2 \
+    testdata testtmp \
     testciphertext testcleartext