2 ifeq ($(filter CORE
, $(DMBS_BUILD_MODULES
)),)
6 # Released into the public domain.
8 # dean [at] fourwalledcubicle [dot] com
9 # www.fourwalledcubicle.com
12 DMBS_BUILD_MODULES
+= CORE
13 DMBS_BUILD_TARGETS
+= help list_targets list_modules list_mandatory list_optional list_provided list_macros
14 DMBS_BUILD_MANDATORY_VARS
+=
15 DMBS_BUILD_OPTIONAL_VARS
+=
16 DMBS_BUILD_PROVIDED_VARS
+= DMBS_VERSION
17 DMBS_BUILD_PROVIDED_MACROS
+= DMBS_CHECK_VERSION ERROR_IF_UNSET ERROR_IF_EMPTY ERROR_IF_NONBOOL
21 # Current DMBS release version
22 DMBS_VERSION
:= 20200719
24 # Macro to check the DMBS version, aborts if the given DMBS version is below the current version
25 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
)))
27 # Macros to use in other modules to check various conditions
28 ERROR_IF_UNSET ?
= $(if
$(filter undefined
, $(origin $(strip $(1)))), $(error Makefile
$(strip $(1)) value not set
))
29 ERROR_IF_EMPTY ?
= $(if
$(strip $($(strip $(1)))), , $(error Makefile
$(strip $(1)) option cannot be blank
))
30 ERROR_IF_NONBOOL ?
= $(if
$(filter Y N
, $($(strip $(1)))), , $(error Makefile
$(strip $(1)) option must be Y or N
))
32 # Converts a given input to a printable output using "(None)" if no items are in the list
33 CONVERT_TO_PRINTABLE
= $(if
$(strip $(1)), $(1), (None
))
35 # Build sorted and filtered lists of the included build module data
36 SORTED_DMBS_BUILD_MODULES
= $(sort $(DMBS_BUILD_MODULES
))
37 SORTED_DMBS_BUILD_TARGETS
= $(sort $(DMBS_BUILD_TARGETS
))
38 SORTED_DMBS_MANDATORY_VARS
= $(sort $(DMBS_BUILD_MANDATORY_VARS
))
39 SORTED_DMBS_OPTIONAL_VARS
= $(filter-out $(SORTED_DMBS_MANDATORY_VARS
), $(sort $(DMBS_BUILD_OPTIONAL_VARS
)))
40 SORTED_DMBS_PROVIDED_VARS
= $(sort $(DMBS_BUILD_PROVIDED_VARS
))
41 SORTED_DMBS_PROVIDED_MACROS
= $(sort $(DMBS_BUILD_PROVIDED_MACROS
))
43 # Create printable versions of the sorted build module data (use "(None)" when no data is available)
44 PRINTABLE_DMBS_BUILD_MODULES
= $(call CONVERT_TO_PRINTABLE
, $(SORTED_DMBS_BUILD_MODULES
))
45 PRINTABLE_DMBS_BUILD_TARGETS
= $(call CONVERT_TO_PRINTABLE
, $(SORTED_DMBS_BUILD_TARGETS
))
46 PRINTABLE_DMBS_MANDATORY_VARS
= $(call CONVERT_TO_PRINTABLE
, $(SORTED_DMBS_MANDATORY_VARS
))
47 PRINTABLE_DMBS_OPTIONAL_VARS
= $(call CONVERT_TO_PRINTABLE
, $(SORTED_DMBS_OPTIONAL_VARS
))
48 PRINTABLE_DMBS_PROVIDED_VARS
= $(call CONVERT_TO_PRINTABLE
, $(SORTED_DMBS_PROVIDED_VARS
))
49 PRINTABLE_DMBS_PROVIDED_MACROS
= $(call CONVERT_TO_PRINTABLE
, $(SORTED_DMBS_PROVIDED_MACROS
))
52 @echo
"==================================================================="
53 @echo
" The DMBS Build System "
54 @echo
" By Dean Camera { dean @ fourwalledcubicle . com } "
55 @echo
"==================================================================="
57 @echo
" This build system is a set of makefile modules for (GNU) Make, to "
58 @echo
" provide a simple system for building DMBS powered applications. "
59 @echo
" Each makefile module can be included from within a user makefile, "
60 @echo
" to expose the build rules documented in the comments at the top of"
61 @echo
" each build module. "
64 @echo
" To execute a rule, define all variables indicated in the desired "
65 @echo
" module as a required parameter before including the build module "
66 @echo
" in your project makefile. Parameters marked as optional will "
67 @echo
" assume a default value in the modules if not user-assigned. "
69 @echo
" By default the target output shows both a friendly summary, as "
70 @echo
" well as the actual invoked command. To suppress the output of the "
71 @echo
" invoked commands and show only the friendly command output, run "
72 @echo
" make with the \"-s\" switch added before the target(s). "
73 @echo
"==================================================================="
75 @echo
" Currently used build system modules in this application: "
77 @printf
" %b" "$(PRINTABLE_DMBS_BUILD_MODULES:%= - %\n)"
80 @echo
" Currently available build targets in this application: "
82 @printf
" %b" "$(PRINTABLE_DMBS_BUILD_TARGETS:%= - %\n)"
85 @echo
" Mandatory variables required by the selected build Modules: "
87 @printf
" %b" "$(PRINTABLE_DMBS_MANDATORY_VARS:%= - %\n)"
90 @echo
" Optional variables required by the selected build Modules: "
92 @printf
" %b" "$(PRINTABLE_DMBS_OPTIONAL_VARS:%= - %\n)"
95 @echo
" Variables provided by the selected build Modules: "
97 @printf
" %b" "$(PRINTABLE_DMBS_PROVIDED_VARS:%= - %\n)"
100 @echo
" Macros provided by the selected build Modules: "
102 @printf
" %b" "$(PRINTABLE_DMBS_PROVIDED_MACROS:%= - %\n)"
104 @echo
"==================================================================="
105 @echo
" The DMBS Build System $(DMBS_VERSION) - Making MAKE easier."
106 @echo
"==================================================================="
108 # Lists build modules included by the project makefile, in alphabetical order
110 @echo Currently Used Build System Modules
:
111 @printf
" %b" "$(PRINTABLE_DMBS_BUILD_MODULES:%= - %\n)"
113 # Lists build targets included by the project makefile, in alphabetical order
115 @echo Currently Available Build Targets
:
116 @printf
" %b" "$(PRINTABLE_DMBS_BUILD_TARGETS:%= - %\n)"
118 # Lists mandatory variables that must be set by the project makefile, in alphabetical order
120 @echo Mandatory Variables for Included Modules
:
121 @printf
" %b" "$(PRINTABLE_DMBS_MANDATORY_VARS:%= - %\n)"
123 # Lists optional variables that must be set by the project makefile, in alphabetical order
125 @echo Optional Variables for Included Modules
:
126 @printf
" %b" "$(PRINTABLE_DMBS_OPTIONAL_VARS:%= - %\n)"
128 # Lists variables provided by the included build modules, in alphabetical order
130 @echo Variables Provided by the Included Modules
:
131 @printf
" %b" "$(PRINTABLE_DMBS_PROVIDED_VARS:%= - %\n)"
133 # Lists macros provided by the included build modules, in alphabetical order
135 @echo Macros Provided by the Included Modules
:
136 @printf
" %b" "$(PRINTABLE_DMBS_PROVIDED_MACROS:%= - %\n)"
138 # Debugging; "make print-VARNAME" will output the variable VARNAME's value
140 @printf
"%s = %s" $(@
:print-
%=%) $($(@
:print-
%=%))
142 # Disable default in-built make rules (those that are needed are explicitly
143 # defined, and doing so has performance benefits when recursively building)
144 ifeq ($(filter -r
,$(MAKEFLAGS
)),)
149 # Phony build targets for this module
150 .PHONY
: $(DMBS_BUILD_TARGETS
)