diff --git a/Makefile b/Makefile
index a58ceef5391a8e33f53f677dda06260313944bb8..f53346bb9c73220b38fe816fdb3424e38010b9b4 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,11 @@
 ##
 ## Makefile for Miosix embedded OS
 ##
-MAKEFILE_VERSION := 1.03
-## Path to kernel directory
+MAKEFILE_VERSION := 1.04
+## Path to kernel directory (edited by init_project_out_of_git_repo.pl)
 KPATH := miosix
-## Path to config directory
-CONFPATH := $(realpath $(KPATH))
+## Path to config directory (edited by init_project_out_of_git_repo.pl)
+CONFPATH := $(KPATH)
 include $(CONFPATH)/config/Makefile.inc
 
 ##
@@ -59,10 +59,16 @@ program:
 	$(PROGRAM_CMDLINE)
 
 all-recursive:
-	$(foreach i,$(SUBDIRS),$(MAKE) -C $(i) CONFPATH="$(CONFPATH)" || exit 1;)
+	$(foreach i,$(SUBDIRS),$(MAKE) -C $(i)                               \
+	  KPATH=$(shell perl $(KPATH)/_tools/relpath.pl $(i) $(KPATH))       \
+	  CONFPATH=$(shell perl $(KPATH)/_tools/relpath.pl $(i) $(CONFPATH)) \
+	  || exit 1;)
 
 clean-recursive:
-	$(foreach i,$(SUBDIRS),$(MAKE) -C $(i) CONFPATH="$(CONFPATH)" clean || exit 1;)
+	$(foreach i,$(SUBDIRS),$(MAKE) -C $(i)                               \
+	  KPATH=$(shell perl $(KPATH)/_tools/relpath.pl $(i) $(KPATH))       \
+	  CONFPATH=$(shell perl $(KPATH)/_tools/relpath.pl $(i) $(CONFPATH)) \
+	  clean || exit 1;)
 
 clean-topdir:
 	-rm -f $(OBJ) main.elf main.hex main.bin main.map $(OBJ:.o=.d)
@@ -77,10 +83,10 @@ main.elf: $(OBJ) all-recursive
 	$(CXX) $(LFLAGS) -o main.elf $(OBJ) $(KPATH)/$(BOOT_FILE) $(LINK_LIBS)
 
 %.o: %.s
-	$(AS) $(AFLAGS) $< -o $@
+	$(AS)  $(AFLAGS) $< -o $@
 
 %.o : %.c
-	$(CC) $(DFLAGS) $(CFLAGS) $< -o $@
+	$(CC)  $(DFLAGS) $(CFLAGS) $< -o $@
 
 %.o : %.cpp
 	$(CXX) $(DFLAGS) $(CXXFLAGS) $< -o $@
diff --git a/miosix/Makefile b/miosix/Makefile
index 001ad2e183c541d64af0ef556cc89eb73becdff9..a1066193b0c766bcdfb5e6d8ba635307eb600ae6 100644
--- a/miosix/Makefile
+++ b/miosix/Makefile
@@ -2,10 +2,8 @@
 ## Makefile for Miosix embedded OS
 ## This makefile builds the whole kernel
 ##
-MAKEFILE_VERSION := 1.03
-## Path to kernel directory
-KPATH := .
-## CONFPATH is forwarded by the parent Makefile
+MAKEFILE_VERSION := 1.04
+## KPATH and CONFPATH are forwarded by the parent Makefile
 include $(CONFPATH)/config/Makefile.inc
 
 ## List of all Miosix OS source files that have no special requirements
@@ -73,13 +71,13 @@ clean:
 	-rm -f $(BOOT_FILE:.o=.d)
 
 %.o: %.s
-	$(AS) $(AFLAGS) $< -o $@
+	$(AS)  $(AFLAGS) $< -o $@
 
 %.o : %.c
 	$(CC)  $(DFLAGS) $(CFLAGS) $< -o $@
 
 %.o : %.cpp
-	$(CXX)  $(DFLAGS) $(CXXFLAGS) $< -o $@
+	$(CXX) $(DFLAGS) $(CXXFLAGS) $< -o $@
 
 #pull in dependecy info for existing .o files
 -include $(OBJ:.o=.d)
diff --git a/miosix/_doc/textdoc/Changelog.txt b/miosix/_doc/textdoc/Changelog.txt
index 6d8ed1640f1100494dc95d42226b80df24c9b153..1d57d7bcb30bd5a0190f16df7a7e62e2062d7c5f 100644
--- a/miosix/_doc/textdoc/Changelog.txt
+++ b/miosix/_doc/textdoc/Changelog.txt
@@ -1,5 +1,8 @@
 Changelog for Miosix np embedded OS
 
+- Improved Makefile path referencing to always use relative paths, as using
+  absolute ones fails when the absolute path contains spaces. This proved to
+  be impossible with makefiles alone and required to add a small perl script
 - Added versioning to miosix_settings.h and board_settings.h to prevent
   misconfiguration when those files are updated.
 - Moved board_settings.h in the config directory to allow out of git tree
diff --git a/miosix/_examples/sad_trombone/Makefile b/miosix/_examples/sad_trombone/Makefile
index 3e4544e026e1ae4f1427ba5e30c1c58f847d21bd..50467d33ccb4f2a6869e80e8b6999199f5c7df8f 100644
--- a/miosix/_examples/sad_trombone/Makefile
+++ b/miosix/_examples/sad_trombone/Makefile
@@ -1,11 +1,11 @@
 ##
 ## Makefile for Miosix embedded OS
 ##
