Change the build system build module makefiles to have a set of sanity check macros...
[pub/lufa.git] / LUFA / Build / lufa.doxygen.in
index 3fb950b..4ec52c8 100644 (file)
@@ -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: