new macro

From:

Julien Lecomte

Subject:

new macro

Date:

Thu, 16 Feb 2006 21:13:34 +0100

User-agent:

Thunderbird 1.5 (Windows/20051201)

Hello all,

I've made this macro which seems to solve all my problems with autoconf
and preventing configuration in folder containing sources. It works on
my linux box, and also on my windows box (cygwin, msys and mingw). (Not
tested on mac, the latest Mac I used was an IIgs !) with full, relative,
and case insensitive paths.

The macro is written trying to mimick at best the coding style of
autoconf macros installed by default. I think it could come in handy for
packages that shouldn't be conf'ed and comp'ed in the source dir (gcc,
cygwin, etc...)

I've attached the main macro file, and a dependency file (since i didn't
find any m4 macro that 'sed's to lowercase)

Julien

# Check to be sure we're not configuring in src dir -*- Autoconf -*-
# Author: Julien Lecomte
# Copyright is granted to Free Software Foundation
# Copyright (C) 2006
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 1
m4_include([m4/ax_m4sh.m4])
# _AC_CONFIG_ELSEWHERE_CHECK(path,path)
# -------------------------------------
AC_DEFUN([_AC_CONFIG_ELSEWHERE],
[if test "$1" = "$2"; then
AC_MSG_ERROR([Configuring in source directory is prohibited for this
package.])
fi])
# _AC_CONFIG_ELSEWHERE_CMD(command,[case-sensitive])
# --------------------
AC_DEFUN([_AC_CONFIG_ELSEWHERE_CMD],
[if ( ($1) || exit) >/dev/null 2>&1 && \
( (cd $srcdir && $1) || exit) >/dev/null 2>&1; then
pwd_curdir="`$1`"
pwd_srcdir="`cd $srcdir && $1`"
m4_ifval([$2], [
pwd_curdir=AS_TR_LCASE([$pwd_curdir])
pwd_srcdir=AS_TR_LCASE([$pwd_srcdir])
])
_AC_CONFIG_ELSEWHERE([$pwd_curdir],[$pwd_srcdir])
fi])
# AC_CONFIG_ELSEWHERE
# -------------------
# Do not allow configure in source directory
#
# Configuring will fail if AC_CANONICAL_BUILD is called before AC_CONFIG_SRCDIR
# So by requiring this macro to be called before AC_CANONICAL_BUILD makes it
# only possible for this macro to be in between AC_CONFIG_SRCDIR and
# AC_CANONICAL_BUILD.
# This also garantees that if a error message is to occur, we bail out as soon
# as possible.
#
# We assume that directories exist, otherwise we print out warnings.
#
# We also check to be sure that you can't try to fool this macro with an
# absolute MinGW/mSys or CygWin path
#
# DRAWBACK : `automake -m' won't work if you use this macro, but it's
# the point of this macro
#
AC_DEFUN([AC_CONFIG_ELSEWHERE],
[AS_REQUIRE([AS_TR_LCASE])dnl
AC_BEFORE([$0], [AC_CANONICAL_BUILD])dnl
if test ! -d "`cd $srcdir && pwd -P`"; then
AC_MSG_WARN([\`$srcdir' could not be identified as a directory.])
elif test ! -d "`pwd -P`" ; then
pwd_curdir="`pwd -P`"
AC_MSG_WARN([\`$pwd_curdir' could not be identified as a directory.])
fi
_AC_CONFIG_ELSEWHERE_CMD([pwd -P])
_AC_CONFIG_ELSEWHERE_CMD([cygpath -ma .])
_AC_CONFIG_ELSEWHERE_CMD([pwd -W],[yes])
])