lufa_doxygen.mk 4.01 KB
Newer Older
1
2
3
4
5
6
7
8
#
#             LUFA Library
#     Copyright (C) Dean Camera, 2012.
#
#  dean [at] fourwalledcubicle [dot] com
#           www.lufa-lib.org
#

9
LUFA_BUILD_MODULES         += DOXYGEN
10
LUFA_BUILD_TARGETS         += doxygen doxygen_upgrade doxygen_create
11
12
13
14
LUFA_BUILD_MANDATORY_VARS  += LUFA_PATH
LUFA_BUILD_OPTIONAL_VARS   += DOXYGEN_CONF DOXYGEN_FAIL_ON_WARNING DOXYGEN_OVERRIDE_PARAMS
LUFA_BUILD_PROVIDED_VARS   += 
LUFA_BUILD_PROVIDED_MACROS += 
15
16
17
18
19
20
21
22
23
24
25

# -----------------------------------------------------------------------------
#                 LUFA Doxygen Buildsystem Makefile Module.
# -----------------------------------------------------------------------------
# DESCRIPTION:
#   Provides a set of targets to automatically build Doxygen documentation for
#   a project (see www.doxygen.org).
# -----------------------------------------------------------------------------
# TARGETS:
#
#    doxygen                   - Build Doxygen Documentation
26
27
28
29
#    doxygen_create            - Create a new Doxygen configuration file using
#                                the latest template
#    doxygen_upgrade           - Upgrade an existing Doxygen configuration file
#                                to the latest template
30
31
32
33
34
35
36
37
38
39
40
41
#
# MANDATORY PARAMETERS:
#
#    LUFA_PATH                 - Path to the LUFA library core
#
# OPTIONAL PARAMETERS:
#
#    DOXYGEN_CONF              - Doxygen configuration filename
#    DOXYGEN_FAIL_ON_WARNING   - Set to Y to fail the build on Doxygen warnings,
#                                N to continue even if warnings occur
#    DOXYGEN_OVERRIDE_PARAMS   - Parameters to override in the doxygen
#                                configuration file
42
43
44
45
46
47
48
49
# PROVIDED VARIABLES:
#
#    (None)
#
# PROVIDED MACROS:
#
#    (None)
#
50
51
# -----------------------------------------------------------------------------

52
53
54
55
56
SHELL = /bin/sh

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))
57
58
59
60

# Default values of optionally user-supplied variables
DOXYGEN_CONF            ?= Doxygen.conf
DOXYGEN_FAIL_ON_WARNING ?= Y
61
DOXYGEN_OVERRIDE_PARAMS ?= QUIET=YES HTML_EXTRA_STYLESHEET=$(patsubst %/,%,$(LUFA_PATH))/DoxygenPages/Style/Style.css
62

63
64
# Sanity check user supplied values
$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
65
$(call ERROR_IF_EMPTY, DOXYGEN_CONF)
66
67
68
$(call ERROR_IF_EMPTY, LUFA_PATH)
$(call ERROR_IF_NONBOOL, DOXYGEN_FAIL_ON_WARNING)

69
70
71
72
# Output Messages
MSG_DOXYGEN_CMD         := ' [DOXYGEN] :'

# Determine Doxygen invocation command
73
BASE_DOXYGEN_CMD := ( cat $(DOXYGEN_CONF) $(DOXYGEN_OVERRIDE_PARAMS:%=; echo "%") ) | doxygen -
74
ifeq ($(DOXYGEN_FAIL_ON_WARNING), Y)
75
   DOXYGEN_CMD := if ( $(BASE_DOXYGEN_CMD) 2>&1 | grep -v "warning: ignoring unsupported tag" ;); then exit 1; fi;
76
else
77
   DOXYGEN_CMD := $(BASE_DOXYGEN_CMD)
78
79
endif

80
81
82
83
# Error if the specified Doxygen configuration file does not exist
$(DOXYGEN_CONF):
	$(error Doxygen configuration file $@ does not exist)

84
# Builds the project documentation using the specified configuration file and the DOXYGEN tool
85
doxygen: $(DOXYGEN_CONF) $(MAKEFILE_LIST)
86
87
88
	@echo $(MSG_DOXYGEN_CMD) Configuration file \"$(DOXYGEN_CONF)\" with parameters \"$(DOXYGEN_OVERRIDE_PARAMS)\"
	$(DOXYGEN_CMD)

89
# Upgrades an existing Doxygen configuration file to the latest Doxygen template, preserving settings
90
doxygen_upgrade: $(DOXYGEN_CONF) $(MAKEFILE_LIST)
91
92
93
94
	@echo $(MSG_DOXYGEN_CMD) Upgrading configuration file \"$(DOXYGEN_CONF)\" with latest template
	doxygen -u $(DOXYGEN_CONF) > /dev/null

# Creates a new Doxygen configuration file with the set file name
95
doxygen_create: $(MAKEFILE_LIST)
96
97
98
	@echo $(MSG_DOXYGEN_CMD) Creating new configuration file \"$(DOXYGEN_CONF)\" with latest template
	doxygen -g $(DOXYGEN_CONF) > /dev/null

99
# Phony build targets for this module
100
.PHONY: doxygen doxygen_upgrade doxygen_create