Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Runing a makefile list of target with wait

I've a make file which runs several of targets , now I want to add new target that will run after some timeout, how can I do it ?

e.g.

execbin: build start run

This is running ok, however I want to add new target called test which will run after two seconds (some timeout) , how can I do that ?

execbin: build start run test

test should execute after the run has finished and also wait 2 seconds before it start , is it possible ?

like image 433
Jenny M Avatar asked Jan 18 '26 21:01

Jenny M


1 Answers

The lazy solution would be to add a new target called 'sleep-2', and a pattern rule do:

execbin: build start run sleep-2 test

sleep-%:
        sleep $(@:sleep-%=%)

This creates a pattern rule that takes the value after the hyphen in a sleep-<> target, and uses it as the amount of time to sleep.

I will echo @MadScientists's answer that this probably will not work if you do make -j, which really does require changing the targets to depend on each other.

like image 139
Petesh Avatar answered Jan 20 '26 09:01

Petesh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!