automake
[Top][All Lists]
Advanced

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

Re: Force a file to be compiled always


From: Ralf Wildenhues
Subject: Re: Force a file to be compiled always
Date: Wed, 3 Nov 2010 20:37:26 +0100
User-agent: Mutt/1.5.20 (2010-08-04)

Hi Benjamin,

* Benjamin Bihler wrote on Wed, Nov 03, 2010 at 11:00:35AM CET:
> almost ten years ago there was a question in this mailing list how to force
> a source file to be compiled always.
> 
> http://lists.gnu.org/archive/html/automake/2002-02/msg00099.html
> 
> Unfortunately the solutions mentioned there seem not to work with me. My
> Makefile.am looks like this:
> 
> ---------------------------------------------------------------
> lib_LTLIBRARIES = libMyLibrary.la
> 
> libMyLibrary_la_SOURCES =     MySourceFile.cpp \
>                         MySourceFile.h
> ---------------------------------------------------------------
> 
> and when I add the .PHONY-line I get this Makefile.am:
> 
> ---------------------------------------------------------------
> lib_LTLIBRARIES = libMyLibrary.la
> 
> .PHONY : MySourceFile.cpp
> 
> libMyLibrary_la_SOURCES =     MySourceFile.cpp \
>                         MySourceFile.h
> ---------------------------------------------------------------

I think for it to work you'd need something like:

lib_LTLIBRARIES = libMyLibrary.la
.PHONY : $(srcdir)/MySourceFile.cpp
libMyLibrary_la_SOURCES = $(srcdir)/MySourceFile.cpp \
                        MySourceFile.h


An alternative and more portable (to some non-GNU makes) way than
marking targets as phony is letting them depend upon some non-existing
pseudo target.  It is comonly named FORCE, and you need to ensure no
file with that name exists in the source or the build tree:

lib_LTLIBRARIES = libMyLibrary.la
MySourceFile.cpp: FORCE
FORCE:
libMyLibrary_la_SOURCES = MySourceFile.cpp \
                        MySourceFile.h


An even better alternative however is to not lie to make about the
actual dependency structure: why do you need your file to be compiled
always?  The answer to that question specifies what the file really
should depend upon (e.g., upon Makefile?).

Hope that helps.

Cheers,
Ralf



reply via email to

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