diff --git a/src/terminal.c b/src/terminal.c
index d7c16d9..638c663 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -28,7 +28,7 @@ along with GNU Emacs. If not, see . */
#include "coding.h"
#include "keyboard.h"
-#ifdef HAVE_LINUX_KD_H
+#if (defined(__linux__) && defined(HAVE_LINUX_KD_H))
# include
# include
# include
@@ -532,7 +532,7 @@ selected frame's terminal). */)
return store_terminal_param (decode_live_terminal (terminal), parameter, value);
}
-#if HAVE_LINUX_KD_H
+#if (defined(__linux__) && defined(HAVE_LINUX_KD_H))
/* Compute the glyph code table for T. */
@@ -575,7 +575,7 @@ calculate_glyph_code_table (struct terminal *t)
Lisp_Object
terminal_glyph_code (struct terminal *t, int ch)
{
-#if HAVE_LINUX_KD_H
+#if (defined(__linux__) && defined(HAVE_LINUX_KD_H))
if (t->type == output_termcap)
{
/* As a hack, recompute the table when CH is the maximum