user2122968
user2122968

Reputation:

the sequence of execution of Makefile

For a Makefile like this:

HOSTARCH := $(shell uname -u | sed -e s/i.86/i386/)    
HOSTOS := $(shell uname -s | tr '[:upper:]''[:lower:]')         
export HOSTARCH HOSTOS      

unconfig:
          @rm -f $(obj)include/config.h

versatilepb_config: unconfig
@board/versatile/split_by_variant.sh $@

when I tape " make versatilepb_config", where would it begin to execute? from the beginning or from "versatilepb_config"? we get the value of HOSTARCH,HOSTOS right now or not? Then how could I print the value of HOSTOS/HOSTARCH in the console?

Upvotes: 0

Views: 387

Answers (1)

BЈовић
BЈовић

Reputation: 64203

The make build system is not executing sequentially (1st line, 2nd line, etc).

When you do make versatilepb_config, it will execute in this order:

  • set global variables (HOSTARCH and HOSTOS in your case)
  • find the rule versatilepb_config
  • then it will find pre-required rule unconfig
  • then it will execute @rm -f $(obj)include/config.h
  • then it will execute @board/versatile/split_by_variant.sh $@

If anything fails, it will stop at that step.

So, if you want to print values from the unconfig step, just add it there:

unconfig:
          @rm -f $(obj)include/config.h
          echo $HOSTARCH
          echo $HOSTOS

Upvotes: 1

Related Questions