1# $NetBSD: directive-include.mk,v 1.7 2021/12/03 22:48:07 rillig Exp $ 2# 3# Tests for the .include directive, which includes another file. 4 5# TODO: Implementation 6 7.MAKEFLAGS: -dc 8 9# All included files are recorded in the variable .MAKE.MAKEFILES. 10# In this test, only the basenames of the files are compared since 11# the directories can differ. 12.include "/dev/null" 13.if ${.MAKE.MAKEFILES:T} != "${.PARSEFILE} null" 14. error 15.endif 16 17# Each file is recorded only once in the variable .MAKE.MAKEFILES. 18# Between 2015-11-26 and 2020-10-31, the very last file could be repeated, 19# due to an off-by-one bug in ParseTrackInput. 20.include "/dev/null" 21.if ${.MAKE.MAKEFILES:T} != "${.PARSEFILE} null" 22. error 23.endif 24 25.include "nonexistent.mk" 26.include "/dev/null" # size 0 27# including a directory technically succeeds, but shouldn't. 28#.include "." # directory 29 30# As of 2020-11-21, anything after the delimiter '"' is ignored. 31.include "/dev/null" and ignore anything in the rest of the line. 32 33# The filename to be included can contain expressions. 34DEV= null 35.include "/dev/${DEV}" 36 37# Expressions in double quotes or angle quotes are first parsed naively, to 38# find the closing '"'. In a second step, the expressions are expanded. This 39# means that the expressions cannot include the characters '"' or '>'. This 40# restriction is not practically relevant since the expressions inside 41# '.include' directives are typically kept as simple as possible. 42# 43# If the whole line were expanded before parsing, the filename to be included 44# would be empty, and the closing '"' would be in the trailing part of the 45# line, which is ignored as of 2021-12-03. 46DQUOT= " 47.include "${DQUOT}" 48 49# When the expression in a filename cannot be evaluated, the failing 50# expression is skipped and the file is included nevertheless. 51# FIXME: Add proper error handling, no file must be included here. 52.include "nonexistent${:U123:Z}.mk" 53 54all: 55