Panotools::Makefile::Utils - Makefile syntax


Simple interface for generating Makefile syntax


Writing Makefiles directly from perl scripts with print and "\t" etc... is prone to error, this library provides a simple perl interface for assembling Makefile rules.

See Panotools::Makefile::Rule and Panotools::Makefile::Variable for object classes that you can use to contruct makefiles.


Access the current platform name (MSWin32, linux, etc...):

  print platform;

Define a different platform and access the new name:

  platform ('MSWin32');
  print platform;

Reset platform to default:

  platform (undef);

Take a text string (typically a single filename or path) and quote/escape spaces and special characters to make it suitable for use as a Makefile 'target' or 'prerequisite':

  $escaped_target = quotetarget ('My Filename.txt');
  $escaped_prerequisite = quoteprerequisite ('My Filename.txt');

Note that the =;:% characters are not usable as filenames, they may be used as control characters in a target or prerequisite. An exception is the : in Windows paths such as C:\WINDOWS which is understood by gnu make.

* and ? are wildcards and will be expanded. You may find that it is possible to use these as actual characters in filenames, but this assumption will lead to subtle errors.

$ can be used in a filename, but when used with brackets, ${FOO} or $(BAR), will be substituted as a make variable.

Targets starting with . are special make targets and not usable as filenames, the workaround is to supply a full path instead of a relative path. i.e: /foo/bar/.hugin rather than .hugin

Additionally the ?<>*|"^\ characters are not portable across filesystems (e.g. USB sticks, CDs, Windows) and should be avoided in filenames.

Take a text string, typically a command-line token, and quote/escape spaces and special characters to make it suitable for use in a Makefile command:

  $escaped_token = quoteshell ('Hello World');