automake
[Top][All Lists]
Advanced

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

Re: Create a custom target


From: Tavian Barnes
Subject: Re: Create a custom target
Date: Mon, 7 Jul 2008 07:39:07 -0600

On Sun, Jul 6, 2008 at 11:25 PM, Ralf Wildenhues <address@hidden> wrote:
> Hello Tavian,
>
> please don't top-post, thank you.

Sorry, I got lazy.  Stupid GMail.

> * Tavian Barnes wrote on Sun, Jul 06, 2008 at 07:45:23PM CEST:
>> On Sun, Jul 6, 2008 at 1:59 AM, Ralf Wildenhues <address@hidden> wrote:
>> >
>> > Most of the Makefile.am text is copied verbatim into the Makefile.in
>> > (and from there into the Makefile).  So if you want to add custom
>> > targets, just write plain make rules:
>> >
>> > bench: prerequisites...
>> >        ... compile
>> >        ...
>> > .PHONY: bench
>>
>> Okay, but how do I then get automake to handle the compilation?  I
>> don't want to type in the compilation commands myself; that's what
>> automake is for.  If I add the benchmarking program to
>> noinst_PROGRAMS, it compiles when 'make' is run, rather than only when
>> 'make bench' is run.
>
> Ah, ok.  Then you can use something like:
>
> EXTRA_PROGRAMS = prog
> prog_SOURCES = ...
> bench: prog$(EXEEXT)
>        execute prog$(EXEEXT)...
> .PHONY: bench

This works great, thanks.  What does .PHONY do?

>> Also, when I wrote a custom target in
>> bench/Makefile.am, the root makefile didn't seem to notice, and
>> running make bench from the root of the project simply gave "make:
>> Nothing to be done for `bench'."
>
> Either you look into nonrecursive Makefiles, or you will have to write a
> forwarding target, e.g.:
>
> bench:
>        cd bench && $(MAKE) $(AM_MAKEFLAGS) bench
> .PHONY: bench

Ha, that's almost exactly what I ended up writing.

> If you have several of those nonstandard targets you need to forward,
> you may want to copy the (slightly more involved) way automake handles
> recursive targets.
>
> Hope that helps.
>
> Cheers,
> Ralf
>

Thanks a lot,
-- 
Tavian Barnes




reply via email to

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