|
GNU Autoconf, Automake and Libtool Authors: Vaughan G.V., Ellison B., Taylor I.L. Published year: 2002 Pages: 49-51/290 |
|
9. A Small GNU Autotools ProjectThis chapter introduces a small--but real--worked example, to illustrate some of the features, and highlight some of the pitfalls, of the GNU Autotools discussed so far. All of the source can be downloaded from the book's web page(5). The text is peppered with my own pet ideas, accumulated over a several years of working with the GNU Autotools and you should be able to easily apply these to your own projects. I will begin by describing some of the choices and problems I encountered during the early stages of the development of this project. Then by way of illustration of the issues covered, move on to showing you a general infrastructure that I use as the basis for all of my own projects, followed by the specifics of the implementation of a portable command line shell library. This chapter then finishes with a sample shell application that uses that library. Later, in 12. A Large GNU Autotools Project and 20. A Complex GNU Autotools Project, the example introduced here will be gradually expanded as new features of GNU Autotools are revealed. |
|
9.1 GNU Autotools in PracticeThis section details some of the specific problems I encountered when starting this project, and is representative of the sorts of things you are likely to want to do in projects of your own, but for which the correct solution may not be immediately evident. You can always refer back to this section for some inspiration if you come across similar situations. I will talk about some of the decisions I made about the structure of the project, and also the trade-offs for the other side of the argument -- you might find the opposite choice to theone I make here is more relevant a particular project of yours. |
|
9.1.1 Project Directory StructureBefore starting to write code for any project, you need to decide on the directory structure you will use to organise the code. I like to build each component of a project in its own subdirectory, and to keep the configuration sources separate from the source code. The great majority of GNU projects I have seen use a similar method, so adopting it yourself will likely make your project more familiar to your developers by association. The top level directory is used for configuration files, such as `configure' and ` aclocal .m4' , and for a few other sundry files, `README' and a copy of the project license for example. Any significant libraries will have a subdirectory of their own, containing all of the sources and headers for that library along with a `Makefile.am' and anything else that is specific to just that library. Libraries that are part of a small like group , a set of pluggable application modules for example, are kept together in a single directory. The sources and headers for the project's main application will be stored in yet another subdirectory, traditionally named `src' . There are other conventional directories your developers might expect too: A `doc' directory for project documentation; and a `test' directory for the project self test suite.
To keep the project top-level directory as uncluttered as possible, as I like to do, you can take advantage of Autoconf's
`AC_CONFIG_AUX_DIR'
by creating another durectory, say
`config'
, which will be used to store many of the GNU Autotools intermediate files, such as
So, this is what you should start with:
|
|
GNU Autoconf, Automake and Libtool Authors: Vaughan G.V., Ellison B., Taylor I.L. Published year: 2002 Pages: 49-51/290 |