Red Antigua Logo
Yet another piece of web.
Ads by Goooooogle
Search this site (by Google)
Tools    (top)
Your IP
Check a site for broken links
(W3C)

Perl modules    (top)
Tree::Numbered::Tools
(CPAN)
Perl tutorials    (top)
Perl modules
HTML::Template
CGI::Application
Mail::POP3Client
Mail::Send
MIME::Tools
Cookies with CGI::Application
Upload files with CGI::Application
Download files with CGI::Application
Redirect with CGI::Application
CPAN shell
Install DBD::mysql from the CPAN shell
Perl trim function
Validate an IP with Perl
Run suid Perl scripts under Apache
Perl taint mode
Perl date functions with Date::Calc

In Spanish
Curso de Perl

C tutorials    (top)
C - Introduction
C - Absolute beginner's Emacs
C - Examples for beginners
C - Makefile examples
C - Autotools examples
Server configurations    (top)
DNS
Apache
Apache Authentication and Access Control
mod_perl on FreeBSD
MySQL
MySQL add account
phpMyAdmin
Squid
DHCP

UNIX on Windows    (top)
Apache setup on Windows
MySQL setup on Windows
PHP setup on Windows
Perl setup on Windows
Emacs setup on Windows
UnxUtils
PuTTY
WinSCP
GIMP on Windows
MinGW - gcc on Windows
MSYS - UNIX-styled shell on Windows
msysDTK - autotools on Windows
GDB for MinGW on Windows

Misc. FreeBSD/UNIX    (top)
CD and DVD creation on FreeBSD using 'k3b' on FreeBSD
'portupgrade' on FreeBSD
'ipf' on FreeBSD
'pf' on FreeBSD
'su' on FreeBSD
Mount an ISO image under FreeBSD
Load the correct sound driver under FreeBSD without knowing what sound card you are using
Simultaneous sound channels on FreeBSD
FreeBSD network stuff
DOS-to-UNIX file conversion
favicon.ico on UNIX
Emacs tips
Sendmail tips
GKrellm
Command Line Calculator
Save multimedia streams with 'mplayer'
xargs - solution to 'Argument list too long'
Process multiple images from the command line using 'ImageMagick'
Turn the system bell off under X Windows
Process each line in an input file from the command line (or in a shell script)
How to keep a program running in the background using 'nohup'
How to remove symbolic links in the current directory using 'find' and 'rm'
How to remove Emacs backup files in the current directory and all subdirectories using 'find' and 'rm'
How to execute .profile without logging in
Configure X to handle non-English characters
How to move /var to /usr/var

Redirect a web page    (top)
Redirect to another web page
Apache redirect
C redirect
Perl redirect
PHP redirect
HTML redirect
JavaScript redirect

Javascript    (top)
Trim function
Login form
Register form
Popup window

Virus list    (top)
Latest 10 viruses - Sophos

Off topic    (top)
Personal home links

autoconf: use autoscan to create configure.ac
autoconf: use autoscan to create configure.ac
IndexPreviousNext
The previous example showed an example of a hand-crafted layout template for configure.ac.
The layout template can be created automatically by another autotool, autoscan.
Just type the following in an empty directory:
autoscan
You should now have 2 files in the current directory:
$ ls
autoscan.log  configure.scan

As we see, the contents of the generated configure.scan is similar to our hand-crafted template:
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.56)
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)

# Checks for programs.

# Checks for libraries.

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_OUTPUT

As the name autoscan implies, you can guess that it can do other things as well, not only create empty configure.ac templates.
As explained in the autoconf manual: Using autoscan to Create configure.ac:

"It (autoscan) searches the source files for common portability problems and creates a file configure.scan which is a preliminary configure.ac..."

Let test the source code search feature of autoscan with a small program.
Create the following two files in the same directory as configure.scan:

sleep.h
#include <stdio.h>
#include <unistd.h>          /* Needed for sleep() */

sleep.c
#include "sleep.h"

#define SECONDS_TO_SLEEP 3

int
main()
{
    unsigned int sleep_left = 0;
    /* sleep() for SECONDS_TO_SLEEP seconds, then print a message. */
    sleep(SECONDS_TO_SLEEP);
    printf("I woke up after %d seconds.\n", SECONDS_TO_SLEEP);
    return 0;
}
Remove earlier created files, repeat autoscan and check the contents of configure.scan:
rm -f autoscan.log configure.scan && autoscan && cat configure.scan

configure.scan
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.56)
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
AC_CONFIG_SRCDIR([sleep.c])
AC_CONFIG_HEADER([config.h])

# Checks for programs.
AC_PROG_CC

# Checks for libraries.

# Checks for header files.
AC_CHECK_HEADERS([unistd.h])

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.
AC_OUTPUT
As we see, autoscan detected our source file sleep.c and added the following macros:

AC_CONFIG_SRCDIR:

some file that is in the package's source directory.

AC_CONFIG_HEADER:

containing C preprocessor #define statements.

AC_PROG_CC:

determine a C compiler to use.

AC_CHECK_HEADERS:

check for existing header file(s) (in our case only one, unistd.h).


To get a very basic, but working input file to autoconf, rename configure.scan to configure.ac...
mv configure.scan configure.ac
... and update the AC_INIT macro, and add the AC_COPYRIGHT macro:

configure.ac
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.56)
AC_INIT(sleep, 0.0.1, me@example.com)
AC_CONFIG_SRCDIR([sleep.c])
AC_CONFIG_HEADER([config.h])
AC_COPYRIGHT([Copyright 2007, Johan Kuuse])

# Checks for programs.
AC_PROG_CC

# Checks for libraries.

# Checks for header files.
AC_CHECK_HEADERS([unistd.h])

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.
AC_OUTPUT
Run autoconf to create configure:
autoconf
Run the configure script, just to test the AC_INIT and AC_COPYRIGHT macros:
./configure --version
You should see something similar to:
sleep configure 0.0.1
generated by GNU Autoconf 2.56

Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.

Copyright 2007, Johan Kuuse
To display the bug report mail address:
./configure --help|tail -1
Should display:
Report bugs to <me@example.com>
IndexPreviousNext
Last modified: Tue Oct 23 15:41:00 Romance Daylight Time 2007