carlossless
carlossless

Reputation: 1181

Splitting $^ in a Makefile

I have the following rules in my Makefile:

appfile appfile.symbols:
    build-the-app

distribute: appfile appfile.symbols
    push -flag1 appfile -flag2 appfile.symbols

I would like to exchange push -flag1 appfile -flag2 appfile.symbols to instead use the dependencies retrieved from $^ like push -flag1 $^1 -flag2 $^2

Is there any way of splitting $^ in order to achieve this?

Thanks.

Upvotes: 1

Views: 39

Answers (2)

ensc
ensc

Reputation: 6994

When dependencies have a certain pattern, you can use filter and filter-out; e.g.

distribute: ...
          push -flag1 $(filter-out %.symbols,$^) -flag2 $(filter %.symbols,$^)

Upvotes: 2

MadScientist
MadScientist

Reputation: 100956

The first prerequisite is in $<. You can use the word function in GNU make to get others (or for all of them if you prefer):

distribute: appfile appfile.symbols
        push -flag1 $< -flag2 $(word 2,$^)

Upvotes: 4

Related Questions