 src/api/api_msg.c           | 3 +++
 src/core/init.c             | 4 ++++
 src/core/memp.c             | 3 +++
 src/core/netif.c            | 4 ++++
 src/core/raw.c              | 4 ++++
 src/core/tcp.c              | 3 +++
 src/core/tcp_in.c           | 6 +++++-
 src/core/tcp_out.c          | 4 ++++
 src/core/timers.c           | 4 ++++
 src/core/udp.c              | 8 ++++++++
 src/include/ipv4/lwip/ip4.h | 4 ++++
 src/include/lwip/ip.h       | 3 +++
 src/include/lwip/ip_addr.h  | 3 +++
 src/include/lwip/netbuf.h   | 3 +++
 src/include/lwip/netif.h    | 3 +++
 src/include/lwip/raw.h      | 3 +++
 src/include/lwip/sockets.h  | 3 +++
 src/include/lwip/tcp.h      | 3 +++
 src/include/lwip/tcp_impl.h | 3 +++
 src/include/lwip/udp.h      | 3 +++
 src/netif/etharp.c          | 3 +++
 21 files changed, 76 insertions(+), 1 deletion(-)

diff --git a/src/api/api_msg.c b/src/api/api_msg.c
index f3e4f9a..19261b0 100644
--- a/src/api/api_msg.c
+++ b/src/api/api_msg.c
@@ -51,7 +51,10 @@
 #include "lwip/tcpip.h"
 #include "lwip/igmp.h"
 #include "lwip/dns.h"
+
+#if LWIP_IPV6
 #include "lwip/mld6.h"
+#endif
 
 #include <string.h>
 
diff --git a/src/core/init.c b/src/core/init.c
index cfd7ff5..d85f2a4 100644
--- a/src/core/init.c
+++ b/src/core/init.c
@@ -56,9 +56,13 @@
 #include "lwip/dns.h"
 #include "lwip/timers.h"
 #include "netif/etharp.h"
+
+#if LWIP_IPV6
 #include "lwip/ip6.h"
 #include "lwip/nd6.h"
 #include "lwip/mld6.h"
+#endif
+
 #include "lwip/api.h"
 #include "netif/ppp/ppp.h"
 
diff --git a/src/core/memp.c b/src/core/memp.c
index edbb982..77c0240 100644
--- a/src/core/memp.c
+++ b/src/core/memp.c
@@ -61,9 +61,12 @@
 #include "netif/ppp/ppp.h"
 #include "netif/ppp/pppoe.h"
 #include "netif/ppp/pppol2tp.h"
+
+#if LWIP_IPV6
 #include "lwip/nd6.h"
 #include "lwip/ip6_frag.h"
 #include "lwip/mld6.h"
+#endif
 
 #include <string.h>
 
diff --git a/src/core/netif.c b/src/core/netif.c
index 36e801b..6508ff7 100644
--- a/src/core/netif.c
+++ b/src/core/netif.c
@@ -40,7 +40,11 @@
 
 #include "lwip/def.h"
 #include "lwip/ip_addr.h"
+
+#if LWIP_IPV6
 #include "lwip/ip6_addr.h"
+#endif
+
 #include "lwip/netif.h"
 #include "lwip/tcp_impl.h"
 #include "lwip/snmp.h"
diff --git a/src/core/raw.c b/src/core/raw.c
index 2843f35..7a0efda 100644
--- a/src/core/raw.c
+++ b/src/core/raw.c
@@ -49,8 +49,12 @@
 #include "lwip/raw.h"
 #include "lwip/stats.h"
 #include "arch/perf.h"
+
+#if LWIP_IPV6
 #include "lwip/ip6.h"
 #include "lwip/ip6_addr.h"
+#endif
+
 #include "lwip/inet_chksum.h"
 
 #include <string.h>
diff --git a/src/core/tcp.c b/src/core/tcp.c
index f89409c..3cac940 100644
--- a/src/core/tcp.c
+++ b/src/core/tcp.c
@@ -52,9 +52,12 @@
 #include "lwip/tcp_impl.h"
 #include "lwip/debug.h"
 #include "lwip/stats.h"
