Variables

Variables are actually wrongly named "variable", as they are really constants, but everybody always calls them variables, so here they shall be called variables, as well.

SRCEXTS = c h
OBJEXTS = o obj
EXTS = $(SRCEXTS) $(OBJEXTS)

Scopes

Variable definitions may be scoped. These are not visible outside the scope of the enclosing target, project or template.

program prog {
   VARIABLE = a b c d
}

Line continuations

Variable definitions may span multiple lines. The line continues as long as the indentation level is higher than the variable definition.

VARIABLE = some values
   the values
      continue
   until here
   OTHERVAR = this line is still part of
   the variable definition
OTHERVAR = this is a new variable definition

Expansion

Variables are not expanded unless they really have to be. Eager contexts include sources and link sections and rules. Variables are not expanded in other variable definitions, but are recursively expanded if the defined variable is expanded in an eager context. Variables are not expanded in rule bodies.

Pseudo-variables

Pseudo-variables can be used to query declarations or to call functions on data.

program prog {
   sources {
      ...
   }
   link {
      mylib1
      mylib2
      -lm
   }
}

PROGLINK = $(prog.link)
# filter by locally built libraries
PROGLIBS = $(prog.link:library)

The above filter syntax can be used to filter out system libraries such as, in this example, -lm. Thus, the PROGLIBS variable would be expanded to mylib1 mylib2, $(PROGLINK) would also include -lm. This may be useful in rules.

This filter syntax cannot be used to filter arbitrary text. It only works on pseudo-variables such as $(mytarget.link).