diff --git a/tools/make-frozen.py b/tools/make-frozen.py
index b053afa08ea11191d4655dad5664d25eab4f5410..c3dfe591c926e4be3aed3a59b78994dcd5579107 100755
--- a/tools/make-frozen.py
+++ b/tools/make-frozen.py
@@ -26,10 +26,16 @@ def module_name(f):
 
 modules = []
 
-for dirpath, dirnames, filenames in os.walk(sys.argv[1]):
+root = sys.argv[1]
+root_len = len(root)
+if root[-1] != "/":
+    root_len += 1
+
+for dirpath, dirnames, filenames in os.walk(root):
     for f in filenames:
-        st = os.stat(dirpath + "/" + f)
-        modules.append((f, st))
+        fullpath = dirpath + "/" + f
+        st = os.stat(fullpath)
+        modules.append((fullpath[root_len:], st))
 
 print("#include <stdint.h>")
 print("const uint16_t mp_frozen_sizes[] = {")