Fix outdated URL in the HID bootloader Python host app documentation.
[pub/USBasp.git] / LUFA / Build / DMBS / DMBS / core.mk
1 #
2 # DMBS Build System
3 # Released into the public domain.
4 #
5 # dean [at] fourwalledcubicle [dot] com
6 # www.fourwalledcubicle.com
7 #
8
9 DMBS_BUILD_MODULES += CORE
10 DMBS_BUILD_TARGETS += help list_targets list_modules list_mandatory list_optional list_provided list_macros
11 DMBS_BUILD_MANDATORY_VARS +=
12 DMBS_BUILD_OPTIONAL_VARS +=
13 DMBS_BUILD_PROVIDED_VARS += DMBS_VERSION
14 DMBS_BUILD_PROVIDED_MACROS += DMBS_CHECK_VERSION ERROR_IF_UNSET ERROR_IF_EMPTY ERROR_IF_NONBOOL
15
16 SHELL = /bin/sh
17
18 # Current DMBS release version
19 DMBS_VERSION := 20160403
20
21 # Macro to check the DMBS version, aborts if the given DMBS version is below the current version
22 DMBS_CHECK_VERSION ?= $(if $(filter-out 0, $(shell test $(DMBS_VERSION) -lt $(1); echo $$?)), , $(error DMBS version $(1) or newer required, current version is $(DMBS_VERSION)))
23
24 # Macros to use in other modules to check various conditions
25 ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
26 ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
27 ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
28
29 # Converts a given input to a printable output using "(None)" if no items are in the list
30 CONVERT_TO_PRINTABLE = $(if $(strip $(1)), $(1), (None))
31
32 # Build sorted and filtered lists of the included build module data
33 SORTED_DMBS_BUILD_MODULES = $(sort $(DMBS_BUILD_MODULES))
34 SORTED_DMBS_BUILD_TARGETS = $(sort $(DMBS_BUILD_TARGETS))
35 SORTED_DMBS_MANDATORY_VARS = $(sort $(DMBS_BUILD_MANDATORY_VARS))
36 SORTED_DMBS_OPTIONAL_VARS = $(filter-out $(SORTED_DMBS_MANDATORY_VARS), $(sort $(DMBS_BUILD_OPTIONAL_VARS)))
37 SORTED_DMBS_PROVIDED_VARS = $(sort $(DMBS_BUILD_PROVIDED_VARS))
38 SORTED_DMBS_PROVIDED_MACROS = $(sort $(DMBS_BUILD_PROVIDED_MACROS))
39
40 # Create printable versions of the sorted build module data (use "(None)" when no data is available)
41 PRINTABLE_DMBS_BUILD_MODULES = $(call CONVERT_TO_PRINTABLE, $(SORTED_DMBS_BUILD_MODULES))
42 PRINTABLE_DMBS_BUILD_TARGETS = $(call CONVERT_TO_PRINTABLE, $(SORTED_DMBS_BUILD_TARGETS))
43 PRINTABLE_DMBS_MANDATORY_VARS = $(call CONVERT_TO_PRINTABLE, $(SORTED_DMBS_MANDATORY_VARS))
44 PRINTABLE_DMBS_OPTIONAL_VARS = $(call CONVERT_TO_PRINTABLE, $(SORTED_DMBS_OPTIONAL_VARS))
45 PRINTABLE_DMBS_PROVIDED_VARS = $(call CONVERT_TO_PRINTABLE, $(SORTED_DMBS_PROVIDED_VARS))
46 PRINTABLE_DMBS_PROVIDED_MACROS = $(call CONVERT_TO_PRINTABLE, $(SORTED_DMBS_PROVIDED_MACROS))
47
48 help:
49 @echo "==================================================================="
50 @echo " The DMBS Build System "
51 @echo " By Dean Camera { dean @ fourwalledcubicle . com } "
52 @echo "==================================================================="
53 @echo "DESCRIPTION: "
54 @echo " This build system is a set of makefile modules for (GNU) Make, to "
55 @echo " provide a simple system for building DMBS powered applications. "
56 @echo " Each makefile module can be included from within a user makefile, "
57 @echo " to expose the build rules documented in the comments at the top of"
58 @echo " each build module. "
59 @echo " "
60 @echo "USAGE: "
61 @echo " To execute a rule, define all variables indicated in the desired "
62 @echo " module as a required parameter before including the build module "
63 @echo " in your project makefile. Parameters marked as optional will "
64 @echo " assume a default value in the modules if not user-assigned. "
65 @echo " "
66 @echo " By default the target output shows both a friendly summary, as "
67 @echo " well as the actual invoked command. To suppress the output of the "
68 @echo " invoked commands and show only the friendly command output, run "
69 @echo " make with the \"-s\" switch added before the target(s). "
70 @echo "==================================================================="
71 @echo " "
72 @echo " Currently used build system modules in this application: "
73 @echo " "
74 @printf " %b" "$(PRINTABLE_DMBS_BUILD_MODULES:%= - %\n)"
75 @echo " "
76 @echo " "
77 @echo " Currently available build targets in this application: "
78 @echo " "
79 @printf " %b" "$(PRINTABLE_DMBS_BUILD_TARGETS:%= - %\n)"
80 @echo " "
81 @echo " "
82 @echo " Mandatory variables required by the selected build Modules: "
83 @echo " "
84 @printf " %b" "$(PRINTABLE_DMBS_MANDATORY_VARS:%= - %\n)"
85 @echo " "
86 @echo " "
87 @echo " Optional variables required by the selected build Modules: "
88 @echo " "
89 @printf " %b" "$(PRINTABLE_DMBS_OPTIONAL_VARS:%= - %\n)"
90 @echo " "
91 @echo " "
92 @echo " Variables provided by the selected build Modules: "
93 @echo " "
94 @printf " %b" "$(PRINTABLE_DMBS_PROVIDED_VARS:%= - %\n)"
95 @echo " "
96 @echo " "
97 @echo " Macros provided by the selected build Modules: "
98 @echo " "
99 @printf " %b" "$(PRINTABLE_DMBS_PROVIDED_MACROS:%= - %\n)"
100 @echo " "
101 @echo "==================================================================="
102 @echo " The DMBS Build System $(DMBS_VERSION) - Making MAKE easier."
103 @echo "==================================================================="
104
105 # Lists build modules included by the project makefile, in alphabetical order
106 list_modules:
107 @echo Currently Used Build System Modules:
108 @printf " %b" "$(PRINTABLE_DMBS_BUILD_MODULES:%= - %\n)"
109
110 # Lists build targets included by the project makefile, in alphabetical order
111 list_targets:
112 @echo Currently Available Build Targets:
113 @printf " %b" "$(PRINTABLE_DMBS_BUILD_TARGETS:%= - %\n)"
114
115 # Lists mandatory variables that must be set by the project makefile, in alphabetical order
116 list_mandatory:
117 @echo Mandatory Variables for Included Modules:
118 @printf " %b" "$(PRINTABLE_DMBS_MANDATORY_VARS:%= - %\n)"
119
120 # Lists optional variables that must be set by the project makefile, in alphabetical order
121 list_optional:
122 @echo Optional Variables for Included Modules:
123 @printf " %b" "$(PRINTABLE_DMBS_OPTIONAL_VARS:%= - %\n)"
124
125 # Lists variables provided by the included build modules, in alphabetical order
126 list_provided:
127 @echo Variables Provided by the Included Modules:
128 @printf " %b" "$(PRINTABLE_DMBS_PROVIDED_VARS:%= - %\n)"
129
130 # Lists macros provided by the included build modules, in alphabetical order
131 list_macros:
132 @echo Macros Provided by the Included Modules:
133 @printf " %b" "$(PRINTABLE_DMBS_PROVIDED_MACROS:%= - %\n)"
134
135 # Debugging; "make print-VARNAME" will output the variable VARNAME's value
136 print-%:
137 @printf "%s = %s" $(@:print-%=%) $($(@:print-%=%))
138
139 # Disable default in-built make rules (those that are needed are explicitly
140 # defined, and doing so has performance benefits when recursively building)
141 ifeq ($(filter -r,$(MAKEFLAGS)),)
142 MAKEFLAGS += -r
143 endif
144 .SUFFIXES:
145
146 # Phony build targets for this module
147 .PHONY: $(DMBS_BUILD_TARGETS)