12 Jan 2019 • Detecting WSL in Makefiles

2024 update: WSLENV doesn't work anymore, do ifdef WSL_DISTRO_NAME instead.

There's a WSLENV variable, but it's empty by default so ifdef doesn't do what you want. ?= can distinguish between empty and undefined, so this works:

WSLENV ?= notwsl
ifndef WSLENV
	# this runs when you _are_ in WSL
endif