mikejsavage.co.uk / blog

RSS feed

12 Jan 2019 / Detecting WSL in Makefiles

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