title: Use shell commands to find Makefile.am in configure.ac
body: <p>I'm trying to add some shell commands to automatically search for Makefile.am in my project autoconf (so that I don't have to worry about forgetting to add an entry next time when there's a new Makefile.am). But it does not seem to work. I've tried to create a minimum project setup to illustrate the problem. The project directory contains:</p>
  
  <pre><code>├── AUTHORS
  ├── ChangeLog
  ├── common.mk.in
  ├── configure.ac
  ├── COPYING
  ├── INSTALL
  ├── install-sh
  ├── Makefile.am
  ├── missing
  ├── NEWS
  ├── proj1
  │   ├── Makefile.am
  │   ├── module1
  │   │   └── Makfile.am
  │   └── module2
  │       └── Makfile.am
  ├── proj2
  │   ├── Makefile.am
  │   ├── module1
  │   │   └── Makfile.am
  │   └── module2
  │       └── Makfile.am
  └── README
  </code></pre>
  
  <p>Most files here are empty, except:</p>
  
  <p>---------configure.ac---------</p>
  
  <pre><code>AC_INIT([TEST], [1.0])
  found_makefile_am=`find . -name 'Makefile.am' | sed -e 's/\.am$//g' -e 's/^\.\///g' | sed ':a;N;$!ba;s/\n/ /g'`
  found_mk=`find . -name '*.mk.in' | sed -e 's/\.am$//g' -e 's/^\.\///g' | sed ':a;N;$!ba;s/\n/ /g'`
  AM_INIT_AUTOMAKE
  #AC_CONFIG_FILES([proj2/Makefile proj1/Makefile Makefile])
  AC_CONFIG_FILES([${found_makefile_am}])
  AC_CONFIG_FILES([${found_mk}])
  AC_OUTPUT
  </code></pre>
  
  <p>---------proj*/Makefile.am---------</p>
  
  <pre><code>SUBDIRS = module1 module2
  </code></pre>
  
  <p>Note that the line:</p>
  
  <pre><code>AC_CONFIG_FILES([${found_mk}])
  </code></pre>
  
  <p>works perfectly but this one:</p>
  
  <pre><code>AC_CONFIG_FILES([${found_makefile_am}])
  </code></pre>
  
  <p>Failed with:</p>
  
  <pre><code>$autoreconf -i
  automake-1.12: error: no 'Makefile.am' found for any configure output
  automake-1.12: Did you forget AC_CONFIG_FILES([Makefile]) in configure.ac?
  autoreconf-2.69: automake failed with exit status: 1
  </code></pre>
  
  <p>And I had to replace it with:</p>
  
  <pre><code>AC_CONFIG_FILES([proj2/Makefile proj1/Makefile Makefile])
  </code></pre>
  
  <p>It just seems to me that the shell variable is not properly expanded right before autoconfig invokes automake. So is there any solution to this problem?</p>