Fastmake functions

This document describes the fastmake functions that are fastmake specific (extend GNU make functionality).  Other functions can be found in GNU make documentation.

Summary
Fastmake functionsThis document describes the fastmake functions that are fastmake specific (extend GNU make functionality).
${pwd}Returns current directory.
$(delprefix prefix, list)Removes prefix from each element of a list
$(delsuffix suffix, list)Removes suffix from each element of a list
$(base paths)Takes a list of paths as parameter and returns file names without directory and suffix.
$(mkdir dir)Recursively creates a directory <dir> if it does not exist.
$(make command_line_arguments)This is the main function that makes the fastmake fast and to be in a single process.
$(makedep src_files, out_files, dep_files, include_paths, include_files, enclosure)Searches for dependecies in C/C++ src_files and write them to out_files
$(cp source, destination)Copies source file to destination.
$(rm file_list)Removes each file or directory from a file_list.
$(ls dir, flags[, regex])Enumerates files and/or directories in a specified location.
$(intersect list1 list2)Returns a set intersection of two lists
$(exclude from, what)Takes first argument as a list and removes from it the elements that are in the second argument.
$(replace source, regex, with)Performs replacement in source according to given regular expression with the third argument.
$(ln source, destination)Makes a hard link of source to destination.
$(echo arg[, filename])If filename is not specified prints arg to standart output otherwise writes arg to filename.
$(arith expression)Evaluates simple arithmetic expression
$(cat expression)Prints the content of a specified file to standart output.
$(tolower arg)Converts expanded arg to lower case
$(toupper arg)Converts expanded arg to upper case

${pwd}

Returns current directory.  Fast alternative to `pwd` command

$(delprefix prefix, list)

Removes prefix from each element of a list

Parameters

prefixprefix to remove
lista list of strings

Example

$(delprefix /home/dir/,/home/dir/a.obj /home/dir/b.obj) - returns a.obj b.obj

$(delsuffix suffix, list)

Removes suffix from each element of a list

Parameters

suffixsuffix to remove
lista list of strings

Example

$(delsuffix .obj,a.obj b.obj) - returns a b

$(base paths)

Takes a list of paths as parameter and returns file names without directory and suffix.

Example

$(base somedir/a.cpp somedir/b.cpp) - returns a b

$(mkdir dir)

Recursively creates a directory <dir> if it does not exist.  Fast alternative to `mkdir -p` command

$(make command_line_arguments)

This is the main function that makes the fastmake fast and to be in a single process.  The function emulates recursive running of make by creating a new context and running a logic with this context.  It does not return exit code because it is not needed.  It throws an exception like any other function in a fastmake or exited normaly.  In case of exception fastmake treats the recipe failed as if a command $(MAKE) in GNU make returns exitcode other than 0.

Example

DIRS = $(ls .,d) # enumerate directories in a current directory
all : $(DIRS:+.dir) # add .dir to each dir in DIRS and make 'all' dependent from them
%.dir :; $(make -C $* $(MAKEFLAGS) $(MAKEMACROS)) # dive into each dir with command args that were passed to current 'make'

$(makedep src_files, out_files, dep_files, include_paths, include_files, enclosure)

Searches for dependecies in C/C++ src_files and write them to out_files

Parameters

src_filesa list of files to scan for dependencies.
out_filesa list of output files to put generated dependencies
dep_filesa list of files which will be written as dependent from generated dependecies
include_pathsinclude search paths.  Usualy the same as those passed to -I flag of a compiler
include_filesforced include header files.  The same as those include to -FI (msvc) or -include (gcc)
enclosurea list of symbol pairs for example “” or <> or both <> “”

$(cp source, destination)

Copies source file to destination.  Fast alternative to `cp` command.  If ‘source’ is a directory then performs recursive copying

$(rm file_list)

Removes each file or directory from a file_list.  If some directory is not empty then it is removed recursively.  Fast alternative to `rm -r` command

$(ls dir, flags[, regex])

Enumerates files and/or directories in a specified location.

Parameters

dirwhere to enumerate files and/or directories
flagscan be a combination of flag symbols (f - files, d - directories, r - dive to subdirectories, p - preserve dir in the result)
regexif specified it is used to filter enumerated entries

Example

$(ls .,f,.*\\.cpp) - returns all .cpp files in a current directory

$(intersect list1 list2)

Returns a set intersection of two lists

$(exclude from, what)

Takes first argument as a list and removes from it the elements that are in the second argument.  Returns the result.

Useful example

DIRS := $(exclude $(ls .,d), CVS SCCS) - enumerate directories from current directory and exclude Linus-hated directories

$(replace source, regex, with)

Performs replacement in source according to given regular expression with the third argument.  See boost::regex_replace for details.

$(ln source, destination)

Makes a hard link of source to destination.  Fast alternative of `ln` command

$(echo arg[, filename])

If filename is not specified prints arg to standart output otherwise writes arg to filename.  Fast alternative to `echo` command.

$(arith expression)

Evaluates simple arithmetic expression

Example

all:; @echo $(arith 1+2)prints ‘3’

$(cat expression)

Prints the content of a specified file to standart output.  Fast alternative to `cat` command

Example

all:; $(cat /etc/passwd)

$(tolower arg)

Converts expanded arg to lower case

$(toupper arg)

Converts expanded arg to upper case