diff --git a/Makefile b/Makefile
index 15a9987a200def17b5060e14a8da98684d56443b..d05da1b9982baa5b006165fd53da4dcc6cbd85fc 100644
--- a/Makefile
+++ b/Makefile
@@ -1524,7 +1524,7 @@ $(DOC_TARGETS): scripts_basic FORCE
 
 PHONY += scripts_gdb
 scripts_gdb: prepare
-	$(Q)$(MAKE) $(build)=scripts/gdb/linux build_constants_py
+	$(Q)$(MAKE) $(build)=scripts/gdb
 
 ifdef CONFIG_GDB_SCRIPTS
 all: scripts_gdb
diff --git a/scripts/Makefile b/scripts/Makefile
index feb1f71381d73a083e42e457444a8b4d3a0896dd..9d442ee050bdd0da3259db18d65255b44575895e 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -39,7 +39,6 @@ build_unifdef: $(obj)/unifdef
 subdir-$(CONFIG_GCC_PLUGINS) += gcc-plugins
 subdir-$(CONFIG_MODVERSIONS) += genksyms
 subdir-$(CONFIG_SECURITY_SELINUX) += selinux
-subdir-$(CONFIG_GDB_SCRIPTS) += gdb
 
 # Let clean descend into subdirs
-subdir-	+= basic dtc kconfig mod package
+subdir-	+= basic dtc gdb kconfig mod package
diff --git a/scripts/gdb/linux/Makefile b/scripts/gdb/linux/Makefile
index aba23be985e4da4872b5cc33f299ba0c34d93db6..754580609360f7e9494be8b81a950c58fa9dae66 100644
--- a/scripts/gdb/linux/Makefile
+++ b/scripts/gdb/linux/Makefile
@@ -14,11 +14,8 @@ quiet_cmd_gen_constants_py = GEN     $@
 	$(CPP) -E -x c -P $(c_flags) $< > $@ ;\
 	sed -i '1,/<!-- end-c-headers -->/d;' $@
 
-targets += constants.py
-$(obj)/constants.py: $(SRCTREE)/$(obj)/constants.py.in FORCE
+extra-y += constants.py
+$(obj)/constants.py: $(src)/constants.py.in FORCE
 	$(call if_changed_dep,gen_constants_py)
 
-build_constants_py: $(obj)/constants.py
-	@:
-
-clean-files := *.pyc *.pyo $(if $(KBUILD_SRC),*.py) $(obj)/constants.py
+clean-files := *.pyc *.pyo $(if $(KBUILD_SRC),*.py)