I have a complex logic for detecting path for Makefile variable. I gave up on doing this in make language, so I coded it in Python, and want to embed the code into Makefile to set variable. However, this doesn't work:
define DETECT_SDK
import os
locations = [
"../google_appengine",
"/usr/local/google_appengine",
"../.locally/google_appengine",
]
for path in locations:
if os.path.exists(path):
print(path)
break
else:
print(".")
endef
SDK_PATH ?= $(shell python -c $(DETECT_SDK))
default:
python -c 'import sys; print(sys.argv)' $(SDK_PATH)
UPDATE: Updated multiline definition from Is it possible to create a multi-line string variable in a Makefile
Previously it was failing with Makefile:2: *** missing separator. Stop.
. Now it fails with another error:
/bin/sh: 1: Syntax error: "(" unexpected
python -c 'import sys; print(sys.argv)'
['-c']