Mac – Bash commands in Makefile

bashmacmakefileshell

I want to use bash commands in Makefile along with MATLAB scripts. Currently when i put a simple bash command in Makefile and run that target, I get error

/bin/bash: ./test1: No such file or directory

I have used a simple bash command

satuaratedrate:
bash -c "cd ~/Desktop/r4/saturatedrate/iperf_s"; echo "I'm in some_dir"; ./test1; echo "is it working"

I have also put SHELL := /bin/bashin beginning of make file as suggested by enter link description here

I am using Mac OsX

Best Answer

The semi-colon will terminate a bash command. So bash -c "cd ~/Desktop/r4/saturatedrate/iperf_s"; starts a bash shell and does the cd command then exits. Then the echo command and then the test1 command - but test1 does not exist in the current directory. Remember the shell command that issued the cd command has exited.

This make command should call test1:

saturatedrate:
    bash -c "cd ~/Desktop/r4/saturatedrate/iperf_s/test1"; 
Related Question