I have a directory structure like this:
./
|
|- values-1/
| |- thing0.yaml
|
|- values-2/
| |- thing1.yaml
|
|- dachart-1/
| |- thing0.yaml (this should be generated by make
| from values-1/thing0.yaml)
|- dachart-2/
| |- thing1.yaml (this should be generated by make
from values-2/thing1.yaml)
the "build rules" are basically identical, but about 30 lines long.
this very simple Makefile illustrates what works:
# WORKING makefile, but with two redundant build rules
.SOURCES:
SHELL=bash
src1_files := $(wildcard values-1/*.yaml)
src2_files := $(wildcard values-2/*.yaml)
dst1_files := $(patsubst values-%,dachart-%,$(src1_files))
dst2_files := $(patsubst values-%,dachart-%,$(src2_files))
all: $(dst2_files) $(dst1_files)
dachart-1/%.yaml: values-1/%.yaml
# SIMPLIFIED EXAMPLES
@echo "source $<"
@echo "target $@"
dachart-2/%.yaml: values-2/%.yaml
@echo "source $<"
@echo "target $@"
But since the build rules are really long and exactly the same, I would like to have one build rule definition for all the files.
After some fooling around I came up with a Makefile that seems to do what I want (and does not error out), alas the $<
expansion does no longer work (see output below).
# NON-working makefile, but kinda what I want (only one build rule)
dachart-1/%.yaml: $(src1_files)
dachart-2/%.yaml: $(src2_files)
%.yaml:
@echo "source $<"
@echo "target $@"
The outputs are:
# working makefile
source values-1/thing0.yaml
target dachart-1/thing0.yaml
# alternate makefile
source
target dachart-1/thing0.yaml
QUESTION: Is there a way to have only one build rule in the sense of my non-working Makefile?