freebsd-src/unit-tests/varcmd.mk
Simon J. Gerraty 2358deb654 Import bmake-20180222
From ChangeLog

* VERSION: 20180222
  Merge with NetBSD make, pick up
  o parse.c: avoid calling sysconf for every call to loadfile

* VERSION: 20180218
  Merge with NetBSD make, pick up
  o var.c: Var_Set handle NULL value anytime.

* VERSION: 20180212
  Merge with NetBSD make, pick up
  o parse.c: do not treat .info as warning with -W

* VERSION: 20171207
  Merge with NetBSD make, pick up
  o var.c: Var_Append use Var_Set if var not previously set
    so that VAR_CMD is handled correctly.
    Add a suitable unit-test.

* VERSION: 20171126

* aclocal.m4: use AC_LINK_IFELSE for AC_C___ATTRIBUTE__
  since AC_TRY_COMPILE puts input inside main()
  which upsets modern compilers.

* VERSION: 20171118
  Merge with NetBSD make, pick up
  o var.c: do not append to variable set on command line
    add unit-test to catch this.
2018-03-01 23:45:44 +00:00

61 lines
892 B
Makefile

# $Id: varcmd.mk,v 1.1.1.3 2017/12/08 03:37:54 sjg Exp $
#
# Test behaviour of recursive make and vars set on command line.
FU=fu
FOO?=foo
.if !empty(.TARGETS)
TAG=${.TARGETS}
.endif
TAG?=default
all: one
show:
@echo "${TAG} FU=<v>${FU}</v> FOO=<v>${FOO}</v> VAR=<v>${VAR}</v>"
one: show
@${.MAKE} -f ${MAKEFILE} FU=bar FOO+=goo two
two: show
@${.MAKE} -f ${MAKEFILE} three
three: show
@${.MAKE} -f ${MAKEFILE} four
.ifmake two
# this should not work
FU+= oops
FOO+= oops
_FU:= ${FU}
_FOO:= ${FOO}
two: immutable
immutable:
@echo "$@ FU='${_FU}'"
@echo "$@ FOO='${_FOO}'"
.endif
.ifmake four
VAR=Internal
.MAKEOVERRIDES+= VAR
.endif
four: show
@${.MAKE} -f ${MAKEFILE} five
M = x
V.y = is y
V.x = is x
V := ${V.$M}
K := ${V}
show-v:
@echo '${TAG} v=${V} k=${K}'
five: show show-v
@${.MAKE} -f ${MAKEFILE} M=y six
six: show-v
@${.MAKE} -f ${MAKEFILE} V=override show-v