Re: Help-make Digest, Vol 210, Issue 1

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Help-make Digest, Vol 210, Issue 1

Budi
David Deutsch, you are BRILLIANT !!

SOLVED !
Thanks billions for crystal clear explanation !

On 6/16/20, [hidden email] <[hidden email]> wrote:

> Send Help-make mailing list submissions to
> [hidden email]
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.gnu.org/mailman/listinfo/help-make
> or, via email, send a message with subject or body 'help' to
> [hidden email]
>
> You can reach the person managing the list at
> [hidden email]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Help-make digest..."
>
>
> Today's Topics:
>
>    1.  (Budi)
>    2. Re: (Budi)
>    3. Re: (Philip Guenther)
>    4. Re: (Budi)
>    5. Re: (David Deutsch)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 16 Jun 2020 06:53:26 +0700
> From: Budi <[hidden email]>
> To: [hidden email]
> Message-ID:
> <[hidden email]>
> Content-Type: text/plain; charset="UTF-8"
>
> How can we have make's 'include' command in makefile not to precede
> the first/default target in the actual processes?
> I found it always processed the earliest, how to solve this?
>
>
>
> ------------------------------
>
> Message: 2
> Date: Tue, 16 Jun 2020 08:38:47 +0700
> From: Budi <[hidden email]>
> To: [hidden email]
> Subject: Re:
> Message-ID:
> <[hidden email]>
> Content-Type: text/plain; charset="UTF-8"
>
> why as I tried to do 'include' command in a recipe it gave :
> make[1]: include: Command not found
> make[1]: *** [Makefile:537: .depend] Error 127
>
> How to do it such, must not be in global (the same scope of target)
>
> On 6/16/20, Budi <[hidden email]> wrote:
>> How can we have make's 'include' command in makefile not to precede
>> the first/default target in the actual processes?
>> I found it always processed the earliest, how to solve this?
>>
>
>
>
> ------------------------------
>
> Message: 3
> Date: Mon, 15 Jun 2020 18:26:52 -0900
> From: Philip Guenther <[hidden email]>
> To: Budi <[hidden email]>
> Cc: make-help mailing list <[hidden email]>
> Subject: Re:
> Message-ID:
> <[hidden email]>
> Content-Type: text/plain; charset="UTF-8"
>
> On Mon, Jun 15, 2020 at 5:16 PM Budi <[hidden email]> wrote:
>
>> How can we have make's 'include' command in makefile not to precede
>> the first/default target in the actual processes?
>> I found it always processed the earliest, how to solve this?
>>
>
> Can you describe the problem you're trying to solve, and then describe what
> you're doing that works and contrast it to what doesn't work but that you
> would like to work?
>
>
> ------------------------------
>
> Message: 4
> Date: Tue, 16 Jun 2020 11:00:05 +0700
> From: Budi <[hidden email]>
> To: Philip Guenther <[hidden email]>
> Cc: make-help mailing list <[hidden email]>
> Subject: Re:
> Message-ID:
> <CAH0GyZDHH1DM9gXnE0wBH20d4odwN0rpL-NrDbDZUYF=[hidden email]>
> Content-Type: text/plain; charset="UTF-8"
>
> a:
>    include makefile_a
>
> Fail as said.
>
> On 6/16/20, Philip Guenther <[hidden email]> wrote:
>> On Mon, Jun 15, 2020 at 5:16 PM Budi <[hidden email]> wrote:
>>
>>> How can we have make's 'include' command in makefile not to precede
>>> the first/default target in the actual processes?
>>> I found it always processed the earliest, how to solve this?
>>>
>>
>> Can you describe the problem you're trying to solve, and then describe
>> what
>> you're doing that works and contrast it to what doesn't work but that you
>> would like to work?
>>
>
>
>
> ------------------------------
>
> Message: 5
> Date: Tue, 16 Jun 2020 09:00:12 +0200
> From: David Deutsch <[hidden email]>
> To: make-help mailing list <[hidden email]>
> Subject: Re:
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset=utf-8
>
> As a rule of thumb: Anything that you indent (the "recipe") as part of a
> target is going to be executed in the shell.
>
> What you did in your example is like typing "include makefile_a" in your
> terminal, which fails as bash doesn't know what to do with it.
>
> Conversely, "include" is a make directive that needs to sit outside of a
> target.
>
> If you want to conditionally include a makefile only when a certain
> target is being built, you can try:
>
> ifeq ($(MAKECMDGOALS),a)
> include makefile_a
> endif
>
> This finds out if the current goal (as in: if you typed 'make a' into
> your shell) is 'a' and then includes 'makefile_a'.
>
> Do note that this only works for the target you supply - 'MAKECMDGOALS'
> does not reflect the target make is building at the time, but only the
> one you supplied as a goal.
>
> -David
>
>
> On 16/06/2020 06:00, Budi wrote:
>> a:
>>    include makefile_a
>>
>> Fail as said.
>>
>> On 6/16/20, Philip Guenther <[hidden email]> wrote:
>>> On Mon, Jun 15, 2020 at 5:16 PM Budi <[hidden email]> wrote:
>>>
>>>> How can we have make's 'include' command in makefile not to precede
>>>> the first/default target in the actual processes?
>>>> I found it always processed the earliest, how to solve this?
>>>>
>>> Can you describe the problem you're trying to solve, and then describe
>>> what
>>> you're doing that works and contrast it to what doesn't work but that you
>>> would like to work?
>>>
>
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> Help-make mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/help-make
>
>
> ------------------------------
>
> End of Help-make Digest, Vol 210, Issue 1
> *****************************************
>

