Adds a check and warning for the null entropy option

If the option MBEDTLS_TEST_NULL_ENTROPY is enabled, the cmake generated
makefile will generate an error unless a UNSAFE_BUILD switch is also enabled.

Equally, a similar warning will always be generated if the Makefile is built,
and another warning is generated on every compilation of entropy.c.

This is to ensure the user is aware of what they're doing when they enable the
null entropy option.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 094d906..7ae33cc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,6 +6,7 @@
 
 option(ENABLE_PROGRAMS "Build mbed TLS programs." ON)
 
+option(UNSAFE_BUILD "Allow unsafe builds. These builds ARE NOT SECURE." OFF)
 
 # the test suites currently have compile errors with MSVC
 if(MSVC)
@@ -14,6 +15,35 @@
     option(ENABLE_TESTING "Build mbed TLS tests." ON)
 endif()
 
+find_package(Perl)
+if(PERL_FOUND)
+
+    # If NULL Entropy is configured, display an appropriate warning
+    execute_process(COMMAND ${PERL_EXECUTABLE} scripts/config.pl get MBEDTLS_TEST_NULL_ENTROPY
+                        RESULT_VARIABLE result)
+    if(${result} EQUAL 0)
+        message(WARNING "\
+            *******************************************************
+            ****  WARNING!  MBEDTLS_TEST_NULL_ENTROPY defined!
+            ****  THIS BUILD HAS NO DEFINED ENTROPY SOURCES
+            ****  AND IS *NOT* SUITABLE FOR PRODUCTION USE
+            *******************************************************")
+        if(NOT UNSAFE_BUILD)
+            message(FATAL_ERROR "\
+\n\
+Warning! You have enabled MBEDTLS_TEST_NULL_ENTROPY. \
+This option is not safe for production use and negates all security \
+It is intended for development use only. \
+\n\
+To confirm you want to build with this option, re-run cmake with the \
+option: \n\
+  cmake -DUNSAFE_BUILD=ON ")
+
+            return()
+        endif()
+    endif()
+endif()
+
 set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}
     CACHE STRING "Choose the type of build: None Debug Release Coverage ASan ASanDbg MemSan MemSanDbg Check CheckFull"
     FORCE)