Remove unused cache.
[pwl6.git] / rules / default.mk
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.
4
5 # Should be defaults.
6 .DELETE_ON_ERROR:
7 .DEFAULT_GOAL: all
8
9 # Force these to be double-colon targets, so individual makefiles can
10 # extend them as necessary (particularly for clean).
11 all::
12 clean::
13 distclean::
14
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 $*=$($*)
19
20 .PHONY: FORCE all clean distclean
21
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))
28
29 # Call before including anything for the current makefile's directory.
30 where-am-i = $(dir $(lastword $(MAKEFILE_LIST)))
31
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
34 # working directory.
35 include-once. = $(call include-once,$(addprefix $(call where-am-i),$1))
36
37
38 # Quiet the output of a command, unless an error occurs. This is
39 # similar to the shell 'chronic' / 'cronic' programs.
40 #
41 # To hide output unless an error occurs, pass a single argument:
42 # $(call quiet,munge somefile)
43 #
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,$@)
48
49 define quiet
50 @echo "$1" $(if $2,"> $2")
51 $(eval QUIETTMP := $(firstword $2 $(shell mktemp -t make-quiet.XXXXX)))
52 @($1) > $(QUIETTMP) \
53 || (STATUS=$$? \
54 && cat "$(QUIETTMP)" \
55 && $(RM) "$(QUIETTMP)" \
56 && exit $$STATUS)
57 $(if $2,,$(RM) "$(QUIETTMP)")
58 endef
59