Hello, On Wed, Oct 04, 2006 at 11:59:40AM +0800, Tzu-Chien Chiu wrote: > Makefile.am > bin_PROGRAMS = bar > bar_LDADD = @top_builddir@/xyz.la > bar_DEPENDENCIES = $(bar_LDADD) @many_objs@
a few nits first: all AC_SUBSTed variables are available as make variables, so you can use $(top_builddir) and $(many_objs). Actually, this is the prefferred way. Consequently, you can use many_objs='$(top_builddir)/foo.lo ...' in your configure.ac. Another nit: if the above snippet comes from top level Makefile, then there is no reason to use top_builddir; top builddir is the current directory. This simplifies the situation: configure.ac: many_objs='foo.lo ...' AC_SUBST(many_objs) Makefile.am: bin_PROGRAMS = bar bar_LDADD = xyz.la bar_DEPENDENCIES = $(bar_LDADD) $(many_objs) linkscript.ld: SECTIONS { .a: { foo.o } .. } > When the number of object files grows, it's difficult to maintain > these files. Better approach anyone, please? I can see only one remaining problem: both linkscript.ld and configure.ac contain the same long list of objects. Then you can select one file, which will have the list, and the other ones will be generated. First solution: linkscript.ld would be the primary source, and configure.ac would do this: many_objs=`sed -n '/^SECTIONS/,/^}/{ s|.*{ *\(.*\)\.o *}.*|$(top_builddir)/\1.lo|p }' $srcdir/linkscript.ld |tr '\n' ' '` Another solution: linkscript.ld might be generated by a rule in Makefile. Actyally, the variable many_objs could be defined directly in Makefile.am, too. Something like this: many_objs = foo.lo bar.lo .. linkscript.ld: Makefile ( \ echo "SECTIONS {"; \ for obj in $(many_objs:.lo=.o); do \ echo " .a { $$obj }"; \ echo "}"; \ ) >$@ Or you can write an awk or ruby script to generate linkscript.ld from a list of object files passed as parameters. Actually, I'm afraid that you real situation might be a bit more complicated than the simplified example which you posted, but I hope that you find my suggestions inspirative anyway. If a problem remains, feel free to ask again. Have a nice day, Stepan Kasal