Reply | Threaded
Open this post in threaded view
|

Re: Help-make Digest, Vol 210, Issue 1

Budi
How do we have 'make' to echo just like Bash but is done in place of
prerequisite so it must be really 'make' command not shell

On 6/17/20, Budi <[hidden email]> wrote:

> David Deutsch, you are BRILLIANT !!
>
> SOLVED !
> Thanks billions for crystal clear explanation !
>
> On 6/16/20, [hidden email] <[hidden email]> wrote:
>> Send Help-make mailing list submissions to
>> [hidden email]
>>
>> To subscribe or unsubscribe via the World Wide Web, visit
>> https://lists.gnu.org/mailman/listinfo/help-make
>> or, via email, send a message with subject or body 'help' to
>> [hidden email]
>>
>> You can reach the person managing the list at
>> [hidden email]
>>
>> When replying, please edit your Subject line so it is more specific
>> than "Re: Contents of Help-make digest..."
>>
>>
>> Today's Topics:
>>
>>    1.  (Budi)
>>    2. Re: (Budi)
>>    3. Re: (Philip Guenther)
>>    4. Re: (Budi)
>>    5. Re: (David Deutsch)
>>
>>
>> ----------------------------------------------------------------------
>>
>> Message: 1
>> Date: Tue, 16 Jun 2020 06:53:26 +0700
>> From: Budi <[hidden email]>
>> To: [hidden email]
>> Message-ID:
>> <[hidden email]>
>> Content-Type: text/plain; charset="UTF-8"
>>
>> How can we have make's 'include' command in makefile not to precede
>> the first/default target in the actual processes?
>> I found it always processed the earliest, how to solve this?
>>
>>
>>
>> ------------------------------
>>
>> Message: 2
>> Date: Tue, 16 Jun 2020 08:38:47 +0700
>> From: Budi <[hidden email]>
>> To: [hidden email]
>> Subject: Re:
>> Message-ID:
>> <[hidden email]>
>> Content-Type: text/plain; charset="UTF-8"
>>
>> why as I tried to do 'include' command in a recipe it gave :
>> make[1]: include: Command not found
>> make[1]: *** [Makefile:537: .depend] Error 127
>>
>> How to do it such, must not be in global (the same scope of target)
>>
>> On 6/16/20, Budi <[hidden email]> wrote:
>>> How can we have make's 'include' command in makefile not to precede
>>> the first/default target in the actual processes?
>>> I found it always processed the earliest, how to solve this?
>>>
>>
>>
>>
>> ------------------------------
>>
>> Message: 3
>> Date: Mon, 15 Jun 2020 18:26:52 -0900
>> From: Philip Guenther <[hidden email]>
>> To: Budi <[hidden email]>
>> Cc: make-help mailing list <[hidden email]>
>> Subject: Re:
>> Message-ID:
>> <[hidden email]>
>> Content-Type: text/plain; charset="UTF-8"
>>
>> On Mon, Jun 15, 2020 at 5:16 PM Budi <[hidden email]> wrote:
>>
>>> How can we have make's 'include' command in makefile not to precede
>>> the first/default target in the actual processes?
>>> I found it always processed the earliest, how to solve this?
>>>
>>
>> Can you describe the problem you're trying to solve, and then describe
>> what
>> you're doing that works and contrast it to what doesn't work but that you
>> would like to work?
>>
>>
>> ------------------------------
>>
>> Message: 4
>> Date: Tue, 16 Jun 2020 11:00:05 +0700
>> From: Budi <[hidden email]>
>> To: Philip Guenther <[hidden email]>
>> Cc: make-help mailing list <[hidden email]>
>> Subject: Re:
>> Message-ID:
>> <CAH0GyZDHH1DM9gXnE0wBH20d4odwN0rpL-NrDbDZUYF=[hidden email]>
>> Content-Type: text/plain; charset="UTF-8"
>>
>> a:
>>    include makefile_a
>>
>> Fail as said.
>>
>> On 6/16/20, Philip Guenther <[hidden email]> wrote:
>>> On Mon, Jun 15, 2020 at 5:16 PM Budi <[hidden email]> wrote:
>>>
>>>> How can we have make's 'include' command in makefile not to precede
>>>> the first/default target in the actual processes?
>>>> I found it always processed the earliest, how to solve this?
>>>>
>>>
>>> Can you describe the problem you're trying to solve, and then describe
>>> what
>>> you're doing that works and contrast it to what doesn't work but that
>>> you
>>> would like to work?
>>>
>>
>>
>>
>> ------------------------------
>>
>> Message: 5
>> Date: Tue, 16 Jun 2020 09:00:12 +0200
>> From: David Deutsch <[hidden email]>
>> To: make-help mailing list <[hidden email]>
>> Subject: Re:
>> Message-ID: <[hidden email]>
>> Content-Type: text/plain; charset=utf-8
>>
>> As a rule of thumb: Anything that you indent (the "recipe") as part of a
>> target is going to be executed in the shell.
>>
>> What you did in your example is like typing "include makefile_a" in your
>> terminal, which fails as bash doesn't know what to do with it.
>>
>> Conversely, "include" is a make directive that needs to sit outside of a
>> target.
>>
>> If you want to conditionally include a makefile only when a certain
>> target is being built, you can try:
>>
>> ifeq ($(MAKECMDGOALS),a)
>> include makefile_a
>> endif
>>
>> This finds out if the current goal (as in: if you typed 'make a' into
>> your shell) is 'a' and then includes 'makefile_a'.
>>
>> Do note that this only works for the target you supply - 'MAKECMDGOALS'
>> does not reflect the target make is building at the time, but only the
>> one you supplied as a goal.
>>
>> -David
>>
>>
>> On 16/06/2020 06:00, Budi wrote:
>>> a:
>>>    include makefile_a
>>>
>>> Fail as said.
>>>
>>> On 6/16/20, Philip Guenther <[hidden email]> wrote:
>>>> On Mon, Jun 15, 2020 at 5:16 PM Budi <[hidden email]> wrote:
>>>>
>>>>> How can we have make's 'include' command in makefile not to precede
>>>>> the first/default target in the actual processes?
>>>>> I found it always processed the earliest, how to solve this?
>>>>>
>>>> Can you describe the problem you're trying to solve, and then describe
>>>> what
>>>> you're doing that works and contrast it to what doesn't work but that
>>>> you
>>>> would like to work?
>>>>
>>
>>
>>
>> ------------------------------
>>
>> Subject: Digest Footer
>>
>> _______________________________________________
>> Help-make mailing list
>> [hidden email]
>> https://lists.gnu.org/mailman/listinfo/help-make
>>
>>
>> ------------------------------
>>
>> End of Help-make Digest, Vol 210, Issue 1
>> *****************************************
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Help-make Digest, Vol 210, Issue 1

