7

all,

I have found that the same Makefile works well in Mac OS X, but does not work in Ubuntu. The snippet is as following:

start:
    @echo $(seperator)
    @if [[ "$(PROJECT)" == "" ]]; then \
         echo " Project powered by CodeMate!"; \
     else \
         echo "  $(PROJECT)"; \
     fi
    @echo $(seperator)

and make complains:

/bin/sh: [[: not found

Any idea?

Cheers,

Li


Updates:

I have changed the above conditional Bash statements to:

if test "$(PROJECT)" = ""; then \

then things work fine. So what is wrong with "[["?

Li Dong
  • 173
  • 1
  • 1
  • 5

2 Answers2

10

Place this at the top of your Makefile:

SHELL := /bin/bash # Use bash syntax

This happens because [[ is a builtin command of bash and you're running it with sh. The above line will set bash as default interpreter for the commands ran on makefile.

0x2b3bfa0
  • 8,620
  • 5
  • 38
  • 59
Robin Winslow
  • 2,606
  • 3
  • 19
  • 25
7

Makefiles use sh by default, not bash.

In Ubuntu sh point to dash, a POSIX compliant and minimalistic shell, not providing the [[ keywork.

enzotib
  • 92,255
  • 11
  • 164
  • 178