autoconf
[Top][All Lists]
Advanced

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

Re: err... this is odd


From: Akim Demaille
Subject: Re: err... this is odd
Date: 29 Nov 2000 12:09:48 +0100
User-agent: Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Channel Islands)

| But I got this warning:
| 
|  | configure.in:32: warning: AC_CONFIG_SUBDIRS: you should use literals
| 
| But the code actually scans the subdirs:
| 
|  | for a in `(cd $srcdir ; echo *)`
|  | do
|  |   if test "$a" != "CVS" -a "$a" != "RCS" ; then
|  |     if test -d "$srcdir/$a" ; then
|  |     if test -f "$srcdir/$a/configure.in"; then
|  |       yesno=`eval echo \\$with_$a`
|  |       if test "x${yesno-}" != xno ; then
|  |         dirs="$dirs $a"
| [...]
|  |       fi
|  |     fi
|  |     fi
|  |   fi
|  | done
|  | 
|  | AC_SUBST(MODULE_LINKOPTS)
|  | AC_SUBST(MODULE_SEGMENTS)
|  | 
|  | AC_SUBST_FILE(dependencies)
|  | dependencies=$srcdir/dependencies
|  | AC_CONFIG_SUBDIRS($dirs)
|  | 
|  | AC_OUTPUT(Makefile,[],dirs="$module_names")
| 
| Is this illegal? Why?

It's not invalid, it's discouraged because it forbids many useful
features, such as recursive --help, and the possibility to statically
extract the list of *possible* subdirs.  Automake might need it.

But your code is understood, no fear.

| How should it be solved instead (automake is not the answer)?

First of all, there is a general agreement that things like this
should not happen: this snippet is doing package maintenance in
configure.in.  This should not happen (nor in Makefiles etc.).
Additionally, it uses wildcards, which are not very welcome in the
Autotools.

If you want to do things cleanly, it should be

if test $with_foo; then
  AC_CONFIG_SUBDIRS(foo)
fi 
if test $with_bar; then
  AC_CONFIG_SUBDIRS(bar)
fi 

Note that this time we separated the package maintenance (listing all
the possible subdirs) from the configuration (selecting which subdir
we visit).

Finally, if you want to do something similar as what's done above (in
the sense of keeping the wildcards), you should keep in mind that
autoconf (the script) wants to know as much as it can when it's run,
which means ``package maintenance duties should be performed by M4,
while configuration stuff is sh's task''.  Morality: use M4.
Something like


define([MY_POSSIBLE_SUBDIRS],
esyscmd([for a in `cd $srcdir ; echo *`
do
  if test "$a" != "CVS" -a "$a" != "RCS" ; then
    if test -d "$a" ; then
       if test -f "$a/configure.in"; then
         echo $a
       fi
    fi
  fi
done]))

for dir in MY_POSSIBLE_SUBDIRS;
do
 yesno=`eval echo \\$with_$dir`
 if test "x${yesno-}" != xno ; then
   dirs="$dirs $a"
[..]
  fi
done



reply via email to

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