diff --git a/libraries/AP_ICEngine/AP_ICEngine.cpp b/libraries/AP_ICEngine/AP_ICEngine.cpp
index c212abe9d2..230d8d8cf2 100644
--- a/libraries/AP_ICEngine/AP_ICEngine.cpp
+++ b/libraries/AP_ICEngine/AP_ICEngine.cpp
@@ -13,6 +13,9 @@
along with this program. If not, see .
*/
+#include "AP_ICEngine.h"
+
+#if AP_ICENGINE_ENABLED
#include
#include
@@ -20,8 +23,6 @@
#include
#include
#include
-#include
-#include "AP_ICEngine.h"
#include
extern const AP_HAL::HAL& hal;
@@ -533,3 +534,5 @@ AP_ICEngine *ice() {
return AP_ICEngine::get_singleton();
}
}
+
+#endif // AP_ICENGINE_ENABLED
diff --git a/libraries/AP_ICEngine/AP_ICEngine.h b/libraries/AP_ICEngine/AP_ICEngine.h
index dd6bb6123e..f5a1818f22 100644
--- a/libraries/AP_ICEngine/AP_ICEngine.h
+++ b/libraries/AP_ICEngine/AP_ICEngine.h
@@ -18,7 +18,12 @@
*/
#pragma once
+#include "AP_ICEngine_config.h"
+
+#if AP_ICENGINE_ENABLED
+
#include
+#include
class AP_ICEngine {
public:
@@ -151,3 +156,5 @@ private:
namespace AP {
AP_ICEngine *ice();
};
+
+#endif // AP_ICENGINE_ENABLED
diff --git a/libraries/AP_ICEngine/AP_ICEngine_config.h b/libraries/AP_ICEngine/AP_ICEngine_config.h
new file mode 100644
index 0000000000..c609d429f1
--- /dev/null
+++ b/libraries/AP_ICEngine/AP_ICEngine_config.h
@@ -0,0 +1,7 @@
+#pragma once
+
+#include
+
+#ifndef AP_ICENGINE_ENABLED
+#define AP_ICENGINE_ENABLED 1
+#endif