xref: /freebsd/contrib/bmake/mk/sys.dependfile.mk (revision 59c8e88e72633afbc47a4ace0d2170d00d51f7dc)
1# $Id: sys.dependfile.mk,v 1.10 2023/05/10 19:23:26 sjg Exp $
2#
3#	@(#) Copyright (c) 2012-2023, 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.if !target(__${.PARSEFILE}__)
17__${.PARSEFILE}__: .NOTMAIN
18
19# This only makes sense for DIRDEPS_BUILD.
20# This allows a mixture of auto generated as well as manually edited
21# dependency files, which can be differentiated by their names.
22# As per dirdeps.mk we only require:
23# 1. a common prefix
24# 2. that machine specific files end in .${MACHINE}
25#
26# The .MAKE.DEPENDFILE_PREFERENCE below is an example.
27
28# All depend file names should start with this
29.MAKE.DEPENDFILE_PREFIX ?= Makefile.depend
30
31.if !empty(.MAKE.DEPENDFILE) && \
32	${.MAKE.DEPENDFILE:M${.MAKE.DEPENDFILE_PREFIX}*} == ""
33# let us do our thing below...
34.undef .MAKE.DEPENDFILE
35.endif
36
37# The order of preference: we will use the first one of these we find.
38# It usually makes sense to order from most specific to least.
39.MAKE.DEPENDFILE_PREFERENCE ?= \
40	${.CURDIR}/${.MAKE.DEPENDFILE_PREFIX}.${MACHINE} \
41	${.CURDIR}/${.MAKE.DEPENDFILE_PREFIX}
42
43# Normally the 1st entry is our default choice
44# Another useful default is ${.MAKE.DEPENDFILE_PREFIX}
45.MAKE.DEPENDFILE_DEFAULT ?= ${.MAKE.DEPENDFILE_PREFERENCE:[1]}
46
47_e := ${.MAKE.DEPENDFILE_PREFERENCE:@m@${exists($m):?$m:}@}
48.if !empty(_e)
49.MAKE.DEPENDFILE := ${_e:[1]}
50.elif ${.MAKE.DEPENDFILE_PREFERENCE:M*${MACHINE}} != "" && ${.MAKE.DEPENDFILE_DEFAULT:E} != ${MACHINE}
51# MACHINE specific depend files are supported, but *not* default.
52# If any already exist, we should follow suit.
53_aml = ${ALL_MACHINE_LIST:Uarm amd64 i386 powerpc:N${MACHINE}} ${MACHINE}
54# make sure we restore MACHINE
55_m := ${MACHINE}
56_e := ${_aml:@MACHINE@${.MAKE.DEPENDFILE_PREFERENCE:@m@${exists($m):?$m:}@}@}
57MACHINE := ${_m}
58.if !empty(_e)
59.MAKE.DEPENDFILE ?= ${.MAKE.DEPENDFILE_PREFERENCE:M*${MACHINE}:[1]}
60.endif
61.endif
62.MAKE.DEPENDFILE ?= ${.MAKE.DEPENDFILE_DEFAULT}
63
64.endif
65