zephyr: port build system to CMake

Convert the Zephyr build to the new CMake-based sytem.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
diff --git a/samples/zephyr/hello-world/CMakeLists.txt b/samples/zephyr/hello-world/CMakeLists.txt
new file mode 100644
index 0000000..d4ef940
--- /dev/null
+++ b/samples/zephyr/hello-world/CMakeLists.txt
@@ -0,0 +1,52 @@
+# Top-level CMakeLists.txt for the skeleton application.
+#
+# Copyright (c) 2017 Open Source Foundries Limited
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# This provides a basic application structure suitable for loading by
+# mcuboot, which is easy to customize on a per-board basis. It can be
+# used as a starting point for new applications.
+
+# The board should be set to a supported target. The default is
+# frdm_k64f.
+if (NOT DEFINED BOARD)
+  set(BOARD frdm_k64f)
+endif()
+
+# The default top-level application configuration is prj.conf.
+# You can place additional board-specific files in boards/${BOARD}.conf,
+# and they will be merged into the configuration along with prj.conf.
+macro(set_conf_file)
+  if(EXISTS ${APPLICATION_SOURCE_DIR}/boards/${BOARD}.conf)
+    set(CONF_FILE "prj.conf ${APPLICATION_SOURCE_DIR}/boards/${BOARD}.conf")
+  else()
+    set(CONF_FILE "prj.conf")
+  endif()
+endmacro()
+
+# Zephyr uses Device Tree (DT) to describe some board hardware
+# configuration.
+#
+# For this simple example, all we need to tell DT is where on the chip
+# flash to link this application image so mcuboot can find it. We do
+# this with a device tree overlay file.
+#
+# See the Zephyr documentation for more information on DT:
+# https://www.zephyrproject.org/doc/dts/device_tree.html
+set(DTC_OVERLAY_FILE "${CMAKE_CURRENT_SOURCE_DIR}/dts.overlay")
+
+# Standard Zephyr application boilerplate.
+include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
+project(NONE)
+
+assert_exists(DTC_OVERLAY_FILE)
+
+# This string ends up getting printed in the device console
+if (NOT DEFINED FROM_WHO)
+  set(FROM_WHO Zephyr)
+endif()
+
+target_compile_definitions(app PRIVATE "-DMCUBOOT_HELLO_WORLD_FROM=\"${FROM_WHO}\"")
+
+target_sources(app PRIVATE src/main.c)
diff --git a/samples/zephyr/hello-world/Makefile b/samples/zephyr/hello-world/Makefile
deleted file mode 100644
index 15176e0..0000000
--- a/samples/zephyr/hello-world/Makefile
+++ /dev/null
@@ -1,46 +0,0 @@
-# Top-level Makefile for the skeleton application.
-#
-# This provides a basic application structure suitable for loading by
-# mcuboot, which is easy to customize on a per-board basis. It can be
-# used as a starting point for new applications.
-
-# The default board is FRDM-K64F. This can be overridden at
-# the command line for other boards supported by Zephyr.
-BOARD ?= frdm_k64f
-# The top-level application configuration is prj.conf. This can also
-# be overridden at the command line if you add another one.
-CONF_FILE ?= prj.conf
-
-# This will merge any board-specific extras from boards/$(BOARD).conf
-# into the configuration.
-CONF_FILE += $(wildcard boards/$(BOARD).conf)
-# These additional "local" files, if present, will be merged in as
-# well, but they are ignored by Git.
-CONF_FILE += $(wildcard local.conf) $(wildcard boards/$(BOARD)-local.conf)
-
-# Zephyr uses Device Tree (DT) to describe some board hardware
-# configuration.
-#
-# For this simple example, all we need to tell DT is where on the chip
-# flash to link this application image so mcuboot can find it. We do
-# this with a device tree overlay file.
-#
-# See the Zephyr documentation for more information on DT:
-# https://www.zephyrproject.org/doc/dts/device_tree.html
-DTC_OVERLAY_FILE := $(CURDIR)/dts.overlay
-export DTC_OVERLAY_FILE
-# If you want to do your DT overlay on a per-board basis (say, if you
-# need to support multiple different boards, each of which needs
-# slightly different DT overlays), then comment the above lines and
-# uncomment the following ones. You can then add board-specific
-# overlay files named boards/$(BOARD).overlay.
-#
-# DTC_OVERLAY_DIR := $(CURDIR)/boards
-# export DTC_OVERLAY_DIR
-
-# This string ends up getting printed in the device console
-FROM_WHO ?= "Zephyr"
-CFLAGS += -DMCUBOOT_HELLO_WORLD_FROM=\"$(FROM_WHO)\"
-
-# The Zephyr Makefiles do the rest.
-include $(ZEPHYR_BASE)/Makefile.inc
diff --git a/samples/zephyr/hello-world/boards/README.rst b/samples/zephyr/hello-world/boards/README.rst
index 1715f42..efa236d 100644
--- a/samples/zephyr/hello-world/boards/README.rst
+++ b/samples/zephyr/hello-world/boards/README.rst
@@ -1,2 +1,2 @@
 You can place per-board configuration and device tree overlays
-here. See the comments in the Makefile for more information.
+here. See the comments in the CMakeLists.txt for more information.
diff --git a/samples/zephyr/hello-world/prj.conf b/samples/zephyr/hello-world/prj.conf
index 193c611..f9137cd 100644
--- a/samples/zephyr/hello-world/prj.conf
+++ b/samples/zephyr/hello-world/prj.conf
@@ -2,6 +2,10 @@
 CONFIG_BOOT_BANNER=y
 CONFIG_BUILD_TIMESTAMP=y
 
+# Enable console and printk()
+CONFIG_PRINTK=y
+CONFIG_STDOUT_CONSOLE=y
+
 # TEXT_SECTION_OFFSET is used to leave space in the binary for the
 # mcuboot header.
 #