Budi
Why in a single `make` prerequisite consist of many targets names, if
there's one target being listed more than once, the first only will
get processed while the next is to be ignored/skipped, how to have
that repeated target name in that prerequisite all are to be processed
?

On 6/18/20, Budi <[hidden email]> wrote:

> How do we have 'make' to echo just like Bash but is done in place of
> prerequisite so it must be really 'make' command not shell
>
> On 6/17/20, Budi <[hidden email]> wrote:
>> David Deutsch, you are BRILLIANT !!
>>
>> SOLVED !
>> Thanks billions for crystal clear explanation !
>>
>> On 6/16/20, [hidden email] <[hidden email]> wrote:
>>> Send Help-make mailing list submissions to
>>> [hidden email]
>>>
>>> To subscribe or unsubscribe via the World Wide Web, visit
>>> https://lists.gnu.org/mailman/listinfo/help-make
>>> or, via email, send a message with subject or body 'help' to
>>> [hidden email]
>>>
>>> You can reach the person managing the list at
>>> [hidden email]
>>>
>>> When replying, please edit your Subject line so it is more specific
>>> than "Re: Contents of Help-make digest..."
>>>
>>>
>>> Today's Topics:
>>>
>>>    1.  (Budi)
>>>    2. Re: (Budi)
>>>    3. Re: (Philip Guenther)
>>>    4. Re: (Budi)
>>>    5. Re: (David Deutsch)
>>>
>>>
>>> ----------------------------------------------------------------------
>>>
>>> Message: 1
>>> Date: Tue, 16 Jun 2020 06:53:26 +0700
>>> From: Budi <[hidden email]>
>>> To: [hidden email]
>>> Message-ID:
>>> <[hidden email]>
>>> Content-Type: text/plain; charset="UTF-8"
>>>
>>> How can we have make's 'include' command in makefile not to precede
>>> the first/default target in the actual processes?
>>> I found it always processed the earliest, how to solve this?
>>>
>>>
>>>
>>> ------------------------------
>>>
>>> Message: 2
>>> Date: Tue, 16 Jun 2020 08:38:47 +0700
>>> From: Budi <[hidden email]>
>>> To: [hidden email]
>>> Subject: Re:
>>> Message-ID:
>>> <[hidden email]>
>>> Content-Type: text/plain; charset="UTF-8"
>>>
>>> why as I tried to do 'include' command in a recipe it gave :
>>> make[1]: include: Command not found
>>> make[1]: *** [Makefile:537: .depend] Error 127
>>>
>>> How to do it such, must not be in global (the same scope of target)
>>>
>>> On 6/16/20, Budi <[hidden email]> wrote:
>>>> How can we have make's 'include' command in makefile not to precede
>>>> the first/default target in the actual processes?
>>>> I found it always processed the earliest, how to solve this?
>>>>
>>>
>>>
>>>
>>> ------------------------------
>>>
>>> Message: 3
>>> Date: Mon, 15 Jun 2020 18:26:52 -0900
>>> From: Philip Guenther <[hidden email]>
>>> To: Budi <[hidden email]>
>>> Cc: make-help mailing list <[hidden email]>
>>> Subject: Re:
>>> Message-ID:
>>> <[hidden email]>
>>> Content-Type: text/plain; charset="UTF-8"
>>>
>>> On Mon, Jun 15, 2020 at 5:16 PM Budi <[hidden email]> wrote:
>>>
>>>> How can we have make's 'include' command in makefile not to precede
>>>> the first/default target in the actual processes?
>>>> I found it always processed the earliest, how to solve this?
>>>>
>>>
>>> Can you describe the problem you're trying to solve, and then describe
>>> what
>>> you're doing that works and contrast it to what doesn't work but that
>>> you
>>> would like to work?
>>>
>>>
>>> ------------------------------
>>>
>>> Message: 4
>>> Date: Tue, 16 Jun 2020 11:00:05 +0700
>>> From: Budi <[hidden email]>
>>> To: Philip Guenther <[hidden email]>
>>> Cc: make-help mailing list <[hidden email]>
>>> Subject: Re:
>>> Message-ID:
>>> <CAH0GyZDHH1DM9gXnE0wBH20d4odwN0rpL-NrDbDZUYF=[hidden email]>
>>> Content-Type: text/plain; charset="UTF-8"
>>>
>>> a:
>>>    include makefile_a
>>>
>>> Fail as said.
>>>
>>> On 6/16/20, Philip Guenther <[hidden email]> wrote:
>>>> On Mon, Jun 15, 2020 at 5:16 PM Budi <[hidden email]> wrote:
>>>>
>>>>> How can we have make's 'include' command in makefile not to precede
>>>>> the first/default target in the actual processes?
>>>>> I found it always processed the earliest, how to solve this?
>>>>>
>>>>
>>>> Can you describe the problem you're trying to solve, and then describe
>>>> what
>>>> you're doing that works and contrast it to what doesn't work but that
>>>> you
>>>> would like to work?
>>>>
>>>
>>>
>>>
>>> ------------------------------
>>>
>>> Message: 5
>>> Date: Tue, 16 Jun 2020 09:00:12 +0200
>>> From: David Deutsch <[hidden email]>
>>> To: make-help mailing list <[hidden email]>
>>> Subject: Re:
>>> Message-ID: <[hidden email]>
>>> Content-Type: text/plain; charset=utf-8
>>>
>>> As a rule of thumb: Anything that you indent (the "recipe") as part of a
>>> target is going to be executed in the shell.
>>>
>>> What you did in your example is like typing "include makefile_a" in your
>>> terminal, which fails as bash doesn't know what to do with it.
>>>
>>> Conversely, "include" is a make directive that needs to sit outside of a
>>> target.
>>>
>>> If you want to conditionally include a makefile only when a certain
>>> target is being built, you can try:
>>>
>>> ifeq ($(MAKECMDGOALS),a)
>>> include makefile_a
>>> endif
>>>
>>> This finds out if the current goal (as in: if you typed 'make a' into
>>> your shell) is 'a' and then includes 'makefile_a'.
>>>
>>> Do note that this only works for the target you supply - 'MAKECMDGOALS'
>>> does not reflect the target make is building at the time, but only the
>>> one you supplied as a goal.
>>>
>>> -David
>>>
>>>
>>> On 16/06/2020 06:00, Budi wrote:
>>>> a:
>>>>    include makefile_a
>>>>
>>>> Fail as said.
>>>>
>>>> On 6/16/20, Philip Guenther <[hidden email]> wrote:
>>>>> On Mon, Jun 15, 2020 at 5:16 PM Budi <[hidden email]> wrote:
>>>>>
>>>>>> How can we have make's 'include' command in makefile not to precede
>>>>>> the first/default target in the actual processes?
>>>>>> I found it always processed the earliest, how to solve this?
>>>>>>
>>>>> Can you describe the problem you're trying to solve, and then describe
>>>>> what
>>>>> you're doing that works and contrast it to what doesn't work but that
>>>>> you
>>>>> would like to work?
>>>>>
>>>
>>>
>>>
>>> ------------------------------
>>>
>>> Subject: Digest Footer
>>>
>>> _______________________________________________
>>> Help-make mailing list
>>> [hidden email]
>>> https://lists.gnu.org/mailman/listinfo/help-make
>>>
>>>
>>> ------------------------------
>>>
>>> End of Help-make Digest, Vol 210, Issue 1
>>> *****************************************
>>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Help-make Digest, Vol 210, Issue 1

