Skip to content

Instantly share code, notes, and snippets.

@MartyLake
Created November 6, 2017 17:27
Show Gist options
  • Save MartyLake/787cb9fe3b7fb973686f6b757833fd1b to your computer and use it in GitHub Desktop.
Save MartyLake/787cb9fe3b7fb973686f6b757833fd1b to your computer and use it in GitHub Desktop.
makefile uses an embedded python script to populate a local variable
#from https://stackoverflow.com/questions/17125269/embed-python-in-makefile-to-set-make-variables
define NEWLINE
endef
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
endef
SDK_PATH ?= $(shell echo '$(subst $(NEWLINE),@NEWLINE@,${DETECT_SDK})' | sed 's/@NEWLINE@/\n/g' | python -)
default:
@echo 'SDK Path Detected: $(SDK_PATH)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment