41992566d594854c49310b8da693b35cc7d89c38
[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 +=
15
16 # -----------------------------------------------------------------------------
17 # DMBS Core Build System Makefile Module.
18 # -----------------------------------------------------------------------------
19 # DESCRIPTION:
20 # Provides a set of core build targets for the DMBS build system
21 # -----------------------------------------------------------------------------
22 # TARGETS:
23 #
24 # help - Build system help
25 # list_targets - List all build targets
26 # list_modules - List all build modules
27 # list_mandatory - List all mandatory make variables required by
28 # the included build modules of the application
29 # list_optional - List all optional make variables required by
30 # the included build modules of the application
31 # list_provided - List all provided make variables from the
32 # included build modules of the application
33 # list_macros - List all provided make macros from the
34 # included build modules of the application
35 #
36 # MANDATORY PARAMETERS:
37 #
38 # (None)
39 #
40 # OPTIONAL PARAMETERS:
41 #
42 # (None)
43 #
44 # PROVIDED VARIABLES:
45 #
46 # DMBS_VERSION
47 #
48 # PROVIDED MACROS:
49 #
50 # (None)
51 #
52 # -----------------------------------------------------------------------------
53
54 SHELL = /bin/sh
55
56
57 # Current DMBS release version
58 DMBS_VERSION = 0.3
59
60
61 # Converts a given input to a printable output using "(None)" if no items are in the list
62 CONVERT_TO_PRINTABLE = $(if $(strip $(1)), $(1), (None))
63
64
65 # Build sorted and filtered lists of the included build module data
66 SORTED_DMBS_BUILD_MODULES = $(sort $(DMBS_BUILD_MODULES))
67 SORTED_DMBS_BUILD_TARGETS = $(sort $(DMBS_BUILD_TARGETS))
68 SORTED_DMBS_MANDATORY_VARS = $(sort $(DMBS_BUILD_MANDATORY_VARS))
69 SORTED_DMBS_OPTIONAL_VARS = $(filter-out $(SORTED_DMBS_MANDATORY_VARS), $(sort $(DMBS_BUILD_OPTIONAL_VARS)))
70 SORTED_DMBS_PROVIDED_VARS = $(sort $(DMBS_BUILD_PROVIDED_VARS))
71 SORTED_DMBS_PROVIDED_MACROS = $(sort $(DMBS_BUILD_PROVIDED_MACROS))
72
73 # Create printable versions of the sorted build module data (use "(None)" when no data is available)
74 PRINTABLE_DMBS_BUILD_MODULES = $(call CONVERT_TO_PRINTABLE, $(SORTED_DMBS_BUILD_MODULES))
75 PRINTABLE_DMBS_BUILD_TARGETS = $(call CONVERT_TO_PRINTABLE, $(SORTED_DMBS_BUILD_TARGETS))
76 PRINTABLE_DMBS_MANDATORY_VARS = $(call CONVERT_TO_PRINTABLE, $(SORTED_DMBS_MANDATORY_VARS))
77 PRINTABLE_DMBS_OPTIONAL_VARS = $(call CONVERT_TO_PRINTABLE, $(SORTED_DMBS_OPTIONAL_VARS))
78 PRINTABLE_DMBS_PROVIDED_VARS = $(call CONVERT_TO_PRINTABLE, $(SORTED_DMBS_PROVIDED_VARS))
79 PRINTABLE_DMBS_PROVIDED_MACROS = $(call CONVERT_TO_PRINTABLE, $(SORTED_DMBS_PROVIDED_MACROS))
80
81 help:
82 @echo "==================================================================="
83 @echo " The DMBS Build System "
84 @echo " By Dean Camera { dean @ fourwalledcubicle . com } "
85 @echo "==================================================================="
86 @echo "DESCRIPTION: "
87 @echo " This build system is a set of makefile modules for (GNU) Make, to "
88 @echo " provide a simple system for building DMBS powered applications. "
89 @echo " Each makefile module can be included from within a user makefile, "
90 @echo " to expose the build rules documented in the comments at the top of"
91 @echo " each build module. "
92 @echo " "
93 @echo "USAGE: "
94 @echo " To execute a rule, define all variables indicated in the desired "
95 @echo " module as a required parameter before including the build module "
96 @echo " in your project makefile. Parameters marked as optional will "
97 @echo " assume a default value in the modules if not user-assigned. "
98 @echo " "
99 @echo " By default the target output shows both a friendly summary, as "
100 @echo " well as the actual invoked command. To suppress the output of the "
101 @echo " invoked commands and show only the friendly command output, run "
102 @echo " make with the \"-s\" switch added before the target(s). "
103 @echo "==================================================================="
104 @echo " "
105 @echo " Currently used build system modules in this application: "
106 @echo " "
107 @printf " %b" "$(PRINTABLE_DMBS_BUILD_MODULES:%= - %\n)"
108 @echo " "
109 @echo " "
110 @echo " Currently available build targets in this application: "
111 @echo " "
112 @printf " %b" "$(PRINTABLE_DMBS_BUILD_TARGETS:%= - %\n)"
113 @echo " "
114 @echo " "
115 @echo " Mandatory variables required by the selected build Modules: "
116 @echo " "
117 @printf " %b" "$(PRINTABLE_DMBS_MANDATORY_VARS:%= - %\n)"
118 @echo " "
119 @echo " "
120 @echo " Optional variables required by the selected build Modules: "
121 @echo " "
122 @printf " %b" "$(PRINTABLE_DMBS_OPTIONAL_VARS:%= - %\n)"
123 @echo " "
124 @echo " "
125 @echo " Variables provided by the selected build Modules: "
126 @echo " "
127 @printf " %b" "$(PRINTABLE_DMBS_PROVIDED_VARS:%= - %\n)"
128 @echo " "
129 @echo " "
130 @echo " Macros provided by the selected build Modules: "
131 @echo " "
132 @printf " %b" "$(PRINTABLE_DMBS_PROVIDED_MACROS:%= - %\n)"
133 @echo " "
134 @echo "==================================================================="
135 @echo " The DMBS Build System $(DMBS_VERSION) - Making MAKE easier."
136 @echo "==================================================================="
137
138 # Lists build modules included by the project makefile, in alphabetical order
139 list_modules:
140 @echo Currently Used Build System Modules:
141 @printf " %b" "$(PRINTABLE_DMBS_BUILD_MODULES:%= - %\n)"
142
143 # Lists build targets included by the project makefile, in alphabetical order
144 list_targets:
145 @echo Currently Available Build Targets:
146 @printf " %b" "$(PRINTABLE_DMBS_BUILD_TARGETS:%= - %\n)"
147
148 # Lists mandatory variables that must be set by the project makefile, in alphabetical order
149 list_mandatory:
150 @echo Mandatory Variables for Included Modules:
151 @printf " %b" "$(PRINTABLE_DMBS_MANDATORY_VARS:%= - %\n)"
152
153 # Lists optional variables that must be set by the project makefile, in alphabetical order
154 list_optional:
155 @echo Optional Variables for Included Modules:
156 @printf " %b" "$(PRINTABLE_DMBS_OPTIONAL_VARS:%= - %\n)"
157
158 # Lists variables provided by the included build modules, in alphabetical order
159 list_provided:
160 @echo Variables Provided by the Included Modules:
161 @printf " %b" "$(PRINTABLE_DMBS_PROVIDED_VARS:%= - %\n)"
162
163 # Lists macros provided by the included build modules, in alphabetical order
164 list_macros:
165 @echo Macros Provided by the Included Modules:
166 @printf " %b" "$(PRINTABLE_DMBS_PROVIDED_MACROS:%= - %\n)"
167
168 # Debugging; "make print-VARNAME" will output the variable VARNAME's value
169 print-%:
170 @printf "%s = %s" $(@:print-%=%) $($(@:print-%=%))
171
172 # Disable default in-built make rules (those that are needed are explicitly
173 # defined, and doing so has performance benefits when recursively building)
174 ifeq ($(filter -r,$(MAKEFLAGS)),)
175 MAKEFLAGS += -r
176 endif
177 .SUFFIXES:
178
179 # Phony build targets for this module
180 .PHONY: $(DMBS_BUILD_TARGETS)