1 # This is free and unencumbered software released into the public
2 # domain. To the extent possible under law, the author of this file
3 # waives all copyright and related or neighboring rights to it.
9 # Force these to be double-colon targets, so individual makefiles can
10 # extend them as necessary (particularly for clean).
15 # http://blog.jgc.org/2015/04/the-one-line-you-should-add-to-every.html
16 # Depends on FORCE because "implicit [pattern] rule search is skipped
17 # for .PHONY targets."
18 print-
%: FORCE
; @echo
$*=$($*)
20 .PHONY
: FORCE
all clean distclean
22 # Use with include to ensure files are included only once. e.g.:
23 # $(call include-once,example.mk more-rules/*.mk)
24 include-once
= $(if
$(wildcard $1),\
25 $(foreach f
,$(sort $(wildcard $1)),\
26 $(eval
include $(filter-out $(MAKEFILE_LIST
),$f))),\
27 $(error
$1: No such file or directory
))
29 # Call before including anything for the current makefile's directory.
30 where-am-i
= $(dir $(lastword
$(MAKEFILE_LIST
)))
32 # Like include-once, but the files are searched for relative to the most
33 # recently included file (usually the current one) not the current
35 include-once.
= $(call include-once
,$(addprefix $(call where-am-i
),$1))
38 # Quiet the output of a command, unless an error occurs. This is
39 # similar to the shell 'chronic' / 'cronic' programs.
41 # To hide output unless an error occurs, pass a single argument:
42 # $(call quiet,munge somefile)
44 # To store output to a file unless an error occurs, pass a second
45 # argument of the filename. If an error occurs, this file will not
46 # exist. Such a file will often be the rule's target.
47 # $(call quiet,munge somefile,$@)
50 @echo
"$1" $(if
$2,"> $2")
51 $(eval QUIETTMP
:= $(firstword $2 $(shell mktemp
-t make-quiet.XXXXX
)))
54 && cat
"$(QUIETTMP)" \
55 && $(RM
) "$(QUIETTMP)" \
57 $(if
$2,,$(RM
) "$(QUIETTMP)")