GNU Autoconf 2.12 for EMX

Current patchlevel: 5

Table of contents

Introduction

Well I quite like OS/2 and spend much of my free time tweaking Linux programs to work with it. And sometimes I even get it!

What I've found that makes porting more difficult is sometimes building all those makefiles and configuration headers. Under Linux and most Unix like O.S. you would run a configure script that guesses most of your system peculiarities (Name of the C/C++ compiler, which headers and libraries are present, whether a function is broken...). But OS/2 is not Unix --nor even similar-- and there are enough differences to break up those configuration scripts, even if you already have a good sh-like shell.

OK, it was the state of the question until now. This port of Autoconf introduces a set of scripts and macro files able to build scripts that work well under OS/2 with EMX using all those wonderful ports of GNU utilities. But hey, that's not all. Now those scripts will work under unix as well!

How it works

Most Linux programs come with a configure script that has the purpose of guessing important system defaults. Currently, most of those scripts are built with a tool named Autoconf, from the FSF, which takes in one or two macro files (configure.in & aclocal.m4) and using the M4 macro processor and another internal set of macro files (mainly acgeneral.m4 & acspecific.m4) creates a third one, named configure. What I've done is tweaking the internal macro files, so that the code they produce is well suited to run under EMX with a filesystem that allows long file names. This release is a major rewriting of the port. The most important changes are listed in the following section.

News in this package

This version is not only a patch release. All of the previously introduced changes have been arranged in a way that make them GNU compliant and unix compatible. I expect this changes to become part of a new official release of Autoconf. Help me to get it!

Requirements for running Autoconf

Here's a list of the EMX programs you'll need. Most of them are at Leo or Hobbes. However I've uploaded a few, standalone OS/2 binaries to my site: they're Kai's ports compiled without gnuregex.dll or gnurx.dll. And you must also be working on a filesystem that allows long file names. This happens under OS/2 with HPFS --and RSX+Win95/NT would do, too, but I haven't got any of them, so I could not test it--.

A simple install from the binaries

A not so simple install from the sources

Note: if you ever need to move autoconf to another directory, you'll have to either reinstall using this procedure, or define the environment variables listed in "Install from the binaries".

Using autoconf

Tips and tricks

Drive unit names and extensions

Unix programs don't know about disk units names, such as 'C:'. I've made Autoconf understand drive unit names, but this doesn't mean that your program does.

In the configuration process Autoconf may introduce absolute pathnames in the code of your program. This will typically happen, either when config.h is created, or by explicit defines when compiling. You might have to add code to let the user override these paths.

OTOH, you might find hand-made rules in aclocal.m4 or in configure.in that check whether a path reference is absolute or not. Typically it looks like in this example:

