mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-11-26 10:49:21 +00:00
Add necessary configury + support code to support slirp in SheepShaver,
the user-space network emulation layer. Enable it on all Unix supported platforms where I know it works.
This commit is contained in:
parent
2cf7fd2a88
commit
b7004b1199
@ -60,11 +60,11 @@ links:
|
||||
Unix/sigsegv.h Unix/sigsegv.cpp Unix/vm_alloc.h Unix/vm_alloc.cpp \
|
||||
Unix/posix_sem.cpp Unix/video_vosf.h Unix/video_blit.h \
|
||||
Unix/video_blit.cpp Unix/config.sub Unix/config.guess \
|
||||
Unix/keycodes Unix/tunconfig Unix/clip_unix.cpp \
|
||||
Unix/m4 Unix/Linux/scsi_linux.cpp Unix/Linux/NetDriver \
|
||||
Unix/keycodes Unix/tunconfig Unix/clip_unix.cpp Unix/m4 \
|
||||
Unix/Linux/scsi_linux.cpp Unix/Linux/NetDriver Unix/ether_unix.cpp \
|
||||
Unix/Darwin/lowmem.c Unix/Darwin/pagezero.c Unix/Darwin/testlmem.sh \
|
||||
dummy/audio_dummy.cpp dummy/clip_dummy.cpp dummy/serial_dummy.cpp \
|
||||
dummy/prefs_editor_dummy.cpp dummy/scsi_dummy.cpp SDL \
|
||||
dummy/prefs_editor_dummy.cpp dummy/scsi_dummy.cpp SDL slirp \
|
||||
MacOSX/sys_darwin.cpp MacOSX/clip_macosx.cpp \
|
||||
MacOSX/macos_util_macosx.h MacOSX/extfs_macosx.h \
|
||||
MacOSX/extfs_macosx.mm Windows/clip_windows.cpp \
|
||||
|
@ -1,510 +0,0 @@
|
||||
/*
|
||||
* ether_linux.cpp - SheepShaver Ethernet Device Driver (DLPI), Linux specific stuff
|
||||
*
|
||||
* SheepShaver (C) 1997-2005 Marc Hellwig and Christian Bauer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "sysdeps.h"
|
||||
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/poll.h>
|
||||
#include <sys/wait.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(HAVE_LINUX_IF_H) && defined(HAVE_LINUX_IF_TUN_H)
|
||||
#include <linux/if.h>
|
||||
#include <linux/if_tun.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_NET_IF_H) && defined(HAVE_NET_IF_TUN_H)
|
||||
#include <net/if.h>
|
||||
#include <net/if_tun.h>
|
||||
#endif
|
||||
|
||||
#include "main.h"
|
||||
#include "macos_util.h"
|
||||
#include "prefs.h"
|
||||
#include "user_strings.h"
|
||||
#include "ether.h"
|
||||
#include "ether_defs.h"
|
||||
|
||||
#define DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
#define STATISTICS 0
|
||||
#define MONITOR 0
|
||||
|
||||
|
||||
// Ethernet device types
|
||||
enum {
|
||||
NET_IF_SHEEPNET,
|
||||
NET_IF_ETHERTAP,
|
||||
NET_IF_TUNTAP,
|
||||
};
|
||||
|
||||
// Constants
|
||||
static const char ETHERCONFIG_FILE_NAME[] = DATADIR "/tunconfig";
|
||||
|
||||
// Global variables
|
||||
static int fd = -1; // fd of sheep_net device
|
||||
|
||||
static pthread_t ether_thread; // Packet reception thread
|
||||
static bool thread_active = false; // Flag: Packet reception thread installed
|
||||
|
||||
static sem_t int_ack; // Interrupt acknowledge semaphore
|
||||
static uint8 ether_addr[6]; // Our Ethernet address
|
||||
|
||||
static bool net_open = false; // Flag: initialization succeeded, network device open
|
||||
static int net_if_type = -1; // Ethernet device type
|
||||
static char *net_if_name; // TUN/TAP device name
|
||||
static const char *net_if_script; // Network config script
|
||||
|
||||
|
||||
// Prototypes
|
||||
static void *receive_func(void *arg);
|
||||
|
||||
|
||||
/*
|
||||
* Execute network script up|down
|
||||
*/
|
||||
|
||||
static bool execute_network_script(const char *action)
|
||||
{
|
||||
if (net_if_script == NULL || net_if_name == NULL)
|
||||
return false;
|
||||
|
||||
int pid = fork();
|
||||
if (pid >= 0) {
|
||||
if (pid == 0) {
|
||||
char *args[4];
|
||||
args[0] = (char *)net_if_script;
|
||||
args[1] = net_if_name;
|
||||
args[2] = (char *)action;
|
||||
args[3] = NULL;
|
||||
execv(net_if_script, args);
|
||||
exit(1);
|
||||
}
|
||||
int status;
|
||||
while (waitpid(pid, &status, 0) != pid);
|
||||
return WIFEXITED(status) && WEXITSTATUS(status) == 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Initialize ethernet
|
||||
*/
|
||||
|
||||
void EtherInit(void)
|
||||
{
|
||||
int nonblock = 1;
|
||||
char str[256];
|
||||
|
||||
// Do nothing if the user disabled the network
|
||||
if (PrefsFindBool("nonet"))
|
||||
return;
|
||||
|
||||
// Do nothing if no Ethernet device specified
|
||||
const char *name = PrefsFindString("ether");
|
||||
if (name == NULL)
|
||||
return;
|
||||
|
||||
// Determine Ether device type
|
||||
net_if_type = -1;
|
||||
if (strncmp(name, "tap", 3) == 0)
|
||||
net_if_type = NET_IF_ETHERTAP;
|
||||
#if ENABLE_TUNTAP
|
||||
else if (strcmp(name, "tun") == 0)
|
||||
net_if_type = NET_IF_TUNTAP;
|
||||
#endif
|
||||
else
|
||||
net_if_type = NET_IF_SHEEPNET;
|
||||
|
||||
// Open sheep_net or ethertap device
|
||||
char dev_name[16];
|
||||
switch (net_if_type) {
|
||||
case NET_IF_ETHERTAP:
|
||||
sprintf(dev_name, "/dev/%s", name);
|
||||
break;
|
||||
case NET_IF_TUNTAP:
|
||||
strcpy(dev_name, "/dev/net/tun");
|
||||
break;
|
||||
case NET_IF_SHEEPNET:
|
||||
strcpy(dev_name, "/dev/sheep_net");
|
||||
break;
|
||||
}
|
||||
fd = open(dev_name, O_RDWR);
|
||||
if (fd < 0) {
|
||||
sprintf(str, GetString(STR_NO_SHEEP_NET_DRIVER_WARN), dev_name, strerror(errno));
|
||||
WarningAlert(str);
|
||||
goto open_error;
|
||||
}
|
||||
|
||||
#if ENABLE_TUNTAP
|
||||
// Open TUN/TAP interface
|
||||
if (net_if_type == NET_IF_TUNTAP) {
|
||||
struct ifreq ifr;
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
|
||||
strcpy(ifr.ifr_name, "tun%d");
|
||||
if (ioctl(fd, TUNSETIFF, (void *) &ifr) != 0) {
|
||||
sprintf(str, GetString(STR_SHEEP_NET_ATTACH_WARN), strerror(errno));
|
||||
WarningAlert(str);
|
||||
goto open_error;
|
||||
}
|
||||
|
||||
// Get network config script file path
|
||||
net_if_script = PrefsFindString("etherconfig");
|
||||
if (net_if_script == NULL)
|
||||
net_if_script = ETHERCONFIG_FILE_NAME;
|
||||
|
||||
// Start network script up
|
||||
if (net_if_script == NULL) {
|
||||
sprintf(str, GetString(STR_TUN_TAP_CONFIG_WARN), "script not found");
|
||||
WarningAlert(str);
|
||||
goto open_error;
|
||||
}
|
||||
net_if_name = strdup(ifr.ifr_name);
|
||||
if (!execute_network_script("up")) {
|
||||
sprintf(str, GetString(STR_TUN_TAP_CONFIG_WARN), "script execute error");
|
||||
WarningAlert(str);
|
||||
goto open_error;
|
||||
}
|
||||
D(bug("Connected to host network interface: %s\n", net_if_name));
|
||||
}
|
||||
#endif
|
||||
|
||||
// Attach to selected Ethernet card
|
||||
if (net_if_type == NET_IF_SHEEPNET && ioctl(fd, SIOCSIFLINK, name) < 0) {
|
||||
sprintf(str, GetString(STR_SHEEP_NET_ATTACH_WARN), strerror(errno));
|
||||
WarningAlert(str);
|
||||
goto open_error;
|
||||
}
|
||||
|
||||
// Set nonblocking I/O
|
||||
ioctl(fd, FIONBIO, &nonblock);
|
||||
|
||||
// Get Ethernet address
|
||||
if (net_if_type == NET_IF_ETHERTAP) {
|
||||
pid_t p = getpid(); // If configured for multicast, ethertap requires that the lower 32 bit of the Ethernet address are our PID
|
||||
ether_addr[0] = 0xfe;
|
||||
ether_addr[1] = 0xfd;
|
||||
ether_addr[2] = p >> 24;
|
||||
ether_addr[3] = p >> 16;
|
||||
ether_addr[4] = p >> 8;
|
||||
ether_addr[5] = p;
|
||||
} else
|
||||
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]));
|
||||
|
||||
// Start packet reception thread
|
||||
if (sem_init(&int_ack, 0, 0) < 0) {
|
||||
WarningAlert("WARNING: Cannot init semaphore");
|
||||
goto open_error;
|
||||
}
|
||||
thread_active = (pthread_create(ðer_thread, NULL, receive_func, NULL) == 0);
|
||||
if (!thread_active) {
|
||||
WarningAlert("WARNING: Cannot start Ethernet thread");
|
||||
goto open_error;
|
||||
}
|
||||
|
||||
// Everything OK
|
||||
net_open = true;
|
||||
return;
|
||||
|
||||
open_error:
|
||||
if (thread_active) {
|
||||
pthread_cancel(ether_thread);
|
||||
pthread_join(ether_thread, NULL);
|
||||
sem_destroy(&int_ack);
|
||||
thread_active = false;
|
||||
}
|
||||
if (fd > 0) {
|
||||
close(fd);
|
||||
fd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Exit ethernet
|
||||
*/
|
||||
|
||||
void EtherExit(void)
|
||||
{
|
||||
// Stop reception thread
|
||||
if (thread_active) {
|
||||
pthread_cancel(ether_thread);
|
||||
pthread_join(ether_thread, NULL);
|
||||
sem_destroy(&int_ack);
|
||||
thread_active = false;
|
||||
}
|
||||
|
||||
// Shut down TUN/TAP interface
|
||||
if (net_if_type == NET_IF_TUNTAP)
|
||||
execute_network_script("down");
|
||||
|
||||
// Free TUN/TAP device name
|
||||
if (net_if_name)
|
||||
free(net_if_name);
|
||||
|
||||
// Close sheep_net device
|
||||
if (fd > 0)
|
||||
close(fd);
|
||||
|
||||
#if STATISTICS
|
||||
// Show statistics
|
||||
printf("%ld messages put on write queue\n", num_wput);
|
||||
printf("%ld error acks\n", num_error_acks);
|
||||
printf("%ld packets transmitted (%ld raw, %ld normal)\n", num_tx_packets, num_tx_raw_packets, num_tx_normal_packets);
|
||||
printf("%ld tx packets dropped because buffer full\n", num_tx_buffer_full);
|
||||
printf("%ld packets received\n", num_rx_packets);
|
||||
printf("%ld packets passed upstream (%ld Fast Path, %ld normal)\n", num_rx_fastpath + num_unitdata_ind, num_rx_fastpath, num_unitdata_ind);
|
||||
printf("EtherIRQ called %ld times\n", num_ether_irq);
|
||||
printf("%ld rx packets dropped due to low memory\n", num_rx_no_mem);
|
||||
printf("%ld rx packets dropped because no stream found\n", num_rx_dropped);
|
||||
printf("%ld rx packets dropped because stream not ready\n", num_rx_stream_not_ready);
|
||||
printf("%ld rx packets dropped because no memory for unitdata_ind\n", num_rx_no_unitdata_mem);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get ethernet hardware address
|
||||
*/
|
||||
|
||||
void AO_get_ethernet_address(uint8 *addr)
|
||||
{
|
||||
if (net_open) {
|
||||
OTCopy48BitAddress(ether_addr, addr);
|
||||
} else {
|
||||
addr[0] = 0x12;
|
||||
addr[1] = 0x34;
|
||||
addr[2] = 0x56;
|
||||
addr[3] = 0x78;
|
||||
addr[4] = 0x9a;
|
||||
addr[5] = 0xbc;
|
||||
}
|
||||
D(bug("AO_get_ethernet_address: got address %02x%02x%02x%02x%02x%02x\n", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Enable multicast address
|
||||
*/
|
||||
|
||||
void AO_enable_multicast(uint8 *addr)
|
||||
{
|
||||
D(bug("AO_enable_multicast\n"));
|
||||
if (net_open) {
|
||||
if (net_if_type != NET_IF_TUNTAP && ioctl(fd, SIOCADDMULTI, addr) < 0) {
|
||||
D(bug("WARNING: couldn't enable multicast address\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Disable multicast address
|
||||
*/
|
||||
|
||||
void AO_disable_multicast(uint8 *addr)
|
||||
{
|
||||
D(bug("AO_disable_multicast\n"));
|
||||
if (net_open) {
|
||||
if (net_if_type != NET_IF_TUNTAP && ioctl(fd, SIOCDELMULTI, addr) < 0) {
|
||||
D(bug("WARNING: couldn't disable multicast address\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Transmit one packet
|
||||
*/
|
||||
|
||||
void AO_transmit_packet(mblk_t *mp)
|
||||
{
|
||||
D(bug("AO_transmit_packet\n"));
|
||||
if (net_open) {
|
||||
|
||||
// Copy packet to buffer
|
||||
uint8 packet[1516], *p = packet;
|
||||
int len = 0;
|
||||
if (net_if_type == NET_IF_ETHERTAP) {
|
||||
*p++ = 0; // Ethertap discards the first 2 bytes
|
||||
*p++ = 0;
|
||||
len += 2;
|
||||
}
|
||||
while (mp) {
|
||||
uint32 size = mp->b_wptr - mp->b_rptr;
|
||||
memcpy(p, mp->b_rptr, size);
|
||||
len += size;
|
||||
p += size;
|
||||
mp = mp->b_cont;
|
||||
}
|
||||
|
||||
#if MONITOR
|
||||
bug("Sending Ethernet packet:\n");
|
||||
for (int i=0; i<len; i++) {
|
||||
bug("%02x ", packet[i]);
|
||||
}
|
||||
bug("\n");
|
||||
#endif
|
||||
|
||||
// Transmit packet
|
||||
if (write(fd, packet, len) < 0) {
|
||||
D(bug("WARNING: couldn't transmit packet\n"));
|
||||
num_tx_buffer_full++;
|
||||
} else
|
||||
num_tx_packets++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Packet reception thread
|
||||
*/
|
||||
|
||||
static void *receive_func(void *arg)
|
||||
{
|
||||
for (;;) {
|
||||
|
||||
// Wait for packets to arrive
|
||||
struct pollfd pf = {fd, POLLIN, 0};
|
||||
int res = poll(&pf, 1, -1);
|
||||
if (res <= 0)
|
||||
break;
|
||||
|
||||
if (ether_driver_opened) {
|
||||
// Trigger Ethernet interrupt
|
||||
D(bug(" packet received, triggering Ethernet interrupt\n"));
|
||||
SetInterruptFlag(INTFLAG_ETHER);
|
||||
TriggerInterrupt();
|
||||
|
||||
// Wait for interrupt acknowledge by EtherInterrupt()
|
||||
sem_wait(&int_ack);
|
||||
} else
|
||||
usleep(20000);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Ethernet interrupt
|
||||
*/
|
||||
|
||||
void EtherIRQ(void)
|
||||
{
|
||||
D(bug("EtherIRQ\n"));
|
||||
num_ether_irq++;
|
||||
OTEnterInterrupt();
|
||||
|
||||
// Send received packets to OpenTransport
|
||||
uint8 packet[1516];
|
||||
for (;;) {
|
||||
|
||||
if (net_if_type != NET_IF_SHEEPNET) {
|
||||
|
||||
// Read packet from ethertap device
|
||||
ssize_t size = read(fd, packet, net_if_type == NET_IF_ETHERTAP ? 1516 : 1514);
|
||||
if (size < 14)
|
||||
break;
|
||||
|
||||
#if MONITOR
|
||||
bug("Receiving Ethernet packet:\n");
|
||||
for (int i=0; i<size; i++) {
|
||||
bug("%02x ", packet[i]);
|
||||
}
|
||||
bug("\n");
|
||||
#endif
|
||||
|
||||
// Pointer to packet data (Ethernet header)
|
||||
uint8 *p = packet;
|
||||
if (net_if_type == NET_IF_ETHERTAP) {
|
||||
p += 2; // Ethertap has two random bytes before the packet
|
||||
size -= 2;
|
||||
}
|
||||
|
||||
// Wrap packet in message block
|
||||
num_rx_packets++;
|
||||
mblk_t *mp;
|
||||
if ((mp = allocb(size, 0)) != NULL) {
|
||||
D(bug(" packet data at %p\n", (void *)mp->b_rptr));
|
||||
memcpy(mp->b_rptr, p, size);
|
||||
mp->b_wptr += size;
|
||||
ether_packet_received(mp);
|
||||
} else {
|
||||
D(bug("WARNING: Cannot allocate mblk for received packet\n"));
|
||||
num_rx_no_mem++;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// Get size of first packet
|
||||
int size = 0;
|
||||
if (ioctl(fd, FIONREAD, &size) < 0 || size == 0)
|
||||
break;
|
||||
|
||||
// Discard packets which are too short
|
||||
if (size < 14) {
|
||||
uint8 dummy[14];
|
||||
read(fd, dummy, size);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Truncate packets which are too long
|
||||
if (size > 1514)
|
||||
size = 1514;
|
||||
|
||||
// Read packet and wrap it in message block
|
||||
num_rx_packets++;
|
||||
mblk_t *mp;
|
||||
if ((mp = allocb(size, 0)) != NULL) {
|
||||
D(bug(" packet data at %p\n", (void *)mp->b_rptr));
|
||||
read(fd, mp->b_rptr, size);
|
||||
#if MONITOR
|
||||
bug("Receiving Ethernet packet:\n");
|
||||
for (int i=0; i<size; i++) {
|
||||
bug("%02x ", ((uint8 *)mp->b_rptr)[i]);
|
||||
}
|
||||
bug("\n");
|
||||
#endif
|
||||
mp->b_wptr += size;
|
||||
ether_packet_received(mp);
|
||||
} else {
|
||||
D(bug("WARNING: Cannot allocate mblk for received packet\n"));
|
||||
read(fd, packet, size); // consume this packet
|
||||
num_rx_no_mem++;
|
||||
}
|
||||
}
|
||||
}
|
||||
OTLeaveInterrupt();
|
||||
|
||||
// Acknowledge interrupt to reception thread
|
||||
D(bug(" EtherIRQ done\n"));
|
||||
sem_post(&int_ack);
|
||||
}
|
@ -17,7 +17,7 @@ CC = @CC@
|
||||
CXX = @CXX@
|
||||
CFLAGS = @CFLAGS@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CPPFLAGS = @CPPFLAGS@ -I../include -I.
|
||||
CPPFLAGS = @CPPFLAGS@ -I../include -I. -I../slirp
|
||||
DEFS = @DEFS@ -D_REENTRANT -DDATADIR=\"$(datadir)/$(APP)\"
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
@ -36,6 +36,10 @@ INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ -s
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
SLIRP_CFLAGS = @SLIRP_CFLAGS@
|
||||
SLIRP_SRCS = @SLIRP_SRCS@
|
||||
SLIRP_OBJS = $(SLIRP_SRCS:../slirp/%.c=obj/%.o)
|
||||
|
||||
# Append disassembler to dyngen, if available
|
||||
ifneq (:no,$(MONSRCS):$(USE_DYNGEN))
|
||||
DYNGENSRCS += $(filter %i386-dis.c,$(MONSRCS))
|
||||
@ -50,7 +54,7 @@ SRCS = ../main.cpp main_unix.cpp ../prefs.cpp ../prefs_items.cpp prefs_unix.cpp
|
||||
../serial.cpp ../extfs.cpp \
|
||||
about_window_unix.cpp ../user_strings.cpp user_strings_unix.cpp \
|
||||
vm_alloc.cpp sigsegv.cpp \
|
||||
sshpty.c strlcpy.c $(SYSSRCS) $(CPUSRCS) $(MONSRCS)
|
||||
sshpty.c strlcpy.c $(SYSSRCS) $(CPUSRCS) $(MONSRCS) $(SLIRP_SRCS)
|
||||
APP = SheepShaver
|
||||
APP_EXE = $(APP)$(EXEEXT)
|
||||
APP_APP = $(APP).app
|
||||
@ -130,6 +134,8 @@ distclean: clean
|
||||
depend dep:
|
||||
makedepend $(CPPFLAGS) -Y. $(SRCS) 2>/dev/null
|
||||
|
||||
$(OBJ_DIR)/%.o : ../slirp/%.c
|
||||
$(CC) $(CPPFLAGS) $(DEFS) $(CFLAGS) $(SLIRP_CFLAGS) -c $< -o $@
|
||||
$(OBJ_DIR)/%.o : %.c
|
||||
$(CC) $(CPPFLAGS) $(DEFS) $(CFLAGS) -c $< -o $@
|
||||
$(OBJ_DIR)/%.o : %.cpp
|
||||
|
@ -300,14 +300,19 @@ AC_HEADER_STDC
|
||||
AC_HEADER_SYS_WAIT
|
||||
AC_CHECK_HEADERS(malloc.h stdint.h)
|
||||
AC_CHECK_HEADERS(mach/vm_map.h mach/mach_init.h sys/mman.h)
|
||||
AC_CHECK_HEADERS(sys/time.h sys/times.h sys/socket.h)
|
||||
AC_CHECK_HEADERS(unistd.h fcntl.h byteswap.h dirent.h)
|
||||
AC_CHECK_HEADERS(linux/if.h, [], [], [
|
||||
#if HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
AC_CHECK_HEADERS(sys/socket.h sys/ioctl.h sys/filio.h sys/bitypes.h sys/wait.h)
|
||||
AC_CHECK_HEADERS(sys/time.h sys/poll.h sys/select.h arpa/inet.h)
|
||||
AC_CHECK_HEADERS(linux/if.h linux/if_tun.h net/if.h net/if_tun.h, [], [], [
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
])
|
||||
AC_CHECK_HEADERS(linux/if_tun.h net/if.h net/if_tun.h)
|
||||
AC_CHECK_HEADERS(AvailabilityMacros.h)
|
||||
AC_CHECK_HEADERS(IOKit/storage/IOBlockStorageDevice.h)
|
||||
AC_CHECK_HEADERS(fenv.h)
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
@ -344,13 +349,14 @@ if [[ "x$ac_cv_signal_sa_restorer" = "xyes" ]]; then
|
||||
fi
|
||||
|
||||
dnl Checks for library functions.
|
||||
AC_CHECK_FUNCS(strdup strlcpy cfmakeraw)
|
||||
AC_CHECK_FUNCS(strdup strerror strlcpy cfmakeraw)
|
||||
AC_CHECK_FUNCS(nanosleep)
|
||||
AC_CHECK_FUNCS(sigaction signal)
|
||||
AC_CHECK_FUNCS(mmap mprotect munmap)
|
||||
AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect)
|
||||
AC_CHECK_FUNCS(exp2f log2f exp2 log2)
|
||||
AC_CHECK_FUNCS(floorf roundf ceilf truncf floor round ceil trunc)
|
||||
AC_CHECK_FUNCS(poll inet_aton)
|
||||
|
||||
dnl Darwin seems to define mach_task_self() instead of task_self().
|
||||
AC_CHECK_FUNCS(mach_task_self task_self)
|
||||
@ -441,19 +447,24 @@ EXTFSSRC=extfs_unix.cpp
|
||||
EXTRASYSSRCS=
|
||||
case "$target_os" in
|
||||
linux*)
|
||||
ETHERSRC=Linux/ether_linux.cpp
|
||||
ETHERSRC=ether_unix.cpp
|
||||
AUDIOSRC=audio_oss_esd.cpp
|
||||
SCSISRC=Linux/scsi_linux.cpp
|
||||
if [[ "x$EMULATED_PPC" = "xno" ]]; then
|
||||
EXTRASYSSRCS="Linux/paranoia.cpp Linux/sheepthreads.c ppc_asm.S"
|
||||
fi
|
||||
;;
|
||||
freebsd*)
|
||||
ETHERSRC=ether_unix.cpp
|
||||
;;
|
||||
netbsd*)
|
||||
ETHERSRC=ether_unix.cpp
|
||||
if [[ "x$EMULATED_PPC" = "xno" ]]; then
|
||||
EXTRASYSSRCS="NetBSD/paranoia.cpp NetBSD/sheepthreads.c ppc_asm.S"
|
||||
fi
|
||||
;;
|
||||
darwin*)
|
||||
ETHERSRC=ether_unix.cpp
|
||||
if [[ "x$EMULATED_PPC" = "xno" ]]; then
|
||||
EXTRASYSSRCS="Darwin/paranoia.cpp ppc_asm.S"
|
||||
fi
|
||||
@ -469,6 +480,19 @@ cygwin*)
|
||||
;;
|
||||
esac
|
||||
|
||||
dnl Is the slirp library supported?
|
||||
if [[ "x$ETHERSRC" = "xether_unix.cpp" ]]; then
|
||||
AC_DEFINE(HAVE_SLIRP, 1, [Define if slirp library is supported])
|
||||
SLIRP_SRCS="\
|
||||
../slirp/bootp.c ../slirp/ip_output.c ../slirp/tcp_input.c \
|
||||
../slirp/cksum.c ../slirp/mbuf.c ../slirp/tcp_output.c \
|
||||
../slirp/debug.c ../slirp/misc.c ../slirp/tcp_subr.c \
|
||||
../slirp/if.c ../slirp/sbuf.c ../slirp/tcp_timer.c \
|
||||
../slirp/ip_icmp.c ../slirp/slirp.c ../slirp/tftp.c \
|
||||
../slirp/ip_input.c ../slirp/socket.c ../slirp/udp.c"
|
||||
fi
|
||||
AC_SUBST(SLIRP_SRCS)
|
||||
|
||||
dnl SDL overrides
|
||||
if [[ "x$WANT_SDL" = "xyes" ]]; then
|
||||
AC_DEFINE(USE_SDL, 1, [Define to enble SDL support.])
|
||||
@ -1196,6 +1220,19 @@ AC_CACHE_CHECK([the format of compiler generated objects],
|
||||
rm -rf conftest*
|
||||
])
|
||||
|
||||
dnl Add -fno-strict-aliasing for slirp sources
|
||||
if [[ "x$HAVE_GCC30" = "xyes" ]]; then
|
||||
SAVED_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -fno-strict-aliasing"
|
||||
AC_CACHE_CHECK([whether the compiler supports -fno-strict-aliasing],
|
||||
ac_cv_gcc_no_strict_aliasing, [
|
||||
AC_TRY_COMPILE([],[],
|
||||
[ac_cv_gcc_no_strict_aliasing=yes; AC_SUBST(SLIRP_CFLAGS, "-fno-strict-aliasing")],
|
||||
[ac_cv_gcc_no_strict_aliasing=no])
|
||||
])
|
||||
CFLAGS="$SAVED_CFLAGS"
|
||||
fi
|
||||
|
||||
dnl Add -mdynamic-no-pic for MacOS X
|
||||
if [[ "x$HAVE_GCC30" = "xyes" ]]; then
|
||||
SAVED_CFLAGS="$CFLAGS"
|
||||
|
@ -52,6 +52,7 @@ user_string_def platform_strings[] = {
|
||||
{STR_NO_SHEEP_NET_DRIVER_WARN, "Cannot open %s (%s). Ethernet will not be available."},
|
||||
{STR_SHEEP_NET_ATTACH_WARN, "Cannot attach to Ethernet card (%s). Ethernet will not be available."},
|
||||
{STR_TUN_TAP_CONFIG_WARN, "Cannot configure TUN/TAP device (%s). Ethernet will not be available."},
|
||||
{STR_SLIRP_NO_DNS_FOUND_WARN, "Cannot get DNS address. Ethernet will not be available."},
|
||||
{STR_NO_AUDIO_DEV_WARN, "Cannot open %s (%s). Audio output will be disabled."},
|
||||
{STR_NO_AUDIO_WARN, "No audio device found, audio output will be disabled."},
|
||||
{STR_NO_ESD_WARN, "Cannot open ESD connection. Audio output will be disabled."},
|
||||
|
@ -45,6 +45,7 @@ enum {
|
||||
STR_NO_SHEEP_NET_DRIVER_WARN,
|
||||
STR_SHEEP_NET_ATTACH_WARN,
|
||||
STR_TUN_TAP_CONFIG_WARN,
|
||||
STR_SLIRP_NO_DNS_FOUND_WARN,
|
||||
STR_NO_AUDIO_DEV_WARN,
|
||||
STR_NO_AUDIO_WARN,
|
||||
STR_NO_ESD_WARN,
|
||||
|
Loading…
Reference in New Issue
Block a user