Next: Shell Substitutions, Previous: File Descriptors, Up: Portable Shell
While autoconf and friends will usually be run on some Unix variety, it can and will be used on other systems, most notably DOS variants. This impacts several assumptions regarding file and path names.
For example, the following code:
case $foo_dir in
/*) # Absolute
;;
*)
foo_dir=$dots$foo_dir ;;
esac
will fail to properly detect absolute paths on those systems, because they can use a drivespec, and will usually use a backslash as directory separator. The canonical way to check for absolute paths is:
case $foo_dir in
[\\/]* | ?:[\\/]* ) # Absolute
;;
*)
foo_dir=$dots$foo_dir ;;
esac
Make sure you quote the brackets if appropriate and keep the backslash as first character (see Limitations of Builtins).
Also, because the colon is used as part of a drivespec, these systems don't
use it as path separator. When creating or accessing paths, use the
PATH_SEPARATOR output variable instead. configure sets this
to the appropriate value (`:' or `;') when it starts up.
File names need extra care as well. While DOS-based environments that are Unixy enough to run autoconf (such as DJGPP) will usually be able to handle long file names properly, there are still limitations that can seriously break packages. Several of these issues can be easily detected by the doschk package.
A short overview follows; problems are marked with sfn/lfn to indicate where they apply: sfn means the issues are only relevant to plain DOS, not to DOS boxes under Windows, while lfn identifies problems that exist even under Windows.
This is perfectly OK on Unices:
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([source.c foo.bar])
AC_OUTPUT
but it causes problems on DOS, as it requires `config.h.in', `source.c.in' and `foo.bar.in'. To make your package more portable to DOS-based environments, you should use this instead:
AC_CONFIG_HEADERS([config.h:config.hin])
AC_CONFIG_FILES([source.c:source.cin foo.bar:foobar.in])
AC_OUTPUT
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 behavior off. While this makes it
possible to share file trees containing long file names between sfn
and lfn environments, it also means the above problem applies there
as well.