Make vdeplug support optional.

Linking with -lvdeplug without checking whether it exists causes
failures from later configure tests; this makes it an optional
dependency in the same way as other libraries.
This commit is contained in:
Adam Sampson 2018-10-31 12:28:32 +00:00
parent 507813529e
commit 5d77f86575
2 changed files with 37 additions and 8 deletions

View File

@ -88,6 +88,11 @@ AC_ARG_WITH(bincue,
AC_ARG_WITH(libvhd, AC_ARG_WITH(libvhd,
AS_HELP_STRING([--with-libvhd], [Enable VHD disk images])) AS_HELP_STRING([--with-libvhd], [Enable VHD disk images]))
AC_ARG_WITH(vdeplug,
AS_HELP_STRING([--with-vdeplug], [Enable VDE virtual network support]),
[],
[with_vdeplug=yes])
dnl Cross Compiling results in 'guesses' being made about the target system. These defaults are oftetimes incorrect. dnl Cross Compiling results in 'guesses' being made about the target system. These defaults are oftetimes incorrect.
dnl The following Environment variables allow you to configure the default guess value for each option in the configure script. dnl The following Environment variables allow you to configure the default guess value for each option in the configure script.
@ -323,8 +328,6 @@ else
SDL_SUPPORT="none" SDL_SUPPORT="none"
fi fi
LIBS="$CFLAGS -lvdeplug"
dnl We need X11, if not using SDL or Mac GUI. dnl We need X11, if not using SDL or Mac GUI.
if [[ "x$WANT_SDL_VIDEO" = "xno" -a "x$WANT_MACOSX_GUI" = "xno" ]]; then if [[ "x$WANT_SDL_VIDEO" = "xno" -a "x$WANT_MACOSX_GUI" = "xno" ]]; then
AC_PATH_XTRA AC_PATH_XTRA
@ -794,6 +797,13 @@ if [[ -n "$CAN_SLIRP" ]]; then
fi fi
AC_SUBST(SLIRP_SRCS) AC_SUBST(SLIRP_SRCS)
dnl Is libvdeplug available?
have_vdeplug=no
AS_IF([test "x$with_vdeplug" = "xyes"], [
have_vdeplug=yes
AC_CHECK_LIB(vdeplug, vde_close, [], [have_vdeplug=no])
])
if [[ "x$WANT_MACOSX_GUI" = "xyes" ]]; then if [[ "x$WANT_MACOSX_GUI" = "xyes" ]]; then
CPPFLAGS="$CPPFLAGS -I../MacOSX" CPPFLAGS="$CPPFLAGS -I../MacOSX"
LIBS="$LIBS -framework CoreAudio -framework AudioUnit -framework AudioToolbox" LIBS="$LIBS -framework CoreAudio -framework AudioUnit -framework AudioToolbox"
@ -1855,6 +1865,7 @@ echo Mac OS X Sound ......................... : $WANT_MACOSX_SOUND
echo SDL support ............................ : $SDL_SUPPORT echo SDL support ............................ : $SDL_SUPPORT
echo BINCUE support ......................... : $have_bincue echo BINCUE support ......................... : $have_bincue
echo LIBVHD support ......................... : $have_libvhd echo LIBVHD support ......................... : $have_libvhd
echo VDE support ............................ : $have_vdeplug
echo XFree86 DGA support .................... : $WANT_XF86_DGA echo XFree86 DGA support .................... : $WANT_XF86_DGA
echo XFree86 VidMode support ................ : $WANT_XF86_VIDMODE echo XFree86 VidMode support ................ : $WANT_XF86_VIDMODE
echo fbdev DGA support ...................... : $WANT_FBDEV_DGA echo fbdev DGA support ...................... : $WANT_FBDEV_DGA

View File

@ -20,9 +20,6 @@
#include "sysdeps.h" #include "sysdeps.h"
extern "C" {
#include <libvdeplug.h>
}
/* /*
* NOTES concerning MacOS X issues: * NOTES concerning MacOS X issues:
* - poll() does not exist in 10.2.8, but is available in 10.4.4 * - poll() does not exist in 10.2.8, but is available in 10.4.4
@ -72,6 +69,12 @@ extern "C" {
#include "ctl.h" #include "ctl.h"
#endif #endif
#ifdef HAVE_LIBVDEPLUG
extern "C" {
#include <libvdeplug.h>
}
#endif
#include "cpu_emulation.h" #include "cpu_emulation.h"
#include "main.h" #include "main.h"
#include "macos_util.h" #include "macos_util.h"
@ -119,7 +122,9 @@ static pthread_t slirp_thread; // Slirp reception thread
static bool slirp_thread_active = false; // Flag: Slirp reception threadinstalled static bool slirp_thread_active = false; // Flag: Slirp reception threadinstalled
static int slirp_output_fd = -1; // fd of slirp output pipe static int slirp_output_fd = -1; // fd of slirp output pipe
static int slirp_input_fds[2] = { -1, -1 }; // fds of slirp input pipe static int slirp_input_fds[2] = { -1, -1 }; // fds of slirp input pipe
#ifdef HAVE_LIBVDEPLUG
static VDECONN *vde_conn; static VDECONN *vde_conn;
#endif
#ifdef SHEEPSHAVER #ifdef SHEEPSHAVER
static bool net_open = false; // Flag: initialization succeeded, network device open static bool net_open = false; // Flag: initialization succeeded, network device open
static uint8 ether_addr[6]; // Our Ethernet address static uint8 ether_addr[6]; // Our Ethernet address
@ -261,10 +266,12 @@ bool ether_init(void)
printf("selected Ethernet device type slirp\n"); printf("selected Ethernet device type slirp\n");
} }
#endif #endif
#ifdef HAVE_LIBVDEPLUG
else if (strcmp(name, "vde") == 0) { else if (strcmp(name, "vde") == 0) {
net_if_type = NET_IF_VDE; net_if_type = NET_IF_VDE;
printf("selected Ethernet device type VDE\n"); printf("selected Ethernet device type VDE\n");
} }
#endif
else { else {
net_if_type = NET_IF_SHEEPNET; net_if_type = NET_IF_SHEEPNET;
printf("selected Ethernet device type sheep_net\n"); printf("selected Ethernet device type sheep_net\n");
@ -319,6 +326,7 @@ bool ether_init(void)
break; break;
} }
#ifdef HAVE_LIBVDEPLUG
//vde switch information //vde switch information
int port = 0; int port = 0;
char *init_group = NULL; char *init_group = NULL;
@ -343,6 +351,7 @@ bool ether_init(void)
fd = vde_datafd(vde_conn); fd = vde_datafd(vde_conn);
} }
} }
#endif
if (net_if_type != NET_IF_SLIRP && net_if_type != NET_IF_VDE) { if (net_if_type != NET_IF_SLIRP && net_if_type != NET_IF_VDE) {
fd = open(dev_name, O_RDWR); fd = open(dev_name, O_RDWR);
@ -431,6 +440,7 @@ bool ether_init(void)
ether_addr[4] = 0x34; ether_addr[4] = 0x34;
ether_addr[5] = 0x56; ether_addr[5] = 0x56;
#endif #endif
#ifdef HAVE_LIBVDEPLUG
} else if (net_if_type == NET_IF_VDE) { } else if (net_if_type == NET_IF_VDE) {
ether_addr[0] = 0x52; ether_addr[0] = 0x52;
ether_addr[1] = 0x54; ether_addr[1] = 0x54;
@ -438,6 +448,7 @@ bool ether_init(void)
ether_addr[3] = 0x12; ether_addr[3] = 0x12;
ether_addr[4] = 0x34; ether_addr[4] = 0x34;
ether_addr[5] = 0x56; ether_addr[5] = 0x56;
#endif
} else } else
ioctl(fd, SIOCGIFADDR, ether_addr); ioctl(fd, SIOCGIFADDR, ether_addr);
D(bug("Ethernet address %02x %02x %02x %02x %02x %02x\n", ether_addr[0], ether_addr[1], ether_addr[2], ether_addr[3], ether_addr[4], ether_addr[5])); D(bug("Ethernet address %02x %02x %02x %02x %02x %02x\n", ether_addr[0], ether_addr[1], ether_addr[2], ether_addr[3], ether_addr[4], ether_addr[5]));
@ -503,9 +514,11 @@ void ether_exit(void)
if (slirp_output_fd > 0) if (slirp_output_fd > 0)
close(slirp_output_fd); close(slirp_output_fd);
#ifdef HAVE_LIBVDEPLUG
// Close vde_connection // Close vde_connection
if (net_if_type == NET_IF_VDE) if (net_if_type == NET_IF_VDE)
vde_close(vde_conn); vde_close(vde_conn);
#endif
#if STATISTICS #if STATISTICS
// Show statistics // Show statistics
printf("%ld messages put on write queue\n", num_wput); printf("%ld messages put on write queue\n", num_wput);
@ -804,6 +817,7 @@ static int16 ether_do_write(uint32 arg)
return noErr; return noErr;
} else } else
#endif #endif
#ifdef HAVE_LIBVDEPLUG
if (net_if_type == NET_IF_VDE) { if (net_if_type == NET_IF_VDE) {
if (fd == -1) { // which means vde service is not running if (fd == -1) { // which means vde service is not running
D(bug("WARNING: Couldn't transmit VDE packet\n")); D(bug("WARNING: Couldn't transmit VDE packet\n"));
@ -820,8 +834,9 @@ static int16 ether_do_write(uint32 arg)
} while (len < 0); } while (len < 0);
return noErr; return noErr;
} } else
else if (write(fd, packet, len) < 0) { #endif
if (write(fd, packet, len) < 0) {
D(bug("WARNING: Couldn't transmit packet\n")); D(bug("WARNING: Couldn't transmit packet\n"));
return excessCollsns; return excessCollsns;
} else } else
@ -995,9 +1010,12 @@ void ether_do_interrupt(void)
} else } else
#endif #endif
{ {
#ifdef HAVE_LIBVDEPLUG
if (net_if_type == NET_IF_VDE) { if (net_if_type == NET_IF_VDE) {
length = vde_recv(vde_conn, Mac2HostAddr(packet), 1514, 0); length = vde_recv(vde_conn, Mac2HostAddr(packet), 1514, 0);
} else { } else
#endif
{
// Read packet from sheep_net device // Read packet from sheep_net device
#if defined(__linux__) #if defined(__linux__)
length = read(fd, Mac2HostAddr(packet), net_if_type == NET_IF_ETHERTAP ? 1516 : 1514); length = read(fd, Mac2HostAddr(packet), net_if_type == NET_IF_ETHERTAP ? 1516 : 1514);