...
case "$LD" in
  /*)	ac_program_LD="$LD";;
  *)	#some other stuff
...
This must be fixed in the following compatible mode:
...
case "$LD" in
  /* | [a-zA-Z]:*) ac_program_LD="$LD";;
  *)    #some other stuff
...
The fixed rule recognizes drive unit names. Also, as the colon ":" is not a valid path character under unix, it causes no big harm.

Compilation flags

Autoconf's default flags for compiling programs are, as of this release
	CC=gcc
	MAKE=make.exe
	CXX=gcc
	CPP="gcc.exe -E"
	CFLAGS="-O2 -Zmt"
	CXXFLAGS="-O2 -Zmt"
	LDFLAGS="-Zexe -Zmt -Zcrtdll -Zsysv-signals -Zbin-files"
	CONFIG_SHELL=sh
Notice the -Zexe flag. It is here to ease your work: if you use it, you will not need to edit the Makefile. OTOH, it is a temporary solution. See below for more on program name extensions.

The flags can be overriden. Either edit the generated configure file or set environment variables

[From within CMD.EXE]
	set MAKE=x11make.exe
	set CFLAGS=-O2
	set CFLAGS=-O2
	set LDFLAGS=-Zexe -Zcrtdll -Zsysv-signals
[From within SH.EXE]
	export MAKE=x11make.exe
	export CFLAGS=-O2
	export CFLAGS=-O2
	export LDFLAGS="-Zexe -Zcrtdll -Zsysv-signals"
or let the configure program run and, at the end, edit config.status changing the variables to suit your needs. (See below)

The default settings are good for X11 programs and won't harm when porting any other kind of application. If you opt to use them, please follow these two rules (extracted from the XFreeOS/2 porting guide):

The config.status file

This script contains all of the configuration parameters and is responsible for converting the *.in files into usable ones. Some tips about this script:

Non portable rules

There are that programs need to guess system dependent features that Autoconf currently doesn't know about. This is usually achieved with rules that are stored in aclocal.m4. Some of these rules are just a set of standard checks put together, but some other are non-portable ones (in the sense that they may not work under OS/2).

The following sections explain how rules are to be modified in order to make them OS/2 compatible. These changes are simple ones and should be notified to the maintainers together with an explanation of where to get this port of Autoconf and its compatible nature.

File names

This release introduces four macros that format file names. They are:
Name Definition Output (OS/2) Output (Unix) Target
AC_EXE_NAME(file) file${EXE_EXT} file.exe file Binary executable file
AC_SCR_NAME(file) file${SCR_EXT} file.cmd file Script file
AC_LIB_NAME(file) ${LIB_PRE}file${LIB_EXT} file.a libfile.a Library file (Static)
AC_OBJ_NAME(file) file${OBJ_EXT} file.o file.o Object file
You should replace ocurrences of unix formatted names with the appropiate rule. For example
	if test -s $ac_dir/ld; then
	  ac_prog_LD=$ac_dir/ld
	else
	  ...
	fi
should become
	if test -s $ac_dir/AC_EXE_NAME(ld); then
	  ac_prog_LD=$ac_dir/AC_EXE_NAME(ld)
	else if test -s $ac_dir/AC_SCR_NAME(ld); then
	  ac_prog_LD=$ac_dir/AC_SCR_NAME(ld)
	else
	  ...
	fi
	fi
The fixed code now understands the right names in OS/2 and adds the possibility of the program (ld) being wrapped with a batch script. Notice the double fi.

Path separators

In this release of autoconf two new important macros are introduced that ease handling pathnames. The first one is AC_JOIN_PATHS. It performs two tasks:

An example of code that has to be fixed using this rule is this one:

	AC_PATH_PROG(INETD, inetd, /usr/libexec/inetd,
	  $PATH:/usr/libexec:/usr/sbin:/usr/etc:etc)
The fixed version looks like this:
	AC_PATH_PROG(INETD, inetd, /usr/libexec/inetd,
	  AC_JOIN_PATHS($PATH,/usr/libexec,/usr/sbin,/usr/etc,etc)

Path search

The second important macro designed to handle pathnames is AC_LOOP_OVER_PATH. Its definition is as follows:
AC_DEFUN(AC_LOOP_OVER_PATH,
[  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}$PATH_IFS"
  for ac_dir in ifelse($#, 2, [AC_FORMAT_PATH([$2$ac_dummy])], $FPATH); do
$1
  done
  IFS="$ac_save_ifs"
])

It takes two parameters:

An example of a rule that should be written using this macro is the following piece of code extracted form Libtool's aclocal.m4:

	[case "$LD" in
	  /*)
	  ac_cv_path_LD="$LD" # Let the user override the test with a path.
	  ;;
	  *)
	  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
	  for ac_dir in $PATH; do
	    test -z "$ac_dir" && ac_dir=.
	    if test -f "$ac_dir/ld"; then
		...
	    fi
	  done
	  IFS="$ac_save_ifs"
	  ;;
	esac])
The fixed version is
	[case "$LD" in
	  /*|[a-zA-Z]:*)
	  ac_cv_path_LD="$LD" # Let the user override the test with a path.
	  ;;
	  *)
	AC_LOOP_OVER_PATH(
	[    test -z "$ac_dir" && ac_dir=.
	    if test -f "$ac_dir/AC_EXE_NAME(ld)"; then
		...
	    fi])
	esac])

Bug reports

If you miss a feature in autoconf, or find something doesn't work, please e-mail me.

When reporting bugs, follow these steps:

Greetings and notes

I must thank Alexander Mai for his many comments on the project, and T.E.Dickey for pointing out some bugs.

Remember:

Getting it

So... here are GNU Autoconf 2.12 for EMX, sources (400k long) and GNU Autoconf 2.12 for EMX, precompiled (236k long)