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