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