xref: /freebsd/contrib/bmake/mk/target-flags.mk (revision c59c3bf34db360695f07735bebc76a768cac5afc)
13cbdda60SSimon J. Gerraty# NAME:
23cbdda60SSimon J. Gerraty#	target-flags.mk - target specific flags
33cbdda60SSimon J. Gerraty#
43cbdda60SSimon J. Gerraty# DESCRIPTION:
53cbdda60SSimon J. Gerraty#	Include this macro file after all others in a makefile and
65bcb7424SSimon J. Gerraty#	follow it with any target specific flag settings.
73cbdda60SSimon J. Gerraty#	For each such variable v in TARGET_FLAG_VARS we set:
83cbdda60SSimon J. Gerraty#.nf
93cbdda60SSimon J. Gerraty#
103cbdda60SSimon J. Gerraty#	_$v := ${$v}
113cbdda60SSimon J. Gerraty#	$v = ${${v}_${.TARGET:T}:U${_$v}}
123cbdda60SSimon J. Gerraty#.fi
133cbdda60SSimon J. Gerraty#
143cbdda60SSimon J. Gerraty#	This allows one to do things like:
153cbdda60SSimon J. Gerraty#.nf
163cbdda60SSimon J. Gerraty#
173cbdda60SSimon J. Gerraty#	TARGET_FLAG_VARS= CFLAGS
183cbdda60SSimon J. Gerraty#	.include <target-flags.mk>
193cbdda60SSimon J. Gerraty#	CFLAGS_fu.o = ${_CFLAGS:N-Wall}
203cbdda60SSimon J. Gerraty#.fi
213cbdda60SSimon J. Gerraty#
223cbdda60SSimon J. Gerraty#	To turn off -Wall for just the target fu.o
233cbdda60SSimon J. Gerraty#	Actually CFLAGS is the default value for TARGET_FLAG_VARS.
243cbdda60SSimon J. Gerraty#
253cbdda60SSimon J. Gerraty# BUGS:
263cbdda60SSimon J. Gerraty#	One must be careful to avoid creating circular references in
273cbdda60SSimon J. Gerraty#	variables.  The original version of this macro file did
283cbdda60SSimon J. Gerraty#	elaborate things with CFLAGS.  The current, simpler
293cbdda60SSimon J. Gerraty#	implementation is ultimately more flexible.
303cbdda60SSimon J. Gerraty#
313cbdda60SSimon J. Gerraty#	It is important that target-flags.mk is included after other
323cbdda60SSimon J. Gerraty#	macro files and that target specific flags that may reference
333cbdda60SSimon J. Gerraty#	_$v are set after that.
343cbdda60SSimon J. Gerraty#
353cbdda60SSimon J. Gerraty#	Only works with a make(1) that does nested evaluation correctly.
363cbdda60SSimon J. Gerraty
373cbdda60SSimon J. Gerraty
383cbdda60SSimon J. Gerraty
39*c59c3bf3SSimon J. Gerraty# SPDX-License-Identifier: BSD-2-Clause
40*c59c3bf3SSimon J. Gerraty#
413cbdda60SSimon J. Gerraty# RCSid:
42*c59c3bf3SSimon J. Gerraty#	$Id: target-flags.mk,v 1.11 2024/02/17 17:26:57 sjg Exp $
433cbdda60SSimon J. Gerraty#
443cbdda60SSimon J. Gerraty#	@(#) Copyright (c) 1998-2002, Simon J. Gerraty
453cbdda60SSimon J. Gerraty#
463cbdda60SSimon J. Gerraty#	This file is provided in the hope that it will
473cbdda60SSimon J. Gerraty#	be of use.  There is absolutely NO WARRANTY.
483cbdda60SSimon J. Gerraty#	Permission to copy, redistribute or otherwise
493cbdda60SSimon J. Gerraty#	use this file is hereby granted provided that
503cbdda60SSimon J. Gerraty#	the above copyright notice and this notice are
513cbdda60SSimon J. Gerraty#	left intact.
523cbdda60SSimon J. Gerraty#
533cbdda60SSimon J. Gerraty#	Please send copies of changes and bug-fixes to:
543cbdda60SSimon J. Gerraty#	sjg@crufty.net
553cbdda60SSimon J. Gerraty#
563cbdda60SSimon J. Gerraty
573cbdda60SSimon J. GerratyTARGET_FLAG_VARS?= CFLAGS
583cbdda60SSimon J. Gerraty.for v in ${TARGET_FLAG_VARS}
593cbdda60SSimon J. Gerraty.ifndef _$v
603cbdda60SSimon J. Gerraty_$v := ${$v}
613cbdda60SSimon J. Gerraty$v  =  ${${v}_${.TARGET:T}:U${_$v}}
623cbdda60SSimon J. Gerraty.endif
633cbdda60SSimon J. Gerraty.endfor
643cbdda60SSimon J. Gerraty
65