Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i import yaml file to use it in gnu make file?

How can I import a list from YAML file, to use it in a GNU make file. The list contains a few c source files as shown below.

---
- file1.c
- file2.c
- file3.c
- file4.c
...
like image 392
Prasad Roy Avatar asked Sep 18 '25 05:09

Prasad Roy


1 Answers

I don't see why it's easier to add the new source file to a yaml file than to just add it to the makefile.

But the direct answer to your question is, there's no already-existing support for yaml files in make. You'd have to write a set of shell commands or a script that could parse out the content then run it from your makefile with something like:

SOURCES := $(shell parsemy foo.yaml)

(implementation of the parsemy script left as an exercise for the reader).

If you think the makefile is too complicated to edit you can put the source definition in a separate makefile and include it:

$ cat sources.mk
SOURCES = \
    foo.c \
    bar.c \
    biz.c

$ cat makefile
include sources.mk

... do other stuff ...
like image 83
MadScientist Avatar answered Sep 19 '25 20:09

MadScientist