diff --git a/Makefile b/Makefile
index d2832a45dffe1a1e0a2c72fc7f6224864dbe9f77..bb917de2491391086de5de07eca0085fd9653adc 100644
--- a/Makefile
+++ b/Makefile
@@ -1010,9 +1010,10 @@ ifdef CONFIG_GDB_SCRIPTS
 endif
 	+$(call if_changed,link-vmlinux)
 
-# Build samples along the rest of the kernel
+# Build samples along the rest of the kernel. This needs headers_install.
 ifdef CONFIG_SAMPLES
 vmlinux-dirs += samples
+samples: headers_install
 endif
 
 # The actual objects are generated when descending,