user3684042
user3684042

Reputation: 671

Pass a variable from bash script to a makefile

I have a bash script (like A.sh) which includes a variable like:

ToBeRead=$(sed -n '$=' LogFile)

I was wondering how can I use this variable in a makefile which is called from A.sh like:

make -f Makefile SayHello

Upvotes: 2

Views: 416

Answers (2)

Will
Will

Reputation: 4469

Forgive me if this is a dumb noob answer, but couldn't you use an environment variable?

In A.sh:

export VARIABLE=value

In makefile:

 # sets VARIABLE if not already set
 VARIABLE?=other_value

I could be wrong I'm new to makefiles as well.

Upvotes: 1

bitmask
bitmask

Reputation: 34618

You can explicitly set make variables:

make ToBeRead:="$(sed -n '$=' Logfile)" SayHello

Upvotes: 4

Related Questions