diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp
index a249f60a45e157895c4f7c4ba2860b52218aead6..812f14b62ad271eaef4f2a1fdcd4d86c2aed85d0 100644
--- a/Marlin/src/Marlin.cpp
+++ b/Marlin/src/Marlin.cpp
@@ -357,10 +357,6 @@ void suicide() {
***************** GCode Handlers *****************
**************************************************/
-#if ENABLED(G38_PROBE_TARGET)
- #include "gcode/probe/G38.h"
-#endif
-
#if HAS_MESH
#include "gcode/probe/G42.h"
#endif
diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp
index 947b3dd71e974da4d4a9df79397848497c4386b6..ec302ace46b8b4efdf7294dc181a691ade28a892 100644
--- a/Marlin/src/gcode/gcode.cpp
+++ b/Marlin/src/gcode/gcode.cpp
@@ -116,7 +116,6 @@ void GcodeSuite::dwell(millis_t time) {
//
// Placeholders for non-migrated codes
//
-extern void gcode_G38(bool is_38_2);
extern void gcode_G42();
extern void gcode_G92();
extern void gcode_M0_M1();
@@ -385,7 +384,7 @@ void GcodeSuite::process_next_command() {
#if ENABLED(G38_PROBE_TARGET)
case 38: // G38.2 & G38.3
if (parser.subcode == 2 || parser.subcode == 3)
- gcode_G38(parser.subcode == 2);
+ G38(parser.subcode == 2);
break;
#endif
diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h
index 90c1aabb6e9135d8b20ab50075404b8ccc91c04c..66cd59232d61209f7ae63738e7d28d6df5875e1d 100644
--- a/Marlin/src/gcode/gcode.h
+++ b/Marlin/src/gcode/gcode.h
@@ -375,7 +375,7 @@ private:
#endif
#if ENABLED(G38_PROBE_TARGET)
- static void G38(bool is_38_2);
+ static void G38(const bool is_38_2);
#endif
#if HAS_MESH
diff --git a/Marlin/src/gcode/probe/G38.h b/Marlin/src/gcode/probe/G38.cpp
similarity index 90%
rename from Marlin/src/gcode/probe/G38.h
rename to Marlin/src/gcode/probe/G38.cpp
index 976569d8f124d6f383ed69c29b33d250aedccc22..71e022cd8319a7198029209414963c6d42e4e79d 100644
--- a/Marlin/src/gcode/probe/G38.h
+++ b/Marlin/src/gcode/probe/G38.cpp
@@ -20,8 +20,17 @@
*
*/
+#include "../../inc/MarlinConfig.h"
+
+#if ENABLED(G38_PROBE_TARGET)
+
#include "../gcode.h"
+#include "../../module/endstops.h"
+#include "../../module/motion.h"
+#include "../../module/stepper.h"
+#include "../../module/probe.h"
+
static bool G38_run_probe() {
bool G38_pass_fail = false;
@@ -88,9 +97,9 @@ static bool G38_run_probe() {
*
* Like G28 except uses Z min probe for all axes
*/
-void gcode_G38(bool is_38_2) {
+void GcodeSuite::G38(const bool is_38_2) {
// Get X Y Z E F
- gcode.get_destination_from_command();
+ get_destination_from_command();
setup_for_endstop_or_probe_move();
@@ -108,3 +117,5 @@ void gcode_G38(bool is_38_2) {
clean_up_after_endstop_or_probe_move();
}
+
+#endif // G38_PROBE_TARGET