1. autoconf - automake
  2. Automake
    1. Makefile.am
    2. Compile time dependencies
  3. Autoconf
    1. Configure.in
    2. Checking for eggs
  4. Preparing things

autoconf - automake

the best thing ever! This explains how Autoconf and Automake should be used to build a package with CHICKEN Scheme that conforms to the GNU Coding Standards. We will assume your program is the one for the second example of the Using the compiler section of the User's Manual.

Note: This is just a draft, I expect to improve it in the future.

Automake

Makefile.am

Your Makefile.am should contain a list of the programs that make up your package and their sources, as well as some additional rules explaining how to compile .scm files:

# A list of the programs we want to build:
bin_PROGRAMS = foo

# The sources for each program we define:
foo_SOURCES = foo.scm bar.scm

# The following line causes autoconf to become aware of the fact that .scm
# files in the *_SOURCES lists should not be ignored:
.scm.o:
# Specify the extension of our object files:
OBJEXT=o
# Specify how to link object files:
LINK=csc -o $@

# The following lines defines a rule for GNU Make explaining how to build a
# .o file from its associated .scm file:
%.o: %.scm
        csc -c $< -o $@ $(CHICKENFLAGS)

Compile time dependencies

If all your .scm files depend at compile time on some other files (which usually happens when you define macros), you'll want to define their dependency. To do that, change %.o: %.scm in your Makefile.am to %.o: %.scm macros.scm, where macros.scm is your compile-time dependency (you could include more than once).

If just a few of your .scm files depend at compile time on other files, you can just state the dependencies. For example:

foo.o: macros.scm

This reads as foo.o should be rebuilt whenever macros.scm changes. You can, of course, include multiple of the above kind of lines and you can also include multiple dependencies in one single line.

Autoconf

Configure.in

The following should be the contents of your configure.in template:

dnl Process this file with autoconf to produce a configure script.
dnl Use the name of an existing source file for your program here:
AC_INIT(foo.scm)

dnl Use the name and version of your package (which doesn't have to match
dnl the names of your executables):
AM_INIT_AUTOMAKE(foo, 1.0)

AC_PREREQ(2.12)

dnl Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET

dnl Test for presence of csc (we should probably bail out with error if
dnl we fail to find it):
AC_CHECK_PROG(CSC, csc, YES)

AC_CHECK_PROG(CHICKEN, chicken, YES)

dnl Use here any special flags you require.  For example, if you want
dnl R5RS macros, use "-require-extension syntax-case"
AC_SUBST(CHICKENFLAGS,"")

AC_OUTPUT(Makefile)

Checking for eggs

TODO: We should write some code that tests for the presence of an egg and, if not found, asks the user to install it and bails out.

Preparing things

Make sure to create the following files:

Then run (TODO: I still need to verify this is the correct order):

$ automake -a
$ aclocal
$ autoconf

It is ok for automake to print some warnings as it creates some missing files.

Voila, your package should be ready. At this point you can use ./configure with its standard parameters such as --prefix. You can also use make dist to prepare a tarball with your package.