1284345Ssjg# $FreeBSD$
2296637Ssjg# $Id: sys.dependfile.mk,v 1.7 2016/02/20 01:57:39 sjg Exp $
3284345Ssjg#
4284345Ssjg#	@(#) Copyright (c) 2012, Simon J. Gerraty
5284345Ssjg#
6284345Ssjg#	This file is provided in the hope that it will
7284345Ssjg#	be of use.  There is absolutely NO WARRANTY.
8284345Ssjg#	Permission to copy, redistribute or otherwise
9284345Ssjg#	use this file is hereby granted provided that 
10284345Ssjg#	the above copyright notice and this notice are
11284345Ssjg#	left intact. 
12284345Ssjg#      
13284345Ssjg#	Please send copies of changes and bug-fixes to:
14284345Ssjg#	sjg@crufty.net
15284345Ssjg#
16284345Ssjg
17284345Ssjg# This only makes sense in meta mode.
18284345Ssjg# This allows a mixture of auto generated as well as manually edited
19284345Ssjg# dependency files, which can be differentiated by their names.
20284345Ssjg# As per dirdeps.mk we only require:
21284345Ssjg# 1. a common prefix
22284345Ssjg# 2. that machine specific files end in .${MACHINE}
23284345Ssjg#
24284345Ssjg# The .MAKE.DEPENDFILE_PREFERENCE below is an example.
25284345Ssjg
26284345Ssjg# All depend file names should start with this
27284345Ssjg.MAKE.DEPENDFILE_PREFIX ?= Makefile.depend
28284345Ssjg
29284345Ssjg.if !empty(.MAKE.DEPENDFILE) && \
30284345Ssjg	${.MAKE.DEPENDFILE:M${.MAKE.DEPENDFILE_PREFIX}*} == ""
31284345Ssjg# let us do our thing below...
32284345Ssjg.undef .MAKE.DEPENDFILE
33284345Ssjg.endif
34284345Ssjg
35284345Ssjg# The order of preference: we will use the first one of these we find.
36284345Ssjg# It usually makes sense to order from most specific to least.
37284345Ssjg.MAKE.DEPENDFILE_PREFERENCE ?= \
38284345Ssjg	${.CURDIR}/${.MAKE.DEPENDFILE_PREFIX}.${MACHINE} \
39284345Ssjg	${.CURDIR}/${.MAKE.DEPENDFILE_PREFIX}
40284345Ssjg
41284345Ssjg# Normally the 1st entry is our default choice
42284345Ssjg# Another useful default is ${.MAKE.DEPENDFILE_PREFIX}
43284345Ssjg.MAKE.DEPENDFILE_DEFAULT ?= ${.MAKE.DEPENDFILE_PREFERENCE:[1]}
44284345Ssjg
45284345Ssjg_e := ${.MAKE.DEPENDFILE_PREFERENCE:@m@${exists($m):?$m:}@}
46284345Ssjg.if !empty(_e)
47284345Ssjg.MAKE.DEPENDFILE := ${_e:[1]}
48284345Ssjg.elif ${.MAKE.DEPENDFILE_PREFERENCE:M*${MACHINE}} != "" && ${.MAKE.DEPENDFILE_DEFAULT:E} != ${MACHINE}
49284345Ssjg# MACHINE specific depend files are supported, but *not* default.
50284345Ssjg# If any already exist, we should follow suit.
51284345Ssjg_aml = ${ALL_MACHINE_LIST:Uarm amd64 i386 powerpc:N${MACHINE}} ${MACHINE}
52296637Ssjg# make sure we restore MACHINE
53296637Ssjg_m := ${MACHINE}
54284345Ssjg_e := ${_aml:@MACHINE@${.MAKE.DEPENDFILE_PREFERENCE:@m@${exists($m):?$m:}@}@}
55296637SsjgMACHINE := ${_m}
56284345Ssjg.if !empty(_e)
57284345Ssjg.MAKE.DEPENDFILE ?= ${.MAKE.DEPENDFILE_PREFERENCE:M*${MACHINE}:[1]}
58284345Ssjg.endif
59284345Ssjg.endif
60284345Ssjg.MAKE.DEPENDFILE ?= ${.MAKE.DEPENDFILE_DEFAULT}
61