Skip to content

Instantly share code, notes, and snippets.

@techtonik
Last active December 18, 2015 13:18
Show Gist options
  • Save techtonik/5788480 to your computer and use it in GitHub Desktop.
Save techtonik/5788480 to your computer and use it in GitHub Desktop.
Using Python inside Makefile
# Black magic to use Python logic for setting Makefile variables
# Real world example that is detecting AppEngine SDK with Python
# Helper code to detect SDK location
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
# /Helper
SDK_PATH ?= $(shell python -c '$(DETECT_SDK)')
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