Item 7: Emulating Autoconf Text Replacement Techniques

Say your project builds a daemon that is configured at startup with values in a configuration text file. How does the daemon know where to find this file on start up? One way is to simply assume it's located in /etc, but a well-written program will allow the user to configure this location when building the software. The system configuration directory has a variable location whose value can be specified on the configure, make all, or make install command lines, as shown in the following examples:

$ ./configure sysconfdir=/etc
...
$ make all sysconfdir=/usr/mypkg/etc
...
$ sudo make install sysconfdir=/usr/local/mypkg/etc
...

All of these examples take advantage of command-line functionality ...

Get Autotools now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.