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:
├── 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
Most files here are empty, except:
---------configure.ac---------
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
---------proj*/Makefile.am---------
SUBDIRS = module1 module2
Note that the line:
AC_CONFIG_FILES([${found_mk}])
works perfectly but this one:
AC_CONFIG_FILES([${found_makefile_am}])
Failed with:
$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
And I had to replace it with:
AC_CONFIG_FILES([proj2/Makefile proj1/Makefile Makefile])
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?