如何在使清洁使用通配符时,修复Makefile的语法错误? [英] How to fix Makefile syntax error when using wildcard on make clean?

查看:241
本文介绍了如何在使清洁使用通配符时,修复Makefile的语法错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的Makefile只包含这一个目标。它看起来是这样的:

I have a simple Makefile that just contains this one target. It looks like this:

SHELL:=/bin/bash

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

当我在bash运行此命令它工作正常,也就是说,它没有给出错误,它消除了所需的文件。然而,当我运行使清洁它提供了以下错误:

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.

推荐答案

SHELL 行更改为

SHELL:=/bin/bash -O extglob

extglob 选项没有默认设置,所以你必须自己做。

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

这篇关于如何在使清洁使用通配符时,修复Makefile的语法错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