In these exercises you learn to make portable source code packages
using autoconf by producing configuration scripts for the interpreter
Note: for help about Autoconf and Automake, look up
in the Gnome browser.
Since Autoconf is a macro language for Unix shell code, you may also
need help about the shell:
A simple example of the use of autoconf is provided in the following package:
Unpack and build it using the following commands:
gtar zxf hello-3.0.tar.gz
Study the files in the package to see how autoconf is used.
Note the following in Makefile.in
- Parameters for filesystem layout (prefix, bindir, ...)
- Parameters for versioning (VERSION, RPMRELEASE)
- The files that should be distributed (DISTFILES)
- targets for building the code (hello)
- targets for deployment (install, uninstall, dist, rpm, ...)
- targets for deriving the Makefile from Makefile.in
Note that the configure.in file defines
- the versioning parameters
- the files to be built by configure: Makefile and hello.spec
Note that hello.spec is a generic RPM spec file. The list of files
does not specify any files, but only directories, i.e., all files in
those directories are included in the rpm. Since the build
is done in a buildroot this is safe.
- Derive a Makefile.in from your Makefile in which you
abstract from any platform specificities, such as installation
directories. Be sure to support the following targets:
- Write a configure.in that generates a Makefile from the
Makefile.in and tests for availability of programs such as
YACC and LEX.
- In the file
abstract.c you can find the following
Note: please rename
HAVE_LIBGC; that will interact better with Autoconf. You should also add a line
to the top of
abstract.c so that the
config.h file created by
configure actually gets used.
In other words, the interpreter will use the Boehm garbage collector for memory allocation if the variable
HAVE_LIBGC is defined, otherwise it will use the C
malloc. This is the kind of
environment dependency that can be resolved using Autoconf.
AC_CHECK_LIB macro, check whether the
gc is available. If it exists, enable the
HAVE_LIBGC variable in
config.h and add
-lgc to the
LIBS makefile variable. Figure out what Autoconf macro does this for you/
To test your
configure script, run it normally (in which case it won't be able to find the library). A copy of the GC library has been installed in
/praktikum/se/nix/Linux/current/lib, so you can allow
configure to find the library as follows:
LDFLAGS="-L /praktikum/se/nix/Linux/current/lib -lpthread" ./configure
Make sure that the
LDFLAGS variable (additional linker flags) gets passed to the linker in your Makefile.
- For building RPMs include an
interpreter.spec.in file in the package, which is instantiated by
interpreter.spec with package name and version. Provide a
make rpm target that builds an RPM from a distribution.
- 16 Sep 2003
- 18 Nov 2002