1 ################################################################################ 38 ################################################################################ 44 $(eval -include $(RNMAKE_ROOT)/Colors.mk)
47 #------------------------------------------------------------------------------ 48 # Inter-makefile helper functions and canned sequences 50 # $(call findGoals,goalpattern...) 51 # Find goal patterns in command-line goal list. Returns whitespace separated 52 # list of matched goals or empty string. 54 $(filter $(1),$(GOAL_LIST))
57 # $(call includeIfGoals,goalpattern...,makefile)
58 # Conditionally include makefile if one of the goal patterns matches the 59 # command-line goal list. 60 define includeIfGoals =
61 $(
if $(call findGoals,$(1)),$(eval include $(2)))
66 # Comparison operators. GNU Make has no comparison functions. Why??? Fake it. 67 # Returns non-empty string if true. 68 neq = $(filter-out $(1),$(2))
69 eq = $(
if $(call neq,$(1),$(2)),,1)
73 # Tests if file exists and specifies a regular file (directory). 74 # Returns non-empty string on true, empty string on false. 75 isFile = $(shell
if [ -f $(1) ]; then echo 1; fi)
76 isDir = $(shell
if [ -d $(1) ]; then echo 1; fi)
78 # $(call findReqFile,file,errmsg)
79 # Find the required file. On failure calls error with appended optional 80 # errmsg. Returns absolute filename. 82 $(
if $(realpath $(1)),$(strip $(realpath $(1))),\
83 $(error $(1): No such file$(
if $(2),: $(strip $(2)),)))
86 # $(call makePath,dir...) 87 # Make search path dir[:dir...]. 103 # $(call printPkgBanner,pkgname,arch,goallist)
104 # Print the package banner. Typically: 105 # pkgname = RNMAKE_PKG_FULL_NAME 107 # goallist = MAKECMDGOALS 108 define printPkgBanner =
109 @
if [
"$(MAKELEVEL)" =
"0" ]; then \
110 printf
"$(color_pkg_banner)$(boldline)\n";\
111 printf
"Package: $(1)\n";\
112 printf
"Package Root: $(RNMAKE_PKG_ROOT)\n";\
113 printf
"Architecture: $(2)\n";\
114 printf
"Directory: $(CURDIR)\n";\
115 printf
"Goal(s): $(3)\n";\
116 printf
"Start: `date`\n";\
117 printf
"$(boldline)$(color_end)\n";\
121 # $(call printDirBanner,dir,goal) 122 # Print directory banner. The dir parameter is relative path from 123 # $(RNMAKE_PKG_ROOT). If the dir parameter is empty, the basename of 124 # $(RNMAKE_PKG_ROOT) is used. 125 define printDirBanner =
126 @
if [
"$(1)" !=
"" ]; then \
127 subdirname=
"$(patsubst $(dir $(RNMAKE_PKG_ROOT))%,%,$(CURDIR)/$(1))";\
129 subdirname=$(notdir $(RNMAKE_PKG_ROOT));\
132 printf
"$(color_dir_banner)$(normline)\n";\
133 printf
"Directory: $$subdirname\n";\
134 printf
"Goal: $(2)\n";\
135 printf
"$(normline)$(color_end)\n";\
139 # $(call printGoalBanner,goal) 141 define printGoalBanner =
142 @
if [
"$(1)" !=
"" ]; then \
143 printf
"\n $(color_tgt_file)$(1)$(color_end)\n";\
147 # $(call printGoalDesc,goal,desc) 149 # Print goal with optional description. 150 define printGoalDesc =
151 $(call printGoalBanner,$(1));
152 $(
if $(2),@printf
"$(2)\n",)
155 # $(call printEchoTgtGoalDesc,desc) 156 # Silly print goal with description. The goal is determined by stripping off 157 # the 'echo-' prefix from the current target $(@). 158 define printEchoTgtGoalDesc =
159 $(call printGoalDesc,$(patsubst echo-%,%,$(@)),$(1))
162 # $(call printFooter,curgoal,lastgoal) 163 # Conditionally print footer. If the goal is the last command-line goal and 164 # the make level is 0 (top), then the footer is printed. 166 @
if [
"$(MAKELEVEL)" =
"0" -a
"$(1)" =
"$(2)" ]; then \
168 printf
"$(color_pkg_banner) ###\n";\
169 printf
"Finished: `date`\n";\
170 printf
" ###$(color_end)\n";\
175 # Print goal banner using the current target $(@). 176 printTgtGoal = $(call printGoalBanner,$(@))
180 ================================================================================
182 ................................................................................
184 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
186 ________________________________________________________________________________
188 boldline := $(eqline)
189 normline := $(tildeline)