Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have a simple Makefile that just contains this one target. 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.

like image 489
nvcleemp Avatar asked Aug 03 '11 05:08

nvcleemp


1 Answers

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.

like image 173
jw013 Avatar answered Sep 27 '22 17:09

jw013