automake
[Top][All Lists]
Advanced

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

Re: How to auto probe a directory


From: David Yu
Subject: Re: How to auto probe a directory
Date: Thu, 10 Jan 2013 11:10:29 +0800

2013/1/9 Stefano Lattarini <address@hidden>

> On 01/06/2013 09:45 AM, David Yu wrote:
> > Hi guys:
> >           I want my project auto probe the Makefile.am entry all
> > directories, if a directory has Makefile.am,  I will create Makefile.in
> > with automake.
> >
> Your best bet is to create a bootstrap script that prepares this
> information for autoconf; something like (untested!):
>
>   #!/bin/sh
>   makefiles=`find . -name Makefile.am | 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 = > subdirs.am
>   for d in $dirs; do test "$d" = . || echo "SUBDIRS += $d"; done >>
> subdirs.am
>
> and then, in configure.ac:
>
>   m4_include([config-files.m4])
>
> and in top-level Makefile.am:
>
>   include $(top_srcdir)/subdirs.am
>
> But is this extra complication really worth?  If you don't have too many
>
I need to try it as your suggestion, create a bootstrap script.

> Makefile.am 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 Makefile.am-holding subdirectory).
>
I don't want to do as that, because my project might be added new modules
by other developers. other developers can add a new module by my script, my
script create a directory and a Makefile.am, So I never know the
directories' name  before the developers build them.

>
> >           After that, I will create Makefile with configure.
> >
> > Here is my key codes of configure.in and Makefile.am
> >
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> > #configure.in
> > DEVICE_COMPILE="shell find ./ -mindepth 2 -name Makefile.am | sed
> > 's/Makefile.am/ /'"
> > AC_SUBST(DEVICE_COMPILE)
> > # probe the device modules
> > for DEVICE_MODULES in `find device -mindepth 2 -name Makefile.am | sed
> > 's/Makefile.am/Makefile/'`
> > do
> >        echo $DEVICE_MODULES
> >         AC_CONFIG_FILES($DEVICE_MODULES)
> > done
> > AC_OUTPUT
> >
> 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).
>
> >
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> > #Makefile.am
> > SUBDIRS = $(@DEVICE_COMPILE@)
> >
> Specifying the list of SUBDIRS as configure-time @subst@ has its share
> of issues too; see:
> <
> http://www.gnu.org/software/automake/manual/automake.html#Subdirectories-with-AC_005fSUBST
> >
>
> >
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> >
> > 1. I can probe the Makefile.am of every directory.
> > 2. But I can't create Makefile.in with "automake --add-missing --copy
> > --force-missing".
> > 3. I added "AC_CONFIG_FILES(test/Makefile)" into configure.in, It can
> > create Makefile.in in test/.
> > 4. I removed  "AC_CONFIG_FILES(test/Makefile)" from configure.in, I can
> > create Makefile with Makefile.in that is created in step 3.
> >
> > I guess automake use "AC_CONFIG_FILES($DEVICE_MODULES)" create
> Makefile.in,
> > 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
> > Makefile.am, But there is not Makefile.in. then  I get a error :
> > *config.status:
> > error: cannot find input file: `test/Makefile.in'*
> > *
> > *
> > 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
> >
>
> HTH,
>   Stefano
>
Waiting for my good news



David Yu
Thanks

*地址:清华大学 FIT楼 4区308*
*手机:13552980886*
*邮箱: address@hidden <address@hidden>
*MSN: address@hidden <address@hidden>


reply via email to

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