David Deutsch
Try to conceptualize it like this:

When make (re-)builds a target, it tries to do the minimal necessary
amount of work to do that. If a target has prerequisites that are far
older than the current version of the target, make will not try to
rebuild them because it assumes they have not changed.

From that follows that once make has built a prerequisite, it assumes
that it is the freshest copy possible and will not try to rebuild it
(why would it! It's brand new!). Through simple mechanics like that,
make establishes the most effective graph to build what you want it to
build.


You seem to assume that it takes the list of prerequisites as a fixed
number of steps to go through before building the target. That is not
what is happening.

If your build tree relies on this assumption than you need to fix up
your build tree to… not do that.


The key to being happy with make is to realize that it is the underlying
model is probably right and you're not talking to it correctly. Iterate
through your options a few times until you find something that does.
Once you have done that, be thankful to make for forcing you to express
what it is you wanted to do in a cleaner way.

Since your questions so far have been rather basic, I would highly
recommend reading the make manual very closely. Even just the first 20
or so pages are an extremely dense trove of information. Studying them
will help you come up with better questions ;-)

- David


On 18/06/2020 07:12, Budi wrote:

> Why in a single `make` prerequisite consist of many targets names, if
> there's one target being listed more than once, the first only will
> get processed while the next is to be ignored/skipped, how to have
> that repeated target name in that prerequisite all are to be processed
> ?
>
> On 6/18/20, Budi <[hidden email]> wrote:
>> How do we have 'make' to echo just like Bash but is done in place of
>> prerequisite so it must be really 'make' command not shell
>>
>> On 6/17/20, Budi <[hidden email]> wrote:
>>> David Deutsch, you are BRILLIANT !!
>>>
>>> SOLVED !
>>> Thanks billions for crystal clear explanation !
>>>
>>> On 6/16/20, [hidden email] <[hidden email]> wrote:
>>>> Send Help-make mailing list submissions to
>>>> [hidden email]
>>>>
>>>> To subscribe or unsubscribe via the World Wide Web, visit
>>>> https://lists.gnu.org/mailman/listinfo/help-make
>>>> or, via email, send a message with subject or body 'help' to
>>>> [hidden email]
>>>>
>>>> You can reach the person managing the list at
>>>> [hidden email]
>>>>
>>>> When replying, please edit your Subject line so it is more specific
>>>> than "Re: Contents of Help-make digest..."
>>>>
>>>>
>>>> Today's Topics:
>>>>
>>>>    1.  (Budi)
>>>>    2. Re: (Budi)
>>>>    3. Re: (Philip Guenther)
>>>>    4. Re: (Budi)
>>>>    5. Re: (David Deutsch)
>>>>
>>>>
>>>> ----------------------------------------------------------------------
>>>>
>>>> Message: 1
>>>> Date: Tue, 16 Jun 2020 06:53:26 +0700
>>>> From: Budi <[hidden email]>
>>>> To: [hidden email]
>>>> Message-ID:
>>>> <[hidden email]>
>>>> Content-Type: text/plain; charset="UTF-8"
>>>>
>>>> How can we have make's 'include' command in makefile not to precede
>>>> the first/default target in the actual processes?
>>>> I found it always processed the earliest, how to solve this?
>>>>
>>>>
>>>>
>>>> ------------------------------
>>>>
>>>> Message: 2
>>>> Date: Tue, 16 Jun 2020 08:38:47 +0700
>>>> From: Budi <[hidden email]>
>>>> To: [hidden email]
>>>> Subject: Re:
>>>> Message-ID:
>>>> <[hidden email]>
>>>> Content-Type: text/plain; charset="UTF-8"
>>>>
>>>> why as I tried to do 'include' command in a recipe it gave :
>>>> make[1]: include: Command not found
>>>> make[1]: *** [Makefile:537: .depend] Error 127
>>>>
>>>> How to do it such, must not be in global (the same scope of target)
>>>>
>>>> On 6/16/20, Budi <[hidden email]> wrote:
>>>>> How can we have make's 'include' command in makefile not to precede
>>>>> the first/default target in the actual processes?
>>>>> I found it always processed the earliest, how to solve this?
>>>>>
>>>>
>>>>
>>>> ------------------------------
>>>>
>>>> Message: 3
>>>> Date: Mon, 15 Jun 2020 18:26:52 -0900
>>>> From: Philip Guenther <[hidden email]>
>>>> To: Budi <[hidden email]>
>>>> Cc: make-help mailing list <[hidden email]>
>>>> Subject: Re:
>>>> Message-ID:
>>>> <[hidden email]>
>>>> Content-Type: text/plain; charset="UTF-8"
>>>>
>>>> On Mon, Jun 15, 2020 at 5:16 PM Budi <[hidden email]> wrote:
>>>>
>>>>> How can we have make's 'include' command in makefile not to precede
>>>>> the first/default target in the actual processes?
>>>>> I found it always processed the earliest, how to solve this?
>>>>>
>>>> Can you describe the problem you're trying to solve, and then describe
>>>> what
>>>> you're doing that works and contrast it to what doesn't work but that
>>>> you
>>>> would like to work?
>>>>
>>>>
>>>> ------------------------------
>>>>
>>>> Message: 4
>>>> Date: Tue, 16 Jun 2020 11:00:05 +0700
>>>> From: Budi <[hidden email]>
>>>> To: Philip Guenther <[hidden email]>
>>>> Cc: make-help mailing list <[hidden email]>
>>>> Subject: Re:
>>>> Message-ID:
>>>> <CAH0GyZDHH1DM9gXnE0wBH20d4odwN0rpL-NrDbDZUYF=[hidden email]>
>>>> Content-Type: text/plain; charset="UTF-8"
>>>>
>>>> a:
>>>>    include makefile_a
>>>>
>>>> Fail as said.
>>>>
>>>> On 6/16/20, Philip Guenther <[hidden email]> wrote:
>>>>> On Mon, Jun 15, 2020 at 5:16 PM Budi <[hidden email]> wrote:
>>>>>
>>>>>> How can we have make's 'include' command in makefile not to precede
>>>>>> the first/default target in the actual processes?
>>>>>> I found it always processed the earliest, how to solve this?
>>>>>>
>>>>> Can you describe the problem you're trying to solve, and then describe
>>>>> what
>>>>> you're doing that works and contrast it to what doesn't work but that
>>>>> you
>>>>> would like to work?
>>>>>
>>>>
>>>>
>>>> ------------------------------
>>>>
>>>> Message: 5
>>>> Date: Tue, 16 Jun 2020 09:00:12 +0200
>>>> From: David Deutsch <[hidden email]>
>>>> To: make-help mailing list <[hidden email]>
>>>> Subject: Re:
>>>> Message-ID: <[hidden email]>
>>>> Content-Type: text/plain; charset=utf-8
>>>>
>>>> As a rule of thumb: Anything that you indent (the "recipe") as part of a
>>>> target is going to be executed in the shell.
>>>>
>>>> What you did in your example is like typing "include makefile_a" in your
>>>> terminal, which fails as bash doesn't know what to do with it.
>>>>
>>>> Conversely, "include" is a make directive that needs to sit outside of a
>>>> target.
>>>>
>>>> If you want to conditionally include a makefile only when a certain
>>>> target is being built, you can try:
>>>>
>>>> ifeq ($(MAKECMDGOALS),a)
>>>> include makefile_a
>>>> endif
>>>>
>>>> This finds out if the current goal (as in: if you typed 'make a' into
>>>> your shell) is 'a' and then includes 'makefile_a'.
>>>>
>>>> Do note that this only works for the target you supply - 'MAKECMDGOALS'
>>>> does not reflect the target make is building at the time, but only the
>>>> one you supplied as a goal.
>>>>
>>>> -David
>>>>
>>>>
>>>> On 16/06/2020 06:00, Budi wrote:
>>>>> a:
>>>>>    include makefile_a
>>>>>
>>>>> Fail as said.
>>>>>
>>>>> On 6/16/20, Philip Guenther <[hidden email]> wrote:
>>>>>> On Mon, Jun 15, 2020 at 5:16 PM Budi <[hidden email]> wrote:
>>>>>>
>>>>>>> How can we have make's 'include' command in makefile not to precede
>>>>>>> the first/default target in the actual processes?
>>>>>>> I found it always processed the earliest, how to solve this?
>>>>>>>
>>>>>> Can you describe the problem you're trying to solve, and then describe
>>>>>> what
>>>>>> you're doing that works and contrast it to what doesn't work but that
>>>>>> you
>>>>>> would like to work?
>>>>>>
>>>>
>>>>
>>>> ------------------------------
>>>>
>>>> Subject: Digest Footer
>>>>
>>>> _______________________________________________
>>>> Help-make mailing list
>>>> [hidden email]
>>>> https://lists.gnu.org/mailman/listinfo/help-make
>>>>
>>>>
>>>> ------------------------------
>>>>
>>>> End of Help-make Digest, Vol 210, Issue 1
>>>> *****************************************
>>>>

