📅 2020-Jan-14 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ cheatsheet, makefile ⬩ 📚 Archive
ifneq ("$(wildcard $(SOME_PATH_VAR))","")
Here we are applying the wildcard
function on the variable holding a path or a wildcard to expand it to a list of files or directories. We then check if this list is not empty by comparing it to an empty string with the ifneq
if-not-equal check.
When assigning to variables, do you use :=
or =
? According to Two Flavors of Variables, using :=
creates a simply expanded variable. The RHS of the assignment is expanded once and the resulting value is reused whenever it is used. Using =
creates a recursively expanded variable, which is expanded everytime it is used. What this means is that this type of variable could hold different values during different times if its RHS expands to different values.
To print text while building:
$(info This text will be printed and execution continues)
$(warning This text will be printed as a warning)
$(error This text will print as error and make will exit)