[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Stop reading Makefile command?
From: |
Cristian Morales Vega |
Subject: |
Re: Stop reading Makefile command? |
Date: |
Thu, 17 Dec 2015 21:35:24 +0000 |
On 17 December 2015 at 17:45, Paul Smith <address@hidden> wrote:
> On Thu, 2015-12-17 at 12:41 -0500, Paul Smith wrote:
>> On Thu, 2015-12-17 at 15:34 +0000, Cristian Morales Vega wrote:
>> > There is any way to say: "stop reading here, suppose this Makefile
>> > has no more contents, end the read-in phase and start the target
>> > -update phase"?
>>
>> No, that's not possible.
>
> Well, besides the obvious of putting the entire rest of the makefile in
> a conditional:
>
> STOP = false
> ...
> STOP = true
>
> # Don't read any of the rest of the makefile if STOP is true
> ifeq ($(STOP),true)
> ...
> endif
> <EOF>
I was trying to avoid that.
My usercase is this: I have a few programs that I want to build for
multiple devices. Developers of each program create a Makefile
defining some common variables and one include, e.g.
-----------
include $(BASE_MAKEFILE)
BINARIES := myprogram
myprogram_CFLAGS := $(shell pkg-config --cflags mydependency)
-----------
Then they can run make DEVICES="<device1> <device2>" and the program
is built for both devices.
Here "pkg-config", and other things in the real system, is a script
which depends on some variables. These variables are different for
each <deviceX>.
What I am doing is checking DEVICES in BASE_MAKEFILE. If it contains
more than one, I call the same Makefile again N times, each time with
a single, different, <deviceX>. At this point the original make
invocation just needs to take care of calling the sub-makes.
The problem is that *once* the myprogram_CFLAGS definition is executed
with DEVICES set with *all* the devices. And in this case pkg-config
fails.
This can be fixed changing the Makefile to either
-----------
include $(BASE_MAKEFILE)
BINARIES := myprogram
myprogram_CFLAGS = $(shell pkg-config --cflags mydependency)
-----------
or
-----------
include $(BASE_MAKEFILE)
ifeq ($(STOP),true)
BINARIES := myprogram
myprogram_CFLAGS := $(shell pkg-config --cflags mydependency)
endif
-----------
But I was trying to let developers use ":=", and avoid asking them to
add two more lines. For that, and avoid an error output from the
pkg-config call, I would need to to stop the read-in phase inside
BASE_MAKEFILE.