NAME

Makefile -- an object that parses makefiles and stores their relevant info

USAGE

$makefile = Makefile::load('filename_or_dir_name');
$makefile = Makefile::load($fileinfo_or_dirinfo);

$makefile->expand_text('$(STRING) $(WITH) $(MAKE) $(VARIABLES) $(OR FUNCTIONS)');

DESCRIPTION

The Makefile package is responsible for parsing a makefile, and subsequently for holding all relevant information from the makefile, such as variable definitions.

A new Makefile class may be created at any time, whenever you discover that it is available. The Makefile constructor parses the makefile, and integrates all of its rules into the makepp's memory database.

expand_text($makefile, 'string', $makefile_line)

  my $expanded_string = $makefile->expand_text('string with make variables',
					       $makefile_line);

Expands all the make variables and expressions in the text and returns the result. If an error occurs, die's with the error message prefixed by $makefile_line.

cleanup_vars

Remove undefined variables from the environment and the command line. Such variables come into existence when perl looks for them, but they need to be ignored for comparing and/or setting them.

cd

Change to the makefile's directory. A synonym of $self->{CWD}->chdir, but you don't have to know about the existence of $self->{CWD}, which is supposedly a private implementation detail.

$makefile->setup_environment()

Sets %ENV. No mechanism for restoring the previous environment is provided. This might do other similar things (e.g. set the umask) in the future.

load('makefile', $default_dir, $command_line_vars, $makecmdgoals, $include_path, $environment, $makeppfile_only)

Makes a new makefile object. The argument is the makefile to load, or else a directory that may contain the makefile. Exits with die if no such makefile exists, or if there is a fatal parse error. Otherwise, returns the Makefile object.

If you do not specify the default directory, then directory containing the makefile is assumed.

If the makefile has already been loaded, then this does not reload the makefile; it returns the old makefile object.

$command_line_vars is a reference to a hash containing the names and values of all variables which were specified on the command line.

$makecmdgoals is the value of $(MAKECMDGOALS) for this makefile.

include_path is an array of FileInfo structures for directories that the include statement should search.

$environment is a hash containing the environment for this particular makefile.

$makeppfile_only is a flag that says only to look for a file called Makeppfile and not makefile or Makefile. This is used to avoid doing implicit loads on subdirectories controlled by make (see the --implicit-load-Makeppfile-only option).

If there is a target in the Makefile for the Makefile itself, the makefile is remade and then reread. Makefile::load does not return until the makefile has been rebuilt.