synapse
synapse

Reputation: 5728

Creating a rule for a file type

How can I create a rule in a makefile for a specific filetype so if I write something like

result.txt: first.txt second.txt

in a makefile and it will concatenate prerequisites.

.txt:
     cat $? > $@

doesn't work

Upvotes: 0

Views: 180

Answers (1)

tripleee
tripleee

Reputation: 189397

Since this seems to have helped, I am reposting it as an answer, with @eriktous' comment added in.

%.txt:
        cat $? >$@

If you don't want to process just the changed files, use $^ instead of $?.

Upvotes: 1

Related Questions