Index: trunk/src/VBox/Devices/Makefile.kmk
===================================================================
--- trunk/src/VBox/Devices/Makefile.kmk	(revision 48177)
+++ trunk/src/VBox/Devices/Makefile.kmk	(revision 48178)
@@ -324,18 +324,23 @@
 
  ifdef VBOX_WITH_INIP
+  VBoxDD_DEFS           += VBOX_WITH_INIP
+  VBoxDD_SOURCES        += \
+        Network/DevINIP.cpp
   ifndef VBOX_WITH_NEW_LWIP
     include $(PATH_SUB_CURRENT)/Network/lwip/Makefile.kmk
+    VBoxDD_INCS         += $(LWIP_INCS)
+    VBoxDD_SOURCES      += $(LWIP_SOURCES)
   else
+    # XXX: Ancestor makefile includes us before NAT service, so NAT
+    #      makefile depends on lwip Makefile included here...
     include $(PATH_SUB_CURRENT)/Network/lwip-new/Makefile.kmk
-  endif
-  VBoxDD_DEFS           += VBOX_WITH_INIP
-  VBoxDD_INCS           += $(LWIP_INCS)
-  VBoxDD_SOURCES        += $(LWIP_SOURCES)
-  VBoxDD_SOURCES        += \
-        Network/DevINIP.cpp
-  ifdef VBOX_WITH_NEW_LWIP
+
     Network/DevINIP.cpp_DEFS += VBOX_WITH_NEW_LWIP
-  endif
- endif
+    $(eval $(call def_vbox_lwip_private, \
+                      VBoxDD, Network/lwip-new))
+    $(eval $(call def_vbox_lwip_flags, \
+                      Network/DevINIP.cpp, Network/lwip-new))
+  endif
+ endif # VBOX_WITH_INIP
 
  ifdef VBOX_WITH_E1000
@@ -407,7 +412,10 @@
 
  ifdef VBOX_WITH_ISCSI
-  Storage/DrvVD.cpp_INCS = $(LWIP_INCS)
   ifdef VBOX_WITH_NEW_LWIP
     Storage/DrvVD.cpp_DEFS += VBOX_WITH_NEW_LWIP
+    $(eval $(call def_vbox_lwip_flags, \
+                      Storage/DrvVD.cpp, Network/lwip-new))
+  else
+    Storage/DrvVD.cpp_INCS = $(LWIP_INCS)
   endif
  endif
Index: trunk/src/VBox/Devices/Network/lwip-new/Makefile.kmk
===================================================================
--- trunk/src/VBox/Devices/Network/lwip-new/Makefile.kmk	(revision 48177)
+++ trunk/src/VBox/Devices/Network/lwip-new/Makefile.kmk	(revision 48178)
@@ -24,80 +24,120 @@
 
 LWIP_INCS += \
-    Network/lwip-new/src/include \
-    Network/lwip-new/src/include/ipv4 \
-    Network/lwip-new/src/include/ipv6 \
-    Network/lwip-new/vbox/include \
-    Network/lwip-new/vbox
+    src/include \
+    src/include/ipv4 \
+    src/include/ipv6 \
+    vbox/include \
+    vbox
 
 LWIP_SOURCES += \