+
+#if LWIP_IPV6
 #include "lwip/ip6.h"
 #include "lwip/ip6_addr.h"
 #include "lwip/nd6.h"
+#endif
 
 #include <string.h>
 
diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c
index bd5d053..36f3522 100644
--- a/src/core/tcp_in.c
+++ b/src/core/tcp_in.c
@@ -55,10 +55,14 @@
 #include "lwip/stats.h"
 #include "lwip/snmp.h"
 #include "arch/perf.h"
+
+#if LWIP_IPV6
 #include "lwip/ip6.h"
 #include "lwip/ip6_addr.h"
+#endif
+
 #include "lwip/inet_chksum.h"
-#if LWIP_ND6_TCP_REACHABILITY_HINTS
+#if LWIP_IPV6 && LWIP_ND6_TCP_REACHABILITY_HINTS 
 #include "lwip/nd6.h"
 #endif /* LWIP_ND6_TCP_REACHABILITY_HINTS */
 
diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c
index bd063c8..b28e6cc 100644
--- a/src/core/tcp_out.c
+++ b/src/core/tcp_out.c
@@ -51,8 +51,12 @@
 #include "lwip/inet_chksum.h"
 #include "lwip/stats.h"
 #include "lwip/snmp.h"
+
+#if LWIP_IPV6
 #include "lwip/ip6.h"
 #include "lwip/ip6_addr.h"
+#endif
+
 #include "lwip/inet_chksum.h"
 #if LWIP_TCP_TIMESTAMPS
 #include "lwip/sys.h"
diff --git a/src/core/timers.c b/src/core/timers.c
index 4203efe..12e4a9c 100644
--- a/src/core/timers.c
+++ b/src/core/timers.c
@@ -56,9 +56,13 @@
 #include "lwip/autoip.h"
 #include "lwip/igmp.h"
 #include "lwip/dns.h"
+
+#if LWIP_IPV6
 #include "lwip/nd6.h"
 #include "lwip/ip6_frag.h"
 #include "lwip/mld6.h"
+#endif
+
 #include "lwip/sys.h"
 #include "lwip/pbuf.h"
 
diff --git a/src/core/udp.c b/src/core/udp.c
index a7b2446..93c7490 100644
--- a/src/core/udp.c
+++ b/src/core/udp.c
@@ -55,12 +55,20 @@
 #include "lwip/memp.h"
 #include "lwip/inet_chksum.h"
 #include "lwip/ip_addr.h"
+
+#if LWIP_IPV6
 #include "lwip/ip6.h"
 #include "lwip/ip6_addr.h"
+#endif
+
 #include "lwip/inet_chksum.h"
 #include "lwip/netif.h"
 #include "lwip/icmp.h"
+
+#if LWIP_IPV6
 #include "lwip/icmp6.h"
+#endif
+
 #include "lwip/stats.h"
 #include "lwip/snmp.h"
 #include "arch/perf.h"
diff --git a/src/include/ipv4/lwip/ip4.h b/src/include/ipv4/lwip/ip4.h
index 19ca66f..6a80ffe 100644
--- a/src/include/ipv4/lwip/ip4.h
+++ b/src/include/ipv4/lwip/ip4.h
@@ -37,7 +37,11 @@
 #include "lwip/def.h"
 #include "lwip/pbuf.h"
 #include "lwip/ip_addr.h"
+
+#if LWIP_IPV6
 #include "lwip/ip6_addr.h"
+#endif
+
 #include "lwip/err.h"
 #include "lwip/netif.h"
 
diff --git a/src/include/lwip/ip.h b/src/include/lwip/ip.h
index fdd9eb0..60abdbb 100644
--- a/src/include/lwip/ip.h
+++ b/src/include/lwip/ip.h
@@ -40,7 +40,10 @@
 #include "lwip/err.h"
 #include "lwip/netif.h"
 #include "lwip/ip4.h"
+
+#if LWIP_IPV6
 #include "lwip/ip6.h"
+#endif
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/src/include/lwip/ip_addr.h b/src/include/lwip/ip_addr.h
index 1ded93f..dbb5a0a 100644
--- a/src/include/lwip/ip_addr.h
+++ b/src/include/lwip/ip_addr.h
@@ -36,7 +36,10 @@
 #include "lwip/def.h"
 
 #include "lwip/ip4_addr.h"
