help-make
[Top][All Lists]
Advanced

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

Re: question for multiple targets


From: Philip Guenther
Subject: Re: question for multiple targets
Date: Tue, 14 Aug 2018 19:21:01 -0900

On Tue, Aug 14, 2018 at 7:04 PM CObject <address@hidden> wrote:

> I want to use multiple targets, but when I run the following code, there
> is an error:
>
> ##################################
> Littleoutput bigoutput:text.g
>       @echo $(subst output, $@) > $@
> ####################################
>
> The result is that only the littleoutput file is generated, and my
> expected result is that the littleoutput and bigoutput files are generated.
> Confused, can you give me some directions?
>

This is the documented behavior: if no target is specified on the command
line (and the .DEFAULT_GOAL variable isn't set) then the first target of
the first rule is the default target.  See below for a specific pointer.

The traditional means for overriding this is to have the first target in
the makefile be one named 'all' whose prerequisites is the complete list of
other targets that should be built by default, ala:
----
all: Littleoutput bigoutput
.PHONY: all

Littleoutput bigoutput:text.g
        @echo $(subst output, $@) > $@
----


The specific documentation pointer in the info pages is in section 4,
"Writing Rules":
----
   The order of rules is not significant, except for determining the
"default goal": the target for `make' to consider, if you do not
otherwise specify one.  The default goal is the target of the first
rule in the first makefile.  If the first rule has multiple targets,
only the first target is taken as the default.
----


Philip Guenther


reply via email to

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