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
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

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




Back: Autoconf Preliminaries
Forward: Guidelines for writing macros
FastBack: Guidelines for writing macros
Up: Writing New Macros for Autoconf
FastForward: Migrating Existing Packages
Top: Autoconf, Automake, and Libtool
Contents: Table of Contents
Index: Index
About: About this document

23.2 Reusing Existing Macros

It goes without saying that it makes sense to reuse macros where possible--indeed, a search of the Autoconf macro archive might turn up a macro which does exactly what you want, alleviating the need to write a macro at all (see section 23.5.1 Autoconf macro archive).

It's more likely, though, that there will be generic, parameterized tests available that you can use to help you get your job done. Autoconf"s `generic' tests provide one such collection of macros. A macro that wants to test for support of a new language keyword, for example, should rely on the AC_TRY_COMPILE macro. This macro can be used to attempt to compile a small program and detect a failure due to, say, a syntax error.

In any case, it is good practice when reusing macros to adhere to their publicized interface--do not rely on implementation details such as shell variables used to record the test's result unless this is explicitly mentioned as part of the macro's behavior. Macros in the Autoconf core can, and do, change their implementation from time to time.

Reusing a macro does not imply that the macro is necessarily invoked from within the definition of your macro. Sometimes you might just want to rely on some action performed by a macro earlier in the configuration run--this is still a form of reuse. In these cases, it is necessary to ensure that this macro has indeed run at least once before your macro is invoked. It is possible to state such a dependency by invoking the AC_REQUIRE macro at the beginning of your macro's definition.

Should you need to write a macro from scratch, the following sections will provide guidelines for writing better macros.

This document was generated by Gary V. Vaughan on February, 8 2006 using texi2html

  Published under the terms of the Open Publication License Design by Interspire