Makefile file name function
This is from gnu.org.
Functions for File Names
$(dir names…)
Extracts the directory-part of each file name in names.
$(dir src/foo.c hacks)
result : ‘src/ ./’
$(notdir names…)
Extracts all but the directory-part of each file name in names.
$(notdir src/foo.c hacks)
result : ‘foo.c hacks’
$(suffix names…)
Extracts the suffix of each file name in names.
$(suffix src/foo.c src-1.0/bar.c hacks)
result : ‘.c .c’.
$(basename names…)
Extracts all but the suffix of each file name in names,
$(basename src/foo.c src-1.0/bar hacks)
result : ‘src/foo src-1.0/bar hacks)
$(addsuffix suffix, names…)
The argument names is regarded as a series of names, separated by whitespace;
$(addsuffix .c, foo bor)
result : ‘foo.c bar.c’.
$(addprefix prefix, names…)
The argument naems is regarded as a series of names, separated by whitespace;
$(addprefix src/, foo bar)
result : ‘src/foo src/bar’
$(join list, list2)
Concatenates the two arguments word by word: the two first words (one from each argument)
concatednated form the first word of the result, the two seconde words from the second word of the result, and so on.
$(join a b,.c .o)
result : ‘a.c b.o’
$(wildcard pattern
The argument pattern is a file name pattern, typically containing wildcard characters (as in shell file name patterns).
example 1
clean :
rm -f *.o
example 2
print: *.c
lpr -p $?
touch print
example 3
objects = *.o
objects contains ‘.o’ not all object files.
example 4
objects := $(wildcard *.o)
objects contains all object files.
$(realpath names…)
For each file name in names return the canonical absolute name. A canonical name does not contain any
. or .. components, nor any repeated path separators (/) or symlinks.
$(abspath names…)
For each file name in names return an absoulte name that does not contain any . or .. components, nor
any repeated path separators (/).