Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a variable in a makefile by reading contents of another file

Tags:

makefile

How can I create a variable on-the-fly from makefile, the value of which would be the entire contents of another data file.

like image 415
Srinath Avatar asked Jul 20 '11 19:07

Srinath


People also ask

What is $@ in makefile?

The variable $@ represents the name of the target and $< represents the first prerequisite required to create the output file.

What does += mean in makefile?

+= is used for appending more text to variables e.g. objects=main.o foo.o bar.o. objects+=new.o. which will set objects to 'main.o foo.o bar.o new.o' = is for recursively expanded variable.

What is automatic variable in makefile?

makefile Variables Automatic Variables Within the context of an individual rule, Make automatically defines a number of special variables. These variables can have a different value for each rule in a makefile and are designed to make writing rules simpler.


1 Answers

Assuming GNU make:

file := whatever.txt variable := $(shell cat ${file}) 
like image 77
Maxim Egorushkin Avatar answered Sep 29 '22 03:09

Maxim Egorushkin