Before we had pkg-config: The -config script
You might see this method in older libraries, but I can't think of any reason why you wouldn't want to use pkg-config, as described here.
something-config script
Your library should install a script file in the bin directory that reports where the library is and how to link to it. These scripts are always very similar so you can use a generic script into which autoconf can substitute your libraries' name.
For instance, the libsomething distribution might contain a something-config.in file. Your configure.in file will mention this in it's AC_OUTPUT macro. For instance:
AC_OUTPUT( Makefile \ something/Makefile \ something/sub/Makefile \ something-config )Notice that we list the name of the generated file. Autoconf knows that it should look for a file with the .in added to this name. Autoconf will create a new file called 'something-config'.
If you add the following line to your top-level Makefile,am then this file will be installed to the 'bin' directory when the user types 'make install'.
bin_SCRIPTS = something-configAM_PATH_SOMETHING
The config script helps, but you can make life even easier for users by installing an m4 macro which can be used in configure.in files. This macro will attempt to call the *-config script, check that the correct version of the library is installed, and set the appropriate automake variables. It may also attempt to compile a sample that uses the library.
This is the most complicated part of your library's project files. I suggest that you download the example and do a search and replace of the library name. So far I have not been able to generate this file automatically like the something-config script.
You will need to add the following lines to your top-level Makefile.am to ensure that the m4 macro is installed in share/aclocal/
m4datadir = $(datadir)/aclocal m4data_DATA = something.m4Also, don't forget to add this line to ensure that the macro is include when you type 'make dist':
EXTRA_DIST = something.m4
Read Using C/C++ libraries with automake and autoconf to see how this macro would be used.
Copyright © Murray Cumming, Openismus GmbH.

This work is licensed under a Creative Commons License.
