Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 1 | # Makefile utilities |
| 2 | |
| 3 | ### |
| 4 | # Utility functions |
| 5 | |
Daniel Dunbar | faf0150 | 2010-01-18 06:48:33 +0000 | [diff] [blame^] | 6 | # Function: streq LHS RHS |
| 7 | # |
| 8 | # Return "true" if LHS == RHS, otherwise "". |
| 9 | # |
| 10 | # LHS == RHS <=> (LHS subst RHS is empty) and (RHS subst LHS is empty) |
| 11 | streq = $(if $(1),$(if $(subst $(1),,$(2))$(subst $(2),,$(1)),,true),$(if $(2),,true)) |
| 12 | |
| 13 | # Function: strneq LHS RHS |
| 14 | # |
| 15 | # Return "true" if LHS != RHS, otherwise "". |
| 16 | strneq = $(if $(call streq,$(1),$(2)),,true) |
| 17 | |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 18 | # Function: Set variable value |
| 19 | # |
| 20 | # Set the given make variable to the given value. |
| 21 | Set = $(eval $(1) := $(2)) |
| 22 | |
| 23 | # Function: Append variable value |
| 24 | # |
| 25 | # Append the given value to the given make variable. |
| 26 | Append = $(eval $(1) += $(2)) |
| 27 | |
| 28 | ### |
| 29 | # Clean up make behavior |
| 30 | |
| 31 | # Cancel all suffix rules. We don't want no stinking suffix rules. |
| 32 | .SUFFIXES: |
| 33 | |
| 34 | ### |
| 35 | # Debugging |
| 36 | |
Daniel Dunbar | 557a6ea | 2010-01-13 16:13:01 +0000 | [diff] [blame] | 37 | # General debugging rule, use 'make print-XXX' to print the definition, value |
| 38 | # and origin of XXX. |
| 39 | make-print-%: |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 40 | $(error PRINT: $(value $*) = "$($*)" (from $(origin $*))) |
| 41 | |