开发者

Calling make from a bash script won't make

开发者 https://www.devze.com 2023-01-26 05:10 出处:网络
I\'m writing a shell script which iterates over a set of variables, edits a source file line by line according to the current iteration value, then remakes, and finally calls the j开发者_如何学运维ust

I'm writing a shell script which iterates over a set of variables, edits a source file line by line according to the current iteration value, then remakes, and finally calls the j开发者_如何学运维ust compiled binary. After execution the old line is restored.

Here is a snippet:

#!/bin/sh
for i in 0..4; do
    perl -i -pe "s/.*/{SUBS[$i]}/ if $. == ${LINE[$i]}" ${SOURCE}
    make
    ./bin/myTool
    perl -i -pe "s/.*/\/\/{SUBS[$i]}/ if $. == ${LINE[$i]}" ${SOURCE}
done

Basically I have about 10 mutually exclusive #define in a C++ source file, and I'm experimenting the effects of each. Since I'm lazy I'd like to make it an automated process, and here I stuck.

Sometimes it happens that the shell says:

`make: Nothing to be done for 'all'`

Now, I tried to diff the file before and after every perlinstruction and the files do appear correct... I can't figure why this happens and how to make it behave correct.

Any idea?

Thank you in advance.


It's probably looping too quickly for make to tell each iteration apart. Either remove the make products or add a delay of 2 seconds at the beginning or end of the loop.


Make only checks if the target timestamp is younger than the source timestamp. That's the only way it can know what needs to be updated. So, if you loop iterations take less than a second then make won't know that anything has changed.

You can either clean up at the top of each iteration or add a delay as Ignacio Vazquez-Abrams has noted.

0

精彩评论

暂无评论...
验证码 换一张
取 消