+
+#if LWIP_IPV6
 #include "lwip/ip6_addr.h"
+#endif
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/src/include/lwip/netbuf.h b/src/include/lwip/netbuf.h
index 58f80fa..7daaba7 100644
--- a/src/include/lwip/netbuf.h
+++ b/src/include/lwip/netbuf.h
@@ -35,7 +35,10 @@
 #include "lwip/opt.h"
 #include "lwip/pbuf.h"
 #include "lwip/ip_addr.h"
+
+#if LWIP_IPV6
 #include "lwip/ip6_addr.h"
+#endif
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/src/include/lwip/netif.h b/src/include/lwip/netif.h
index 5c7bf16..6afc5dd 100644
--- a/src/include/lwip/netif.h
+++ b/src/include/lwip/netif.h
@@ -39,7 +39,10 @@
 #include "lwip/err.h"
 
 #include "lwip/ip_addr.h"
+
+#if LWIP_IPV6
 #include "lwip/ip6_addr.h"
+#endif
 
 #include "lwip/def.h"
 #include "lwip/pbuf.h"
diff --git a/src/include/lwip/raw.h b/src/include/lwip/raw.h
index 350e29d..8ca14c8 100644
--- a/src/include/lwip/raw.h
+++ b/src/include/lwip/raw.h
@@ -40,7 +40,10 @@
 #include "lwip/def.h"
 #include "lwip/ip.h"
 #include "lwip/ip_addr.h"
+
+#if LWIP_IPV6
 #include "lwip/ip6_addr.h"
+#endif
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/src/include/lwip/sockets.h b/src/include/lwip/sockets.h
index 7406dca..e4fdc49 100644
--- a/src/include/lwip/sockets.h
+++ b/src/include/lwip/sockets.h
@@ -43,7 +43,10 @@
 #include "lwip/ip_addr.h"
 #include "lwip/err.h"
 #include "lwip/inet.h"
+
+#if LWIP_IPV6
 #include "lwip/inet6.h"
+#endif
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/src/include/lwip/tcp.h b/src/include/lwip/tcp.h
index 134cd6b..5957437 100644
--- a/src/include/lwip/tcp.h
+++ b/src/include/lwip/tcp.h
@@ -41,8 +41,11 @@
 #include "lwip/ip.h"
 #include "lwip/icmp.h"
 #include "lwip/err.h"
+
+#if LWIP_IPV6
 #include "lwip/ip6.h"
 #include "lwip/ip6_addr.h"
+#endif
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/src/include/lwip/tcp_impl.h b/src/include/lwip/tcp_impl.h
index 84a4765..58fa764 100644
--- a/src/include/lwip/tcp_impl.h
+++ b/src/include/lwip/tcp_impl.h
@@ -42,8 +42,11 @@
 #include "lwip/ip.h"
 #include "lwip/icmp.h"
 #include "lwip/err.h"
+
+#if LWIP_IPV6
 #include "lwip/ip6.h"
 #include "lwip/ip6_addr.h"
+#endif
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/src/include/lwip/udp.h b/src/include/lwip/udp.h
index 927c2f5..84253a0 100644
--- a/src/include/lwip/udp.h
+++ b/src/include/lwip/udp.h
@@ -40,7 +40,10 @@
 #include "lwip/netif.h"
 #include "lwip/ip_addr.h"
 #include "lwip/ip.h"
+
+#if LWIP_IPV6
 #include "lwip/ip6_addr.h"
+#endif
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/src/netif/etharp.c b/src/netif/etharp.c
index 6b773a4..fc070ca 100644
--- a/src/netif/etharp.c
+++ b/src/netif/etharp.c
@@ -55,7 +55,10 @@
 #include "lwip/dhcp.h"
 #include "lwip/autoip.h"
 #include "netif/etharp.h"
+
+#if LWIP_IPV6
 #include "lwip/ip6.h"
+#endif
 
 #if PPPOE_SUPPORT
 #include "netif/ppp/pppoe.h"