-    Network/lwip-new/src/api/api_lib.c \
-    Network/lwip-new/src/api/api_msg.c \
-    Network/lwip-new/src/api/err.c \
-    Network/lwip-new/src/api/netbuf.c \
-    Network/lwip-new/src/api/netdb.c \
-    Network/lwip-new/src/api/netifapi.c \
-    Network/lwip-new/src/api/sockets.c \
-    Network/lwip-new/src/api/tcpip.c \
-    Network/lwip-new/src/core/def.c \
-    Network/lwip-new/src/core/dhcp.c \
-    Network/lwip-new/src/core/dns.c \
-    Network/lwip-new/src/core/inet_chksum.c \
-    Network/lwip-new/src/core/init.c \
-    Network/lwip-new/src/core/ipv4/autoip.c \
-    Network/lwip-new/src/core/ipv4/icmp.c \
-    Network/lwip-new/src/core/ipv4/igmp.c \
-    Network/lwip-new/src/core/ipv4/ip4.c \
-    Network/lwip-new/src/core/ipv4/ip4_addr.c \
-    Network/lwip-new/src/core/ipv4/ip_frag.c \
-    Network/lwip-new/src/core/ipv6/dhcp6.c \
-    Network/lwip-new/src/core/ipv6/ethip6.c \
-    Network/lwip-new/src/core/ipv6/icmp6.c \
-    Network/lwip-new/src/core/ipv6/inet6.c \
-    Network/lwip-new/src/core/ipv6/ip6.c \
-    Network/lwip-new/src/core/ipv6/ip6_addr.c \
-    Network/lwip-new/src/core/ipv6/ip6_frag.c \
-    Network/lwip-new/src/core/ipv6/mld6.c \
-    Network/lwip-new/src/core/ipv6/nd6.c \
-    Network/lwip-new/src/core/mem.c \
-    Network/lwip-new/src/core/memp.c \
-    Network/lwip-new/src/core/netif.c \
-    Network/lwip-new/src/core/pbuf.c \
-    Network/lwip-new/src/core/raw.c \
-    Network/lwip-new/src/core/stats.c \
-    Network/lwip-new/src/core/sys.c \
-    Network/lwip-new/src/core/tcp.c \
-    Network/lwip-new/src/core/tcp_in.c \
-    Network/lwip-new/src/core/tcp_out.c \
-    Network/lwip-new/src/core/timers.c \
-    Network/lwip-new/src/core/udp.c \
-    Network/lwip-new/src/netif/etharp.c \
-    Network/lwip-new/vbox/sys_arch.c \
-    Network/lwip-new/vbox/VBoxLwipCore.cpp
+    src/api/api_lib.c \
+    src/api/api_msg.c \
+    src/api/err.c \
+    src/api/netbuf.c \
+    src/api/netdb.c \
+    src/api/netifapi.c \
+    src/api/sockets.c \
+    src/api/tcpip.c \
+    src/core/def.c \
+    src/core/dhcp.c \
+    src/core/dns.c \
+    src/core/inet_chksum.c \
+    src/core/init.c \
+    src/core/ipv4/autoip.c \
+    src/core/ipv4/icmp.c \
+    src/core/ipv4/igmp.c \
+    src/core/ipv4/ip4.c \
+    src/core/ipv4/ip4_addr.c \
+    src/core/ipv4/ip_frag.c \
+    src/core/ipv6/dhcp6.c \
+    src/core/ipv6/ethip6.c \
+    src/core/ipv6/icmp6.c \
+    src/core/ipv6/inet6.c \
+    src/core/ipv6/ip6.c \
+    src/core/ipv6/ip6_addr.c \
+    src/core/ipv6/ip6_frag.c \
+    src/core/ipv6/mld6.c \
+    src/core/ipv6/nd6.c \
+    src/core/mem.c \
+    src/core/memp.c \
+    src/core/netif.c \
+    src/core/pbuf.c \
+    src/core/raw.c \
+    src/core/stats.c \
+    src/core/sys.c \
+    src/core/tcp.c \
+    src/core/tcp_in.c \
+    src/core/tcp_out.c \
+    src/core/timers.c \
+    src/core/udp.c \
+    src/netif/etharp.c \
+    vbox/sys_arch.c \
+    vbox/VBoxLwipCore.cpp
 
 # LWIP_SOURCES += \
-#     Network/lwip-new/src/core/snmp/asn1_dec.c \
-#     Network/lwip-new/src/core/snmp/asn1_enc.c \
-#     Network/lwip-new/src/core/snmp/mib2.c \
-#     Network/lwip-new/src/core/snmp/mib_structs.c \
-#     Network/lwip-new/src/core/snmp/msg_in.c \
-#     Network/lwip-new/src/core/snmp/msg_out.c \
+#     src/core/snmp/asn1_dec.c \
+#     src/core/snmp/asn1_enc.c \
+#     src/core/snmp/mib2.c \
+#     src/core/snmp/mib_structs.c \
+#     src/core/snmp/msg_in.c \
+#     src/core/snmp/msg_out.c \
 
 # LWIP_SOURCES += \
-#     Network/lwip-new/src/netif/slipif.c \
+#     src/netif/slipif.c \
 
 # LWIP_SOURCES += \
