Using Autoconf With Mktclapp

This article describes one approach for using autoconf to generate configure scripts for projects that use mktclapp. The configure scripts that are generated using this approach have been tested to compile natively on Linux, Windows95 (Cygwin20), SunOS, and HPUX and to cross-compile from Linux to Windows95. The configure script also supports using a build directory that is completely independent of the source directory. The source code can even be on a read-only filesystem, such as a CD-ROM.

This information is provided as a public service, with the hope that it might be useful to someone. There is no warranty as to how well this system works. Nor is there any promise of support.


The image to the right gives an overview of how the scheme described in this article works. The developer must come up with two input files: and The first file, is the M4 script that autoconf uses to generate its configure shell script. There is a template file included with this article that should work in most applications with little or no modification. The is a TCL script that will be used to generate a Makefile for the project. The configure script will make a few modifications to this TCL script before it runs, in order to customize it for the target platform. A template is also included with this article.

After generating the file, the developer then runs GNU Autoconf version 1.13 to generate a configure shell script. The configure shell script becomes part of the source tree. The configure shell script is not considered a build product. It is placed under configuration management just like any other source file.

To build the project, the developer creates a new directory that is separate from the source tree. Suppose the source tree is rooted in a directory named src which is a peer of the build directory which is named bld. To build the project, the developer changes to the bld directory and types:


This command runs the configure script that autoconf generated. The configure script examines the system on which it is running, discovers an appropriate C compiler, compiler options, Tcl/Tk libraries, and BLT libraries, then generates a Makefile and a file named makemake.tcl based on All of these generated files are in the build directory. (Notice that the Makefile is built without a template This is a bit unusual for autoconf, but it is part of the design. Read on...)

After the configure script is run, the developer types:


This command launches the make utility on the Makefile that the configure script generated. This Makefile is very simple. About all it does is run makemake.tcl to generate a new makefile called The make program then calls itself recursively on the newly generated in order to build the project. Note that the project is build in the local directory, not the source directory. Note also that any old version of the make utility will do. GNU make is not required.

Advantages To This Approach

There are, of course, many ways to make use of autoconf. And most other ways are more conventional that the scheme described above. But this approach does have certain advantages.

How To Adapt This Approach To Your Own Project

If you want to try using the build scheme described here, first get a copy of the template. You can find the template at:

You will need to modify this file to suit your application. But the modifications are normally modest. First change the argument of the AC_INIT() macro to be the name of a file in your project's source tree. If your project does not use the BLT extension, then disable the tests for BLT by commenting them out. If your project uses some extensions other than BLT, you may have to add new test to the Use the existing code as your guide.

The contains comments to help you understand how it works. You may also want to refer to the Autoconf manual for information on the Autoconf macros.

The next step is to generate a suitable You can begin with the template at:

The template is really a working file for a specific project. The project is not Open-Source and so the source code is not available. But that is not important. The comments in the template file should give you plenty of guidance on how to adapt the template to your particular project. Remember, you are working with plain ordinary TCL code. The output of the script will become a makefile. Be creative.

The final step is to run autoconf version 1.13 or later to generate the configure script. You can obtain a copy of autoconf from lots of places on the net. Use a search engine to find one near you if you don't already have autoconf installed on your machine.

Parting Words

For additional information, read the template files.

It is important to emphasize that there are many different ways of building a project, and many different ways of using autoconf. You are welcomed to use the approach outlined here if it suits your needs. Hopefully you will find this information helpful. But the techniques described here will not work in every circumstance. You may have to change things. You may have to use a completely different build scheme.

If you fix bugs or make extensions to the template files described above, then patches sent to the author at will be welcomed. Your patches will be gratefully acknowledged and added to the distribution. Reports of bugs without fixes, or requests for new features, may or may not be acknowledged.