Reply | Threaded
Open this post in threaded view
|

Re: Help-make Digest, Vol 210, Issue 1

Budi
In reply to this post by Budi
Why this working nice

CXXFLAGS := -Wcast-qual -std=c++11 $(EXTRACXXFLAGS)

becomes awful when
override CXXFLAGS := -Wcast-qual -std=c++11 $(EXTRACXXFLAGS)

due to the destroyed $(EXTRACXXFLAGS) ?

What is the culprit, and How to restore or solve it ?

Reply | Threaded
Open this post in threaded view
|

A solution to achieve partial .NOTPARALLEL

David Deutsch
In reply to this post by Budi
Hey everybody,

I've been looking through the mailing list trying to come up with an
answer to how I could do .NOT_PARALLEL for some targets but not others.

There hasn't been a solution thus far and it has been mentioned that
implementing it in make itself might be highly non-trivial. I think that
I've come up with a solution for my case that I wanted to share with
you. Perhaps it could inform a more generalized solution.

So in my case, I want to create linux user accounts as a target like so:


/home/[newUserName]/:
    adduser [newUserName]


If you run this in parallel with other targets like it (just replacing
[newUserName], of course), it fails because you get user ID conflicts
(it tries to use the same user ID for all of the accounts, because they
all iterate on the same base number, which creates a lot of issues)


