diff --git a/Makefile b/Makefile
index 96d168b48d75b4696cf66d56550024915b5d8639..1b6616f593662aaee65ab3a768e4dd84347e4644 100644
--- a/Makefile
+++ b/Makefile
@@ -108,7 +108,9 @@ ASTLDFLAGS+=$(LDOPTS)
 #Uncomment this to see all build commands instead of 'quiet' output
 #NOISY_BUILD=yes
 
-ASTTOPDIR:=$(shell echo $(CURDIR) | sed -e 's/ /\\ /g')
+empty:=
+space:=$(empty) $(empty)
+ASTTOPDIR:=$(subst $(space),\$(space),$(CURDIR))
 
 # Overwite config files on "make samples"
 OVERWRITE=y