VirtualBox

source: vbox/trunk/src/VBox/NetworkServices/NAT/Makefile.kmk

Last change on this file was 109110, checked in by vboxsync, 11 days ago

NetworkServices/NAT: Add build integration for alternative libslirp based NAT engine, needs VBOX_WITH_LWIP_NAT= to be activated, bugref:10268 [scm]

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1# $Id: Makefile.kmk 109110 2025-04-29 13:52:19Z vboxsync $
2## @file
3# Sub-makefile for NAT Networking
4#
5
6#
7# Copyright (C) 2006-2024 Oracle and/or its affiliates.
8#
9# This file is part of VirtualBox base platform packages, as
10# available from https://www.215389.xyz.
11#
12# This program is free software; you can redistribute it and/or
13# modify it under the terms of the GNU General Public License
14# as published by the Free Software Foundation, in version 3 of the
15# License.
16#
17# This program is distributed in the hope that it will be useful, but
18# WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20# General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program; if not, see <https://www.gnu.org/licenses>.
24#
25# SPDX-License-Identifier: GPL-3.0-only
26#
27
28SUB_DEPTH = ../../../..
29include $(KBUILD_PATH)/subheader.kmk
30
31#
32# Hardened stub exe for VBoxNetNAT.
33#
34ifdef VBOX_WITH_HARDENING
35 PROGRAMS += VBoxNetNATHardened
36 VBoxNetNATHardened_TEMPLATE = VBoxR3HardenedExe
37 VBoxNetNATHardened_NAME = VBoxNetNAT
38 ifdef VBOX_WITH_AUTOMATIC_DEFS_QUOTING
39 VBoxNetNATHardened_DEFS = SERVICE_NAME="VBoxNetNAT"
40 else
41 VBoxNetNATHardened_DEFS = SERVICE_NAME=\"VBoxNetNAT\"
42 endif
43 VBoxNetNATHardened_SOURCES = VBoxNetNATHardened.cpp
44 VBoxNetNATHardened_LDFLAGS.win = /SUBSYSTEM:windows
45 $(call VBOX_SET_VER_INFO_EXE,VBoxNetNATHardened,VirtualBox NAT Engine,$(VBOX_WINDOWS_ICON_FILE)) # Version info / description.
46endif
47
48
49#
50# VBoxNetNAT.
51#
52ifdef VBOX_WITH_HARDENING
53 DLLS += VBoxNetNAT
54else
55 PROGRAMS += VBoxNetNAT
56endif
57VBoxNetNAT_TEMPLATE := $(if-expr defined(VBOX_WITH_HARDENING),VBoxMainDll,VBoxMainClientSignedExe)
58VBoxNetNAT_NAME := VBoxNetNAT
59VBoxNetNAT_DEFS = \
60 IPv6 \
61 $(if $(VBOX_WITH_INTNET_SERVICE_IN_R3),VBOX_WITH_INTNET_SERVICE_IN_R3,) \
62 $(if $(VBOX_WITH_LWIP_NAT),VBOX_WITH_LWIP_NAT,)
63
64# VBoxNetNAT_DEFS.linux = WITH_VALGRIND # instrument lwip memp.c
65
66ifdef VBOX_WITH_LWIP_NAT
67
68 ifndef LWIP_SOURCES
69 include $(PATH_SUB_CURRENT)/../../Devices/Network/lwip-new/Config.kmk
70 endif
71
72 VBoxNetNAT_DEFS.win = VBOX_COM_OUTOFPROC_MODULE _WIN32_WINNT=0x501 # Windows XP
73
74 # Convince Solaris headers to expose socket stuff we need.
75 #
76 # Setting _XOPEN_SOURCE to either 500 or 600 would always work, but
77 # <sys/feature_tests.h> insists that 600 requires C99 and so it
78 # explodes for older g++. It also insists that 500 is NOT to be used
79 # with C99.
80 #
81 # Newer g++ in C++11 mode (formerly known as C++0x) needs 600, so it
82 # employs sleight of hand to pretend it's C99 to keep feature test
83 # happy.
84 #
85 # Compile the C code with settings that match g++. This probably
86 # should be centralized so that whole codebase uses consistent
87 # settings.
88 ifeq ($(KBUILD_TARGET),solaris)
89 ifneq ($(VBOX_GCC_VERSION_CXX),)
90 if $(VBOX_GCC_VERSION_CXX) >= 40600
91 # we compile C++ code with -std=c++0x / -std=c++11
92 VBoxNetNAT_CFLAGS.solaris += -std=c99
93 VBoxNetNAT_DEFS.solaris += _XOPEN_SOURCE=600
94 else
95 VBoxNetNAT_DEFS.solaris += _XOPEN_SOURCE=500
96 endif
97 endif
98 VBoxNetNAT_DEFS.solaris += __EXTENSIONS__=1
99 endif
100
101 # (current dir is for for lwipopts.h)
102 VBoxNetNAT_INCS += . $(addprefix ../../Devices/Network/lwip-new/,$(LWIP_INCS))
103
104 VBoxNetNAT_SOURCES = \
105 VBoxNetLwipNAT.cpp \
106 ../NetLib/IntNetIf.cpp \
107 ../NetLib/VBoxNetPortForwardString.cpp \
108 $(addprefix ../../Devices/Network/lwip-new/,$(LWIP_SOURCES)) \
109 proxy_pollmgr.c \
110 proxy_rtadvd.c \
111 proxy.c \
112 pxremap.c \
113 pxtcp.c \
114 pxudp.c \
115 pxdns.c \
116 fwtcp.c \
117 fwudp.c \
118 portfwd.c \
119 proxy_dhcp6ds.c \
120 proxy_tftpd.c
121
122 ifeq ($(KBUILD_TARGET),win)
123 VBoxNetNAT_SOURCES += pxping_win.c # unprivileged Icmp API
124 else
125 VBoxNetNAT_SOURCES += pxping.c # raw sockets
126 VBoxNetNAT_CFLAGS.linux += -Wno-address-of-packed-member # Needed for GCC 9.
127 endif
128
129 VBoxNetNAT_SOURCES.darwin += rtmon_bsd.c
130 VBoxNetNAT_SOURCES.freebsd += rtmon_bsd.c
131 VBoxNetNAT_SOURCES.linux += rtmon_linux.c
132 VBoxNetNAT_SOURCES.solaris += rtmon_bsd.c
133 VBoxNetNAT_SOURCES.win += \
134 rtmon_win.c \
135 RTWinPoll.cpp \
136 RTWinSocketPair.cpp
137
138 VBoxNetNAT_LIBS = \
139 $(LIB_RUNTIME)
140 VBoxNetNAT_LIBS.solaris += socket nsl
141
142 VBoxNetNAT_LDFLAGS.win = /SUBSYSTEM:windows
143
144 # ifeq ($(VBOX_WITH_HARDENING),)
145 # ifn1of ($(KBUILD_TARGET), darwin win)
146 # # helper for debugging unprivileged
147 # VBoxNetNAT_DEFS += VBOX_RAWSOCK_DEBUG_HELPER
148 # VBoxNetNAT_SOURCES += getrawsock.c
149 # endif
150 # endif
151else
152
153 VBoxNetNAT_DEFS.win = VBOX_COM_OUTOFPROC_MODULE
154
155 VBoxNetNAT_INCS += \
156 $(PATH_ROOT)/src/libs/libslirp-4.9.0/src \
157 $(PATH_OUT)/obj/VBox-libslirp
158
159 VBoxNetNAT_SOURCES = \
160 VBoxNetSlirpNAT.cpp \
161 ../NetLib/IntNetIf.cpp \
162 ../NetLib/VBoxNetPortForwardString.cpp
163
164 VBoxNetNAT_SOURCES.win += \
165 RTWinPoll.cpp \
166 RTWinSocketPair.cpp
167
168 VBoxNetNAT_LIBS = \
169 $(PATH_STAGE_LIB)/VBox-libslirp$(VBOX_SUFF_LIB) \
170 $(LIB_RUNTIME)
171 VBoxNetNAT_LIBS.solaris += socket nsl
172 VBoxNetNAT_LIBS.darwin += resolv
173
174 VBoxNetNAT_LDFLAGS.win = /SUBSYSTEM:windows
175endif # VBOX_WITH_LWIP_NAT
176
177ifdef VBOX_WITH_HARDENING
178 $(call VBOX_SET_VER_INFO_DLL,VBoxNetNAT,VirtualBox NAT Engine (dll),$(VBOX_WINDOWS_ICON_FILE)) # Version info / description.
179else
180 $(call VBOX_SET_VER_INFO_EXE,VBoxNetNAT,VirtualBox NAT Engine,$(VBOX_WINDOWS_ICON_FILE)) # Version info / description.
181endif
182
183include $(FILE_KBUILD_SUB_FOOTER)
184
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette