sbs
sbs

Reputation: 1311

How to run a command in a Makefile if one file is newer than another?

I'm trying to run some command (in the example below, echo) if one file ('glide.lock') is newer than a directory ('vendor').

On one operating system, this works:

deps:
    @test glide.lock -nt vendor; \
    RETVAL=$$?; \
    if [ $$RETVAL -eq 0 ]; then \
        echo dependencies out of date; \
    fi

But on another (Ubuntu), it doesn't. On both systems manually running test glide.lock -nt vendor and checking $? gives the correct answer.

How can I do this in the most compatible way possible?

Upvotes: 0

Views: 618

Answers (1)

Beta
Beta

Reputation: 99094

It's a bit of a hack, but how about:

vendor: glide.lock
    echo dependencies out of date

Upvotes: 2

Related Questions