-MAKEFILE_VERSION := 1.03
-## Path to kernel directory
+MAKEFILE_VERSION := 1.04
+## Path to kernel directory (edited by init_project_out_of_git_repo.pl)
 KPATH := miosix
-## Path to config directory
-CONFPATH := $(realpath $(KPATH))
+## Path to config directory (edited by init_project_out_of_git_repo.pl)
+CONFPATH := $(KPATH)
 include $(CONFPATH)/config/Makefile.inc
 
 ##
@@ -59,10 +59,16 @@ program:
 	$(PROGRAM_CMDLINE)
 
 all-recursive:
-	$(foreach i,$(SUBDIRS),$(MAKE) -C $(i) CONFPATH="$(CONFPATH)" || exit 1;)
+	$(foreach i,$(SUBDIRS),$(MAKE) -C $(i)                               \
+	  KPATH=$(shell perl $(KPATH)/_tools/relpath.pl $(i) $(KPATH))       \
+	  CONFPATH=$(shell perl $(KPATH)/_tools/relpath.pl $(i) $(CONFPATH)) \
+	  || exit 1;)
 
 clean-recursive:
-	$(foreach i,$(SUBDIRS),$(MAKE) -C $(i) CONFPATH="$(CONFPATH)" clean || exit 1;)
+	$(foreach i,$(SUBDIRS),$(MAKE) -C $(i)                               \
+	  KPATH=$(shell perl $(KPATH)/_tools/relpath.pl $(i) $(KPATH))       \
+	  CONFPATH=$(shell perl $(KPATH)/_tools/relpath.pl $(i) $(CONFPATH)) \
+	  clean || exit 1;)
 
 clean-topdir:
 	-rm -f $(OBJ) main.elf main.hex main.bin main.map $(OBJ:.o=.d)
@@ -77,10 +83,10 @@ main.elf: $(OBJ) all-recursive
 	$(CXX) $(LFLAGS) -o main.elf $(OBJ) $(KPATH)/$(BOOT_FILE) $(LINK_LIBS)
 
 %.o: %.s
-	$(AS) $(AFLAGS) $< -o $@
+	$(AS)  $(AFLAGS) $< -o $@
 
 %.o : %.c
-	$(CC) $(DFLAGS) $(CFLAGS) $< -o $@
+	$(CC)  $(DFLAGS) $(CFLAGS) $< -o $@
 
 %.o : %.cpp
 	$(CXX) $(DFLAGS) $(CXXFLAGS) $< -o $@
diff --git a/miosix/_tools/init_project_out_of_git_tree.pl b/miosix/_tools/init_project_out_of_git_tree.pl
index c80024fa8af6970d7a9afeaa1fe40d1dc9f013e7..ee6eb8ea45d7d55c280d46f1835ef3fb8c9abd70 100644
--- a/miosix/_tools/init_project_out_of_git_tree.pl
+++ b/miosix/_tools/init_project_out_of_git_tree.pl
@@ -50,7 +50,7 @@ sub copy_and_fixup_makefile
 	while(<$in>)
 	{
 		s/^KPATH := miosix$/KPATH := $relpath\/miosix/;
-		s/^CONFPATH := \$\(realpath \$\(KPATH\)\)$/CONFPATH := \$\(realpath \.\)/;
+		s/^CONFPATH := \$\(KPATH\)$/CONFPATH := \./;
 		print $out "$_";
 	}
 	close($in);
diff --git a/miosix/_tools/relpath.pl b/miosix/_tools/relpath.pl
new file mode 100644
index 0000000000000000000000000000000000000000..3a915adbe3d8929f48124977eaf000dc3220cbd3
--- /dev/null
+++ b/miosix/_tools/relpath.pl
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+
+# This script is used by the makefiles to convert a relative path from
+# a source directory to a relative path to a target directory when recursively
+# calling make. Unfortunately, GNU make has no such feature built in. It has,
+# however, a way to convert a relative path to an absolute one, that can be
+# passed to recursive makefiles while still referencing the same directory,
+# but dealing with absolute paths and makefiles is totally useless. Why?
+# Because an absolute path may easily end up containing a space character in
+# some of the directories, and GNU make fails *very* badly when dealing with
+# spaces in filenames. Using relative paths instead only requires that the
+# paths between directories containing source files are whitespace free, and
+# noth *all* the directory names up to the root one.
+
+use Cwd qw(abs_path);
+use File::Spec;
+
+die "Use: perl relpath.pl from to\n" unless($#ARGV+1==2);
+my $from=abs_path($ARGV[0]);
+my $to=abs_path($ARGV[1]);
+my $relpath=File::Spec->abs2rel($to,$from);
+print "$relpath";
+#print STDERR "========== from='$from' to='$to' relpath='$relpath'\n";
diff --git a/miosix/config/Makefile.inc b/miosix/config/Makefile.inc
index dab3ec41ae91bed4c8ad8040f7bea786d858c6fd..f5db34eeecf7ba3375fb8a4341466fa0b2f92d65 100644
--- a/miosix/config/Makefile.inc
+++ b/miosix/config/Makefile.inc
@@ -265,7 +265,7 @@ endif
 ## a new board or porting Miosix to a new architecture                    ##
 ############################################################################
 
-ifneq ($(MAKEFILE_VERSION),1.03)
+ifneq ($(MAKEFILE_VERSION),1.04)
     $(info You are using an incompatible makefile. Make sure it matches \
       the one distributed with the current version of the kernel)
     $(error Error)