xref: /freebsd/contrib/bmake/mk/sys.dependfile.mk (revision 86c9d9918f1db7cdd968b60f8902466887bcd9e9)
1# $Id: sys.dependfile.mk,v 1.8 2016/03/11 01:34:13 sjg Exp $
2#
3#	@(#) Copyright (c) 2012, Simon J. Gerraty
4#
5#	This file is provided in the hope that it will
6#	be of use.  There is absolutely NO WARRANTY.
7#	Permission to copy, redistribute or otherwise
8#	use this file is hereby granted provided that
9#	the above copyright notice and this notice are
10#	left intact.
11#
12#	Please send copies of changes and bug-fixes to:
13#	sjg@crufty.net
14#
15
16# This only makes sense in meta mode.
17# This allows a mixture of auto generated as well as manually edited
18# dependency files, which can be differentiated by their names.
19# As per dirdeps.mk we only require:
20# 1. a common prefix
21# 2. that machine specific files end in .${MACHINE}
22#
23# The .MAKE.DEPENDFILE_PREFERENCE below is an example.
24
25# All depend file names should start with this
26.MAKE.DEPENDFILE_PREFIX ?= Makefile.depend
27
28.if !empty(.MAKE.DEPENDFILE) && \
29	${.MAKE.DEPENDFILE:M${.MAKE.DEPENDFILE_PREFIX}*} == ""
30# let us do our thing below...
31.undef .MAKE.DEPENDFILE
32.endif
33
34# The order of preference: we will use the first one of these we find.
35# It usually makes sense to order from most specific to least.
36.MAKE.DEPENDFILE_PREFERENCE ?= \
37	${.CURDIR}/${.MAKE.DEPENDFILE_PREFIX}.${MACHINE} \
38	${.CURDIR}/${.MAKE.DEPENDFILE_PREFIX}
39
40# Normally the 1st entry is our default choice
41# Another useful default is ${.MAKE.DEPENDFILE_PREFIX}
42.MAKE.DEPENDFILE_DEFAULT ?= ${.MAKE.DEPENDFILE_PREFERENCE:[1]}
43
44_e := ${.MAKE.DEPENDFILE_PREFERENCE:@m@${exists($m):?$m:}@}
45.if !empty(_e)
46.MAKE.DEPENDFILE := ${_e:[1]}
47.elif ${.MAKE.DEPENDFILE_PREFERENCE:M*${MACHINE}} != "" && ${.MAKE.DEPENDFILE_DEFAULT:E} != ${MACHINE}
48# MACHINE specific depend files are supported, but *not* default.
49# If any already exist, we should follow suit.
50_aml = ${ALL_MACHINE_LIST:Uarm amd64 i386 powerpc:N${MACHINE}} ${MACHINE}
51# make sure we restore MACHINE
52_m := ${MACHINE}
53_e := ${_aml:@MACHINE@${.MAKE.DEPENDFILE_PREFERENCE:@m@${exists($m):?$m:}@}@}
54MACHINE := ${_m}
55.if !empty(_e)
56.MAKE.DEPENDFILE ?= ${.MAKE.DEPENDFILE_PREFERENCE:M*${MACHINE}:[1]}
57.endif
58.endif
59.MAKE.DEPENDFILE ?= ${.MAKE.DEPENDFILE_DEFAULT}
60