diff --git a/configure.in b/configure.in
index 405ebddadbe468f83a49c6bcf42faac7afb957a7..a399ccb2909566f1644cc6d97676e5893166490f 100644
--- a/configure.in
+++ b/configure.in
@@ -2128,7 +2128,7 @@ AC_CHECK_FUNCS(alarm bcmp bfill bmove bzero chsize cuserid fchmod fcntl \
   shmget shmat shmdt shmctl sigaction sigemptyset sigaddset \
   sighold sigset sigthreadmask \
   snprintf socket stpcpy strcasecmp strerror strsignal strnlen strpbrk strstr strtol \
-  strtoll strtoul strtoull tell tempnam thr_setconcurrency vidattr)
+  strtoll strtoul strtoull tell tempnam thr_setconcurrency vidattr printstack)
 
 #
 #
diff --git a/sql/stacktrace.c b/sql/stacktrace.c
index 295a7a3e1e28b010ff2dce3fb9693bc0fc5afee7..a8648ca4e5aeca89a93cca3ebeec68292033a756 100644
--- a/sql/stacktrace.c
+++ b/sql/stacktrace.c
@@ -227,7 +227,7 @@ stack trace is much more helpful in diagnosing the problem, so please do \n\
 resolve it\n");
 }
 
-#elif defined(__sun)
+#elif defined(HAVE_PRINTSTACK)
 
 /* Use Solaris' symbolic stack trace routine. */
 #include <ucontext.h>
diff --git a/sql/stacktrace.h b/sql/stacktrace.h
index 718b545b775b53b2f62e101d4b6c5a04da7c0b6b..1366a6cf9961e2cee00b939c20838e98877917f5 100644
--- a/sql/stacktrace.h
+++ b/sql/stacktrace.h
@@ -35,7 +35,7 @@ void check_thread_lib(void);
 #define HAVE_STACKTRACE
 extern void set_exception_pointers(EXCEPTION_POINTERS *ep);
 #define init_stacktrace() {}
-#elif defined(__sun)
+#elif defined(HAVE_PRINTSTACK)
 #define HAVE_STACKTRACE
 #define init_stacktrace() {}
 #endif