autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ensure a VPATH build (was: new macro)


From: Ralf Wildenhues
Subject: ensure a VPATH build (was: new macro)
Date: Fri, 17 Feb 2006 14:12:26 +0100
User-agent: Mutt/1.5.11

Hi Julien,

* Julien Lecomte wrote on Thu, Feb 16, 2006 at 09:13:34PM CET:
> 
> 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.

What about this simpler, a bit simple-minded version:
  if test -f configure || test -f configure.gnu ||
     { test -n "$ac_configure" && test -f "$ac_configure"; }; then
    AS_MSG_ERROR([Configuring in source directory is prohibited for this 
package.])
  fi

together with ensuring that the internal macro AC_CONFIG_AUX_DIRS has
been expanded?  If you wanted to get even fancier, you could instead
look for the file named in AC_CONFIG_SRCDIR.

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

A sh/m4 polymorphic version of m4_tolower/m4_toupper may be a useful
addition to m4sh.m4.  Your code is not exactly that: it also translates
`*' to `P'.  That may also be useful in its own right, but it serves a
different purpose than for what you use it.

A few technical notes to your code are inline, without deciding whether
it's useful to integrate this into Autoconf or not (I am not to decide
this), but assuming so, so that you could freely use unpublished macros.

Cheers,
Ralf


First, additions to Autoconf are best posted as patches (unified diffs
against the CVS version), to the autoconf-patches mailing list.

> # Check to be sure we're not configuring in src dir         -*- Autoconf -*-
> 
> # Author: Julien Lecomte
> # Copyright is granted to Free Software Foundation

I believe the FSF requires either a copyright assignment or disclaimer
(in written form) for nontrivial additions.

*snip*
> # _AC_CONFIG_ELSEWHERE_CHECK(path,path)
> # -------------------------------------
> AC_DEFUN([_AC_CONFIG_ELSEWHERE],
> [if test "$1" = "$2"; then

For safety with old shells or test, you should write
   if test "X$1" = "X$2"

>   AC_MSG_ERROR([Configuring in source directory is prohibited for this 
> package.])
> fi])
> 
> # _AC_CONFIG_ELSEWHERE_CMD(command,[case-sensitive])
> # --------------------

(very nitpicky: it'd be pretty to have the underlines aligned with the
end of the previous line; several instances of this.)

> AC_DEFUN([_AC_CONFIG_ELSEWHERE_CMD],
> [if ( ($1) || exit) >/dev/null 2>&1 && \
>     ( (cd $srcdir && $1) || exit) >/dev/null 2>&1; then

I believe the `|| exit' are not necessary.

>   pwd_curdir="`$1`"
>   pwd_srcdir="`cd $srcdir && $1`"

The double quotes are not necessary here.

>   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

(nitpick mode: I believe it is MSYS and Cygwin; it'd be nicer not to use
plain words in all-caps; nice would be no space before colon, and some
commas and periods sprinkled in resp. at the ends of the sentences.)

> #
> AC_DEFUN([AC_CONFIG_ELSEWHERE],
> [AS_REQUIRE([AS_TR_LCASE])dnl

This requirement makes no sense: you don't give AS_TR_LCASE an argument,
but one is necessary.  I think you should be able to just delete this.

> 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.])

Or `pwd' may simply not support `-P'.

> 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])

`pwd' may not support `-W' either.

> ])

*snip*
> # m4_error(MSG, [EXIT-STATUS])
> # -----------------------
> # Fatal the user who wrongly wrote the configure.ac
> m4_define([m4_error],
> [m4_errprintn(m4_location[: error: $1])dnl
> m4_exit(m4_if([$2],, 1, [$2]))])

There exists m4_fatal (but it needs to be documented), so
I guess it's better to use that instead of your m4_error.

> # _AS_TR_LCASE_PREPARE
> # -----------------
> m4_defun([_AS_TR_LCASE_PREPARE],
> [AS_REQUIRE([_AS_CR_PREPARE])dnl
> # Sed expression to map a string onto a valid variable name.
> as_tr_lcase="eval sed 'y%*$as_cr_LETTERS%P$as_cr_letters%;'"

The semicolon is not necessary.

> ])

> # AS_TR_LCASE(EXPRESSION)
> # --------------------
> # Transform EXPRESSION into lowercase. No substition on spaces, and special
> # chars.
> # sh/m4 polymorphic.
> # Be sure to update the definition of `$as_tr_lcase' if you change this.
> m4_defun([AS_TR_LCASE],
> [AS_REQUIRE([_$0_PREPARE])dnl
> AS_LITERAL_IF([$1],
>           [m4_translit([[$1]],
>                     [*ABCDEFGHIJKLMNOPQRSTUVWXYZ],
>                     [Pabcdefghijklmnopqrstuvwxyz])],

You could use unpublished macros m4_cr_LETTERS and m4_cr_letters here
(side note: AS_TR_CPP could do so as well).

>           [`echo "$1" | $as_tr_lcase`])])




reply via email to

[Prev in Thread] Current Thread [Next in Thread]