[Top][All Lists]

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

Re: allowing users to add source files without rerunning the autotools?

From: Stefano Lattarini
Subject: Re: allowing users to add source files without rerunning the autotools?
Date: Wed, 18 Jan 2012 19:03:13 +0100

Hi Bill.

On 01/18/2012 06:42 PM, Bill Sacks wrote:
> [SNIP]
> This would be the typical way to set up
> noinst_LIBRARIES = libjupcommon.a
> libjupcommon_a_SOURCES = jupcommon.h print.c jupcommon2.h print2.c
> Instead I did the following:
> noinst_LIBRARIES = libjupcommon.a
> libjupcommon_a_SOURCES_standard = print.c
> libjupcommon_a_SOURCES := $(libjupcommon_a_SOURCES_standard) $(shell cat 
> Srcfiles)
> am_libjupcommon_a_OBJECTS := $(addsuffix .o, $(basename 
> $(libjupcommon_a_SOURCES)))
This is probably doomed to failure, since Automake needs to process the
contents of libjupcommon_a_SOURCES at automake runtime.  In particular,
any GNU-make specific syntax used in the value of libjupcommon_a_SOURCES
won't be recognized by automake.

> where Srcfiles contains:
> print2.c
I assume this 'Srcfiles' file is static, and not generated by rules in your
Makefile, right?  In this case, you could generate, from the 'Srcfiles'
file itself, a fragment, that will add the extra files in there
to $(libjupcommon_a_SOURCES): Srcfiles
        echo "libjupcommon_a_SOURCES += `cat Srcfiles`" >$@

Then you can include it in your to extend the "default" value
of $(libjupcommon_a_SOURCES):

  libjupcommon_a_SOURCES = print.c
  include $(srcdir)/

This should work; but has the downside that you'll also a script to
bootstrap your initial, by creating an initial version of

> However, the manual specification of am_libjupcommon_a_OBJECTS feels like
> something I shouldn't be doing -- I'm worried that will make the build system
> less robust. But some sort of manual creation of the OBJECTS list seemed
> necessary since automake didn't know all of the source files.
This was to be expected unfortunately, given the rationale above about
Automake not grasping GNU make constructs.

> (I also left out the header files so that the OBJECTS list would be created
> correctly, but I'm less worried about that.)
> Is there a more robust way to achieve the same thing?
You might give a try to my advice.  I can't assure it will work, but IMHO
it's worth a shot.  And if something is unclear or confusing, just ask.

> And are there fundamental problems with automake not knowing all of the source
> files?
Yes; definitely yes.  See the automake manual for more details (I'd give you
a more precise link, but today it seems that has "gone dark to raise
awareness agains SOPA and PIPA bills").


reply via email to

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