Makefile rule to create several files, that each depend on different targets -
i trying write makefile file aggregation. following: have data several days ate breakfast lunch , dinner. files named like:
monday_breakfast.meal monday_lunch.meal monday_dinner.meal tuesday_breakfast.meal ...
or if working numbers makes simpler:
00_00.meal 00_11.meal 00_22.meal 11_00.meal ...
the objective aggregate 3 files each day single file each day, days. possible write rule this? tricky part don't know how many days worth of files there when run make, want generic.
i thinking like:
days= $(sort $(patsubst _*,,*.meal)) day: %.day: $(days):
but stuck. using sort of exercise learn more makefiles---it seemed easy @ first can not think through.
make's ability manipulate strings not 1 might desire. here goes.
suppose have:
monday_breakfast.meal monday_lunch.meal monday_dinner.meal tuesday_breakfast.meal tuesday_lunch.meal tuesday_dinner.meal wednesday_breakfast.meal
first, names of meal
files:
meals := $(wildcard *.meal)
then somehow want reduce list names of days. if take one filename:
firstmeal := monday_breakfast.meal
we can split turning underscore space, grab first fragment:
frags := $(subst _, , $(firstmeal)) # monday breakfast.meal firstday := $(word 1, $(frags)) # monday
so can meals:
days := $(sort $(foreach x,$(meals), $(word 1,$(subst _, ,$(x)))))
(the sort
removes repetitions in list.)
now have days
("monday tuesday wednesday"), want write rule or rules aggregation. how easy depends on kind of aggregation mean, tool you'll use, , whether accepts wildcards.
Comments
Post a Comment