开发者

How to fix Makefile syntax error when using wildcard on make clean?

开发者 https://www.devze.com 2023-03-25 17:20 出处:网络
I have a simple Makefile that just contains this one t开发者_JS百科arget. It looks like this: SHELL:=/bin/bash

I have a simple Makefile that just contains this one t开发者_JS百科arget. It looks like this:

SHELL:=/bin/bash

clean:
    rm !(*.tex|Makefile|*.pdf)

When I run this command in bash it works fine, i.e. it gives no errors and it removes the desired files. However when I run make clean it gives the following errors:

$ make clean
rm !(*.tex|Makefile|*.pdf)
/bin/bash: -c: line 0: syntax error near unexpected token `('
/bin/bash: -c: line 0: `rm !(*.tex|Makefile|*.pdf)'
make: *** [clean] Error 1

Has anybody got an idea what I'm doing wrong? Thanks.


Change the SHELL line to

SHELL:=/bin/bash -O extglob

The extglob option is not set by default, so you have to do that yourself.

0

精彩评论

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