2

I'm trying to port a project over to a new system, but the makefile has stopped working. Its important to note that the two computing systems have shared data storage.

In order to juggle the build process, I use several shell calls inside the make file. On the new system, this causes the error

make: /usr/bin/sh: Command not found

On the new system, the shell executables are located in /bin/ and on the old system the are located in /usr/bin. I haven't explicitly told make to look in /usr/bin/, and I dont know how to tell it otherwise. The only other discussion related to this topic that I could find is about detecting which shell is present, not helping GNU make find the right shell.

How to detect shell used in GNU make?

Any ideas about how to solve this problem?

Mr.Weathers
  • 398
  • 1
  • 5
  • 19
  • It's very, very surprising that there's a system out there that doesn't have `/bin/sh` available. Almost every single shell script ever written includes `#!/bin/sh` and the top and if `/bin/sh` doesn't exist none of them will work. – MadScientist May 01 '18 at 17:34
  • the system does have `/bin/sh`, but for some reason `make` is searching for `/usr/bin/sh` – Mr.Weathers May 02 '18 at 00:52

1 Answers1

4

Use the SHELL environment variable. Either set it in the environment (export SHELL=/bin/sh) before invoking make, or put SHELL=/bin/sh on the make command line.

Likely the problem is actually that you've incorrectly set SHELL=/usr/bin/sh in a startup file (.profile or .login or some such) on the new system, which will cause problems for any program that tries to use it, not just make.

Chris Dodd
  • 119,907
  • 13
  • 134
  • 226
  • 2
    Make never uses the user's setting of `SHELL` (that would be a disaster for portability) so it's not a problem with settings in startup files etc. Make always uses `/bin/sh` as the setting for `SHELL` by default no matter what the user's `SHELL` variable is set to. If he is seeing `/usr/bin/sh` then he must have explicitly added `SHELL = /usr/bin/sh` to his makefile. That's the problem: that line should be removed. – MadScientist May 01 '18 at 17:43
  • 1
    I don't explicitly set `SHELL=` anywhere in my bashrc or in the makefile, and checking `echo $SHELL` in both systems gives `/bin/bash` as expected. Despite this, using `make SHELL=/bin/bash` fixes the issue. I don't know why make would tend to override the environment variable but this does fix my issue. – Mr.Weathers May 02 '18 at 02:48
  • 1
    Run this command: `echo 'all:;@echo $(SHELL)' | make -f-` What does it print out? – MadScientist May 02 '18 at 03:31