[make] use input/output files inside makefile

whired123

Member
Joined
Nov 15, 2021
Messages
151
Reaction score
10
Credits
1,097
First a few details

Code:
$ tree
├── makefile
├── snippet.txt
└── template.txt

$ cat template.txt 
aaa $input bbb

$ cat snippet.txt 
xxx

$ cat makefile 
test:
	sh -c "input=$(cat snippet.txt) envsubst < template.txt > output2.txt"

Let's do some tests

Code:
$ input=$(cat snippet.txt) envsubst < template.txt > output1.txt

$ make
sh -c "input= envsubst < template.txt > output2.txt"

Let's look at the outputs

Code:
$ cat output1.txt 
aaa xxx bbb

$ cat output2.txt 
aaa  bbb

Why doesn't xxx appear in the output2.txt file?
 


Single quotes instead of parentheses

Code:
$ cat makefile 
test:
    sh -c "input=`cat snippet.txt` envsubst < template.txt"


$ make
sh -c "input=`cat snippet.txt` envsubst < template.txt"
aaa xxx bbb

Works!!!
 


Follow Linux.org

Staff online

Members online


Latest posts

Top