yanglint BUILD optional interactive yanglint

Detected also based on ioctl.h presence.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 13edcc5..19bbf08 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,7 +15,6 @@
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/")
 
 include(GNUInstallDirs)
-include(CheckSymbolExists)
 include(UseCompat)
 include(ABICheck)
 include(SourceFormat)
@@ -245,6 +244,7 @@
 option(ENABLE_COVERAGE "Build code coverage report from tests" OFF)
 option(ENABLE_FUZZ_TARGETS "Build target programs suitable for fuzzing with AFL" OFF)
 option(ENABLE_INTERNAL_DOCS "Generate doxygen documentation also from internal headers" OFF)
+option(ENABLE_YANGLINT_INTERACTIVE "Enable interactive CLI yanglint" ON)
 option(BUILD_SHARED_LIBS "By default, shared libs are enabled. Turn off for a static build." ON)
 set(YANG_MODULE_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/yang/modules/libyang" CACHE STRING "Directory where to copy the YANG modules to")
 
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index b92f80c..0e1ee17 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -1,6 +1,16 @@
+include(CheckIncludeFile)
+
 # config file for tools
 configure_file(${PROJECT_SOURCE_DIR}/tools/config.h.in ${PROJECT_BINARY_DIR}/tools/config.h @ONLY)
 
+# find ioctl
+check_include_file("sys/ioctl.h" HAVE_IOCTL)
+if(NOT HAVE_IOCTL)
+    message(STATUS "Disabling interactive yanglint, sys/ioctl.h not found...")
+    set(ENABLE_YANGLINT_INTERACTIVE OFF)
+endif()
+
+# find getopt library on WIN32
 if(WIN32)
     find_library(GETOPT_LIBRARY NAMES getopt REQUIRED)
     find_path(GETOPT_INCLUDE_DIR NAMES getopt.h REQUIRED)
diff --git a/tools/lint/CMakeLists.txt b/tools/lint/CMakeLists.txt
index 14f8b76..059305e 100644
--- a/tools/lint/CMakeLists.txt
+++ b/tools/lint/CMakeLists.txt
@@ -1,11 +1,4 @@
 # yanglint
-
-if(WIN32)
-    set(YANGLINT_INTERACTIVE OFF)
-else()
-    set(YANGLINT_INTERACTIVE ON)
-endif()
-
 set(lintsrc
     main_ni.c
     cmd.c
@@ -25,7 +18,8 @@
     yl_schema_features.c
     common.c
 )
-if(YANGLINT_INTERACTIVE)
+
+if(ENABLE_YANGLINT_INTERACTIVE)
     set(lintsrc ${lintsrc}
         main.c
         completion.c