Search code examples
unixmakefilebsd

${_+_} in a BSD Makefile


I've found ${_+_} in the FreeBSD Makefile.

What is the meaning of ${_+_} in BSD Makefiles?


Solution

  • ${_+_} refers to a variable. It is defined in share/mk/sys.mk which gets read by the make process. So user Zack pointed to the right direction in his comment; this variable expands to a + sign in some cases, depending on the flags given to make:

    .if !empty(.MAKEFLAGS:M-n) && ${.MAKEFLAGS:M-n} == "-n"
    _+_     ?=
    .else
    _+_     ?=  +
    .endif
    

    The rationale for this can be found in the comment for this commit and this one, where the symbol was introduced:

    Make make recurse into sub-directories and sub-makes when given
    two -n flags.  If only one -n flag is given the old behaviour
    is retained (POLA).