My solution looks like this:


ifeq ($(origin NOTPARALLEL),undefined)
NOTPARALLEL :=
endif

/home/[newUserName]/: | $(NOTPARALLEL)
    adduser [newUserName]

NOTPARALLEL += /home/[newUserName]/


so that no matter how many times or where I use this snippet, all of the
targets are lined up sequentially.


This got me wondering though: Perhaps this kind of "grouped
non-parallel" approach could actually work out and be cheap to implement?

As in - If you write:

.NOTPARALLEL: target_a target_b target_c

target_a:
    myCmd

target_b:
    myCmd

target_c:
    myCmd


That gets interpreted as:

ifeq ($(origin NOTPARALLEL),undefined)
NOTPARALLEL :=
endif

target_a: | $(NOTPARALLEL)
    myCmd

NOTPARALLEL += target_a

target_b: | $(NOTPARALLEL)
    myCmd

NOTPARALLEL += target_b

target_c: | $(NOTPARALLEL)
    myCmd

NOTPARALLEL += target_c


I know that it's not a perfect solution (and it would be hard to make
this work with pattern rules), but perhaps it's good enough to at least
cover most of the cases where people expect ".NOTPARALLEL: x y z" to
work this way?

The other caveat of this is that an order-only-prerequisite only means
that this would work for newly generated files, not for updating them.
For that you'd need regular prerequisites, but then you'd interfere with
recipes that depend on a clean $^ variable.


