aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Build
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2012-06-10 08:06:13 +0000
committerDean Camera <dean@fourwalledcubicle.com>2012-06-10 08:06:13 +0000
commit53be52922fa690b57fcfdd2ea531f876516b3b67 (patch)
tree613bd3df574e5a20062483496512540e42c1ddfd /LUFA/Build
parent3808f5c36d0ee183e9825e645cc984f1c6047ef5 (diff)
downloadlufa-53be52922fa690b57fcfdd2ea531f876516b3b67.tar.gz
lufa-53be52922fa690b57fcfdd2ea531f876516b3b67.tar.bz2
lufa-53be52922fa690b57fcfdd2ea531f876516b3b67.zip
Change the build system build module makefiles to have a set of sanity check macros they can call to verify user data. Add additional sanity checks.
Diffstat (limited to 'LUFA/Build')
-rw-r--r--LUFA/Build/lufa.atprogram.in20
-rw-r--r--LUFA/Build/lufa.avrdude.in20
-rw-r--r--LUFA/Build/lufa.build.in35
-rw-r--r--LUFA/Build/lufa.cppcheck.in17
-rw-r--r--LUFA/Build/lufa.dfu.in18
-rw-r--r--LUFA/Build/lufa.doxygen.in17
-rw-r--r--LUFA/Build/lufa.sources.in13
7 files changed, 74 insertions, 66 deletions
diff --git a/LUFA/Build/lufa.atprogram.in b/LUFA/Build/lufa.atprogram.in
index 59fedcd43..d7acc56ec 100644
--- a/LUFA/Build/lufa.atprogram.in
+++ b/LUFA/Build/lufa.atprogram.in
@@ -38,22 +38,22 @@ LUFA_BUILD_OPTIONAL_VARS += ATPROGRAM_PROGRAMMER ATPROGRAM_INTERFACE ATPROGRAM_
#
# -----------------------------------------------------------------------------
-# Sanity-check values of mandatory user-supplied variables
-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
+ERROR_IF_UNSET = $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
+ERROR_IF_EMPTY = $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
+ERROR_IF_NONBOOL = $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
# Default values of optionally user-supplied variables
ATPROGRAM_PROGRAMMER ?= jtagice3
ATPROGRAM_INTERFACE ?= jtag
ATPROGRAM_PORT ?=
+# Sanity check user supplied values
+$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
+$(call ERROR_IF_EMPTY, MCU)
+$(call ERROR_IF_EMPTY, TARGET)
+$(call ERROR_IF_EMPTY, ATPROGRAM_PROGRAMMER)
+$(call ERROR_IF_EMPTY, ATPROGRAM_INTERFACE)
+
# Output Messages
MSG_ATPROGRAM_CMD := ' [ATPRGRM] :'
diff --git a/LUFA/Build/lufa.avrdude.in b/LUFA/Build/lufa.avrdude.in
index 1f0812b35..12d118adc 100644
--- a/LUFA/Build/lufa.avrdude.in
+++ b/LUFA/Build/lufa.avrdude.in
@@ -38,22 +38,22 @@ 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)
-
-ifeq ($(MCU),)
- $(error Makefile MCU option cannot be blank)
-endif
-ifeq ($(TARGET),)
- $(error Makefile TARGET option cannot be blank)
-endif
+ERROR_IF_UNSET = $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
+ERROR_IF_EMPTY = $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
+ERROR_IF_NONBOOL = $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
# Default values of optionally user-supplied variables
AVRDUDE_PROGRAMMER ?= jtagicemkii
AVRDUDE_PORT ?= usb
AVRDUDE_FLAGS ?=
+# Sanity check user supplied values
+$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
+$(call ERROR_IF_EMPTY, MCU)
+$(call ERROR_IF_EMPTY, TARGET)
+$(call ERROR_IF_EMPTY, AVRDUDE_PROGRAMMER)
+$(call ERROR_IF_EMPTY, AVRDUDE_PORT)
+
# Output Messages
MSG_AVRDUDE_CMD := ' [AVRDUDE] :'
diff --git a/LUFA/Build/lufa.build.in b/LUFA/Build/lufa.build.in
index 59b81d939..b1f9efe9c 100644
--- a/LUFA/Build/lufa.build.in
+++ b/LUFA/Build/lufa.build.in
@@ -55,26 +55,9 @@ 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)
-
-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
+ERROR_IF_UNSET = $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
+ERROR_IF_EMPTY = $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
+ERROR_IF_NONBOOL = $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
# Default values of optionally user-supplied variables
BOARD ?= NONE
@@ -87,6 +70,18 @@ CPP_FLAGS ?=
ASM_FLAGS ?=
CC_FLAGS ?=
+# Sanity check user supplied values
+$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
+$(call ERROR_IF_EMPTY, MCU)
+$(call ERROR_IF_EMPTY, TARGET)
+$(call ERROR_IF_EMPTY, ARCH)
+$(call ERROR_IF_EMPTY, F_USB)
+$(call ERROR_IF_EMPTY, LUFA_PATH)
+$(call ERROR_IF_EMPTY, BOARD)
+$(call ERROR_IF_EMPTY, OPTIMIZATION)
+$(call ERROR_IF_EMPTY, C_STANDARD)
+$(call ERROR_IF_EMPTY, CPP_STANDARD)
+
# Determine the utility prefix to use for the selected architecture
ifeq ($(ARCH), AVR8)
CROSS := avr-
diff --git a/LUFA/Build/lufa.cppcheck.in b/LUFA/Build/lufa.cppcheck.in
index 330ec1d49..03f310d09 100644
--- a/LUFA/Build/lufa.cppcheck.in
+++ b/LUFA/Build/lufa.cppcheck.in
@@ -46,6 +46,10 @@ LUFA_BUILD_OPTIONAL_VARS += CPPCHECK_PATH CPPCHECK_INCLUDES CPPCHECK_EXCLUDES C
#
# -----------------------------------------------------------------------------
+ERROR_IF_UNSET = $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
+ERROR_IF_EMPTY = $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
+ERROR_IF_NONBOOL = $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
+
# Default values of optionally user-supplied variables
CPPCHECK_PATH ?= .
CPPCHECK_INCLUDES ?=
@@ -57,20 +61,23 @@ CPPCHECK_FAIL_ON_WARNING ?= Y
CPPCHECK_QUIET ?= Y
CPPCHECK_FLAGS ?=
+# Sanity check user supplied values
+$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
+$(call ERROR_IF_EMPTY, CPPCHECK_PATH)
+$(call ERROR_IF_EMPTY, CPPCHECK_MSG_TEMPLATE)
+$(call ERROR_IF_EMPTY, CPPCHECK_ENABLE)
+$(call ERROR_IF_NONBOOL, CPPCHECK_FAIL_ON_WARNING)
+$(call ERROR_IF_NONBOOL, CPPCHECK_QUIET)
+
# Build a default argument list for cppcheck
BASE_CPPCHECK_FLAGS := --template="$(CPPCHECK_MSG_TEMPLATE)" $(CPPCHECK_INCLUDES:%=-I%) $(CPPCHECK_EXCLUDES:%=-i%) --inline-suppr --force --std=c99
# Sanity check parameters and construct additional command line arguments to cppcheck
-
ifeq ($(CPPCHECK_FAIL_ON_WARNING), Y)
BASE_CPPCHECK_FLAGS += --error-exitcode=1
-else ifneq ($(CPPCHECK_FAIL_ON_WARNING), N)
- $(error CPPCHECK_FAIL_ON_WARNING must be Y or N)
endif
ifeq ($(CPPCHECK_QUIET), Y)
BASE_CPPCHECK_FLAGS += --quiet
-else ifneq ($(CPPCHECK_QUIET), N)
- $(error CPPCHECK_QUIET must be Y or N)
endif
# Output Messages
diff --git a/LUFA/Build/lufa.dfu.in b/LUFA/Build/lufa.dfu.in
index 8122bfde3..9c05bb7c1 100644
--- a/LUFA/Build/lufa.dfu.in
+++ b/LUFA/Build/lufa.dfu.in
@@ -36,16 +36,16 @@ 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)
+ERROR_IF_UNSET = $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
+ERROR_IF_EMPTY = $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
+ERROR_IF_NONBOOL = $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
-ifeq ($(MCU),)
- $(error Makefile MCU option cannot be blank)
-endif
-ifeq ($(TARGET),)
- $(error Makefile TARGET option cannot be blank)
-endif
+# Sanity-check values of mandatory user-supplied variables
+$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
+$(call ERROR_IF_UNSET, MCU)
+$(call ERROR_IF_UNSET, TARGET)
+$(call ERROR_IF_EMPTY, MCU)
+$(call ERROR_IF_EMPTY, TARGET)
# Output Messages
MSG_COPY_CMD := ' [CP] :'
diff --git a/LUFA/Build/lufa.doxygen.in b/LUFA/Build/lufa.doxygen.in
index 3fb950bc3..4ec52c8a4 100644
--- a/LUFA/Build/lufa.doxygen.in
+++ b/LUFA/Build/lufa.doxygen.in
@@ -35,25 +35,30 @@ LUFA_BUILD_OPTIONAL_VARS += DOXYGEN_CONF DOXYGEN_FAIL_ON_WARNING DOXYGEN_OVERRI
# configuration file
# -----------------------------------------------------------------------------
-# Sanity-check values of mandatory user-supplied variables
-LUFA_PATH ?= $(error Makefile LUFA_PATH value not set)
+ERROR_IF_UNSET = $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
+ERROR_IF_EMPTY = $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
+ERROR_IF_NONBOOL = $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
# Default values of optionally user-supplied variables
DOXYGEN_CONF ?= Doxygen.conf
DOXYGEN_FAIL_ON_WARNING ?= Y
DOXYGEN_OVERRIDE_PARAMS ?= QUIET=YES HTML_STYLESHEET=$(patsubst %/,%,$(LUFA_PATH))/DoxygenPages/Style/Style.css
+# Sanity check user supplied values
+$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
+$(call ERROR_IF_EMPTY, LUFA_PATH)
+$(call ERROR_IF_EMPTY, LUFA_PATH)
+$(call ERROR_IF_NONBOOL, DOXYGEN_FAIL_ON_WARNING)
+
# Output Messages
MSG_DOXYGEN_CMD := ' [DOXYGEN] :'
# Determine Doxygen invocation command
-BASE_DOXYGEN_CMD = ( cat Doxygen.conf $(DOXYGEN_OVERRIDE_PARAMS:%=; echo "%") ) | doxygen -
+BASE_DOXYGEN_CMD = ( cat $(DOXYGEN_CONF) $(DOXYGEN_OVERRIDE_PARAMS:%=; echo "%") ) | doxygen -
ifeq ($(DOXYGEN_FAIL_ON_WARNING), Y)
DOXYGEN_CMD = if ( $(BASE_DOXYGEN_CMD) 2>&1 | grep -v "warning: ignoring unsupported tag" ;); then exit 1; fi;
-else ifeq ($(DOXYGEN_FAIL_ON_WARNING), N)
- DOXYGEN_CMD = $(BASE_DOXYGEN_CMD)
else
- $(error DOXYGEN_FAIL_ON_WARNING must be Y or N.)
+ DOXYGEN_CMD = $(BASE_DOXYGEN_CMD)
endif
doxygen:
diff --git a/LUFA/Build/lufa.sources.in b/LUFA/Build/lufa.sources.in
index 6d28056cc..6ca480bce 100644
--- a/LUFA/Build/lufa.sources.in
+++ b/LUFA/Build/lufa.sources.in
@@ -35,13 +35,14 @@ 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)
+ERROR_IF_UNSET = $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
+ERROR_IF_EMPTY = $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
+ERROR_IF_NONBOOL = $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
-ifeq ($(ARCH),)
- $(error Makefile ARCH option cannot be blank)
-endif
+# Sanity check user supplied values
+$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
+$(call ERROR_IF_EMPTY, LUFA_PATH)
+$(call ERROR_IF_EMPTY, ARCH)
# Allow LUFA_ROOT_PATH to be overridden elsewhere to support legacy LUFA makefiles
LUFA_ROOT_PATH ?= $(patsubst %/,%,$(LUFA_PATH))