From 5af18ba2883d51c54bad8de23bcea01fb22c4daa Mon Sep 17 00:00:00 2001
From: Dean Camera <dean@fourwalledcubicle.com>
Date: Sun, 3 Jun 2012 12:39:53 +0000
Subject: [PATCH] Add explicit blank checks in the build system for user-set
 but blank variables that must not be blank.

---
 LUFA/Build/lufa.avrdude.in | 11 +++++++++--
 LUFA/Build/lufa.build.in   | 27 ++++++++++++++++++++-------
 LUFA/Build/lufa.dfu.in     | 11 +++++++++--
 LUFA/Build/lufa.doxygen.in |  2 +-
 LUFA/Build/lufa.sources.in |  8 ++++++--
 5 files changed, 45 insertions(+), 14 deletions(-)

diff --git a/LUFA/Build/lufa.avrdude.in b/LUFA/Build/lufa.avrdude.in
index 52cb44b8d..a0bef19cc 100644
--- a/LUFA/Build/lufa.avrdude.in
+++ b/LUFA/Build/lufa.avrdude.in
@@ -39,8 +39,15 @@ LUFA_BUILD_OPTIONAL_VARS  += AVRDUDE_PROGRAMMER AVRDUDE_PORT AVRDUDE_FLAGS
 # -----------------------------------------------------------------------------
 
 # Sanity-check values of mandatory user-supplied variables
-MCU                ?= $(error Makefile MCU value not set.)
-TARGET             ?= $(error Makefile TARGET value not set.)
+MCU                ?= $(error Makefile MCU value not set)
+TARGET             ?= $(error Makefile TARGET value not set)
+
+ifeq ($(MCU),)
+   $(error Makefile MCU option cannot be blank)
+endif
+ifeq ($(TARGET),)
+   $(error Makefile TARGET option cannot be blank)
+endif
 
 # Default values of optionally user-supplied variables
 AVRDUDE_PROGRAMMER ?= jtagicemkii
diff --git a/LUFA/Build/lufa.build.in b/LUFA/Build/lufa.build.in
index a8569a6ce..115763ab4 100644
--- a/LUFA/Build/lufa.build.in
+++ b/LUFA/Build/lufa.build.in
@@ -54,12 +54,25 @@ LUFA_BUILD_OPTIONAL_VARS  += BOARD OPTIMIZATION C_STANDARD CPP_STANDARD F_CPU C_
 # -----------------------------------------------------------------------------
 
 # Sanity-check values of mandatory user-supplied variables
-MCU            ?= $(error Makefile MCU value not set.)
-TARGET         ?= $(error Makefile TARGET value not set.)
-ARCH           ?= $(error Makefile ARCH value not set.)
-SRC            ?= $(error Makefile SRC value not set.)
-F_USB          ?= $(error Makefile F_USB value not set.)
-LUFA_PATH      ?= $(error Makefile LUFA_PATH value not set.)
+MCU            ?= $(error Makefile MCU value not set)
+TARGET         ?= $(error Makefile TARGET value not set)
+ARCH           ?= $(error Makefile ARCH value not set)
+SRC            ?= $(error Makefile SRC value not set)
+F_USB          ?= $(error Makefile F_USB value not set)
+LUFA_PATH      ?= $(error Makefile LUFA_PATH value not set)
+
+ifeq ($(MCU),)
+   $(error Makefile MCU option cannot be blank)
+endif
+ifeq ($(TARGET),)
+   $(error Makefile TARGET option cannot be blank)
+endif
+ifeq ($(ARCH),)
+   $(error Makefile ARCH option cannot be blank)
+endif
+ifeq ($(F_USB),)
+   $(error Makefile F_USB option cannot be blank)
+endif
 
 # Default values of optionally user-supplied variables
 BOARD          ?= NONE
@@ -80,7 +93,7 @@ else ifeq ($(ARCH), XMEGA)
 else ifeq ($(ARCH), UC3)
    CROSS       := avr32-
 else
-    $(error Unsupported architecture.)
+    $(error Unsupported architecture "$(ARCH)".)
 endif
 
 # Output Messages
diff --git a/LUFA/Build/lufa.dfu.in b/LUFA/Build/lufa.dfu.in
index 91922d0cb..33b5b7dc0 100644
--- a/LUFA/Build/lufa.dfu.in
+++ b/LUFA/Build/lufa.dfu.in
@@ -37,8 +37,15 @@ LUFA_BUILD_OPTIONAL_VARS  +=
 # -----------------------------------------------------------------------------
 
 # Sanity-check values of mandatory user-supplied variables
-MCU            ?= $(error Makefile MCU value not set.)
-TARGET         ?= $(error Makefile TARGET value not set.)
+MCU            ?= $(error Makefile MCU value not set)
+TARGET         ?= $(error Makefile TARGET value not set)
+
+ifeq ($(MCU),)
+   $(error Makefile MCU option cannot be blank)
+endif
+ifeq ($(TARGET),)
+   $(error Makefile TARGET option cannot be blank)
+endif
 
 # Output Messages
 MSG_COPY_CMD   := ' [CP]      :'
diff --git a/LUFA/Build/lufa.doxygen.in b/LUFA/Build/lufa.doxygen.in
index 0a6ad6e25..1a5ede8e9 100644
--- a/LUFA/Build/lufa.doxygen.in
+++ b/LUFA/Build/lufa.doxygen.in
@@ -36,7 +36,7 @@ LUFA_BUILD_OPTIONAL_VARS  += DOXYGEN_CONF DOXYGEN_FAIL_ON_WARNING DOXYGEN_OVERRI
 # -----------------------------------------------------------------------------
 
 # Sanity-check values of mandatory user-supplied variables
-LUFA_PATH               ?= $(error Makefile LUFA_PATH value not set.)
+LUFA_PATH               ?= $(error Makefile LUFA_PATH value not set)
 
 # Default values of optionally user-supplied variables
 DOXYGEN_CONF            ?= Doxygen.conf
diff --git a/LUFA/Build/lufa.sources.in b/LUFA/Build/lufa.sources.in
index c189e792f..47cda0c99 100644
--- a/LUFA/Build/lufa.sources.in
+++ b/LUFA/Build/lufa.sources.in
@@ -36,8 +36,12 @@ LUFA_BUILD_OPTIONAL_VARS  +=
 # -----------------------------------------------------------------------------
 
 # Sanity-check values of mandatory user-supplied variables
-ARCH           ?= $(error Makefile ARCH value not set.)
-LUFA_PATH      ?= $(error Makefile LUFA_PATH value not set.)
+ARCH           ?= $(error Makefile ARCH value not set)
+LUFA_PATH      ?= $(error Makefile LUFA_PATH value not set)
+
+ifeq ($(ARCH),)
+   $(error Makefile ARCH option cannot be blank)
+endif
 
 # Allow LUFA_ROOT_PATH to be overridden elsewhere to support legacy LUFA makefiles
 LUFA_ROOT_PATH ?= $(patsubst %/,%,$(LUFA_PATH))
-- 
GitLab