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

Solution 1:

Assuming GNU make:

file := whatever.txt
variable := $(shell cat ${file})

Solution 2:

I'm guessing that you like to set a variable in your Makefile to the contents of another file:

FILE=test.txt
VARIABLE=`cat $(FILE)`

target:
    echo $(VARIABLE)

Solution 3:

GNU make version 4.2 supports file reading operation, so with respect to Maxim Egorushkin's great answer there is an optional way to solve this problem now:

FILE     := test.txt
variable :=$(file < $(FILE))