Danijel
Danijel

Reputation: 8604

GNU make: text replacement at two places in the same string?

In a GNU makefile, I need to rename
/infiles/signal_*.wav
to
/outfiles/out_signal_*.wav

This works (using subst):

SIGNALIN += $(wildcard /infiles/signal_*.wav)

TEMP += $(subst infiles,outfiles, $(SIGNALIN) )
SIGNALOUT += $(subst signal,out_signal, $(TEMP) )

Is there a better, one-line way that would not include the TEMP line?

Upvotes: 0

Views: 24

Answers (2)

Renaud Pacalet
Renaud Pacalet

Reputation: 29177

In your case there are not really replacements at two places. What you want is replace /infiles/ at the beginning of each word by /outfiles/out_. And that's one place. Try:

SIGNALOUT := $(patsubst /infiles/%,/outfiles/out_%,$(SIGNALIN))

Upvotes: 0

tripleee
tripleee

Reputation: 189447

You can wrap function calls:

SIGNALOUT += $(subst signal,out_signal,$(subst infiles,outfiles,$(SIGNALIN)))

Upvotes: 1

Related Questions