I am trying to run a bash switch case in a make global variable. By itself, the switch run fine:
#!/bin/bash
case "$(uname -s)" in CYGWIN*|MINGW*|MSYS*) echo "Hi!";; esac;
# Hi!
I tried to use this answer as example: Assign a makefile variable value to a bash command result?, but when I put it inside the VARAIBLE := $(shell thing)
I got an invalid syntax:
SHELL := /bin/bash
.SHELLFLAGS := -eu -o pipefail -c ${SHELLFLAGS}
IS_UNIX := $(shell case "$$(uname -s)" in CYGWIN*|MINGW*|MSYS*) printf "Hi!";; esac;)
all:
echo IS_UNIX ${IS_UNIX}
# /bin/bash: -c: line 0: syntax error near unexpected token `newline'
The echo IS_UNIX
and the printf "Hi!"
are just dummy things to make this example simple. In my real code I am using them like this:
...
ifeq (${OS},Windows_NT)
ifndef PYTHON_BIN
PYTHON_BIN := $(shell which python)
IS_UNIX := $(shell case "$$(uname -s)" in CYGWIN*|MINGW*|MSYS*) printf "Hi!";; esac;)
ifneq (,${IS_UNIX})
PYTHON_BIN := $(shell cygpath -w "${PYTHON_BIN}")
endif
endif
else
...