Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

9.1 Macro Definitions

Autoconf macros are defined using the AC_DEFUN macro, which is similar to the M4 builtin m4_define macro. In addition to defining a macro, AC_DEFUN adds to it some code that is used to constrain the order in which macros are called (see Prerequisite Macros).

An Autoconf macro definition looks like this:

     AC_DEFUN(macro-name, macro-body)

You can refer to any arguments passed to the macro as ‘$1’, ‘$2’, etc. See How to define new macros, for more complete information on writing M4 macros.

Be sure to properly quote both the macro-body and the macro-name to avoid any problems if the macro happens to have been previously defined.

Each macro should have a header comment that gives its prototype, and a brief description. When arguments have default values, display them in the prototype. For example:

     # AC_MSG_ERROR(ERROR, [EXIT-STATUS = 1])
     # --------------------------------------
     m4_define([AC_MSG_ERROR],
       [{ AS_MESSAGE([error: $1], [2])
          exit m4_default([$2], [1]); }])

Comments about the macro should be left in the header comment. Most other comments make their way into configure, so just keep using ‘#’ to introduce comments.

If you have some special comments about pure M4 code, comments that make no sense in configure and in the header comment, then use the builtin dnl: it causes M4 to discard the text through the next newline.

Keep in mind that dnl is rarely needed to introduce comments; dnl is more useful to get rid of the newlines following macros that produce no output, such as AC_REQUIRE.


 
 
  Published under the terms of the GNU General Public License Design by Interspire