On Thu, 14 Apr 2011, Gilles wrote:

However, some applications use if/else blocks just as this one instead
of eg. "#ifdef HAVE_FOR" conditional compiling:
============
if (uClinux) {
        *pid = vfork();
} else {
        *pid = fork();
}
============

Is it possible to modify configure.ac so that it goes ahead and
compiles applications that handle fork/vfork without preprocessor
commands?

The proper solution for this is to have configure test for both fork() and vfork() (and maybe posix_spawn()). Then you have to decide which one you prefer:

In configure.ac:

AC_CHECK_FUNCS([fork posix_spawnp spawnvp vfork])

In the program:

#if HAVE_VFORK
  use vfork
#if HAVE_POSIX_SPAWNP
  use posix_spawn
#if HAVE_SPAWNVP
  use spawnvp
#elif HAVE_FORK
  use fork
#else
#error Need a way to fork a program!
#else

Vfork was supposed to be antique and going away but has been making a resurgence in heavily-threaded programs, however, posix_spawnp() is still preferred in that case (when available).

Bob
--
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/

_______________________________________________
Autoconf mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/autoconf

Reply via email to