@dircategory Individual utilities
@direntry
* autoscan: (autoconf)autoscan Invocation.
- Semi-automatic @file{configure.ac} writing
+ Semi-automatic @file{configure.ac} writing
* ifnames: (autoconf)ifnames Invocation.
- Listing the conditionals in source code
+ Listing the conditionals in source code
* autoconf: (autoconf)autoconf Invocation.
- How to create configuration scripts
+ How to create configuration scripts
* autoreconf: (autoconf)autoreconf Invocation.
- Remaking multiple @code{configure} scripts
+ Remaking multiple @code{configure} scripts
* configure: (autoconf)configure Invocation.
- Configuring a package
+ Configuring a package
* config.status: (autoconf)config.status Invocation.
- Recreating a configuration
+ Recreating a configuration
@end direntry
@ifinfo
@group
configure.ac --.
- | .------> autoconf* -----> configure
+ | .------> autoconf* -----> configure
[aclocal.m4] --+---+
- | `-----> [autoheader*] --> [config.h.in]
+ | `-----> [autoheader*] --> [config.h.in]
[acsite.m4] ---'
@end group
Files used in configuring a software package:
@example
@group
- .-------------> [config.cache]
+ .-------------> [config.cache]
configure* ------------+-------------> config.log
- |
+ |
[config.h.in] -. v .-> [config.h] -.
- +--> config.status* -+ +--> make*
+ +--> config.status* -+ +--> make*
Makefile.in ---' `-> Makefile ---'
@end group
@end example
@example
AC_CHECK_HEADER([stdio.h],
- [AC_DEFINE([HAVE_STDIO_H])],
- [AC_MSG_ERROR([Sorry, can't do anything for you])])
+ [AC_DEFINE([HAVE_STDIO_H])],
+ [AC_MSG_ERROR([Sorry, can't do anything for you])])
@end example
@noindent
@example
AC_CHECK_HEADER(stdio.h,
- [AC_DEFINE(HAVE_STDIO_H)],
- [AC_MSG_ERROR([Sorry, can't do anything for you])])
+ [AC_DEFINE(HAVE_STDIO_H)],
+ [AC_MSG_ERROR([Sorry, can't do anything for you])])
@end example
@noindent
@example
AC_CHECK_HEADER(stdio.h,
- AC_DEFINE(HAVE_STDIO_H),
- AC_MSG_ERROR([Sorry, can't do anything for you]))
+ AC_DEFINE(HAVE_STDIO_H),
+ AC_MSG_ERROR([Sorry, can't do anything for you]))
@end example
You may have to use text that also resembles a macro call. In this
@example
AC_CONFIG_FILES(Makefile:boiler/top.mk:boiler/bot.mk
- lib/Makefile:boiler/lib.mk)
+ lib/Makefile:boiler/lib.mk)
@end example
@noindent
@example
.sh:
- rm -f $@@ $@@.tmp
- sed 's,@@datadir\@@,$(pkgdatadir),g' $< >$@@.tmp
- chmod +x $@@.tmp
- mv $@@.tmp $@@
+ rm -f $@@ $@@.tmp
+ sed 's,@@datadir\@@,$(pkgdatadir),g' $< >$@@.tmp
+ chmod +x $@@.tmp
+ mv $@@.tmp $@@
@end example
Three things are noteworthy:
@example
time.info: time.texinfo
- $(MAKEINFO) $(srcdir)/time.texinfo
+ $(MAKEINFO) $(srcdir)/time.texinfo
@end example
@node Automatic Remaking, , Build Directories, Makefile Substitutions
@example
@group
$(srcdir)/configure: configure.ac aclocal.m4
- cd $(srcdir) && autoconf
+ cd $(srcdir) && autoconf
# autoheader might not change config.h.in, so touch a stamp file.
$(srcdir)/config.h.in: stamp-h.in
$(srcdir)/stamp-h.in: configure.ac aclocal.m4
- cd $(srcdir) && autoheader
- echo timestamp > $(srcdir)/stamp-h.in
+ cd $(srcdir) && autoheader
+ echo timestamp > $(srcdir)/stamp-h.in
config.h: stamp-h
stamp-h: config.h.in config.status
- ./config.status
+ ./config.status
Makefile: Makefile.in config.status
- ./config.status
+ ./config.status
config.status: configure
- ./config.status --recheck
+ ./config.status --recheck
@end group
@end example
@example
AH_TEMPLATE([CRAY_STACKSEG_END],
- [Define to one of _getb67, GETB67, getb67
- for Cray-2 and Cray-YMP systems. This
- function is required for alloca.c support
- on those systems.])
+ [Define to one of _getb67, GETB67, getb67
+ for Cray-2 and Cray-YMP systems. This
+ function is required for alloca.c support
+ on those systems.])
@end example
@noindent
@example
fubar=42
AC_CONFIG_COMMANDS(fubar,
- [echo this is extra $fubar, and so on.],
- [fubar=$fubar])
+ [echo this is extra $fubar, and so on.],
+ [fubar=$fubar])
@end example
Here is a better one:
@example
AC_CONFIG_LINKS(host.h:config/$machine.h
- object.h:config/$obj_format.h)
+ object.h:config/$obj_format.h)
@end example
@noindent
@example
AC_CHECK_MEMBER(struct passwd.pw_gecos,,
- [AC_MSG_ERROR([We need `passwd.pw_gecos'!])],
- [#include <pwd.h>])
+ [AC_MSG_ERROR([We need `passwd.pw_gecos'!])],
+ [#include <pwd.h>])
@end example
You can use this macro for sub members:
File names need extra care as well. While @sc{dos}-based environments
that are Unixy enough to run @command{autoconf} (such as DJGPP) will
usually be able to handle long file names properly, there are still
-limitations that can seriously break packages:
+limitations that can seriously break packages. Several of these issues can
+be easily detected by
+@uref{ftp://ftp.gnu.org/gnu/non-gnu/doschk/doschk-1.1.tar.gz, the doschk
+package}.
+
+A short overview follows; problems are marked with @sc{sfn}/@sc{lfn} to
+indicate where they apply: @sc{sfn} means the issues are only relevant to
+plain @sc{dos}, not to @sc{dos} boxes under Windows, while @sc{lfn}
+identifies problems that exist even under Windows.
@table @asis
-@item No multiple dots
-@sc{dos} cannot handle multiple dots in filenames. This is an
-especially important thing to remember when building a portable
-configure script, as @command{autoconf} uses a .in suffix for template
-files.
+@item No multiple dots (@sc{sfn})
+@sc{dos} cannot handle multiple dots in filenames. This is an especially
+important thing to remember when building a portable configure script,
+as @command{autoconf} uses a .in suffix for template files.
This is perfectly OK on Unices:
AC_OUTPUT
@end example
-@item Case insensitivity
+@item No leading dot (@sc{sfn})
+@sc{dos} cannot handle filenames that start with a dot. This is an especially
+important thing to remember when building a portable configure script,
+as @command{autoconf} uses a .in suffix for template files.
+
+@item Case insensitivity (@sc{lfn})
@sc{dos} is case insensitive, so you cannot, for example, have both a
file called @samp{INSTALL} and a directory called @samp{install}. This
also affects @command{make}; if there's a file called @samp{INSTALL} in
the directory, @command{make install} will do nothing (unless the
@samp{install} target is marked as PHONY).
-@item The 8+3 limit
+@item The 8+3 limit (@sc{sfn})
Because the @sc{dos} file system only stores the first 8 characters of
the filename and the first 3 of the extension, those must be unique.
That means that @samp{foobar-part1.c}, @samp{foobar-part2.c} and
@samp{foobar-prettybird.c} all resolve to the same filename
(@samp{FOOBAR-P.C}). The same goes for @samp{foo.bar} and
@samp{foo.bartender}.
+Note: This is not usually a problem under Windows, as it uses numeric
+tails in the short version of filenames to make them unique. However,
+a registry setting can turn this behaviour off. While this makes it
+possible to share file trees containing long file names between @sc{sfn}
+and @sc{lfn} environments, it also means the above problem also applies.
+
+@item Illegal characters
+Some characters are illegal in @sc{dos} filenames, and should therefore
+be avoided. In a @sc{lfn} environment, these are '/', '\', '?', '*', ':',
+'<', '>', '|' and '"'. In a @sc{sfn} environment, other characters are
+also illegal. These include '+', ',', '[' and ']'.
@end table
@node Shell Substitutions, Assignments, File System Conventions, Portable Shell
@example
$ gawk 'function die () @{ print "Aaaaarg!" @}
- BEGIN @{ die () @}'
+ BEGIN @{ die () @}'
gawk: cmd. line:2: BEGIN @{ die () @}
gawk: cmd. line:2: ^ parse error
$ gawk 'function die () @{ print "Aaaaarg!" @}
- BEGIN @{ die() @}'
+ BEGIN @{ die() @}'
Aaaaarg!
@end example
@example
dir=`expr "x$file" : 'x\(.*\)/[^/]*' \|
- '.' : '.'
+ '.' : '.'
@end example
@noindent
Unix spec. So @samp{ln -s file link} will generate @file{link.exe},
which will attempt to call @file{file.exe} if run. But this feature only
works for executables, so @samp{cp -p} is used instead for these
-systems. DJGPP version 2.04 and later have full symlink support.
+systems. DJGPP versions 2.04 and later have full symlink support.
@item @command{mv}
# The order of these tests is important.
AC_TRY_CPP([#include <sys/statvfs.h>
#include <sys/fstyp.h>],
- [AC_DEFINE(FSTYPE_STATVFS) fstype=SVR4])
+ [AC_DEFINE(FSTYPE_STATVFS) fstype=SVR4])
if test $fstype = no; then
AC_TRY_CPP([#include <sys/statfs.h>
#include <sys/fstyp.h>],
- [AC_DEFINE(FSTYPE_USG_STATFS) fstype=SVR3])
+ [AC_DEFINE(FSTYPE_USG_STATFS) fstype=SVR3])
fi
if test $fstype = no; then
AC_TRY_CPP([#include <sys/statfs.h>
#include <sys/vmount.h>],
- [AC_DEFINE(FSTYPE_AIX_STATFS) fstype=AIX])
+ [AC_DEFINE(FSTYPE_AIX_STATFS) fstype=AIX])
fi
# (more cases omitted here)
AC_MSG_RESULT([$fstype])
true && ac_cv_shell_true_works=yes
if test $ac_cv_shell_true_works = yes; then
AC_DEFINE([TRUE_WORKS], 1
- [Define if `true(1)' works properly.])
+ [Define if `true(1)' works properly.])
fi[]dnl
])])
@end group
true && ac_cv_shell_true_works=yes])
if test $ac_cv_shell_true_works = yes; then
AC_DEFINE([TRUE_WORKS], 1
- [Define if `true(1)' works properly.])
+ [Define if `true(1)' works properly.])
fi[]dnl
])
@end group
#ifndef tzname /* For SGI. */
extern char *tzname[]; /* RS6000 and others reject char **tzname. */
#endif],
- [atoi (*tzname);],
- [ac_cv_var_tzname=yes],
- [ac_cv_var_tzname=no])
+ [atoi (*tzname);],
+ [ac_cv_var_tzname=yes],
+ [ac_cv_var_tzname=no])
@end example
@noindent
#ifndef tzname /* For SGI. */
extern char *tzname[]; /* RS6000 and others reject char **tzname. */
#endif]],
- [atoi (*tzname);])],
- [ac_cv_var_tzname=yes],
- [ac_cv_var_tzname=no])
+ [atoi (*tzname);])],
+ [ac_cv_var_tzname=yes],
+ [ac_cv_var_tzname=no])
@end example
@c FIXME: Quadrigraphs and hopeless cases.
@example
AC_CACHE_CHECK([for EMX OS/2 environment], [ac_cv_emxos2],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [return __EMX__;])],
- [ac_cv_emxos2=yes],
- [ac_cv_emxos2=no])])
+ [ac_cv_emxos2=yes],
+ [ac_cv_emxos2=no])])
@end example
@noindent
@example
AC_CACHE_CHECK([for EMX OS/2 environment],
- [ac_cv_emxos2],
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
- [return __EMX__;])],
- [ac_cv_emxos2=yes],
- [ac_cv_emxos2=no])])
+ [ac_cv_emxos2],
+ [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
+ [return __EMX__;])],
+ [ac_cv_emxos2=yes],
+ [ac_cv_emxos2=no])])
@end example
When using @code{AC_TRY_RUN} or any macro that cannot work when
define([_AC_EMXOS2],
[AC_CACHE_CHECK([for EMX OS/2 environment], [ac_cv_emxos2],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [return __EMX__;])],
- [ac_cv_emxos2=yes],
- [ac_cv_emxos2=no])])
+ [ac_cv_emxos2=yes],
+ [ac_cv_emxos2=no])])
test "$ac_cv_emxos2" = yes && EMXOS2=yes[]dnl
])# _AC_EMXOS2
@end example
@example
case "$target" in
i386-*-mach* | i386-*-gnu*)
- obj_format=aout emulation=mach bfd_gas=yes ;;
+ obj_format=aout emulation=mach bfd_gas=yes ;;
i960-*-bout) obj_format=bout ;;
esac
@end example
@example
AC_CONFIG_LINKS(host.h:config/$machine.h
- object.h:config/$obj_format.h)
+ object.h:config/$obj_format.h)
@end example
You can also use the host system type to find cross-compilation tools.
@example
AC_DEFUN(TEST_MACRO,
[AC_ARG_WITH(foo,
- AC_HELP_STRING([--with-foo],
- [use foo (default is NO)]),
- ac_cv_use_foo=$withval, ac_cv_use_foo=no),
+ AC_HELP_STRING([--with-foo],
+ [use foo (default is NO)]),
+ ac_cv_use_foo=$withval, ac_cv_use_foo=no),
AC_CACHE_CHECK(whether to use foo,
- ac_cv_use_foo, ac_cv_use_foo=no)])
+ ac_cv_use_foo, ac_cv_use_foo=no)])
@end example
Please note that the call to @code{AC_HELP_STRING} is @strong{unquoted}.
@example
AC_DEFUN(MY_ARG_WITH,
[AC_ARG_WITH([$1],
- AC_HELP_STRING([--with-$1], [use $1 (default is $2)]),
- ac_cv_use_$1=$withval, ac_cv_use_$1=no),
+ AC_HELP_STRING([--with-$1], [use $1 (default is $2)]),
+ ac_cv_use_$1=$withval, ac_cv_use_$1=no),
AC_CACHE_CHECK(whether to use $1, ac_cv_use_$1, ac_cv_use_$1=$2)])
@end example
@end defmac
@example
transform = @@program_transform_name@@
install: all
- $(INSTALL_PROGRAM) myprog $(bindir)/`echo myprog | \
- sed '$(transform)'`
+ $(INSTALL_PROGRAM) myprog $(bindir)/`echo myprog | \
+ sed '$(transform)'`
uninstall:
- rm -f $(bindir)/`echo myprog | sed '$(transform)'`
+ rm -f $(bindir)/`echo myprog | sed '$(transform)'`
@end example
@noindent
@example
PROGRAMS = cp ls rm
install:
- for p in $(PROGRAMS); do \
- $(INSTALL_PROGRAM) $$p $(bindir)/`echo $$p | \
- sed '$(transform)'`; \
- done
+ for p in $(PROGRAMS); do \
+ $(INSTALL_PROGRAM) $$p $(bindir)/`echo $$p | \
+ sed '$(transform)'`; \
+ done
uninstall:
- for p in $(PROGRAMS); do \
- rm -f $(bindir)/`echo $$p | sed '$(transform)'`; \
- done
+ for p in $(PROGRAMS); do \
+ rm -f $(bindir)/`echo $$p | sed '$(transform)'`; \
+ done
@end example
Whether to do the transformations on documentation files (Texinfo or
@group
config.h: stamp-h
stamp-h: config.h.in config.status
- ./config.status config.h
- echo > stamp-h
+ ./config.status config.h
+ echo > stamp-h
Makefile: Makefile.in config.status
- ./config.status Makefile
+ ./config.status Makefile
@end group
@end example
@group
config.h: stamp-h
stamp-h: config.h.in config.status
- CONFIG_COMMANDS= CONFIG_LINKS= CONFIG_FILES= \
- CONFIG_HEADERS=config.h ./config.status
- echo > stamp-h
+ CONFIG_COMMANDS= CONFIG_LINKS= CONFIG_FILES= \
+ CONFIG_HEADERS=config.h ./config.status
+ echo > stamp-h
Makefile: Makefile.in config.status
- CONFIG_COMMANDS= CONFIG_LINKS= CONFIG_HEADERS= \
- CONFIG_FILES=Makefile ./config.status
+ CONFIG_COMMANDS= CONFIG_LINKS= CONFIG_HEADERS= \
+ CONFIG_FILES=Makefile ./config.status
@end group
@end example
@example
@group
configure.ac --. .------> autoconf* -----> configure
- +---+
+ +---+
[aclocal.m4] --+ `---.
[acsite.m4] ---' |
- +--> [autoheader*] -> [config.h.in]
+ +--> [autoheader*] -> [config.h.in]
[acconfig.h] ----. |
- +-----'
+ +-----'
[config.h.top] --+
[config.h.bot] --'
@end group
@example
AC_CHECK_TYPE([@var{type}],
- [AC_DEFINE([@var{type}], [@var{default}],
- [Define to `@var{default}' if <sys/types.h>
- does not define.])])
+ [AC_DEFINE([@var{type}], [@var{default}],
+ [Define to `@var{default}' if <sys/types.h>
+ does not define.])])
@end example
In order to keep backward compatibility, the two versions of
AC_REQUIRE([AC_CANONICAL_HOST])[]dnl
case $host_os in
*cygwin* ) CYGWIN=yes;;
- * ) CYGWIN=no;;
+ * ) CYGWIN=no;;
esac
@end example
@example
AC_LINK_FILES(config/$machine.h config/$obj_format.h,
- host.h object.h)
+ host.h object.h)
@end example
@noindent
@example
AC_CONFIG_LINKS(host.h:config/$machine.h
- object.h:config/$obj_format.h)
+ object.h:config/$obj_format.h)
@end example
@end defmac
@group
AC_CONFIG_FILES(@var{file}@dots{})
AC_CONFIG_COMMANDS([default],
- @var{extra-cmds}, @var{init-cmds})
+ @var{extra-cmds}, @var{init-cmds})
AC_OUTPUT
@end group
@end example
@example
fubar=27
AC_OUTPUT_COMMANDS([echo this is extra $fubar, and so on.],
- fubar=$fubar)
+ fubar=$fubar)
AC_OUTPUT_COMMANDS([echo this is another, extra, bit],
- [echo init bit])
+ [echo init bit])
@end example
Aside from the fact that @code{AC_CONFIG_COMMANDS} requires an
[#if defined M_XENIX && !defined M_UNIX
yes
#endif],
- [AC_MSG_RESULT([yes]); XENIX=yes],
- [AC_MSG_RESULT([no]); XENIX=])
+ [AC_MSG_RESULT([yes]); XENIX=yes],
+ [AC_MSG_RESULT([no]); XENIX=])
@end example
@end defmac