best regards,
David


Reply | Threaded
Open this post in threaded view
|

Re: A solution to achieve partial .NOTPARALLEL

David Boyce-3
I haven't looked closely at your example but the problem reminds me of one
for which I have a different solution. See attached Makefile and run "make
help" to get started. My solution assumes Linux or at least the presence of
an equivalent command-line interface to file locking.

David B

On Fri, Jul 31, 2020 at 6:35 AM David Deutsch <[hidden email]> wrote:

> Hey everybody,
>
> I've been looking through the mailing list trying to come up with an
> answer to how I could do .NOT_PARALLEL for some targets but not others.
>
> There hasn't been a solution thus far and it has been mentioned that
> implementing it in make itself might be highly non-trivial. I think that
> I've come up with a solution for my case that I wanted to share with
> you. Perhaps it could inform a more generalized solution.
>
> So in my case, I want to create linux user accounts as a target like so:
>
>
> /home/[newUserName]/:
>     adduser [newUserName]
>
>
> If you run this in parallel with other targets like it (just replacing
> [newUserName], of course), it fails because you get user ID conflicts
> (it tries to use the same user ID for all of the accounts, because they
> all iterate on the same base number, which creates a lot of issues)
>
>
> My solution looks like this:
>
>
> ifeq ($(origin NOTPARALLEL),undefined)
> NOTPARALLEL :=
> endif
>
> /home/[newUserName]/: | $(NOTPARALLEL)
>     adduser [newUserName]
>
> NOTPARALLEL += /home/[newUserName]/
>
>
> so that no matter how many times or where I use this snippet, all of the
> targets are lined up sequentially.
>
>
> This got me wondering though: Perhaps this kind of "grouped
> non-parallel" approach could actually work out and be cheap to implement?
>
> As in - If you write:
>
> .NOTPARALLEL: target_a target_b target_c
>
> target_a:
>     myCmd
>
> target_b:
>     myCmd
>
> target_c:
>     myCmd
>
>
> That gets interpreted as:
>
> ifeq ($(origin NOTPARALLEL),undefined)
> NOTPARALLEL :=
> endif
>
> target_a: | $(NOTPARALLEL)
>     myCmd
>
> NOTPARALLEL += target_a
>
> target_b: | $(NOTPARALLEL)
>     myCmd
>
> NOTPARALLEL += target_b
>
> target_c: | $(NOTPARALLEL)
>     myCmd
>
> NOTPARALLEL += target_c
>
>
> I know that it's not a perfect solution (and it would be hard to make
> this work with pattern rules), but perhaps it's good enough to at least
> cover most of the cases where people expect ".NOTPARALLEL: x y z" to
> work this way?
>
> The other caveat of this is that an order-only-prerequisite only means
> that this would work for newly generated files, not for updating them.
> For that you'd need regular prerequisites, but then you'd interfere with
> recipes that depend on a clean $^ variable.
>
>
> best regards,
> David
>
>
>

Makefile (1K) Download Attachment