]>
Commit | Line | Data |
---|---|---|
39236c6e A |
1 | # -*- mode: makefile;-*- |
2 | # | |
f427ee49 | 3 | # Copyright (C) 1999-2020 Apple Inc. All rights reserved. |
39236c6e A |
4 | # |
5 | # MakeInc.cmd contains command paths for use during | |
6 | # the build, as well as make fragments and text | |
7 | # strings that may be evaluated as utility functions. | |
8 | # | |
9 | ||
1c79356b A |
10 | # |
11 | # Commands for the build environment | |
12 | # | |
cb323159 | 13 | |
f427ee49 A |
14 | # |
15 | # Build Logging and Verbosity | |
16 | # | |
cb323159 | 17 | |
b0d623f7 | 18 | ifeq ($(RC_XBS),YES) |
cb323159 | 19 | VERBOSE = YES |
b0d623f7 | 20 | else |
cb323159 | 21 | VERBOSE = NO |
b0d623f7 | 22 | endif |
1c79356b | 23 | |
cb323159 A |
24 | ECHO = echo |
25 | ||
cb323159 | 26 | ERR = $(ECHO) > /dev/stderr |
f427ee49 | 27 | PRINTF = printf |
cb323159 A |
28 | |
29 | QUIET ?= 0 | |
30 | ifneq ($(QUIET),0) | |
f427ee49 | 31 | PRINTF = printf > /dev/null |
cb323159 A |
32 | ifeq ($(VERBOSE),YES) |
33 | override VERBOSE = NO | |
34 | endif | |
35 | endif | |
fe8ab488 | 36 | |
f427ee49 A |
37 | # Helper functions for logging operations. |
38 | LOG_PFX_LEN = 15 | |
39 | LOG_PFX_LEN_ADJ = $(LOG_PFX_LEN) | |
40 | LOG = $(PRINTF) "$2%$4s$(Color0) $3%s$(Color0)\n" "$1" | |
41 | ||
42 | CONCISE ?= 0 | |
43 | ifneq ($(CONCISE),0) | |
44 | # Concise logging puts all logs on the same line (CSI K to clear and | |
45 | # carriage return). | |
46 | LOG = $(PRINTF) "$2%$4s$(Color0) $3%s$(Color0)\033[K\r" "$1" | |
47 | endif | |
48 | ||
49 | _LOG_COMP = $(call LOG,$1,$(ColorC),$(ColorF),$(LOG_PFX_LEN_ADJ)) | |
50 | _LOG_HOST = $(call LOG,$1,$(ColorH),$(ColorF),$(LOG_PFX_LEN)) | |
51 | _LOG_HOST_LINK = $(call LOG,$1,$(ColorH),$(ColorLF),$(LOG_PFX_LEN)) | |
52 | ||
53 | # Special operations. | |
54 | LOG_LDFILELIST = $(call LOG,LDFILELIST,$(ColorL),$(ColorLF),$(LOG_PFX_LEN_ADJ)) | |
55 | LOG_MIG = $(call LOG,MIG,$(ColorM),$(ColorF),$(LOG_PFX_LEN_ADJ)) | |
56 | LOG_LD = $(call LOG,LD,$(ColorL),$(ColorF),$(LOG_PFX_LEN_ADJ)) | |
2a1bd2d3 | 57 | LOG_ALIGN = $(call LOG,--------->,$(Color0),$(Color0),$(LOG_PFX_LEN)) |
f427ee49 A |
58 | |
59 | # Compiling/machine-specific operations. | |
60 | LOG_CC = $(call _LOG_COMP,CC) | |
61 | LOG_CXX = $(call _LOG_COMP,C++) | |
62 | LOG_AS = $(call _LOG_COMP,AS) | |
63 | LOG_LTO = $(call _LOG_COMP,LTO) | |
64 | LOG_SYMBOLSET = $(call _LOG_COMP,SYMSET) | |
65 | LOG_SYMBOLSETPLIST = $(call _LOG_COMP,SYMSETPLIST) | |
66 | ||
67 | # Host-side operations. | |
68 | LOG_IIG = $(call _LOG_HOST,IIG) | |
69 | LOG_HOST_CC = $(call _LOG_HOST,CC) | |
70 | LOG_HOST_LD = $(call _LOG_HOST,LD) | |
71 | LOG_HOST_CODESIGN = $(call _LOG_HOST,CODESIGN) | |
72 | LOG_HOST_BISON = $(call _LOG_HOST,BISON) | |
73 | LOG_HOST_FLEX = $(call _LOG_HOST,FLEX) | |
74 | LOG_INSTALL = $(call _LOG_HOST,INSTALL) | |
75 | LOG_INSTALLSYM = $(call _LOG_HOST,INSTALLSYM) | |
76 | LOG_INSTALLHDR = $(call _LOG_HOST,INSTALLHDR) | |
77 | LOG_INSTALLMACROS = $(call _LOG_HOST,INSTALLMACROS) | |
78 | LOG_INSTALLPY = $(call _LOG_HOST,INSTALLPY) | |
79 | LOG_MAN = $(call _LOG_HOST,MAN) | |
80 | LOG_MANLINK = $(call _LOG_HOST,MANLINK) | |
81 | LOG_ALIAS = $(call _LOG_HOST,ALIAS) | |
82 | LOG_STRIP = $(call _LOG_HOST,STRIP) | |
83 | LOG_DSYMUTIL = $(call _LOG_HOST,DSYMUTIL) | |
84 | LOG_LIBTOOL = $(call _LOG_HOST,LIBTOOL) | |
2a1bd2d3 | 85 | LOG_FILEPREP = $(call _LOG_HOST,FILEPREP) |
f427ee49 A |
86 | |
87 | # Host-side linking operations. | |
88 | LOG_GENASSYM = $(call _LOG_HOST_LINK,GENASSYM) | |
89 | LOG_GENERATE= $(call _LOG_HOST_LINK,GENERATE) | |
90 | LOG_CTFCONVERT = $(call _LOG_HOST_LINK,CTFCONVERT) | |
91 | LOG_CTFMERGE = $(call _LOG_HOST_LINK,CTFMERGE) | |
92 | LOG_CTFINSERT = $(call _LOG_HOST_LINK,CTFINSERT) | |
93 | LOG_DSYMUTIL = $(call _LOG_HOST_LINK,DSYMUTIL) | |
94 | LOG_SUPPORTED_KPI = $(call _LOG_HOST_LINK,SUPPORTED_KPI) | |
95 | ||
b0d623f7 | 96 | ifeq ($(VERBOSE),YES) |
cb323159 A |
97 | _v = |
98 | _vstdout = | |
f427ee49 | 99 | _vstderr = |
39236c6e | 100 | XCRUN = /usr/bin/xcrun -verbose |
b0d623f7 | 101 | else |
cb323159 A |
102 | _v = @ |
103 | _vstdout = > /dev/null | |
f427ee49 | 104 | _vstderr = 2&> /dev/null |
b0d623f7 A |
105 | XCRUN = /usr/bin/xcrun |
106 | endif | |
107 | ||
cb323159 A |
108 | VERBOSE_GENERATED_MAKE_FRAGMENTS = NO |
109 | ||
f427ee49 A |
110 | # |
111 | # Defaults | |
112 | # | |
113 | ||
d9a64523 | 114 | SDKROOT ?= macosx |
39236c6e | 115 | HOST_SDKROOT ?= macosx |
316670eb A |
116 | |
117 | # SDKROOT may be passed as a shorthand like "iphoneos.internal". We | |
118 | # must resolve these to a full path and override SDKROOT. | |
119 | ||
120 | ifeq ($(SDKROOT_RESOLVED),) | |
39236c6e A |
121 | export SDKROOT_RESOLVED := $(shell $(XCRUN) -sdk $(SDKROOT) -show-sdk-path) |
122 | ifeq ($(strip $(SDKROOT)_$(SDKROOT_RESOLVED)),/_) | |
123 | export SDKROOT_RESOLVED := / | |
316670eb A |
124 | endif |
125 | endif | |
126 | override SDKROOT = $(SDKROOT_RESOLVED) | |
b0d623f7 | 127 | |
39236c6e A |
128 | ifeq ($(HOST_SDKROOT_RESOLVED),) |
129 | export HOST_SDKROOT_RESOLVED := $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -show-sdk-path) | |
d9a64523 A |
130 | ifeq ($(strip $(HOST_SDKROOT_RESOLVED)),) |
131 | export HOST_SDKROOT_RESOLVED := / | |
132 | endif | |
39236c6e A |
133 | endif |
134 | override HOST_SDKROOT = $(HOST_SDKROOT_RESOLVED) | |
135 | ||
6d2010ae | 136 | ifeq ($(PLATFORM),) |
39236c6e A |
137 | export PLATFORMPATH := $(shell $(XCRUN) -sdk $(SDKROOT) -show-sdk-platform-path) |
138 | export PLATFORM := $(shell echo $(PLATFORMPATH) | sed 's,^.*/\([^/]*\)\.platform$$,\1,') | |
6d2010ae A |
139 | ifeq ($(PLATFORM),) |
140 | export PLATFORM := MacOSX | |
3e170ce0 A |
141 | else ifeq ($(shell echo $(PLATFORM) | tr A-Z a-z),watchos) |
142 | export PLATFORM := WatchOS | |
6d2010ae A |
143 | endif |
144 | endif | |
145 | ||
cb323159 A |
146 | ifeq ($(PLATFORM),MacOSX) |
147 | ifeq (DriverKit,$(shell echo $(SDKROOT_RESOLVED) | sed 's,^.*/\([^/1-9]*\)[1-9][^/]*\.sdk$$,\1,')) | |
148 | export PLATFORM := DriverKit | |
149 | export DRIVERKIT ?= 1 | |
150 | export DRIVERKITROOT ?= /System/DriverKit | |
151 | export DRIVERKITRUNTIMEROOT = $(DRIVERKITROOT)/Runtime | |
152 | endif | |
153 | endif | |
154 | ||
39236c6e A |
155 | ifeq ($(SDKVERSION),) |
156 | export SDKVERSION := $(shell $(XCRUN) -sdk $(SDKROOT) -show-sdk-version) | |
157 | endif | |
158 | ||
6d2010ae A |
159 | # CC/CXX get defined by make(1) by default, so we can't check them |
160 | # against the empty string to see if they haven't been set | |
161 | ifeq ($(origin CC),default) | |
316670eb | 162 | export CC := $(shell $(XCRUN) -sdk $(SDKROOT) -find clang) |
6d2010ae A |
163 | endif |
164 | ifeq ($(origin CXX),default) | |
316670eb | 165 | export CXX := $(shell $(XCRUN) -sdk $(SDKROOT) -find clang++) |
6d2010ae A |
166 | endif |
167 | ifeq ($(MIG),) | |
168 | export MIG := $(shell $(XCRUN) -sdk $(SDKROOT) -find mig) | |
169 | endif | |
39236c6e A |
170 | ifeq ($(MIGCOM),) |
171 | export MIGCOM := $(shell $(XCRUN) -sdk $(SDKROOT) -find migcom) | |
172 | endif | |
b0d623f7 | 173 | ifeq ($(MIGCC),) |
6d2010ae | 174 | export MIGCC := $(CC) |
b0d623f7 | 175 | endif |
cb323159 A |
176 | ifeq ($(IIG),) |
177 | export IIG := $(shell $(XCRUN) -sdk $(SDKROOT) -find iig) | |
178 | endif | |
6d2010ae A |
179 | ifeq ($(STRIP),) |
180 | export STRIP := $(shell $(XCRUN) -sdk $(SDKROOT) -find strip) | |
181 | endif | |
182 | ifeq ($(LIPO),) | |
183 | export LIPO := $(shell $(XCRUN) -sdk $(SDKROOT) -find lipo) | |
184 | endif | |
185 | ifeq ($(LIBTOOL),) | |
186 | export LIBTOOL := $(shell $(XCRUN) -sdk $(SDKROOT) -find libtool) | |
187 | endif | |
188 | ifeq ($(NM),) | |
189 | export NM := $(shell $(XCRUN) -sdk $(SDKROOT) -find nm) | |
190 | endif | |
191 | ifeq ($(UNIFDEF),) | |
192 | export UNIFDEF := $(shell $(XCRUN) -sdk $(SDKROOT) -find unifdef) | |
193 | endif | |
6d2010ae A |
194 | ifeq ($(DSYMUTIL),) |
195 | export DSYMUTIL := $(shell $(XCRUN) -sdk $(SDKROOT) -find dsymutil) | |
196 | endif | |
197 | ifeq ($(CTFCONVERT),) | |
198 | export CTFCONVERT := $(shell $(XCRUN) -sdk $(SDKROOT) -find ctfconvert) | |
199 | endif | |
200 | ifeq ($(CTFMERGE),) | |
201 | export CTFMERGE := $(shell $(XCRUN) -sdk $(SDKROOT) -find ctfmerge) | |
202 | endif | |
39236c6e A |
203 | ifeq ($(CTFINSERT),) |
204 | export CTFINSERT := $(shell $(XCRUN) -sdk $(SDKROOT) -find ctf_insert) | |
6d2010ae A |
205 | endif |
206 | ifeq ($(NMEDIT),) | |
207 | export NMEDIT := $(shell $(XCRUN) -sdk $(SDKROOT) -find nmedit) | |
208 | endif | |
b0d623f7 | 209 | |
3e170ce0 A |
210 | # |
211 | # Platform options | |
212 | # | |
5ba3f43e | 213 | SUPPORTED_EMBEDDED_PLATFORMS := iPhoneOS iPhoneOSNano tvOS AppleTVOS WatchOS BridgeOS |
3e170ce0 | 214 | SUPPORTED_SIMULATOR_PLATFORMS := iPhoneSimulator iPhoneNanoSimulator tvSimulator AppleTVSimulator WatchSimulator |
cb323159 | 215 | SUPPORTED_PLATFORMS := MacOSX DriverKit $(SUPPORTED_SIMULATOR_PLATFORMS) $(SUPPORTED_EMBEDDED_PLATFORMS) |
3e170ce0 | 216 | |
6d2010ae | 217 | # Platform-specific tools |
5ba3f43e | 218 | EDM_DBPATH ?= $(PLATFORMPATH)/usr/local/standalone/firmware/device_map.db |
6d2010ae A |
219 | |
220 | # Scripts or tools we build ourselves | |
fe8ab488 A |
221 | # |
222 | # setsegname - Rename segments in a Mach-O object file | |
223 | # kextsymboltool - Create kext pseudo-kext Mach-O kexts binaries | |
224 | # decomment - Strip out comments to detect whether a file is comments-only | |
225 | # installfile - Atomically copy files, esp. when multiple architectures | |
226 | # are trying to install the same target header | |
227 | # replacecontents - Write contents to a file and update modtime *only* if | |
228 | # contents differ | |
229 | # | |
39236c6e A |
230 | SEG_HACK = $(OBJROOT)/SETUP/setsegname/setsegname |
231 | KEXT_CREATE_SYMBOL_SET = $(OBJROOT)/SETUP/kextsymboltool/kextsymboltool | |
232 | DECOMMENT = $(OBJROOT)/SETUP/decomment/decomment | |
6d2010ae | 233 | NEWVERS = $(SRCROOT)/config/newvers.pl |
39236c6e | 234 | INSTALL = $(OBJROOT)/SETUP/installfile/installfile |
fe8ab488 | 235 | REPLACECONTENTS = $(OBJROOT)/SETUP/replacecontents/replacecontents |
3e170ce0 | 236 | JSONCOMPILATIONDB = $(OBJROOT)/SETUP/json_compilation_db/json_compilation_db |
1c79356b | 237 | |
6d2010ae | 238 | # Standard BSD tools |
1c79356b | 239 | RM = /bin/rm -f |
39236c6e | 240 | RMDIR = /bin/rmdir |
1c79356b | 241 | CP = /bin/cp |
b0d623f7 | 242 | MV = /bin/mv |
0c530ab8 | 243 | LN = /bin/ln -fs |
1c79356b A |
244 | CAT = /bin/cat |
245 | MKDIR = /bin/mkdir -p | |
fe8ab488 | 246 | CHMOD = /bin/chmod |
2d21ac55 | 247 | FIND = /usr/bin/find |
316670eb | 248 | XARGS = /usr/bin/xargs |
fe8ab488 | 249 | PAX = /bin/pax |
1c79356b | 250 | BASENAME = /usr/bin/basename |
39236c6e | 251 | DIRNAME = /usr/bin/dirname |
0b4e3aa0 | 252 | TR = /usr/bin/tr |
39236c6e | 253 | TOUCH = /usr/bin/touch |
fe8ab488 | 254 | SLEEP = /bin/sleep |
39236c6e A |
255 | AWK = /usr/bin/awk |
256 | SED = /usr/bin/sed | |
39236c6e | 257 | PLUTIL = /usr/bin/plutil |
1c79356b | 258 | |
6d2010ae A |
259 | # |
260 | # Command to generate host binaries. Intentionally not | |
261 | # $(CC), which controls the target compiler | |
262 | # | |
39236c6e A |
263 | ifeq ($(HOST_OS_VERSION),) |
264 | export HOST_OS_VERSION := $(shell sw_vers -productVersion) | |
265 | endif | |
6d2010ae | 266 | ifeq ($(HOST_CC),) |
39236c6e | 267 | export HOST_CC := $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -find clang) |
6d2010ae A |
268 | endif |
269 | ifeq ($(HOST_FLEX),) | |
270 | export HOST_FLEX := $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -find flex) | |
271 | endif | |
272 | ifeq ($(HOST_BISON),) | |
273 | export HOST_BISON := $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -find bison) | |
274 | endif | |
39236c6e A |
275 | ifeq ($(HOST_GM4),) |
276 | export HOST_GM4 := $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -find gm4) | |
277 | endif | |
6d2010ae | 278 | ifeq ($(HOST_CODESIGN),) |
39236c6e A |
279 | export HOST_CODESIGN := /usr/bin/codesign |
280 | endif | |
281 | ifeq ($(HOST_CODESIGN_ALLOCATE),) | |
282 | export HOST_CODESIGN_ALLOCATE := $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -find codesign_allocate) | |
6d2010ae A |
283 | endif |
284 | ||
39236c6e A |
285 | # |
286 | # The following variables are functions invoked with "call", and thus | |
287 | # behave similarly to externally compiled commands | |
288 | # | |
289 | ||
290 | # $(1) is an expanded kernel config from a TARGET_CONFIGS_UC tuple | |
291 | # $(2) is an expanded arch config from a TARGET_CONFIGS_UC tuple | |
292 | # $(3) is an expanded machine config from a TARGET_CONFIGS_UC tuple | |
293 | _function_create_build_configs_join = $(strip $(1))^$(strip $(2))^$(strip $(3)) | |
294 | ||
295 | # $(1) is an un-expanded kernel config from a TARGET_CONFIGS_UC tuple | |
296 | # $(2) is an un-expanded arch config from a TARGET_CONFIGS_UC tuple | |
297 | # $(3) is an un-expanded machine config from a TARGET_CONFIGS_UC tuple | |
298 | _function_create_build_configs_do_expand = $(call _function_create_build_configs_join, \ | |
299 | $(if $(filter DEFAULT,$(1)), \ | |
39037602 | 300 | $(DEFAULT_KERNEL_CONFIG), \ |
39236c6e A |
301 | $(1) \ |
302 | ), \ | |
303 | $(if $(filter DEFAULT,$(2)), \ | |
39037602 | 304 | $(DEFAULT_ARCH_CONFIG), \ |
39236c6e A |
305 | $(2) \ |
306 | ), \ | |
307 | $(if $(filter DEFAULT,$(3)), \ | |
39037602 A |
308 | $(if $(filter DEFAULT,$(2)), \ |
309 | $(DEFAULT_$(DEFAULT_ARCH_CONFIG)_MACHINE_CONFIG), \ | |
39236c6e | 310 | $(DEFAULT_$(strip $(2))_MACHINE_CONFIG) \ |
39037602 | 311 | ), \ |
39236c6e A |
312 | $(3) \ |
313 | ) \ | |
314 | ) | |
315 | ||
316 | # $(1) is an un-expanded TARGET_CONFIGS_UC list, which must be consumed | |
317 | # 3 elements at a time | |
318 | function_create_build_configs = $(sort \ | |
319 | $(strip \ | |
39037602 A |
320 | $(call _function_create_build_configs_do_expand, \ |
321 | $(word 1,$(1)), \ | |
322 | $(word 2,$(1)), \ | |
323 | $(word 3,$(1)), \ | |
39236c6e A |
324 | ) \ |
325 | $(if $(word 4,$(1)), \ | |
326 | $(call function_create_build_configs, \ | |
327 | $(wordlist 4,$(words $(1)),$(1)) \ | |
328 | ), \ | |
39236c6e A |
329 | ) \ |
330 | ) \ | |
331 | ) | |
332 | ||
39037602 A |
333 | # Similar to build configs, but alias configs are a 4-tuple |
334 | ||
335 | # $(1) is an expanded kernel config from a TARGET_CONFIGS_ALIASES_UC tuple | |
336 | # $(2) is an expanded arch config from a TARGET_CONFIGS_ALIASES_UC tuple | |
337 | # $(3) is an expanded kernel machine config from a TARGET_CONFIGS_ALIASES_UC tuple | |
338 | # $(4) is an expanded SoC platform config from a TARGET_CONFIGS_ALIASES_UC tuple, | |
339 | # which should be an alias of $(3) | |
340 | _function_create_alias_configs_join = $(strip $(1))^$(strip $(2))^$(strip $(3))^$(strip $(4)) | |
341 | ||
342 | _function_create_alias_configs_do_expand = $(call _function_create_alias_configs_join, \ | |
343 | $(if $(filter DEFAULT,$(1)), \ | |
344 | $(DEFAULT_KERNEL_CONFIG), \ | |
345 | $(1) \ | |
346 | ), \ | |
347 | $(if $(filter DEFAULT,$(2)), \ | |
348 | $(DEFAULT_ARCH_CONFIG), \ | |
349 | $(2) \ | |
350 | ), \ | |
351 | $(3), \ | |
352 | $(4) \ | |
353 | ) | |
354 | ||
355 | function_create_alias_configs = $(sort \ | |
356 | $(strip \ | |
357 | $(call _function_create_alias_configs_do_expand, \ | |
358 | $(word 1,$(1)), \ | |
359 | $(word 2,$(1)), \ | |
360 | $(word 3,$(1)), \ | |
361 | $(word 4,$(1)), \ | |
362 | ) \ | |
363 | $(if $(word 5,$(1)), \ | |
364 | $(call function_create_alias_configs, \ | |
365 | $(wordlist 5,$(words $(1)),$(1)) \ | |
366 | ), \ | |
367 | ) \ | |
368 | ) \ | |
369 | ) | |
370 | ||
39236c6e A |
371 | # $(1) is a fully-expanded kernel config |
372 | # $(2) is a fully-expanded arch config | |
373 | # $(3) is a fully-expanded machine config. "NONE" is not represented in the objdir path | |
374 | function_convert_target_config_uc_to_objdir = $(if $(filter NONE,$(3)),$(strip $(1))_$(strip $(2)),$(strip $(1))_$(strip $(2))_$(strip $(3))) | |
375 | ||
376 | # $(1) is a fully-expanded build config (like "RELEASE^X86_64^NONE") | |
377 | function_convert_build_config_to_objdir = $(call function_convert_target_config_uc_to_objdir, \ | |
39037602 | 378 | $(word 1,$(subst ^, ,$(1))), \ |
39236c6e A |
379 | $(word 2,$(subst ^, ,$(1))), \ |
380 | $(word 3,$(subst ^, ,$(1))) \ | |
381 | ) | |
382 | ||
383 | # $(1) is a fully-expanded build config (like "RELEASE^X86_64^NONE") | |
384 | function_extract_kernel_config_from_build_config = $(word 1,$(subst ^, ,$(1))) | |
385 | function_extract_arch_config_from_build_config = $(word 2,$(subst ^, ,$(1))) | |
386 | function_extract_machine_config_from_build_config = $(word 3,$(subst ^, ,$(1))) | |
387 | ||
388 | # $(1) is an input word | |
389 | # $(2) is a list of colon-separate potential substitutions like "FOO:BAR BAZ:QUX" | |
390 | # $(3) is a fallback if no substitutions were made | |
391 | function_substitute_word_with_replacement = $(strip $(if $(2), \ | |
392 | $(if $(filter $(word 1,$(subst :, ,$(word 1,$(2)))),$(1)), \ | |
393 | $(word 2,$(subst :, ,$(word 1,$(2)))), \ | |
394 | $(call function_substitute_word_with_replacement,$(1),$(wordlist 2,$(words $(2)),$(2)),$(3))), \ | |
395 | $(3) \ | |
396 | ) \ | |
397 | ) | |
398 | ||
399 | # You can't assign a variable to an empty space without these | |
400 | # shenanigans | |
401 | empty := | |
402 | space := $(empty) $(empty) | |
403 | ||
404 | # Arithmetic | |
405 | # $(1) is the number to increment | |
39037602 | 406 | NUM32 = x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x |
fe8ab488 A |
407 | increment = $(words x $(wordlist 1,$(1),$(NUM32))) |
408 | decrement = $(words $(wordlist 2,$(1),$(NUM32))) | |
409 | ||
410 | # Create a sequence from 1 to $(1) | |
411 | # F(N) = if N > 0: return F(N-1) + "N" else: return "" | |
412 | sequence = $(if $(wordlist 1,$(1),$(NUM32)),$(call sequence,$(call decrement,$(1))) $(1),) | |
413 | ||
414 | # Reverse a list of words in $(1) | |
415 | reverse = $(if $(word 2,$(1)),$(call reverse,$(wordlist 2,$(words $(1)),$(1)))) $(word 1,$(1)) | |
39236c6e | 416 | |
2d21ac55 | 417 | # vim: set ft=make: |