Introduction
One of autotools’ primary purposes is to allow software to be built and installed on a wide range of platforms. The configure script is responsible for a great deal of this flexibility. When it is run, it interrogates the system on which it is being run to determine the features available. If required features are missing, the script can do any number of things, including but not limited to:
- reporting a problem and bailing out
- trying an alternate approach
- attempting to fetch the missing software and continuing/aborting depending on the outcome
- recommending that the person running the configure script install the required bits
- mocking the user
In this post, I will note a few of the variables that can be used to determine the configuration of the system.
Return to the workplace
$ cd ~/src/greeting
Modify configure.ac to report some findings
$ patch configure.ac
--- configure.ac.orig 2009-03-20 14:49:16.000000000 -0700 +++ configure.ac 2009-03-20 14:46:16.000000000 -0700 @@ -1,5 +1,11 @@ AC_INIT([greeting],[0.0.1]) AM_INIT_AUTOMAKE([1.9 tar-ustar]) + +AC_PATH_PROG(RUNTIME, mono, no) +if test "x$RUNTIME" = "x" ; then + AC_MSG_ERROR([Can't find "mono" in your PATH]) +fi + AC_PATH_PROG(CSC, gmcs, no) if test "x$CSC" = "x" ; then AC_MSG_ERROR([Can't find "gmcs" in your PATH]) @@ -8,3 +14,12 @@ Makefile ]) AC_OUTPUT + +echo "=================" +echo "" +echo "Thank you for configuring '$PACKAGE_NAME' version '$PACKAGE_VERSION'" +echo "Runtime: $RUNTIME" +echo "C# compiler: $CSC" +echo "installation prefix: $prefix" +echo "" +echo "=================" ^D^D
Re-run configure to see results
$ autoconf && ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking how to create a ustar tar archive... gnutar
checking for mono... /usr/bin/mono
checking for gmcs... /usr/bin/gmcs
configure: creating ./config.status
config.status: creating Makefile
=================
Thank you for configuring 'greeting' version '0.0.1'
Runtime: /usr/bin/mono
C# compiler: /usr/bin/gmcs
installation prefix: /usr/local
=================
Conclusion
One of the primary reasons that autotools is so powerful is that it can figure out what’s on your system and use it to build the software in the package. In following posts, we will make use of some of these system configuration variables.