Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
952 views
in Technique[技术] by (71.8m points)

makefile - Make: how to continue after a command fails?

The command $ make all gives errors such as rm: cannot remove '.lambda': No such file or directory so it stops. I want it to ignore the rm-not-found-errors. How can I force-make?

Makefile

all:
        make clean
        make .lambda
        make .lambda_t
        make .activity
        make .activity_t_lambda
clean:
        rm .lambda .lambda_t .activity .activity_t_lambda

.lambda:
        awk '{printf "%.4f 
", log(2)/log(2.71828183)/$$1}' t_year > .lambda

.lambda_t:
        paste .lambda t_year > .lambda_t

.activity:
        awk '{printf "%.4f 
", $$1*2.71828183^(-$$1*$$2)}' .lambda_t > .activity

.activity_t_lambda:
        paste .activity t_year .lambda  | sed -e 's@@&@g' -e 's@$$@\\@g' | tee > .activity_t_lambda > ../RESULTS/currentActivity.tex
Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try the -i flag (or --ignore-errors). The documentation seems to suggest a more robust way to achieve this, by the way:

To ignore errors in a command line, write a - at the beginning of the line's text (after the initial tab). The - is discarded before the command is passed to the shell for execution.

For example,

clean:
  -rm -f *.o

This causes rm to continue even if it is unable to remove a file.

All examples are with rm, but are applicable to any other command you need to ignore errors from (i.e. mkdir).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...