3 # Released into the public domain.
5 # dean [at] fourwalledcubicle [dot] com
6 # www.fourwalledcubicle.com
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
+=
16 # -----------------------------------------------------------------------------
17 # DMBS Core Build System Makefile Module.
18 # -----------------------------------------------------------------------------
20 # Provides a set of core build targets for the DMBS build system
21 # -----------------------------------------------------------------------------
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
36 # MANDATORY PARAMETERS:
40 # OPTIONAL PARAMETERS:
52 # -----------------------------------------------------------------------------
57 # Current DMBS release version
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
))
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
))
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
))
82 @echo
"==================================================================="
83 @echo
" The DMBS Build System "
84 @echo
" By Dean Camera { dean @ fourwalledcubicle . com } "
85 @echo
"==================================================================="
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. "
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. "
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
"==================================================================="
105 @echo
" Currently used build system modules in this application: "
107 @printf
" %b" "$(PRINTABLE_DMBS_BUILD_MODULES:%= - %\n)"
110 @echo
" Currently available build targets in this application: "
112 @printf
" %b" "$(PRINTABLE_DMBS_BUILD_TARGETS:%= - %\n)"
115 @echo
" Mandatory variables required by the selected build Modules: "
117 @printf
" %b" "$(PRINTABLE_DMBS_MANDATORY_VARS:%= - %\n)"
120 @echo
" Optional variables required by the selected build Modules: "
122 @printf
" %b" "$(PRINTABLE_DMBS_OPTIONAL_VARS:%= - %\n)"
125 @echo
" Variables provided by the selected build Modules: "
127 @printf
" %b" "$(PRINTABLE_DMBS_PROVIDED_VARS:%= - %\n)"
130 @echo
" Macros provided by the selected build Modules: "
132 @printf
" %b" "$(PRINTABLE_DMBS_PROVIDED_MACROS:%= - %\n)"
134 @echo
"==================================================================="
135 @echo
" The DMBS Build System $(DMBS_VERSION) - Making MAKE easier."
136 @echo
"==================================================================="
138 # Lists build modules included by the project makefile, in alphabetical order
140 @echo Currently Used Build System Modules
:
141 @printf
" %b" "$(PRINTABLE_DMBS_BUILD_MODULES:%= - %\n)"
143 # Lists build targets included by the project makefile, in alphabetical order
145 @echo Currently Available Build Targets
:
146 @printf
" %b" "$(PRINTABLE_DMBS_BUILD_TARGETS:%= - %\n)"
148 # Lists mandatory variables that must be set by the project makefile, in alphabetical order
150 @echo Mandatory Variables for Included Modules
:
151 @printf
" %b" "$(PRINTABLE_DMBS_MANDATORY_VARS:%= - %\n)"
153 # Lists optional variables that must be set by the project makefile, in alphabetical order
155 @echo Optional Variables for Included Modules
:
156 @printf
" %b" "$(PRINTABLE_DMBS_OPTIONAL_VARS:%= - %\n)"
158 # Lists variables provided by the included build modules, in alphabetical order
160 @echo Variables Provided by the Included Modules
:
161 @printf
" %b" "$(PRINTABLE_DMBS_PROVIDED_VARS:%= - %\n)"
163 # Lists macros provided by the included build modules, in alphabetical order
165 @echo Macros Provided by the Included Modules
:
166 @printf
" %b" "$(PRINTABLE_DMBS_PROVIDED_MACROS:%= - %\n)"
168 # Debugging; "make print-VARNAME" will output the variable VARNAME's value
170 @printf
"%s = %s" $(@
:print-
%=%) $($(@
:print-
%=%))
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
)),)
179 # Phony build targets for this module
180 .PHONY
: $(DMBS_BUILD_TARGETS
)