0

I was required to run a makefile on mint, I input the option 'clean' about:

clean:
<tab> rm -f test_{a,b}.o

I type this order in shells rm -f test_{a,b}.o, and it do delete the file test_a.o and test_b.o, but it doesn't work on Mint OS, but it work on CentOS7.

I want to find the reason for this problem. now I use rm -f test_a.o test_b.o instead temporarily.

Z.Lun
  • 247
  • 1
  • 2
  • 20
  • Does this answer your question? [How can I use Bash syntax in Makefile targets?](https://stackoverflow.com/questions/589276/how-can-i-use-bash-syntax-in-makefile-targets) – Benjamin W. Mar 01 '23 at 04:19

1 Answers1

1

This depends on the shell: brace expansion is supported by Bash, but for example not by dash, which is the default /bin/sh shell on Ubuntu; and /bin/sh is the default shell in Makefiles. You could switch the shell used in the Makefile with

SHELL = /bin/bash
Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
  • On a Mint machine, I tried the order in the command window, it success. and then use `make clean` in the same window, it failed. so the shell used by `make` is different from its parent bash? – Z.Lun Mar 01 '23 at 04:38
  • Your answer is right. I open a shell on Mint, then `echo $SHELL` it is `/bin/bash`; and I write in makefile with `echo $(SHELL)`, it is `/bin/sh`; what a error.. – Z.Lun Mar 01 '23 at 04:57
  • 1
    It would be a complete disaster for portability, if make used whatever random shell the user who typed `make` happened to be using. It always uses `/bin/sh`. The value of the `$SHELL` environment variable in the environment of the person who invoked make is irrelevant. – MadScientist Mar 01 '23 at 14:31