3 ms·
Ooh, a tricky one. It may be much more difficult. SOURCES := $(shell find foo -type f -name '*.jsx') TARGETS := $(patsubst foo/%.jsx,bar/%.js,$(SOURCES))
by dozzie 11y ago
Ooh, a tricky one. It may be much more difficult.
SOURCES := $(shell find foo -type f -name '*.jsx')
TARGETS := $(patsubst foo/%.jsx,bar/%.js,$(SOURCES))
.PHONY: all
all: $(TARGETS)
bar/%.js: foo/%.jsx
mkdir -p $(dir $@)
minify $< > $@
- foldr 11y agoI admit, this is easy enough with 'patsubst' and 'dir'. I had not discovered those, and doing the same job with sed got too messy to be worth the trouble. I haven’t seen example code for this particular pattern before, so thanks, it’s useful. I'll switch over to make now.
- dozzie 11y agoI'm glad you like this solution. Indeed, the $(patsubt) function is one of the most useful, along with $(wildcard) and $(foreach).