21.5.1 Syntactic conventions

back: writing macros within the gnu autotools framework
forward: debugging with m4
 
fastback: m4
up: writing macros within the gnu autotools framework
fastforward: writing portable bourne shell
top: autoconf, automake, and libtool
contents: table of contents
index: index
about: about this document

Some conventions have grown over the life of the GNU Autotools, mostly as a disciplined way of avoiding M4 pitfalls. These conventions are designed to make your macros more robust, your code easier to read and, most importantly, improve your chances for getting things to work the first time! A brief list of recommended conventions appears below:

  • Do not use the M4 built-in changequote . Any good macro will already perform sufficient quoting.
  • Never use the argument macros (e.g. `$1' ) within shell comments and dnl remarks. If such a comment were to be placed within a macro definition, M4 will expand the argument macros leading to strange results. Instead, quote the argument number to prevent unwanted expansion. For instance, you would use `$[1]' in the comment.
  • Quote the M4 comment character, `#' . This can appear often in shell code fragments and can have undesirable effects if M4 ignores any expansions in the text between the `#' and the next newline.
  • In general, macros invoked from `configure.in' should be placed one per line. Many of the GNU Autotools macros conclude their definitions with a dnl to prevent unwanted whitespace from accumulating in `configure' .
  • Many of the AC_ macros, and others which emulate their good behavior, permit default values for unspecified arguments. It is considered good style to explicitly show your intention to use an empty argument by using a pair of quotes, such as [] .
  • Always quote the names of macros used within the definitions of other macros.
  • When writing new macros, generate a small `configure.in' that uses (and abuses !) the macro--particularly with respect to quoting. Generate a `configure' script with autoconf and inspect the results.

This document was generated by Gary V. Vaughan on May, 24 2001 using texi2html


GNU Autoconf, Automake and Libtool
GNU Autoconf, Automake, and Libtool
ISBN: 1578701902
EAN: 2147483647
Year: 2002
Pages: 290

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net