-#     Network/lwip-new/src/netif/ppp/auth.c \
-#     Network/lwip-new/src/netif/ppp/chap.c \
-#     Network/lwip-new/src/netif/ppp/chpms.c \
-#     Network/lwip-new/src/netif/ppp/fsm.c \
-#     Network/lwip-new/src/netif/ppp/ipcp.c \
-#     Network/lwip-new/src/netif/ppp/lcp.c \
-#     Network/lwip-new/src/netif/ppp/magic.c \
-#     Network/lwip-new/src/netif/ppp/md5.c \
-#     Network/lwip-new/src/netif/ppp/pap.c \
-#     Network/lwip-new/src/netif/ppp/ppp.c \
-#     Network/lwip-new/src/netif/ppp/ppp_oe.c \
-#     Network/lwip-new/src/netif/ppp/randm.c \
-#     Network/lwip-new/src/netif/ppp/vj.c
+#     src/netif/ppp/auth.c \
+#     src/netif/ppp/chap.c \
+#     src/netif/ppp/chpms.c \
+#     src/netif/ppp/fsm.c \
+#     src/netif/ppp/ipcp.c \
+#     src/netif/ppp/lcp.c \
+#     src/netif/ppp/magic.c \
+#     src/netif/ppp/md5.c \
+#     src/netif/ppp/pap.c \
+#     src/netif/ppp/ppp.c \
+#     src/netif/ppp/ppp_oe.c \
+#     src/netif/ppp/randm.c \
+#     src/netif/ppp/vj.c
+
+
+define def_vbox_lwip_flags # VAR_BaseName, path/to/lwip/dir
+  $(strip $1)_INCS += $(foreach incdir, $(LWIP_INCS), $(strip $2)/$(incdir))
+endef
+
+define _def_vbox_lwip_use # VAR_BaseName, path/to/lwip/dir
+  $(strip $1)_SOURCES += \
+        $(foreach file, $(LWIP_SOURCES), $(strip $2)/$(file))
+
+  # if individual lwip files need special settings, add them here:
+  # $(strip $2)/src/foo/bar.c_CFLAGS += -magic
+endef
+
+###
+### Call this if you want to expose lwip to your component as a whole.
+### In this case individual lwip files (added to _SOURCES of your
+### component) will pick up lwip includes etc from your component
+### settings.
+###
+### This is, for example, how NetworkServices/NAT uses it.
+###
+define def_vbox_lwip_public # VAR_BaseName, path/to/lwip/dir
+  $(eval $(call _def_vbox_lwip_use, $1, $2))
+  $(eval $(call def_vbox_lwip_flags, $1, $2))
+endef
+
+###
+### Call this if you want to expose lwip only to a few selected files.
+### In this case each lwip file is configured with lwip includes etc
+### separately and you are supposed to call def_vbox_lwip_flags
+### yourself for those of your files that use lwip.
+###
+### This is, for example, how Devices uses it.
+###
+define def_vbox_lwip_private # VAR_BaseName, path/to/lwip/dir
+  $(eval $(call _def_vbox_lwip_use, $1, $2))
+  $(foreach file, $(LWIP_SOURCES), \
+    $(eval $(call def_vbox_lwip_flags, $(strip $2)/$(file), $2)))
+endef
 
 
Index: trunk/src/VBox/NetworkServices/NAT/Makefile.kmk
===================================================================
--- trunk/src/VBox/NetworkServices/NAT/Makefile.kmk	(revision 48177)
+++ trunk/src/VBox/NetworkServices/NAT/Makefile.kmk	(revision 48178)
@@ -18,13 +18,10 @@
 include $(KBUILD_PATH)/subheader.kmk
 
-define def_vbox_nat_network_service_sources
-    $(1)_SOURCES += $2/$3
-endef
-
-define def_vbox_nat_network_service_incs
-    $(1)_INCS += $2/$3
-endef
-
 ifdef VBOX_WITH_LWIP_NAT
+# XXX: This file depends on lwip makefile already included by Devices,
+#      which is included by ancestor makefile before us...
+#if !defined(LWIP_SOURCES) # ???
+#  include ../../Devices/Network/lwip-new/Makefile.kmk
+#endif
 
 ifdef VBOX_WITH_HARDENING
@@ -78,11 +75,6 @@
     RTWinSocketPair.cpp
 
-#
-# Note: not spaces please in "Devices,$("
-#
-$(foreach file,$(LWIP_SOURCES),$(eval $(call def_vbox_nat_network_service_sources, VBoxNetLwipNAT, ../../Devices,$(file))))
-
-$(foreach incs,$(LWIP_INCS),$(eval $(call def_vbox_nat_network_service_incs, VBoxNetLwipNAT, ../../Devices,$(incs))))
-
+$(eval $(call def_vbox_lwip_public, \
+    VBoxNetLwipNAT, ../../Devices/Network/lwip-new))
 endif
 
