15f1e34d9SAlexandre Perrin# NAME: 25f1e34d9SAlexandre Perrin# target-flags.mk - target specific flags 35f1e34d9SAlexandre Perrin# 45f1e34d9SAlexandre Perrin# DESCRIPTION: 55f1e34d9SAlexandre Perrin# Include this macro file after all others in a makefile and 66a91b982SJohn Marino# follow it with any target specific flag settings. 75f1e34d9SAlexandre Perrin# For each such variable v in TARGET_FLAG_VARS we set: 85f1e34d9SAlexandre Perrin#.nf 95f1e34d9SAlexandre Perrin# 105f1e34d9SAlexandre Perrin# _$v := ${$v} 115f1e34d9SAlexandre Perrin# $v = ${${v}_${.TARGET:T}:U${_$v}} 125f1e34d9SAlexandre Perrin#.fi 135f1e34d9SAlexandre Perrin# 145f1e34d9SAlexandre Perrin# This allows one to do things like: 155f1e34d9SAlexandre Perrin#.nf 165f1e34d9SAlexandre Perrin# 175f1e34d9SAlexandre Perrin# TARGET_FLAG_VARS= CFLAGS 185f1e34d9SAlexandre Perrin# .include <target-flags.mk> 195f1e34d9SAlexandre Perrin# CFLAGS_fu.o = ${_CFLAGS:N-Wall} 205f1e34d9SAlexandre Perrin#.fi 215f1e34d9SAlexandre Perrin# 225f1e34d9SAlexandre Perrin# To turn off -Wall for just the target fu.o 235f1e34d9SAlexandre Perrin# Actually CFLAGS is the default value for TARGET_FLAG_VARS. 245f1e34d9SAlexandre Perrin# 255f1e34d9SAlexandre Perrin# BUGS: 265f1e34d9SAlexandre Perrin# One must be careful to avoid creating circular references in 275f1e34d9SAlexandre Perrin# variables. The original version of this macro file did 285f1e34d9SAlexandre Perrin# elaborate things with CFLAGS. The current, simpler 295f1e34d9SAlexandre Perrin# implementation is ultimately more flexible. 305f1e34d9SAlexandre Perrin# 315f1e34d9SAlexandre Perrin# It is important that target-flags.mk is included after other 325f1e34d9SAlexandre Perrin# macro files and that target specific flags that may reference 335f1e34d9SAlexandre Perrin# _$v are set after that. 345f1e34d9SAlexandre Perrin# 355f1e34d9SAlexandre Perrin# Only works with a make(1) that does nested evaluation correctly. 365f1e34d9SAlexandre Perrin 375f1e34d9SAlexandre Perrin 385f1e34d9SAlexandre Perrin 395f1e34d9SAlexandre Perrin# RCSid: 40*a34d5fb1SAntonio Huete Jimenez# $Id: target-flags.mk,v 1.10 2020/08/19 17:51:53 sjg Exp $ 415f1e34d9SAlexandre Perrin# 425f1e34d9SAlexandre Perrin# @(#) Copyright (c) 1998-2002, Simon J. Gerraty 435f1e34d9SAlexandre Perrin# 445f1e34d9SAlexandre Perrin# This file is provided in the hope that it will 455f1e34d9SAlexandre Perrin# be of use. There is absolutely NO WARRANTY. 465f1e34d9SAlexandre Perrin# Permission to copy, redistribute or otherwise 475f1e34d9SAlexandre Perrin# use this file is hereby granted provided that 485f1e34d9SAlexandre Perrin# the above copyright notice and this notice are 495f1e34d9SAlexandre Perrin# left intact. 505f1e34d9SAlexandre Perrin# 515f1e34d9SAlexandre Perrin# Please send copies of changes and bug-fixes to: 525f1e34d9SAlexandre Perrin# sjg@crufty.net 535f1e34d9SAlexandre Perrin# 545f1e34d9SAlexandre Perrin 555f1e34d9SAlexandre PerrinTARGET_FLAG_VARS?= CFLAGS 565f1e34d9SAlexandre Perrin.for v in ${TARGET_FLAG_VARS} 575f1e34d9SAlexandre Perrin.ifndef _$v 585f1e34d9SAlexandre Perrin_$v := ${$v} 595f1e34d9SAlexandre Perrin$v = ${${v}_${.TARGET:T}:U${_$v}} 605f1e34d9SAlexandre Perrin.endif 615f1e34d9SAlexandre Perrin.endfor 625f1e34d9SAlexandre Perrin 63