xref: /dflybsd-src/contrib/bmake/mk/sys.dependfile.mk (revision a34d5fb143d34c0e1d2580296c500e2c8a5bc5dc)
1*a34d5fb1SAntonio Huete Jimenez# $Id: sys.dependfile.mk,v 1.9 2020/08/19 17:51:53 sjg Exp $
25f1e34d9SAlexandre Perrin#
35f1e34d9SAlexandre Perrin#	@(#) Copyright (c) 2012, Simon J. Gerraty
45f1e34d9SAlexandre Perrin#
55f1e34d9SAlexandre Perrin#	This file is provided in the hope that it will
65f1e34d9SAlexandre Perrin#	be of use.  There is absolutely NO WARRANTY.
75f1e34d9SAlexandre Perrin#	Permission to copy, redistribute or otherwise
85f1e34d9SAlexandre Perrin#	use this file is hereby granted provided that
95f1e34d9SAlexandre Perrin#	the above copyright notice and this notice are
105f1e34d9SAlexandre Perrin#	left intact.
115f1e34d9SAlexandre Perrin#
125f1e34d9SAlexandre Perrin#	Please send copies of changes and bug-fixes to:
135f1e34d9SAlexandre Perrin#	sjg@crufty.net
145f1e34d9SAlexandre Perrin#
155f1e34d9SAlexandre Perrin
165f1e34d9SAlexandre Perrin# This only makes sense in meta mode.
175f1e34d9SAlexandre Perrin# This allows a mixture of auto generated as well as manually edited
185f1e34d9SAlexandre Perrin# dependency files, which can be differentiated by their names.
195f1e34d9SAlexandre Perrin# As per dirdeps.mk we only require:
205f1e34d9SAlexandre Perrin# 1. a common prefix
215f1e34d9SAlexandre Perrin# 2. that machine specific files end in .${MACHINE}
225f1e34d9SAlexandre Perrin#
235f1e34d9SAlexandre Perrin# The .MAKE.DEPENDFILE_PREFERENCE below is an example.
245f1e34d9SAlexandre Perrin
255f1e34d9SAlexandre Perrin# All depend file names should start with this
265f1e34d9SAlexandre Perrin.MAKE.DEPENDFILE_PREFIX ?= Makefile.depend
275f1e34d9SAlexandre Perrin
286a91b982SJohn Marino.if !empty(.MAKE.DEPENDFILE) && \
296a91b982SJohn Marino	${.MAKE.DEPENDFILE:M${.MAKE.DEPENDFILE_PREFIX}*} == ""
306a91b982SJohn Marino# let us do our thing below...
316a91b982SJohn Marino.undef .MAKE.DEPENDFILE
326a91b982SJohn Marino.endif
336a91b982SJohn Marino
345f1e34d9SAlexandre Perrin# The order of preference: we will use the first one of these we find.
355f1e34d9SAlexandre Perrin# It usually makes sense to order from most specific to least.
365f1e34d9SAlexandre Perrin.MAKE.DEPENDFILE_PREFERENCE ?= \
375f1e34d9SAlexandre Perrin	${.CURDIR}/${.MAKE.DEPENDFILE_PREFIX}.${MACHINE} \
385f1e34d9SAlexandre Perrin	${.CURDIR}/${.MAKE.DEPENDFILE_PREFIX}
395f1e34d9SAlexandre Perrin
405f1e34d9SAlexandre Perrin# Normally the 1st entry is our default choice
415f1e34d9SAlexandre Perrin# Another useful default is ${.MAKE.DEPENDFILE_PREFIX}
425f1e34d9SAlexandre Perrin.MAKE.DEPENDFILE_DEFAULT ?= ${.MAKE.DEPENDFILE_PREFERENCE:[1]}
435f1e34d9SAlexandre Perrin
445f1e34d9SAlexandre Perrin_e := ${.MAKE.DEPENDFILE_PREFERENCE:@m@${exists($m):?$m:}@}
455f1e34d9SAlexandre Perrin.if !empty(_e)
465f1e34d9SAlexandre Perrin.MAKE.DEPENDFILE := ${_e:[1]}
475f1e34d9SAlexandre Perrin.elif ${.MAKE.DEPENDFILE_PREFERENCE:M*${MACHINE}} != "" && ${.MAKE.DEPENDFILE_DEFAULT:E} != ${MACHINE}
485f1e34d9SAlexandre Perrin# MACHINE specific depend files are supported, but *not* default.
495f1e34d9SAlexandre Perrin# If any already exist, we should follow suit.
505f1e34d9SAlexandre Perrin_aml = ${ALL_MACHINE_LIST:Uarm amd64 i386 powerpc:N${MACHINE}} ${MACHINE}
51f445c897SJohn Marino# make sure we restore MACHINE
52f445c897SJohn Marino_m := ${MACHINE}
535f1e34d9SAlexandre Perrin_e := ${_aml:@MACHINE@${.MAKE.DEPENDFILE_PREFERENCE:@m@${exists($m):?$m:}@}@}
54f445c897SJohn MarinoMACHINE := ${_m}
555f1e34d9SAlexandre Perrin.if !empty(_e)
565f1e34d9SAlexandre Perrin.MAKE.DEPENDFILE ?= ${.MAKE.DEPENDFILE_PREFERENCE:M*${MACHINE}:[1]}
575f1e34d9SAlexandre Perrin.endif
585f1e34d9SAlexandre Perrin.endif
595f1e34d9SAlexandre Perrin.MAKE.DEPENDFILE ?= ${.MAKE.DEPENDFILE_DEFAULT}
60