xref: /freebsd/contrib/bmake/mk/target-flags.mk (revision 8aac90f18aef7c9eea906c3ff9a001ca7b94f375)
1# NAME:
2#	target-flags.mk - target specific flags
3#
4# DESCRIPTION:
5#	Include this macro file after all others in a makefile and
6#	follow it with any target specific flag settings.
7#	For each such variable v in TARGET_FLAG_VARS we set:
8#.nf
9#
10#	_$v := ${$v}
11#	$v = ${${v}_${.TARGET:T}:U${_$v}}
12#.fi
13#
14#	This allows one to do things like:
15#.nf
16#
17#	TARGET_FLAG_VARS= CFLAGS
18#	.include <target-flags.mk>
19#	CFLAGS_fu.o = ${_CFLAGS:N-Wall}
20#.fi
21#
22#	To turn off -Wall for just the target fu.o
23#	Actually CFLAGS is the default value for TARGET_FLAG_VARS.
24#
25# BUGS:
26#	One must be careful to avoid creating circular references in
27#	variables.  The original version of this macro file did
28#	elaborate things with CFLAGS.  The current, simpler
29#	implementation is ultimately more flexible.
30#
31#	It is important that target-flags.mk is included after other
32#	macro files and that target specific flags that may reference
33#	_$v are set after that.
34#
35#	Only works with a make(1) that does nested evaluation correctly.
36
37
38
39# SPDX-License-Identifier: BSD-2-Clause
40#
41# RCSid:
42#	$Id: target-flags.mk,v 1.11 2024/02/17 17:26:57 sjg Exp $
43#
44#	@(#) Copyright (c) 1998-2002, Simon J. Gerraty
45#
46#	This file is provided in the hope that it will
47#	be of use.  There is absolutely NO WARRANTY.
48#	Permission to copy, redistribute or otherwise
49#	use this file is hereby granted provided that
50#	the above copyright notice and this notice are
51#	left intact.
52#
53#	Please send copies of changes and bug-fixes to:
54#	sjg@crufty.net
55#
56
57TARGET_FLAG_VARS?= CFLAGS
58.for v in ${TARGET_FLAG_VARS}
59.ifndef _$v
60_$v := ${$v}
61$v  =  ${${v}_${.TARGET:T}:U${_$v}}
62.endif
63.endfor
64
65