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