7

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.

kenorb
  • 155,785
  • 88
  • 678
  • 743
nvcleemp
  • 514
  • 8
  • 21
  • Nice syntax to clean out everything but the Makefile itself, the latex source and any resulting pdf's. – dala Aug 09 '11 at 14:01

1 Answers1

13

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.

jw013
  • 1,718
  • 17
  • 22