On Tue, Aug 14, 2018 at 7:04 PM CObject <nibing671...@foxmail.com> 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
_______________________________________________
Help-make mailing list
Help-make@gnu.org
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to