Allow to set BUILD_EMULATOR outside the core build system.

For example, you can set it as enviromental variable, command line
makefile variable, or board config variable.

Change-Id: I5a4dbb70270cb4952109b5d96fbbf61eb2603502
diff --git a/core/main.mk b/core/main.mk
index 49e0a9a..bb876b8 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -183,6 +183,7 @@
 $(error stop)
 endif
 
+ifndef BUILD_EMULATOR
 ifeq (darwin,$(HOST_OS))
 GCC_REALPATH = $(realpath $(shell which $(HOST_CC)))
 ifneq ($(findstring llvm-gcc,$(GCC_REALPATH)),)
@@ -199,10 +200,11 @@
 else   # HOST_OS is not darwin
   BUILD_EMULATOR := true
 endif  # HOST_OS is darwin
+endif
 
 $(shell echo 'VERSIONS_CHECKED := $(VERSION_CHECK_SEQUENCE_NUMBER)' \
         > $(OUT_DIR)/versions_checked.mk)
-$(shell echo 'BUILD_EMULATOR := $(BUILD_EMULATOR)' \
+$(shell echo 'BUILD_EMULATOR ?= $(BUILD_EMULATOR)' \
         >> $(OUT_DIR)/versions_checked.mk)
 endif