[Top][All Lists]

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

Re: How to auto probe a directory

From: Stefano Lattarini
Subject: Re: How to auto probe a directory
Date: Wed, 09 Jan 2013 12:58:56 +0100

On 01/06/2013 09:45 AM, David Yu wrote:
> Hi guys:
>           I want my project auto probe the entry all
> directories, if a directory has,  I will create
> with automake.
Your best bet is to create a bootstrap script that prepares this
information for autoconf; something like (untested!):

  makefiles=`find . -name | sed 's/\.am/'`
  dirs=`echo "$makefiles" | sed 's,/Makefile$,,'
  for f in $makefiles; do echo "AC_CONFIG_FILES([$f])"; done > config-files.m4
  echo SUBDIRS = >
  for d in $dirs; do test "$d" = . || echo "SUBDIRS += $d"; done >>

and then, in


and in top-level

  include $(top_srcdir)/

But is this extra complication really worth?  If you don't have too many and subdirectories, I suggest you to list them explicitly in
AC_CONFIG_FILES ans SUBDIRS.  That will save you lot of headaches later
(among them, the need to explicitly re-run the above bootstrap by hand
whenever you add, remove or rename a subdirectory).

>           After that, I will create Makefile with configure.
> Here is my key codes of and
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> DEVICE_COMPILE="shell find ./ -mindepth 2 -name | sed
> 's/ /'"
> # probe the device modules
> for DEVICE_MODULES in `find device -mindepth 2 -name | sed
> 's/'`
> do
>        echo $DEVICE_MODULES
> done
This has no hope to work, since the arguments of AC_CONFIG_FILES must
be known by autoconf and automake at m4 runtime, not at shell runtime.

(True, you can run shell code from m4 as well -- with the 'm4_esyscmd'
and 'm4_esyscmd_s' autoconf-provided macros -- but doing so will
likely prove even more brittle than the "bootstrap script" approach
I suggested above).

> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Specifying the list of SUBDIRS as configure-time @subst@ has its share
of issues too; see:

> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> 1. I can probe the of every directory.
> 2. But I can't create with "automake --add-missing --copy
> --force-missing".
> 3. I added "AC_CONFIG_FILES(test/Makefile)" into, It can
> create in test/.
> 4. I removed  "AC_CONFIG_FILES(test/Makefile)" from, I can
> create Makefile with that is created in step 3.
> I guess automake use "AC_CONFIG_FILES($DEVICE_MODULES)" create,
> but automake can't run the shell command, So "$DEVICE_MODULES" is NULL or
> invalid. While It can execute the shell command in the process of
> configure, so configure can create Makefile entry every directory that has
>, But there is not then  I get a error :
> *config.status:
> error: cannot find input file: `test/'*
> *
> *
> My question is  how to use shell command in the process of automake.
> Other method is ok too.
> My English is not good, I hope you can get it.
> David Yu
> Thanks


reply via email to

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