danglingpointer
danglingpointer

Reputation: 4920

How to provide make file argument to substitute in ifdef condition

I know its simple but I'm missing something here.

I want to build my code in host that is x86. When I give just make it builds for the arm.

I'm wondering how to make this build to my host? I set the variable LOCAL_BUILD:=host and the gave make host I got the error.

make: *** No rule to make target 'host'.  Stop.

common.makefile, this how it looks like.

DEFAULT: all

# Generic platform code

LOCAL_BUILD:=host

ifdef LOCAL_BUILD
include $(PLATFORM)/scripts/x86.makefile
else
include $(PLATFORM)/scripts/arm.makefile
endif

all:
ifndef  LOCAL_BUILD
    TOP=$(TOP)/scripts/see.sh
endif
    mkdir -p $(BUILD_DIR)
    $(MAKE) imag

EDIT: by default it builds for the arm, I mean just make from dir builds for arm.

How to substitute the ifdef variable from make argument?

Any help very appreciated thanks.

Upvotes: 1

Views: 1169

Answers (1)

Maxim Egorushkin
Maxim Egorushkin

Reputation: 136286

How to substitute the ifdef variable from make argument?

Variables assigned to in make command line override assignments in the makefile, e.g.:

$ cat Makefile
LOCAL_BUILD := anything
$(info LOCAL_BUILD=${LOCAL_BUILD})

$ make
LOCAL_BUILD=anything
make: *** No targets.  Stop.

$ make LOCAL_BUILD=host
LOCAL_BUILD=host
make: *** No targets.  Stop.

Upvotes: 2

Related Questions