2c3632d14f
Lots of code refactoring, simplification and cleanup. Lots of new unit-tests providing much higher code coverage. All courtesy of rillig at netbsd. Other significant changes: o new read-only variable .SHELL which provides the path of the shell used to run scripts (as defined by the .SHELL target). o variable parsing detects more errors. o new debug option -dl: LINT mode, does the equivalent of := for all variable assignments so that file and line number are reported for variable parse errors.
43 lines
996 B
Makefile
43 lines
996 B
Makefile
# $NetBSD: envfirst.mk,v 1.2 2020/07/27 18:57:42 rillig Exp $
|
|
#
|
|
# The -e option makes environment variables stronger than global variables.
|
|
|
|
.if ${FROM_ENV} != value-from-env
|
|
.error ${FROM_ENV}
|
|
.endif
|
|
|
|
# Try to override the variable; this does not have any effect.
|
|
FROM_ENV= value-from-mk
|
|
.if ${FROM_ENV} != value-from-env
|
|
.error ${FROM_ENV}
|
|
.endif
|
|
|
|
# Try to append to the variable; this also doesn't have any effect.
|
|
FROM_ENV+= appended
|
|
.if ${FROM_ENV} != value-from-env
|
|
.error ${FROM_ENV}
|
|
.endif
|
|
|
|
# The default assignment also cannot change the variable.
|
|
FROM_ENV?= default
|
|
.if ${FROM_ENV} != value-from-env
|
|
.error ${FROM_ENV}
|
|
.endif
|
|
|
|
# Neither can the assignment modifiers.
|
|
.if ${FROM_ENV::=from-condition}
|
|
.endif
|
|
.if ${FROM_ENV} != value-from-env
|
|
.error ${FROM_ENV}
|
|
.endif
|
|
|
|
# Even .undef doesn't work since it only affects the global context,
|
|
# which is independent from the environment variables.
|
|
.undef FROM_ENV
|
|
.if ${FROM_ENV} != value-from-env
|
|
.error ${FROM_ENV}
|
|
.endif
|
|
|
|
all:
|
|
@: nothing
|