Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:dgollub
synergy
synergy-zeroconf-poc_20080222.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File synergy-zeroconf-poc_20080222.diff of Package synergy
diff --git a/cmd/Makefile.am b/cmd/Makefile.am index 2472175..e63ca0b 100644 --- a/cmd/Makefile.am +++ b/cmd/Makefile.am @@ -17,6 +17,7 @@ SUBDIRS = \ launcher \ synergyc \ synergys \ + synergyd \ $(NULL) EXTRA_DIST = \ diff --git a/cmd/synergyc/Makefile.am b/cmd/synergyc/Makefile.am index 8994266..0034a94 100644 --- a/cmd/synergyc/Makefile.am +++ b/cmd/synergyc/Makefile.am @@ -84,6 +84,7 @@ synergyc_LDADD = \ $(top_builddir)/lib/base/libbase.a \ $(top_builddir)/lib/common/libcommon.a \ $(top_builddir)/lib/arch/libarch.a \ + $(top_builddir)/lib/zeroconf/libzeroconf.a \ $(NULL) INCLUDES = \ -I$(top_srcdir)/lib/common \ diff --git a/cmd/synergyd/Makefile.am b/cmd/synergyd/Makefile.am new file mode 100644 index 0000000..11b6703 --- /dev/null +++ b/cmd/synergyd/Makefile.am @@ -0,0 +1,89 @@ +# synergy -- mouse and keyboard sharing utility +# Copyright (C) 2002 Chris Schoeneman +# +# This package is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# found in the file COPYING that should have accompanied this file. +# +# This package 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. + +## Process this file with automake to produce Makefile.in +NULL = + +COMMON_SOURCE_FILES = \ + synergyd.cpp \ + $(NULL) + +EXTRA_DIST = \ + $(NULL) + +MAINTAINERCLEANFILES = \ + Makefile.in \ + $(NULL) + +bin_PROGRAMS = synergyd +if XWINDOWS +synergyd_SOURCES = \ + $(COMMON_SOURCE_FILES) \ + $(NULL) + +synergyd_LDFLAGS = \ + $(LIBXML2_LIBS) \ + $(AVAHI_LIBS) \ + $(NULL) +endif + +if MSWINDOWS +synergyd_SOURCES = \ + $(COMMON_SOURCE_FILES) \ + $(MSWINDOWS_SOURCE_FILES) \ + $(NULL) +endif +if CARBON +synergyd_SOURCES = \ + $(COMMON_SOURCE_FILES) \ + $(NULL) +synergyd_LDFLAGS = \ + -framework ScreenSaver \ + -framework IOKit \ + -framework ApplicationServices \ + -framework Foundation \ + $(LIBXML2_LIBS) \ + $(NULL) +endif + +synergyd_CXXFLAGS = \ + $(LIBXML2_CFLAGS) \ + $(AVAHI_CFLAGS) \ + $(NULL) + + +synergyd_LDADD = \ + $(top_builddir)/lib/client/libclient.a \ + $(top_builddir)/lib/server/libserver.a \ + $(top_builddir)/lib/platform/libplatform.a \ + $(top_builddir)/lib/synergy/libsynergy.a \ + $(top_builddir)/lib/net/libnet.a \ + $(top_builddir)/lib/io/libio.a \ + $(top_builddir)/lib/mt/libmt.a \ + $(top_builddir)/lib/base/libbase.a \ + $(top_builddir)/lib/common/libcommon.a \ + $(top_builddir)/lib/arch/libarch.a \ + $(top_builddir)/lib/zeroconf/libzeroconf.a \ + $(NULL) +INCLUDES = \ + -I$(top_srcdir)/lib/common \ + -I$(top_srcdir)/lib/arch \ + -I$(top_srcdir)/lib/base \ + -I$(top_srcdir)/lib/mt \ + -I$(top_srcdir)/lib/io \ + -I$(top_srcdir)/lib/net \ + -I$(top_srcdir)/lib/synergy \ + -I$(top_srcdir)/lib/platform \ + -I$(top_srcdir)/lib/client \ + -I$(top_srcdir)/lib/server \ + -I$(top_srcdir)/lib/zeroconf \ + $(NULL) diff --git a/cmd/synergyd/synergyd-autostart.desktop b/cmd/synergyd/synergyd-autostart.desktop new file mode 100644 index 0000000..09835a5 --- /dev/null +++ b/cmd/synergyd/synergyd-autostart.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Encoding=UTF-8 +Exec=synergyd +Name=Synergy Session Daemon +Terminal=false +X-KDE-autostart-phase=2 +X-KDE-autostart-after=panel +X-KDE-StartupNotify=false diff --git a/cmd/synergyd/synergyd.cpp b/cmd/synergyd/synergyd.cpp new file mode 100644 index 0000000..8407315 --- /dev/null +++ b/cmd/synergyd/synergyd.cpp @@ -0,0 +1,984 @@ +/* + * synergyd -- mouse and keyboard sharing utility + * Copyright (C) 2002 Chris Schoeneman + * Copyright (C) 2007 Daniel Gollub + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file COPYING that should have accompanied this file. + * + * This package 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. + */ + +#include <string.h> + +#include "CArch.h" +#include "CThread.h" +#include "XArch.h" +#include "XSocket.h" +#include "XScreen.h" + +#include "ProtocolTypes.h" +#include "Version.h" + + +#include "CClient.h" +#include "CServer.h" +#include "CClientListener.h" +#include "CClientProxy.h" + +#include "CPrimaryClient.h" + +#include "CConfigXml.h" +#include "CScreen.h" +#include "CSocketMultiplexer.h" +#include "CTCPSocketFactory.h" +#include "CEventQueue.h" +#include "CFunctionEventJob.h" +#if WINAPI_XWINDOWS +#include "CXWindowsScreen.h" +#elif WINAPI_CARBON +#include "COSXScreen.h" +#endif + + +#include "LogOutputters.h" + +#include "stdfstream.h" + +#include "CZeroConf.h" + +#define USR_CONFIG_NAME ".synergyd.conf" +#define SYS_CONFIG_NAME "synergyd.conf" + +enum EServerState { + kUninitialized, + kInitializing, + kInitializingToStart, + kInitialized, + kStarting, + kStarted +}; + +static CZeroConf *zc = NULL; +static CClient* s_client = NULL; +static CScreen* s_screen = NULL; +static bool isClient = false; +static bool connected = false; +static bool serviceRegistered = false; + + +static EServerState s_serverState = kUninitialized; +static CServer* s_server = NULL; +static CPrimaryClient* s_primaryClient = NULL; +static CClientListener* s_listener = NULL; +static CEvent::Type s_forceReconnectEvent = CEvent::kUnknown; +static CEvent::Type s_newClientEvent = CEvent::kUnknown; +static CEvent::Type s_startServerEvent = CEvent::kUnknown; +static CEvent::Type s_serverStartEvent = CEvent::kUnknown; +static CEvent::Type s_serverStoppedEvent = CEvent::kUnknown; +static bool s_suspended = false; +//static CEvent::Type s_reloadConfigEvent = CEvent::kUnknown; +//static CEventQueueTimer* s_timer = NULL; + +static void handleSuspend(const CEvent& event, void*); +static void handleResume(const CEvent& event, void*); + + + +class CArgs { +public: + CArgs() : + m_pname(NULL), + m_backend(false), + m_restartable(true), + m_daemon(true), + m_configFile(), + m_logFilter(NULL), + m_display(NULL), + m_serverAddress(NULL), + m_synergyAddress(NULL), + m_config(NULL) + { s_instance = this; } + ~CArgs() { s_instance = NULL; } + +public: + static CArgs* s_instance; + const char* m_pname; + bool m_backend; + bool m_restartable; + bool m_daemon; + CString m_configFile; + const char* m_logFilter; + const char* m_display; + CString m_name; + CNetworkAddress* m_serverAddress; + CNetworkAddress* m_synergyAddress; + CConfigXml* m_config; +}; + +#define ARG CArgs::s_instance +CArgs *CArgs::s_instance = NULL; + +static +CScreen* +createClientScreen() +{ +#if WINAPI_MSWINDOWS + return new CScreen(new CMSWindowsScreen(false)); +#elif WINAPI_XWINDOWS + return new CScreen(new CXWindowsScreen(ARG->m_display, false)); +#elif WINAPI_CARBON + return new CScreen(new COSXScreen(false)); +#endif +} + +static +CScreen* +createServerScreen() +{ +#if WINAPI_MSWINDOWS + return new CScreen(new CMSWindowsScreen(true)); +#elif WINAPI_XWINDOWS + return new CScreen(new CXWindowsScreen(ARG->m_display, true)); +#elif WINAPI_CARBON + return new CScreen(new COSXScreen(true)); +#endif +} + +/// Events +CEvent::Type getForceReconnectEvent() +{ + return CEvent::registerTypeOnce(s_forceReconnectEvent, "forceReconnect"); +} + +CEvent::Type getNewClientEvent() +{ + return CEvent::registerTypeOnce(s_newClientEvent, "newClientEvent"); +} + +CEvent::Type getStartServerEvent() +{ + return CEvent::registerTypeOnce(s_startServerEvent, "startServerEvent"); +} + +CEvent::Type getServerStartedEvent() +{ + return CEvent::registerTypeOnce(s_serverStartEvent, "serverStartedEvent"); +} + +CEvent::Type getServerStoppedEvent() +{ + return CEvent::registerTypeOnce(s_serverStoppedEvent, "serverStoppedEvent"); +} + +/// Client +static void handleClientConnected(const CEvent&, void*) +{ + LOG((CLOG_NOTE "connected to server")); +} + +static void handleClientFailed(const CEvent& e, void*) +{ + CClient::CFailInfo* info = + reinterpret_cast<CClient::CFailInfo*>(e.getData()); + + if (!ARG->m_restartable || !info->m_retry) { + LOG((CLOG_ERR "failed to connect to server: %s", info->m_what)); + EVENTQUEUE->addEvent(CEvent(CEvent::kQuit)); + } + else { + LOG((CLOG_WARN "failed to connect to server: %s", info->m_what)); + } + + connected = false; +} + +static void closeClient(CClient* client) +{ + if (client == NULL) { + return; + } + + EVENTQUEUE->removeHandler(CClient::getConnectedEvent(), client); + EVENTQUEUE->removeHandler(CClient::getConnectionFailedEvent(), client); + EVENTQUEUE->removeHandler(CClient::getDisconnectedEvent(), client); + delete client; +} + + +static void closeClientScreen(CScreen* screen) +{ + if (screen != NULL) { + EVENTQUEUE->removeHandler(IScreen::getErrorEvent(), + screen->getEventTarget()); + delete screen; + } +} + + + +static void stopClient() +{ + closeClient(s_client); + closeClientScreen(s_screen); + s_client = NULL; + s_screen = NULL; + connected = false; +} + +static void handleClientDisconnected(const CEvent&, void*) +{ + LOG((CLOG_NOTE "disconnected from server")); + if (!ARG->m_restartable) { + EVENTQUEUE->addEvent(CEvent(CEvent::kQuit)); + } + + stopClient(); + + // Trigger an event to start the server again ... + EVENTQUEUE->addEvent(CEvent(getStartServerEvent(), IEventQueue::getSystemTarget())); +} + +static CClient *openClient(const CString& name, const CNetworkAddress& address, CScreen* screen) +{ + CClient* client = new CClient(name, address, + new CTCPSocketFactory, NULL, screen); + + EVENTQUEUE->adoptHandler(CClient::getConnectedEvent(), + client->getEventTarget(), + new CFunctionEventJob(handleClientConnected)); + EVENTQUEUE->adoptHandler(CClient::getConnectionFailedEvent(), + client->getEventTarget(), + new CFunctionEventJob(handleClientFailed)); + EVENTQUEUE->adoptHandler(CClient::getDisconnectedEvent(), + client->getEventTarget(), + new CFunctionEventJob(handleClientDisconnected)); + + return client; +} + +static void version() +{ + LOG((CLOG_PRINT "%s %s, protocol version %d.%d\n%s", + ARG->m_pname, + kVersion, + kProtocolMajorVersion, + kProtocolMinorVersion, + kCopyright)); +} + +static void handleScreenError(const CEvent&, void*) +{ + LOG((CLOG_CRIT "error on screen")); + EVENTQUEUE->addEvent(CEvent(CEvent::kQuit)); +} + +static CScreen* openClientScreen() +{ + CScreen* screen = createClientScreen(); + + EVENTQUEUE->adoptHandler(IScreen::getErrorEvent(), + screen->getEventTarget(), + new CFunctionEventJob( + &handleScreenError)); + + return screen; +} + +static bool startClient() +{ + if (s_screen == NULL) + s_screen = openClientScreen(); + + if (s_client == NULL) + s_client = openClient(ARG->m_name, *ARG->m_serverAddress, s_screen); + + s_client->connect(); + + LOG((CLOG_DEBUG " [%u] Started Client", pthread_self() )); + + return true; +} + +static void help() +{ +#if WINAPI_XWINDOWS +# define USAGE_DISPLAY_ARG \ +" [--display <display>]" +# define USAGE_DISPLAY_INFO \ +" --display <display> connect to the X server at <display>\n" +#else +# define USAGE_DISPLAY_ARG +# define USAGE_DISPLAY_INFO +#endif + + LOG((CLOG_PRINT +"Usage: %s" +" [--daemon|--no-daemon]" +" [--debug <level>]" +USAGE_DISPLAY_ARG +" [--restart|--no-restart]" +"\n\n" +"Start the synergy mouse/keyboard sharing server.\n" +"\n" +" -d, --debug <level> filter out log messages with priorty below level.\n" +" level may be: FATAL, ERROR, WARNING, NOTE, INFO,\n" +" DEBUG, DEBUG1, DEBUG2.\n" +USAGE_DISPLAY_INFO +" -f, --no-daemon run the client in the foreground.\n" +"* --daemon run the client as a daemon.\n" +" -1, --no-restart do not try to restart the client if it fails for\n" +" some reason.\n" +"* --restart restart the client automatically if it fails.\n" +" -h, --help display this help and exit.\n" +" --version display version information and exit.\n" +"\n" +"* marks defaults.\n" +"\n" +"Where log messages go depends on the platform and whether or not the\n" +"client is running as a daemon.", + ARG->m_pname )); + +} + +#define BYE "\nTry `%s --help' for more information." + +static bool isArg(int argi, int argc, const char* const* argv, + const char* name1, const char* name2, + int minRequiredParameters = 0) +{ + if ((name1 != NULL && strcmp(argv[argi], name1) == 0) || + (name2 != NULL && strcmp(argv[argi], name2) == 0)) { + // match. check args left. + if (argi + minRequiredParameters >= argc) { + LOG((CLOG_PRINT "%s: missing arguments for `%s'" BYE, + ARG->m_pname, argv[argi], ARG->m_pname)); + exit(kExitArgs); + } + return true; + } + + // no match + return false; +} + +static void parse(int argc, const char* const* argv) +{ + assert(ARG->m_pname != NULL); + assert(argv != NULL); + assert(argc >= 1); + + // parse options + int i; + for (i = 1; i < argc; ++i) { + if (isArg(i, argc, argv, "-d", "--debug", 1)) { + // change logging level + ARG->m_logFilter = argv[++i]; + } + + else if (isArg(i, argc, argv, "-n", "--name", 1)) { + // save screen name + ARG->m_name = argv[++i]; + } + + /* + else if (isArg(i, argc, argv, "-a", "--address", 1)) { + // save listen address + try { + *ARG->m_synergyAddress = CNetworkAddress(argv[i + 1], + kDefaultPort); + ARG->m_synergyAddress->resolve(); + } + catch (XSocketAddress& e) { + LOG((CLOG_PRINT "%s: %s" BYE, + ARG->m_pname, e.what(), ARG->m_pname)); + exit(kExitArgs); + } + ++i; + } + */ + + else if (isArg(i, argc, argv, "-f", "--no-daemon")) { + // not a daemon + ARG->m_daemon = false; + } + + else if (isArg(i, argc, argv, NULL, "--daemon")) { + // daemonize + ARG->m_daemon = true; + } + +#if WINAPI_XWINDOWS + else if (isArg(i, argc, argv, "-display", "--display", 1)) { + // use alternative display + ARG->m_display = argv[++i]; + } +#endif + + else if (isArg(i, argc, argv, "-1", "--no-restart")) { + // don't try to restart + ARG->m_restartable = false; + } + + else if (isArg(i, argc, argv, NULL, "--restart")) { + // try to restart + ARG->m_restartable = true; + } + + else if (isArg(i, argc, argv, "-z", NULL)) { + ARG->m_backend = true; + } + + else if (isArg(i, argc, argv, "-h", "--help")) { + help(); + exit(kExitSuccess); + } + + else if (isArg(i, argc, argv, NULL, "--version")) { + version(); + exit(kExitSuccess); + } + + else if (isArg(i, argc, argv, "--", NULL)) { + // remaining arguments are not options + ++i; + break; + } + + else if (argv[i][0] == '-') { + LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, + ARG->m_pname, argv[i], ARG->m_pname)); + exit(kExitArgs); + } + + else { + // this and remaining arguments are not options + break; + } + } + + // increase default filter level for daemon. the user must + // explicitly request another level for a daemon. + if (ARG->m_daemon && ARG->m_logFilter == NULL) { + ARG->m_logFilter = "INFO"; + } + + // set log filter + if (!CLOG->setFilter(ARG->m_logFilter)) { + LOG((CLOG_PRINT "%s: unrecognized log level `%s'" BYE, + ARG->m_pname, ARG->m_logFilter, ARG->m_pname)); + exit(kExitArgs); + } + + // identify system + LOG((CLOG_INFO "Synergy client %s on %s", kVersion, ARCH->getOSName().c_str())); +} + +// Server +static CScreen* openServerScreen() +{ + CScreen* screen = createServerScreen(); + + EVENTQUEUE->adoptHandler(IScreen::getErrorEvent(), + screen->getEventTarget(), + new CFunctionEventJob( + &handleScreenError)); + EVENTQUEUE->adoptHandler(IScreen::getSuspendEvent(), + screen->getEventTarget(), + new CFunctionEventJob( + &handleSuspend)); + EVENTQUEUE->adoptHandler(IScreen::getResumeEvent(), + screen->getEventTarget(), + new CFunctionEventJob( + &handleResume)); + + return screen; +} + +static void closeServerScreen(CScreen* screen) +{ + if (screen != NULL) { + EVENTQUEUE->removeHandler(IScreen::getErrorEvent(), + screen->getEventTarget()); + EVENTQUEUE->removeHandler(IScreen::getSuspendEvent(), + screen->getEventTarget()); + EVENTQUEUE->removeHandler(IScreen::getResumeEvent(), + screen->getEventTarget()); + delete screen; + } +} + +static CPrimaryClient *openPrimaryClient(const CString& name, CScreen* screen) +{ + LOG((CLOG_DEBUG1 "creating primary screen")); + return new CPrimaryClient(name, screen); +} + +static void closePrimaryClient(CPrimaryClient* primaryClient) +{ + delete primaryClient; +} + +static void handleNoClients(const CEvent&, void*) +{ + // NOOP +} + +static void handleClientsDisconnected(const CEvent&, void*) +{ + EVENTQUEUE->addEvent(CEvent(CEvent::kQuit)); +} + +static bool initServer() +{ + // skip if already initialized or initializing + if (s_serverState != kUninitialized) { + return true; + } + + CScreen* serverScreen = NULL; + CPrimaryClient* primaryClient = NULL; + try { + CString name = ARG->m_config->getCanonicalName(ARG->m_name); + serverScreen = openServerScreen(); + primaryClient = openPrimaryClient(name, serverScreen); + s_screen = serverScreen; + s_primaryClient = primaryClient; + s_serverState = kInitialized; + return true; + } + catch (XScreenUnavailable& e) { + LOG((CLOG_WARN "cannot open primary screen: %s", e.what())); + closePrimaryClient(primaryClient); + closeServerScreen(serverScreen); + } + catch (XScreenOpenFailure& e) { + LOG((CLOG_CRIT "cannot open primary screen: %s", e.what())); + closePrimaryClient(primaryClient); + closeServerScreen(serverScreen); + return false; + } + catch (XBase& e) { + LOG((CLOG_CRIT "failed to start server: %s", e.what())); + closePrimaryClient(primaryClient); + closeServerScreen(serverScreen); + return false; + } + + return false; +} + +static void serverHandleClientConnected(const CEvent&, void* vlistener) +{ + LOG((CLOG_DEBUG "[%u] %s(%p)", pthread_self(), __func__, vlistener)); + + CClientListener* listener = reinterpret_cast<CClientListener*>(vlistener); + CClientProxy* client = listener->getNextClient(); + + if (client != NULL) + s_server->adoptClient(client); +} + + + +static CClientListener *openClientListener(const CNetworkAddress& address) +{ + assert(address.isValid()); + + CClientListener* listen = + new CClientListener(address, new CTCPSocketFactory, NULL); + EVENTQUEUE->adoptHandler(CClientListener::getConnectedEvent(), listen, + new CFunctionEventJob( + &serverHandleClientConnected, listen)); + return listen; +} + +static void closeClientListener(CClientListener* listen) +{ + LOG((CLOG_DEBUG "[%u] %s(%p)", pthread_self(), __func__, listen)); + + if (listen != NULL) { + EVENTQUEUE->removeHandler(CClientListener::getConnectedEvent(), listen); + delete listen; + } +} + +static CServer *openServer(const CConfigXml& config, CPrimaryClient* primaryClient) +{ + LOG((CLOG_DEBUG "[%u] %s(%p)", pthread_self(), __func__, primaryClient)); + + CServer* server = new CServer(config, primaryClient); + EVENTQUEUE->adoptHandler(CServer::getDisconnectedEvent(), server, + new CFunctionEventJob(handleNoClients)); + return server; +} + +static void closeServer(CServer* server) +{ + LOG((CLOG_DEBUG "[%u] %s(%p)", pthread_self(), __func__, server)); + + if (server == NULL) { + return; + } + + // tell all clients to disconnect + server->disconnect(); + + // wait for clients to disconnect for up to timeout seconds + double timeout = 3.0; + CEventQueueTimer* timer = EVENTQUEUE->newOneShotTimer(timeout, NULL); + EVENTQUEUE->adoptHandler(CEvent::kTimer, timer, + new CFunctionEventJob(handleClientsDisconnected)); + EVENTQUEUE->adoptHandler(CServer::getDisconnectedEvent(), server, + new CFunctionEventJob(handleClientsDisconnected)); + CEvent event; + EVENTQUEUE->getEvent(event); + while (event.getType() != CEvent::kQuit) { + EVENTQUEUE->dispatchEvent(event); + CEvent::deleteData(event); + EVENTQUEUE->getEvent(event); + } + EVENTQUEUE->removeHandler(CEvent::kTimer, timer); + EVENTQUEUE->deleteTimer(timer); + EVENTQUEUE->removeHandler(CServer::getDisconnectedEvent(), server); + + // done with server + delete server; +} + +static bool startServer() +{ + LOG((CLOG_DEBUG "[%u] %s", pthread_self(), __func__)); + + // create the event queue + + // if configuration has no screens then add this system + // as the default +// if (ARG->m_config->begin() == ARG->m_config->end()) { + ARG->m_config->addScreen(ARG->m_name); +// } + + // set the contact address, if provided, in the config. + // otherwise, if the config doesn't have an address, use + // the default. + if (ARG->m_synergyAddress->isValid()) { + ARG->m_config->setSynergyAddress(*ARG->m_synergyAddress); + } else if (!ARG->m_config->getSynergyAddress().isValid()) { + ARG->m_config->setSynergyAddress( CNetworkAddress(kDefaultPort)); + } + + // canonicalize the primary screen name + CString primaryName = ARG->m_config->getCanonicalName(ARG->m_name); + if (primaryName.empty()) { + LOG((CLOG_CRIT "unknown screen name `%s'", ARG->m_name.c_str())); + return kExitFailed; + } + + // skip if already started or starting + if (s_serverState == kStarting || s_serverState == kStarted) { + return true; + } + + // initialize if necessary + if (s_serverState != kInitialized) { + if (!initServer()) { + // hard initialization failure + return false; + } + if (s_serverState == kInitializing) { + // not ready to start + s_serverState = kInitializingToStart; + return true; + } + assert(s_serverState == kInitialized); + } + + double retryTime; + CClientListener* listener = NULL; + try { + listener = openClientListener(ARG->m_config->getSynergyAddress()); + s_server = openServer(*ARG->m_config, s_primaryClient); + s_listener = listener; + LOG(( CLOG_DEBUG "started server: %u", pthread_self() )); + s_serverState = kStarted; + EVENTQUEUE->addEvent(CEvent(getServerStartedEvent(), IEventQueue::getSystemTarget())); + return true; + } + catch (XSocketAddressInUse& e) { + LOG((CLOG_WARN "cannot listen for clients: %s", e.what())); + closeClientListener(listener); + retryTime = 10.0; + } + catch (XBase& e) { + LOG((CLOG_CRIT "failed to start server: %s", e.what())); + closeClientListener(listener); + return false; + } + + return false; +} + +static void stopServer() +{ + LOG((CLOG_DEBUG "[%u] %s", pthread_self(), __func__)); + + if (s_serverState == kStarted) { + closeClientListener(s_listener); + closeServer(s_server); + s_server = NULL; + s_listener = NULL; + s_serverState = kInitialized; + } + else if (s_serverState == kStarting) { + s_serverState = kInitialized; + } + assert(s_server == NULL); + assert(s_listener == NULL); + EVENTQUEUE->addEvent(CEvent(getServerStoppedEvent(), IEventQueue::getSystemTarget())); +} + +static void cleanupServer() +{ + LOG((CLOG_DEBUG "[%u] %s", pthread_self(), __func__)); + stopServer(); + if (s_serverState == kInitialized) { + closePrimaryClient(s_primaryClient); + closeServerScreen(s_screen); + s_primaryClient = NULL; + s_screen = NULL; + s_serverState = kUninitialized; + } + else if (s_serverState == kInitializing || + s_serverState == kInitializingToStart) { + s_serverState = kUninitialized; + } + assert(s_primaryClient == NULL); + assert(s_screen == NULL); + assert(s_serverState == kUninitialized); +} + +static void handleSuspend(const CEvent&, void*) +{ + if (!s_suspended) { + LOG((CLOG_INFO "suspend")); + stopServer(); + s_suspended = true; + } +} + +static void handleResume(const CEvent&, void*) +{ + if (s_suspended) { + LOG((CLOG_INFO "resume")); + startServer(); + s_suspended = false; + } +} + + + +/* +static void forceReconnect(const CEvent&, void*) +{ + if (s_server != NULL) { + s_server->disconnect(); + } +} +*/ + +static void handleNewClient(const CEvent &event, void *data) +{ + + LOG((CLOG_DEBUG "[%u] %s(%i, %p)", pthread_self(), __func__, event.getType(), data)); + + if (s_serverState == kStarting || s_serverState == kStarted) + cleanupServer(); + + startClient(); +} + +static bool loadConfig(const CString& pathname) +{ + // load configuration + LOG((CLOG_DEBUG "opening configuration \"%s\"", pathname.c_str())); + + if (!ARG->m_config->load( pathname )) + return false; + + LOG((CLOG_DEBUG "configuration read successfully")); + return true; +} + +static void loadConfig() +{ + bool loaded = false; + + // load the config file, if specified + if (!ARG->m_configFile.empty()) { + loaded = loadConfig(ARG->m_configFile); + } + + // load the default configuration if no explicit file given + else { + // get the user's home directory + CString path = ARCH->getUserDirectory(); + if (!path.empty()) { + // complete path + path = ARCH->concatPath(path, USR_CONFIG_NAME); + + // now try loading the user's configuration + if (loadConfig(path)) { + loaded = true; + ARG->m_configFile = path; + } + } + if (!loaded) { + // try the system-wide config file + path = ARCH->getSystemDirectory(); + if (!path.empty()) { + path = ARCH->concatPath(path, SYS_CONFIG_NAME); + if (loadConfig(path)) { + loaded = true; + ARG->m_configFile = path; + } + } + } + } + + if (!loaded) { + LOG((CLOG_PRINT "%s: no configuration available", ARG->m_pname)); + exit(kExitConfig); + } +} + +static void handleStartServer(const CEvent&, void*) +{ + startServer(); +} + +static void handleServerStarted(const CEvent &event, void *data) +{ + // If the server got already registered once, we reannounce + // the service again, to trigger the clients. + if (serviceRegistered) + zc->unregisterService(); + + zc->registerService(); + serviceRegistered = true; +} + +static void handleServerStopped(const CEvent &event, void *data) +{ + zc->unregisterService(); + serviceRegistered = false; +} + +//// Zeroconf +void probeClient(const CNetworkAddress &address, const CString &servicename) +{ + LOG(( CLOG_DEBUG "[%u]", pthread_self())); + + if (connected) + return; + + // Check config for valid/trusted Synergy Host. + if (!ARG->m_config->isHost(servicename)) { + LOG(( CLOG_DEBUG "%s - \'%s\' is not in the list - Sorry.", __func__, servicename.c_str())); + + return; + } + + connected = true; + + LOG(( CLOG_DEBUG "%s - \'%s\' in the map. Intersting!", __func__, address.getHostname().c_str())); + + *ARG->m_serverAddress = address; + ARG->m_serverAddress->resolve(); + + isClient = true; + + EVENTQUEUE->addEvent(CEvent(getNewClientEvent(), IEventQueue::getSystemTarget())); +} + +void initialBrowseFinished() +{ + LOG(( CLOG_DEBUG "[%u]", pthread_self())); + + if (connected) + return; + + EVENTQUEUE->addEvent(CEvent(getStartServerEvent(), IEventQueue::getSystemTarget())); +} + +int main(int argc, char **argv) +{ + CArgs args; + CArch arch; + + ARG->m_serverAddress = new CNetworkAddress; + ARG->m_synergyAddress = new CNetworkAddress; + ARG->m_config = new CConfigXml; + ARG->m_pname = ARCH->getBasename(argv[0]); + + parse(argc, argv); + + loadConfig(); + + CSocketMultiplexer multiplexer; + + // create the event queue + CEventQueue eventQueue; + + zc = new CZeroConf(); + if (!zc) { + LOG(( CLOG_ERR "Can't initiailze Zerconf component." )); + return -1; + } + + // register Zeroconf Callbacks + zc->setNewServiceCb(probeClient); + zc->setBrowseAllForNowCb(initialBrowseFinished); + + // start Zeroconf Service Discovery for Synergy instances. + zc->startDiscover(); + + if (ARG->m_name.empty()) + ARG->m_name = zc->getHostname(); + + LOG(( CLOG_NOTE "Multicast DNS Hostname: %s", zc->getHostname().c_str())); + LOG(( CLOG_NOTE "Zeroconf Service: %s", zc->getServicename().c_str())); + + // FIXME: This event loop isn't likely the smartest choice for starting/stopping/connecting/... + // client/server processes. + EVENTQUEUE->adoptHandler(getServerStartedEvent(), IEventQueue::getSystemTarget(), new CFunctionEventJob(&handleServerStarted)); + EVENTQUEUE->adoptHandler(getServerStoppedEvent(), IEventQueue::getSystemTarget(), new CFunctionEventJob(&handleServerStopped)); + EVENTQUEUE->adoptHandler(getStartServerEvent(), IEventQueue::getSystemTarget(), new CFunctionEventJob(&handleStartServer)); + EVENTQUEUE->adoptHandler(getNewClientEvent(), IEventQueue::getSystemTarget(), new CFunctionEventJob(&handleNewClient)); + + CEvent event; + EVENTQUEUE->getEvent(event); + + while (event.getType() != CEvent::kQuit) { + EVENTQUEUE->dispatchEvent(event); + CEvent::deleteData(event); + EVENTQUEUE->getEvent(event); + } + + EVENTQUEUE->removeHandler(getNewClientEvent(), IEventQueue::getSystemTarget()); + EVENTQUEUE->removeHandler(getStartServerEvent(), IEventQueue::getSystemTarget()); + EVENTQUEUE->removeHandler(getServerStoppedEvent(), IEventQueue::getSystemTarget()); + EVENTQUEUE->removeHandler(getServerStartedEvent(), IEventQueue::getSystemTarget()); + + zc->stopDiscover(); + + delete zc; + delete ARG->m_config; + delete ARG->m_synergyAddress; + + return 0; +} + diff --git a/config.h.in b/config.h.in index 79c9102..0dec85b 100644 --- a/config.h.in +++ b/config.h.in @@ -1,5 +1,8 @@ /* config.h.in. Generated from configure.in by autoheader. */ +/* Avahi Zeroconf support */ +#undef HAVE_AVAHI + /* Define if your compiler has bool support. */ #undef HAVE_CXX_BOOL @@ -34,6 +37,9 @@ /* Define to 1 if you have the <istream> header file. */ #undef HAVE_ISTREAM +/* libxml2 support */ +#undef HAVE_LIBXML2 + /* Define to 1 if you have the <locale.h> header file. */ #undef HAVE_LOCALE_H @@ -155,16 +161,16 @@ /* Define to the type of arg 5 for `select'. */ #undef SELECT_TYPE_ARG5 -/* The size of a `char', as computed by sizeof. */ +/* The size of `char', as computed by sizeof. */ #undef SIZEOF_CHAR -/* The size of a `int', as computed by sizeof. */ +/* The size of `int', as computed by sizeof. */ #undef SIZEOF_INT -/* The size of a `long', as computed by sizeof. */ +/* The size of `long', as computed by sizeof. */ #undef SIZEOF_LONG -/* The size of a `short', as computed by sizeof. */ +/* The size of `short', as computed by sizeof. */ #undef SIZEOF_SHORT /* Define to 1 if you have the ANSI C header files. */ @@ -182,5 +188,5 @@ /* Define to 1 if the X Window System is missing or not being used. */ #undef X_DISPLAY_MISSING -/* Define to `unsigned' if <sys/types.h> does not define. */ +/* Define to `unsigned int' if <sys/types.h> does not define. */ #undef size_t diff --git a/config/config.guess b/config/config.guess deleted file mode 100755 index 6ead80a..0000000 --- a/config/config.guess +++ /dev/null @@ -1,1327 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -# Free Software Foundation, Inc. - -timestamp='2001-08-21' - -# This file 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. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Written by Per Bothner <bothner@cygnus.com>. -# Please send patches to <config-patches@gnu.org>. -# -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. -# -# The plan is that this can be called by configure scripts if you -# don't specify an explicit build system type. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] - -Output the configuration name of the system \`$me' is run on. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to <config-patches@gnu.org>." - -version="\ -GNU config.guess ($timestamp) - -Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; - --version | -v ) - echo "$version" ; exit 0 ;; - --help | --h* | -h ) - echo "$usage"; exit 0 ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" >&2 - exit 1 ;; - * ) - break ;; - esac -done - -if test $# != 0; then - echo "$me: too many arguments$help" >&2 - exit 1 -fi - - -dummy=dummy-$$ -trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 - -# CC_FOR_BUILD -- compiler used by this script. -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. - -set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int dummy(){}" > $dummy.c ; - for c in cc gcc c89 ; do - ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ; - if test $? = 0 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - rm -f $dummy.c $dummy.o $dummy.rel ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac' - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -case "${UNAME_MACHINE}" in - i?86) - test -z "$VENDOR" && VENDOR=pc - ;; - *) - test -z "$VENDOR" && VENDOR=unknown - ;; -esac -test -f /etc/SuSE-release && VENDOR=suse - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:NetBSD:*:*) - # Netbsd (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. - # Determine the machine/vendor (is the vendor relevant). - case "${UNAME_MACHINE}" in - amiga) machine=m68k-unknown ;; - arm32) machine=arm-unknown ;; - atari*) machine=m68k-atari ;; - sun3*) machine=m68k-sun ;; - mac68k) machine=m68k-apple ;; - macppc) machine=powerpc-apple ;; - hp3[0-9][05]) machine=m68k-hp ;; - ibmrt|romp-ibm) machine=romp-ibm ;; - *) machine=${UNAME_MACHINE}-unknown ;; - esac - # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE}" in - i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep __ELF__ >/dev/null - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? - os=netbsd - else - os=netbsdelf - fi - ;; - *) - os=netbsd - ;; - esac - # The OS release - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" - exit 0 ;; - alpha:OSF1:*:*) - if test $UNAME_RELEASE = "V4.0"; then - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - fi - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - cat <<EOF >$dummy.s - .data -\$Lformat: - .byte 37,100,45,37,120,10,0 # "%d-%x\n" - - .text - .globl main - .align 4 - .ent main -main: - .frame \$30,16,\$26,0 - ldgp \$29,0(\$27) - .prologue 1 - .long 0x47e03d80 # implver \$0 - lda \$2,-1 - .long 0x47e20c21 # amask \$2,\$1 - lda \$16,\$Lformat - mov \$0,\$17 - not \$1,\$18 - jsr \$26,printf - ldgp \$29,0(\$26) - mov 0,\$16 - jsr \$26,exit - .end main -EOF - eval $set_cc_for_build - $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null - if test "$?" = 0 ; then - case `./$dummy` in - 0-0) - UNAME_MACHINE="alpha" - ;; - 1-0) - UNAME_MACHINE="alphaev5" - ;; - 1-1) - UNAME_MACHINE="alphaev56" - ;; - 1-101) - UNAME_MACHINE="alphapca56" - ;; - 2-303) - UNAME_MACHINE="alphaev6" - ;; - 2-307) - UNAME_MACHINE="alphaev67" - ;; - 2-1307) - UNAME_MACHINE="alphaev68" - ;; - esac - fi - rm -f $dummy.s $dummy - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit 0 ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit 0 ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit 0 ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit 0;; - amiga:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit 0 ;; - arc64:OpenBSD:*:*) - echo mips64el-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - arc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - hkmips:OpenBSD:*:*) - echo mips-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - pmax:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sgi:OpenBSD:*:*) - echo mips-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - wgrisc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit 0 ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit 0;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit 0;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit 0 ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit 0 ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - i86pc:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit 0 ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit 0 ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit 0 ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit 0 ;; - sparc*:NetBSD:*) - echo `uname -p`-unknown-netbsd${UNAME_RELEASE} - exit 0 ;; - atari*:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit 0 ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit 0 ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit 0 ;; - sun3*:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mac68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit 0 ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit 0 ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit 0 ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit 0 ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit 0 ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus -#include <stdio.h> /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - eval $set_cc_for_build - $CC_FOR_BUILD $dummy.c -o $dummy \ - && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ - && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - echo mips-mips-riscos${UNAME_RELEASE} - exit 0 ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit 0 ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit 0 ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit 0 ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit 0 ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit 0 ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] - then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit 0 ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit 0 ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit 0 ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit 0 ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit 0 ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit 0 ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix - exit 0 ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit 0 ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - sed 's/^ //' << EOF >$dummy.c - #include <sys/systemcfg.h> - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - eval $set_cc_for_build - $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - echo rs6000-ibm-aix3.2.5 - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit 0 ;; - *:AIX:*:[45]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit 0 ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit 0 ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit 0 ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit 0 ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit 0 ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit 0 ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit 0 ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit 0 ;; - 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - case "${HPUX_REV}" in - 11.[0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - esac ;; - esac - fi ;; - esac - if [ "${HP_ARCH}" = "" ]; then - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include <stdlib.h> - #include <unistd.h> - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } -EOF - eval $set_cc_for_build - (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy` - if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi - rm -f $dummy.c $dummy - fi ;; - esac - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit 0 ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit 0 ;; - 3050*:HI-UX:*:*) - sed 's/^ //' << EOF >$dummy.c - #include <unistd.h> - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - eval $set_cc_for_build - $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - echo unknown-hitachi-hiuxwe2 - exit 0 ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit 0 ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit 0 ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit 0 ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit 0 ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit 0 ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit 0 ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit 0 ;; - hppa*:OpenBSD:*:*) - echo hppa-unknown-openbsd - exit 0 ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit 0 ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit 0 ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit 0 ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit 0 ;; - CRAY*X-MP:*:*:*) - echo xmp-cray-unicos - exit 0 ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*T3D:*:*:*) - echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY-2:*:*:*) - echo cray2-cray-unicos - exit 0 ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit 0 ;; - hp300:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit 0 ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; - *:FreeBSD:*:*) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit 0 ;; - *:OpenBSD:*:*) - echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - exit 0 ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit 0 ;; - i*:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit 0 ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit 0 ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i386-pc-interix - exit 0 ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit 0 ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit 0 ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - *:GNU:*:*) - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit 0 ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit 0 ;; - arm*:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux - exit 0 ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux - exit 0 ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux - exit 0 ;; - mips:Linux:*:*) - case `sed -n '/^byte/s/^.*: \(.*\) endian/\1/p' < /proc/cpuinfo` in - big) echo mips-${VENDOR}-linux && exit 0 ;; - little) echo mipsel-${VENDOR}-linux && exit 0 ;; - esac - case `sed -n '/^system type/s/^.*: \([^ ]*\).*/\1/p' < /proc/cpuinfo` in - SGI|sgi) echo mips-${VENDOR}-linux-gnu && exit 0 ;; - esac - ;; - ppc:Linux:*:*|ppc64:Linux:*:*) - echo powerpc-${VENDOR}-linux - exit 0 ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu - exit 0 ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-${VENDOR}-linux${LIBC} - exit 0 ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-${VENDOR}-linux ;; - PA8*) echo hppa2.0-${VENDOR}-linux ;; - *) echo hppa-${VENDOR}-linux ;; - esac - exit 0 ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-${VENDOR}-linux - exit 0 ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux - exit 0 ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux - exit 0 ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux - exit 0 ;; - x86_64:Linux:*:*) - echo x86_64-${VENDOR}-linux - exit 0 ;; - i*86:Linux:*:*) - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. cd to the root directory to prevent - # problems with other programs or directories called `ld' in the path. - ld_supported_targets=`cd /; ld --help 2>&1 \ - | sed -ne '/supported targets:/!d - s/[ ][ ]*/ /g - s/.*supported targets: *// - s/ .*// - p'` - case "$ld_supported_targets" in - elf32-i386) - TENTATIVE="${UNAME_MACHINE}-${VENDOR}-linux" - ;; - a.out-i386-linux) - echo "${UNAME_MACHINE}-${VENDOR}-linuxaout" - exit 0 ;; - coff-i386) - echo "${UNAME_MACHINE}-${VENDOR}-linuxcoff" - exit 0 ;; - "") - # Either a pre-BFD a.out linker (linuxoldld) or - # one that does not give us useful --help. - echo "${UNAME_MACHINE}-${VENDOR}-linuxoldld" - exit 0 ;; - esac - # Determine whether the default compiler is a.out or elf - cat >$dummy.c <<EOF -#include <features.h> -#ifdef __cplusplus -#include <stdio.h> /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif -#ifdef __ELF__ -# ifdef __GLIBC__ -# if __GLIBC__ >= 2 - printf ("%s-${VENDOR}-linux\n", argv[1]); -# else - printf ("%s-${VENDOR}-linuxlibc1\n", argv[1]); -# endif -# else - printf ("%s-${VENDOR}-linuxlibc1\n", argv[1]); -# endif -#else - printf ("%s-${VENDOR}-linuxaout\n", argv[1]); -#endif - return 0; -} -EOF - eval $set_cc_for_build - $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 - ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 - exit 0 ;; - i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit 0 ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit 0 ;; - i*86:*:5:[78]*) - case `/bin/uname -X | grep "^Machine"` in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit 0 ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` - echo ${UNAME_MACHINE}-pc-isc$UNAME_REL - elif /bin/uname -X 2>/dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` - (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit 0 ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit 0 ;; - pc:*:*:*) - # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. - echo i386-pc-msdosdjgpp - exit 0 ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit 0 ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit 0 ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit 0 ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit 0 ;; - M68*:*:R3V[567]*:*) - test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; - 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4.3${OS_REL} && exit 0 - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4 && exit 0 ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit 0 ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit 0 ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit 0 ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit 0 ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit 0 ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says <Richard.M.Bartel@ccMail.Census.GOV> - echo i586-unisys-sysv4 - exit 0 ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes <hewes@openmarket.com>. - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit 0 ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit 0 ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit 0 ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit 0 ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit 0 ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit 0 ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit 0 ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit 0 ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit 0 ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit 0 ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit 0 ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; - *:Darwin:*:*) - echo `uname -p`-apple-darwin${UNAME_RELEASE} - exit 0 ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - if test "${UNAME_MACHINE}" = "x86pc"; then - UNAME_MACHINE=pc - fi - echo `uname -p`-${UNAME_MACHINE}-nto-qnx - exit 0 ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit 0 ;; - NSR-[KW]:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit 0 ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit 0 ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit 0 ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit 0 ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. - if test "$cputype" = "386"; then - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit 0 ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit 0 ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit 0 ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex - exit 0 ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit 0 ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit 0 ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit 0 ;; - *:ITS:*:*) - echo pdp10-unknown-its - exit 0 ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit 0 ;; -esac - -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - -cat >$dummy.c <<EOF -#ifdef _SEQUENT_ -# include <sys/types.h> -# include <sys/utsname.h> -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include <sys/param.h> - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include <sys/param.h> -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -eval $set_cc_for_build -$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0 -rm -f $dummy.c $dummy - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit 0 ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - c34*) - echo c34-convex-bsd - exit 0 ;; - c38*) - echo c38-convex-bsd - exit 0 ;; - c4*) - echo c4-convex-bsd - exit 0 ;; - esac -fi - -cat >&2 <<EOF -$0: unable to guess system type - -This script, last modified $timestamp, has failed to recognize -the operating system you are using. It is advised that you -download the most up to date version of the config scripts from - - ftp://ftp.gnu.org/pub/gnu/config/ - -If the version you run ($0) is already up to date, please -send the following data and any information you think might be -pertinent to <config-patches@gnu.org> in order to provide the needed -information to handle your system. - -config.guess timestamp = $timestamp - -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` - -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} -EOF - -exit 1 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/config/config.sub b/config/config.sub deleted file mode 100755 index 83f4b01..0000000 --- a/config/config.sub +++ /dev/null @@ -1,1410 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -# Free Software Foundation, Inc. - -timestamp='2001-08-13' - -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# This file 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. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Please send patches to <config-patches@gnu.org>. -# -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS - -Canonicalize a configuration name. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to <config-patches@gnu.org>." - -version="\ -GNU config.sub ($timestamp) - -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; - --version | -v ) - echo "$version" ; exit 0 ;; - --help | --h* | -h ) - echo "$usage"; exit 0 ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo $1 - exit 0;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis) - os= - basic_machine=$1 - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ - | c4x | clipper \ - | d10v | d30v | dsp16xx \ - | fr30 \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | i370 | i860 | i960 | ia64 \ - | m32r | m68000 | m68k | m88k | mcore \ - | mips16 | mips64 | mips64el | mips64orion | mips64orionel \ - | mips64vr4100 | mips64vr4100el | mips64vr4300 \ - | mips64vr4300el | mips64vr5000 | mips64vr5000el \ - | mipsbe | mipsel | mipsle | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | ns16k | ns32k \ - | openrisc \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ - | pyramid \ - | s390 | s390x \ - | sh | sh[34] | sh[34]eb | shbe | shle \ - | sparc | sparc64 | sparclet | sparclite | sparcv9 | sparcv9b \ - | strongarm \ - | tahoe | thumb | tic80 | tron \ - | v850 \ - | we32k \ - | x86 | xscale \ - | z8k) - basic_machine=$basic_machine-unknown - ;; - m6811 | m68hc11 | m6812 | m68hc12) - # Motorola 68HC11/12. - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alphapca5[67]-* | arc-* \ - | arm-* | armbe-* | armle-* | armv*-* \ - | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c54x-* \ - | clipper-* | cray2-* | cydra-* \ - | d10v-* | d30v-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fr30-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | m32r-* \ - | m68000-* | m680[01234]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | mcore-* \ - | mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \ - | mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipsel-* \ - | mipsle-* | mipstx39-* | mipstx39el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ - | pyramid-* \ - | romp-* | rs6000-* \ - | s390-* | s390x-* \ - | sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* \ - | sparc-* | sparc64-* | sparc86x-* | sparclite-* \ - | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* \ - | t3e-* | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \ - | v850-* | vax-* \ - | we32k-* \ - | x86-* | x86_64-* | xmp-* | xps100-* | xscale-* \ - | ymp-* \ - | z8k-*) - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | ymp) - basic_machine=ymp-cray - os=-unicos - ;; - cray2) - basic_machine=cray2-cray - os=-unicos - ;; - [cjt]90) - basic_machine=${basic_machine}-cray - os=-unicos - ;; - crds | unos) - basic_machine=m68k-crds - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - mingw32) - basic_machine=i386-pc - os=-mingw32 - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mipsel*-linux*) - basic_machine=mipsel-unknown - ;; - mips*-linux*) - basic_machine=mips-unknown - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - mmix*) - basic_machine=mmix-knuth - os=-mmixware - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pentium | p5 | k5 | k6 | nexgen) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon) - basic_machine=i686-pc - ;; - pentiumii | pentium2) - basic_machine=i686-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc) basic_machine=powerpc-unknown - ;; - ppc64) basic_machine=powerpc-unknown - ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sparclite-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=t3e-cray - os=-unicos - ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - windows32) - basic_machine=i386-pc - os=-windows32-msvcrt - ;; - xmp) - basic_machine=xmp-cray - os=-unicos - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - mips) - case $os in - linux*) - basic_machine=mips-unknown - ;; - *) - basic_machine=mips-mips - ;; - esac - ;; - romp) - basic_machine=romp-ibm - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sh3 | sh4 | sh3eb | sh4eb) - basic_machine=sh-unknown - ;; - sparc | sparcv9 | sparcv9b) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - c4x*) - basic_machine=c4x-none - os=-coff - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ - | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux* | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nto*) - os=-nto-qnx - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -wince*) - os=-wince - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -ns2 ) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -ose*) - os=-ose - ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 - ;; - m68*-cisco) - os=-aout - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-be) - os=-beos - ;; - *-ibm) - os=-aix - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -vxsim* | -vxworks*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os -exit 0 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/config/depcomp b/config/depcomp deleted file mode 100755 index 6589965..0000000 --- a/config/depcomp +++ /dev/null @@ -1,411 +0,0 @@ -#! /bin/sh - -# depcomp - compile a program generating dependencies as side-effects -# Copyright 1999, 2000 Free Software Foundation, Inc. - -# 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, 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. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. - -if test -z "$depmode" || test -z "$source" || test -z "$object"; then - echo "depcomp: Variables source, object and depmode must be set" 1>&2 - exit 1 -fi -# `libtool' can also be set to `yes' or `no'. - -depfile=${depfile-`echo "$object" | sed 's,\([^/]*\)$,.deps/\1,;s/\.\([^.]*\)$/.P\1/'`} -tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} - -rm -f "$tmpdepfile" - -# Some modes work just like other modes, but use different flags. We -# parameterize here, but still list the modes in the big case below, -# to make depend.m4 easier to write. Note that we *cannot* use a case -# here, because this file can only contain one case statement. -if test "$depmode" = hp; then - # HP compiler uses -M and no extra arg. - gccflag=-M - depmode=gcc -fi - -if test "$depmode" = dashXmstdout; then - # This is just like dashmstdout with a different argument. - dashmflag=-xM - depmode=dashmstdout -fi - -case "$depmode" in -gcc3) -## gcc 3 implements dependency tracking that does exactly what -## we want. Yay! Note: for some reason libtool 1.4 doesn't like -## it if -MD -MP comes after the -MF stuff. Hmm. - "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - mv "$tmpdepfile" "$depfile" - ;; - -gcc) -## There are various ways to get dependency output from gcc. Here's -## why we pick this rather obscure method: -## - Don't want to use -MD because we'd like the dependencies to end -## up in a subdir. Having to rename by hand is ugly. -## (We might end up doing this anyway to support other compilers.) -## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like -## -MM, not -M (despite what the docs say). -## - Using -M directly means running the compiler twice (even worse -## than renaming). - if test -z "$gccflag"; then - gccflag=-MD, - fi - "$@" -Wp,"$gccflag$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -## The second -e expression handles DOS-style file names with drive letters. - sed -e 's/^[^:]*: / /' \ - -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" -## This next piece of magic avoids the `deleted header file' problem. -## The problem is that when a header file which appears in a .P file -## is deleted, the dependency causes make to die (because there is -## typically no way to rebuild the header). We avoid this by adding -## dummy dependencies for each header file. Too bad gcc doesn't do -## this for us directly. - tr ' ' ' -' < "$tmpdepfile" | -## Some versions of gcc put a space before the `:'. On the theory -## that the space means something, we add a space to the output as -## well. -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -hp) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -sgi) - if test "$libtool" = yes; then - "$@" "-Wp,-MDupdate,$tmpdepfile" - else - "$@" -MDupdate "$tmpdepfile" - fi - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - - if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files - echo "$object : \\" > "$depfile" - - # Clip off the initial element (the dependent). Don't try to be - # clever and replace this with sed code, as IRIX sed won't handle - # lines with more than a fixed number of characters (4096 in - # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; - # the IRIX cc adds comments like `#:fec' to the end of the - # dependency line. - tr ' ' ' -' < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ - tr ' -' ' ' >> $depfile - echo >> $depfile - - # The second pass generates a dummy entry for each header file. - tr ' ' ' -' < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ - >> $depfile - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -aix) - # The C for AIX Compiler uses -M and outputs the dependencies - # in a .u file. This file always lives in the current directory. - # Also, the AIX compiler puts `$object:' at the start of each line; - # $object doesn't have directory information. - stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'` - tmpdepfile="$stripped.u" - outname="$stripped.o" - if test "$libtool" = yes; then - "$@" -Wc,-M - else - "$@" -M - fi - - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - - if test -f "$tmpdepfile"; then - # Each line is of the form `foo.o: dependent.h'. - # Do two passes, one to just change these to - # `$object: dependent.h' and one to simply `dependent.h:'. - sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" - sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -tru64) - # The Tru64 AIX compiler uses -MD to generate dependencies as a side - # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. - # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put - # dependencies in `foo.d' instead, so we check for that too. - # Subdirectories are respected. - - tmpdepfile1="$object.d" - tmpdepfile2=`echo "$object" | sed -e 's/.o$/.d/'` - if test "$libtool" = yes; then - "$@" -Wc,-MD - else - "$@" -MD - fi - - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" - exit $stat - fi - - if test -f "$tmpdepfile1"; then - tmpdepfile="$tmpdepfile1" - else - tmpdepfile="$tmpdepfile2" - fi - if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" - # That's a space and a tab in the []. - sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" - else - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -#nosideeffect) - # This comment above is used by automake to tell side-effect - # dependency tracking mechanisms from slower ones. - -dashmstdout) - # Important note: in order to support this mode, a compiler *must* - # always write the proprocessed file to stdout, regardless of -o, - # because we must use -o when running libtool. - test -z "$dashmflag" && dashmflag=-M - ( IFS=" " - case " $* " in - *" --mode=compile "*) # this is libtool, let us make it quiet - for arg - do # cycle over the arguments - case "$arg" in - "--mode=compile") - # insert --quiet before "--mode=compile" - set fnord "$@" --quiet - shift # fnord - ;; - esac - set fnord "$@" "$arg" - shift # fnord - shift # "$arg" - done - ;; - esac - "$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" - ) & - proc=$! - "$@" - stat=$? - wait "$proc" - if test "$stat" != 0; then exit $stat; fi - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - tr ' ' ' -' < "$tmpdepfile" | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -dashXmstdout) - # This case only exists to satisfy depend.m4. It is never actually - # run, as this mode is specially recognized in the preamble. - exit 1 - ;; - -makedepend) - # X makedepend - ( - shift - cleared=no - for arg in "$@"; do - case $cleared in no) - set ""; shift - cleared=yes - esac - case "$arg" in - -D*|-I*) - set fnord "$@" "$arg"; shift;; - -*) - ;; - *) - set fnord "$@" "$arg"; shift;; - esac - done - obj_suffix="`echo $object | sed 's/^.*\././'`" - touch "$tmpdepfile" - ${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@" - ) & - proc=$! - "$@" - stat=$? - wait "$proc" - if test "$stat" != 0; then exit $stat; fi - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - tail +3 "$tmpdepfile" | tr ' ' ' -' | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" "$tmpdepfile".bak - ;; - -cpp) - # Important note: in order to support this mode, a compiler *must* - # always write the proprocessed file to stdout, regardless of -o, - # because we must use -o when running libtool. - ( IFS=" " - case " $* " in - *" --mode=compile "*) - for arg - do # cycle over the arguments - case $arg in - "--mode=compile") - # insert --quiet before "--mode=compile" - set fnord "$@" --quiet - shift # fnord - ;; - esac - set fnord "$@" "$arg" - shift # fnord - shift # "$arg" - done - ;; - esac - "$@" -E | - sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | - sed '$ s: \\$::' > "$tmpdepfile" - ) & - proc=$! - "$@" - stat=$? - wait "$proc" - if test "$stat" != 0; then exit $stat; fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - cat < "$tmpdepfile" >> "$depfile" - sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -msvisualcpp) - # Important note: in order to support this mode, a compiler *must* - # always write the proprocessed file to stdout, regardless of -o, - # because we must use -o when running libtool. - ( IFS=" " - case " $* " in - *" --mode=compile "*) - for arg - do # cycle over the arguments - case $arg in - "--mode=compile") - # insert --quiet before "--mode=compile" - set fnord "$@" --quiet - shift # fnord - ;; - esac - set fnord "$@" "$arg" - shift # fnord - shift # "$arg" - done - ;; - esac - "$@" -E | - sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" - ) & - proc=$! - "$@" - stat=$? - wait "$proc" - if test "$stat" != 0; then exit $stat; fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" - echo " " >> "$depfile" - . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -none) - exec "$@" - ;; - -*) - echo "Unknown depmode $depmode" 1>&2 - exit 1 - ;; -esac - -exit 0 diff --git a/config/install-sh b/config/install-sh deleted file mode 100755 index e9de238..0000000 --- a/config/install-sh +++ /dev/null @@ -1,251 +0,0 @@ -#!/bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5 (mit/util/scripts/install.sh). -# -# Copyright 1991 by the Massachusetts Institute of Technology -# -# Permission to use, copy, modify, distribute, and sell this software and its -# documentation for any purpose is hereby granted without fee, provided that -# the above copyright notice appear in all copies and that both that -# copyright notice and this permission notice appear in supporting -# documentation, and that the name of M.I.T. not be used in advertising or -# publicity pertaining to distribution of the software without specific, -# written prior permission. M.I.T. makes no representations about the -# suitability of this software for any purpose. It is provided "as is" -# without express or implied warranty. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. It can only install one file at a time, a restriction -# shared with many OS's install programs. - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -transformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - true -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - chmodcmd="" - else - instcmd=mkdir - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f $src -o -d $src ] - then - true - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" - -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift - - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi - - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi - -# Make a temp file name in the proper directory. - - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd $src $dsttmp && - - trap "rm -f ${dsttmp}" 0 && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && - -# Now rename the file to the real destination. - - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile - -fi && - - -exit 0 diff --git a/config/missing b/config/missing deleted file mode 100755 index 0a7fb5a..0000000 --- a/config/missing +++ /dev/null @@ -1,283 +0,0 @@ -#! /bin/sh -# Common stub for a few missing GNU programs while installing. -# Copyright 1996, 1997, 1999, 2000 Free Software Foundation, Inc. -# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. - -# 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, 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. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -if test $# -eq 0; then - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 -fi - -run=: - -# In the cases where this matters, `missing' is being run in the -# srcdir already. -if test -f configure.ac; then - configure_ac=configure.ac -else - configure_ac=configure.in -fi - -case "$1" in ---run) - # Try to run requested program, and just exit if it succeeds. - run= - shift - "$@" && exit 0 - ;; -esac - -# If it does not exist, or fails to run (possibly an outdated version), -# try to emulate it. -case "$1" in - - -h|--h|--he|--hel|--help) - echo "\ -$0 [OPTION]... PROGRAM [ARGUMENT]... - -Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an -error status if there is no known handling for PROGRAM. - -Options: - -h, --help display this help and exit - -v, --version output version information and exit - --run try to run the given command, and emulate it if it fails - -Supported PROGRAM values: - aclocal touch file \`aclocal.m4' - autoconf touch file \`configure' - autoheader touch file \`config.h.in' - automake touch all \`Makefile.in' files - bison create \`y.tab.[ch]', if possible, from existing .[ch] - flex create \`lex.yy.c', if possible, from existing .c - help2man touch the output file - lex create \`lex.yy.c', if possible, from existing .c - makeinfo touch the output file - tar try tar, gnutar, gtar, then tar without non-portable flags - yacc create \`y.tab.[ch]', if possible, from existing .[ch]" - ;; - - -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "missing 0.3 - GNU automake" - ;; - - -*) - echo 1>&2 "$0: Unknown \`$1' option" - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 - ;; - - aclocal) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`acinclude.m4' or \`${configure_ac}'. You might want - to install the \`Automake' and \`Perl' packages. Grab them from - any GNU archive site." - touch aclocal.m4 - ;; - - autoconf) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`${configure_ac}'. You might want to install the - \`Autoconf' and \`GNU m4' packages. Grab them from any GNU - archive site." - touch configure - ;; - - autoheader) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`acconfig.h' or \`${configure_ac}'. You might want - to install the \`Autoconf' and \`GNU m4' packages. Grab them - from any GNU archive site." - files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` - test -z "$files" && files="config.h" - touch_files= - for f in $files; do - case "$f" in - *:*) touch_files="$touch_files "`echo "$f" | - sed -e 's/^[^:]*://' -e 's/:.*//'`;; - *) touch_files="$touch_files $f.in";; - esac - done - touch $touch_files - ;; - - automake) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. - You might want to install the \`Automake' and \`Perl' packages. - Grab them from any GNU archive site." - find . -type f -name Makefile.am -print | - sed 's/\.am$/.in/' | - while read f; do touch "$f"; done - ;; - - bison|yacc) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.y' file. You may need the \`Bison' package - in order for those modifications to take effect. You can get - \`Bison' from any GNU archive site." - rm -f y.tab.c y.tab.h - if [ $# -ne 1 ]; then - eval LASTARG="\${$#}" - case "$LASTARG" in - *.y) - SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" y.tab.c - fi - SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" y.tab.h - fi - ;; - esac - fi - if [ ! -f y.tab.h ]; then - echo >y.tab.h - fi - if [ ! -f y.tab.c ]; then - echo 'main() { return 0; }' >y.tab.c - fi - ;; - - lex|flex) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.l' file. You may need the \`Flex' package - in order for those modifications to take effect. You can get - \`Flex' from any GNU archive site." - rm -f lex.yy.c - if [ $# -ne 1 ]; then - eval LASTARG="\${$#}" - case "$LASTARG" in - *.l) - SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" lex.yy.c - fi - ;; - esac - fi - if [ ! -f lex.yy.c ]; then - echo 'main() { return 0; }' >lex.yy.c - fi - ;; - - help2man) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a dependency of a manual page. You may need the - \`Help2man' package in order for those modifications to take - effect. You can get \`Help2man' from any GNU archive site." - - file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` - if test -z "$file"; then - file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` - fi - if [ -f "$file" ]; then - touch $file - else - test -z "$file" || exec >$file - echo ".ab help2man is required to generate this page" - exit 1 - fi - ;; - - makeinfo) - if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then - # We have makeinfo, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.texi' or \`.texinfo' file, or any other file - indirectly affecting the aspect of the manual. The spurious - call might also be the consequence of using a buggy \`make' (AIX, - DU, IRIX). You might want to install the \`Texinfo' package or - the \`GNU make' package. Grab either from any GNU archive site." - file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` - if test -z "$file"; then - file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` - fi - touch $file - ;; - - tar) - shift - if test -n "$run"; then - echo 1>&2 "ERROR: \`tar' requires --run" - exit 1 - fi - - # We have already tried tar in the generic part. - # Look for gnutar/gtar before invocation to avoid ugly error - # messages. - if (gnutar --version > /dev/null 2>&1); then - gnutar ${1+"$@"} && exit 0 - fi - if (gtar --version > /dev/null 2>&1); then - gtar ${1+"$@"} && exit 0 - fi - firstarg="$1" - if shift; then - case "$firstarg" in - *o*) - firstarg=`echo "$firstarg" | sed s/o//` - tar "$firstarg" ${1+"$@"} && exit 0 - ;; - esac - case "$firstarg" in - *h*) - firstarg=`echo "$firstarg" | sed s/h//` - tar "$firstarg" ${1+"$@"} && exit 0 - ;; - esac - fi - - echo 1>&2 "\ -WARNING: I can't seem to be able to run \`tar' with the given arguments. - You may want to install GNU tar or Free paxutils, or check the - command line arguments." - exit 1 - ;; - - *) - echo 1>&2 "\ -WARNING: \`$1' is needed, and you do not seem to have it handy on your - system. You might have modified some files without having the - proper tools for further handling them. Check the \`README' file, - it often tells you about the needed prerequirements for installing - this package. You may also peek at any GNU archive site, in case - some other package would contain this missing \`$1' program." - exit 1 - ;; -esac - -exit 0 diff --git a/config/mkinstalldirs b/config/mkinstalldirs deleted file mode 100755 index 4f58503..0000000 --- a/config/mkinstalldirs +++ /dev/null @@ -1,40 +0,0 @@ -#! /bin/sh -# mkinstalldirs --- make directory hierarchy -# Author: Noah Friedman <friedman@prep.ai.mit.edu> -# Created: 1993-05-16 -# Public domain - -# $Id: mkinstalldirs,v 1.13 1999/01/05 03:18:55 bje Exp $ - -errstatus=0 - -for file -do - set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` - shift - - pathcomp= - for d - do - pathcomp="$pathcomp$d" - case "$pathcomp" in - -* ) pathcomp=./$pathcomp ;; - esac - - if test ! -d "$pathcomp"; then - echo "mkdir $pathcomp" - - mkdir "$pathcomp" || lasterr=$? - - if test ! -d "$pathcomp"; then - errstatus=$lasterr - fi - fi - - pathcomp="$pathcomp/" - done -done - -exit $errstatus - -# mkinstalldirs ends here diff --git a/configure.in b/configure.in index b33bf5f..e4ebf41 100644 --- a/configure.in +++ b/configure.in @@ -52,6 +52,7 @@ AM_CONDITIONAL(MSWINDOWS, test x$acx_host_winapi = xMSWINDOWS) AM_CONDITIONAL(CARBON, test x$acx_host_winapi = xCARBON) AM_CONDITIONAL(XWINDOWS, test x$acx_host_winapi = xXWINDOWS) + dnl checks for programs AC_PROG_CC AC_PROG_CXX @@ -80,6 +81,12 @@ else CXXFLAGS="$CXXFLAGS -DNDEBUG" fi +dnl enable code coverrage/profiling +AC_ARG_ENABLE([profiling], [ --enable-profiling enable profiling]) +if test "x$enable_profiling" == xyes; then + CXXFLAGS="$CXXFLAGS -fprofile-arcs -ftest-coverage -O0" +fi + dnl check compiler ACX_CHECK_CXX @@ -241,10 +248,47 @@ dnl enable maximum compiler warnings and warnings are errors. ACX_CXX_WARNINGS ACX_CXX_WARNINGS_ARE_ERRORS +dnl Enable ZeroConf implementation +AC_ARG_ENABLE([avahi], [ --enable-avahi enable Zeroconf (Avahi)]) +if test "x$enable_avahi" == xyes; then + PKG_CHECK_MODULES([AVAHI], [avahi-client], [AC_DEFINE([HAVE_AVAHI], 1, [Avahi Zeroconf support])]) + AC_SUBST(AVAHI_CFLAGS) + AC_SUBST(AVAHI_LIBS) + AM_CONDITIONAL(AVAHI, true) +else + AM_CONDITIONAL(AVAHI, false) + +fi + +dnl Enable Bonjour implementation +AC_ARG_ENABLE([bonjour], [ --enable-bonjour enable Zeroconf (Bonjour)]) +if test "x$enable_bonjour" == xyes; then + AC_DEFINE([HAVE_BONJOUR], 1, [Bonjour Zeroconf support]) +# BONJOUR_LIBS="-ldns_sd -lnss_mdns-0.2" + AM_CONDITIONAL(BONJOUR, true) +else + AM_CONDITIONAL(BONJOUR, false) +fi + +dnl Enable Test Suite +dnl "check" check +AC_ARG_ENABLE([testsuite], [ --enable-testsuite enable Testsuite]) +if test "x$enable_testsuite" == xyes; then + + PKG_CHECK_MODULES([CHECK], [check]) + AC_SUBST(CHECK_CFLAGS) + AC_SUBST(CHECK_LIBS) +fi + +dnl Check for libxml2 +PKG_CHECK_MODULES([LIBXML2], [libxml-2.0]) +AC_SUBST(LIBXML2_CFLAGS) +AC_SUBST(LIBXML2_LIBS) + dnl adjust compiler and linker variables CXXFLAGS="$CXXFLAGS $SYNERGY_CXXFLAGS $ARCH_CFLAGS" OBJCXXFLAGS="$OBJCXXFLAGS $CXXFLAGS $ARCH_CFLAGS" -LIBS="$NANOSLEEP_LIBS $INET_ATON_LIBS $ARCH_LIBS $LIBS" +LIBS="$NANOSLEEP_LIBS $INET_ATON_LIBS $ARCH_LIBS $LIBS $BONJOUR_LIBS" dnl we need to have an environment variable set when building on OS X. dnl i'm not sure of the right way to do that. writing 'export ...' to @@ -267,6 +311,7 @@ Makefile cmd/Makefile cmd/launcher/Makefile cmd/synergyc/Makefile +cmd/synergyd/Makefile cmd/synergys/Makefile dist/Makefile dist/nullsoft/Makefile @@ -285,4 +330,5 @@ lib/net/Makefile lib/platform/Makefile lib/server/Makefile lib/synergy/Makefile +lib/zeroconf/Makefile ]) diff --git a/lib/Makefile.am b/lib/Makefile.am index 2a57133..d408b11 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -24,6 +24,7 @@ SUBDIRS = \ platform \ client \ server \ + zeroconf \ $(NULL) EXTRA_DIST = \ diff --git a/lib/arch/CArchDaemonUnix.cpp b/lib/arch/CArchDaemonUnix.cpp index 93d50d4..1a9f0da 100644 --- a/lib/arch/CArchDaemonUnix.cpp +++ b/lib/arch/CArchDaemonUnix.cpp @@ -15,6 +15,7 @@ #include "CArchDaemonUnix.h" #include "XArchUnix.h" #include <unistd.h> +#include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> @@ -57,7 +58,8 @@ CArchDaemonUnix::daemonize(const char* name, DaemonFunc func) setsid(); // chdir to root so we don't keep mounted filesystems points busy - chdir("/"); + if (chdir("/") < 0) + throw XArchDaemonFailed(new XArchEvalUnix(errno)); // mask off permissions for any but owner umask(077); @@ -71,7 +73,10 @@ CArchDaemonUnix::daemonize(const char* name, DaemonFunc func) // of standard I/O safely goes in the bit bucket. open("/dev/null", O_RDONLY); open("/dev/null", O_RDWR); - dup(1); + + + if (dup(1) < 0) + throw XArchDaemonFailed(new XArchEvalUnix(errno)); // invoke function return func(1, &name); diff --git a/lib/arch/CArchMultithreadPosix.cpp b/lib/arch/CArchMultithreadPosix.cpp index ec11fc5..e157f4a 100644 --- a/lib/arch/CArchMultithreadPosix.cpp +++ b/lib/arch/CArchMultithreadPosix.cpp @@ -392,8 +392,17 @@ CArchMultithreadPosix::newCurrentThread() { lockMutex(m_threadMutex); CArchThreadImpl* thread = find(pthread_self()); + + // don't emit an assert - just add the new thread in the list + // This is needed to reference foreign threads - e.g. from ZeroConf callbacks + if (!thread) { + thread = new CArchThreadImpl; + thread->m_thread = pthread_self(); + insert(thread); + } + unlockMutex(m_threadMutex); - assert(thread != NULL); + return thread; } diff --git a/lib/arch/CArchNetworkBSD.cpp b/lib/arch/CArchNetworkBSD.cpp index 6b36cff..5284fec 100644 --- a/lib/arch/CArchNetworkBSD.cpp +++ b/lib/arch/CArchNetworkBSD.cpp @@ -315,7 +315,12 @@ CArchNetworkBSD::pollSocket(CPollEntry pe[], int num, double timeout) // the unblock event was signalled. flush the pipe. char dummy[100]; do { - read(unblockPipe[0], dummy, sizeof(dummy)); + if (read(unblockPipe[0], dummy, sizeof(dummy)) < 0) { + if (errno != EAGAIN) { + delete[] pfd; + throwError(errno); + } + } } while (errno != EAGAIN); // don't count this unblock pipe in return value @@ -487,7 +492,8 @@ CArchNetworkBSD::unblockPollSocket(CArchThread thread) const int* unblockPipe = getUnblockPipeForThread(thread); if (unblockPipe != NULL) { char dummy = 0; - write(unblockPipe[1], &dummy, 1); + if (write(unblockPipe[1], &dummy, 1) < 0) + throwError(errno); } } diff --git a/lib/arch/CMultibyte.cpp b/lib/arch/CMultibyte.cpp index 517d72d..14a33ef 100644 --- a/lib/arch/CMultibyte.cpp +++ b/lib/arch/CMultibyte.cpp @@ -22,10 +22,14 @@ #if HAVE_LOCALE_H # include <locale.h> #endif + #if HAVE_WCHAR_H || defined(_MSC_VER) # include <wchar.h> -#elif __APPLE__ +#endif + +#if __APPLE__ || __GNUC__ // wtf? Darwin puts mbtowc() et al. in stdlib + // ... gcc 4.3 requires this as well. include pathes got cleaned up... # include <stdlib.h> #else // platform apparently has no wchar_t support. provide dummy diff --git a/lib/base/CStringUtil.cpp b/lib/base/CStringUtil.cpp index 4636193..789532f 100644 --- a/lib/base/CStringUtil.cpp +++ b/lib/base/CStringUtil.cpp @@ -20,6 +20,7 @@ #include <cstdio> #include <cstdlib> #include <algorithm> +#include <string.h> // // CStringUtil diff --git a/lib/client/CClient.cpp b/lib/client/CClient.cpp index 1e450a1..fb69b8d 100644 --- a/lib/client/CClient.cpp +++ b/lib/client/CClient.cpp @@ -12,6 +12,9 @@ * GNU General Public License for more details. */ +#include <string.h> +#include <stdlib.h> + #include "CClient.h" #include "CServerProxy.h" #include "CScreen.h" diff --git a/lib/client/CServerProxy.cpp b/lib/client/CServerProxy.cpp index acef43b..7091563 100644 --- a/lib/client/CServerProxy.cpp +++ b/lib/client/CServerProxy.cpp @@ -24,6 +24,7 @@ #include "TMethodEventJob.h" #include "XBase.h" #include <memory> +#include <string.h> // // CServerProxy diff --git a/lib/net/CTCPSocket.cpp b/lib/net/CTCPSocket.cpp index 8e31317..e272b80 100644 --- a/lib/net/CTCPSocket.cpp +++ b/lib/net/CTCPSocket.cpp @@ -24,6 +24,7 @@ #include "CArch.h" #include "XArch.h" #include <string.h> +#include <stdlib.h> // // CTCPSocket diff --git a/lib/platform/CXWindowsScreen.cpp b/lib/platform/CXWindowsScreen.cpp index 9c4ab13..939c1c4 100644 --- a/lib/platform/CXWindowsScreen.cpp +++ b/lib/platform/CXWindowsScreen.cpp @@ -27,6 +27,7 @@ #include "IEventQueue.h" #include "TMethodEventJob.h" #include <cstring> +#include <stdlib.h> #if X_DISPLAY_MISSING # error X11 is required to build synergy #else @@ -92,6 +93,10 @@ CXWindowsScreen::CXWindowsScreen(const char* displayName, bool isPrimary) : m_xtestIsXineramaUnaware(true), m_xkb(false) { + + pthread_t tid = pthread_self(); + + LOG((CLOG_DEBUG "[TID: %u (0x%x)] %s (s_screen: %p)", tid, tid, __func__, s_screen)); assert(s_screen == NULL); s_screen = this; @@ -146,6 +151,11 @@ CXWindowsScreen::CXWindowsScreen(const char* displayName, bool isPrimary) : CXWindowsScreen::~CXWindowsScreen() { + pthread_t tid = pthread_self(); + + + LOG((CLOG_DEBUG "[TID: %u (0x%x)] %s (s_screen: %p)", tid, tid, __func__, s_screen)); + assert(s_screen != NULL); assert(m_display != NULL); diff --git a/lib/platform/CXWindowsUtil.cpp b/lib/platform/CXWindowsUtil.cpp index 9478d65..cc371e3 100644 --- a/lib/platform/CXWindowsUtil.cpp +++ b/lib/platform/CXWindowsUtil.cpp @@ -1345,11 +1345,11 @@ CXWindowsUtil::getWindowProperty(Display* display, Window window, } if (okay) { - LOG((CLOG_DEBUG2 "read property %d on window 0x%08x: bytes=%d", property, window, (data == NULL) ? 0 : data->size())); + //LOG((CLOG_DEBUG2 "read property %d on window 0x%08x: bytes=%d", property, window, (data == NULL) ? 0 : data->size())); return true; } else { - LOG((CLOG_DEBUG2 "can't read property %d on window 0x%08x", property, window)); + //LOG((CLOG_DEBUG2 "can't read property %d on window 0x%08x", property, window)); return false; } } diff --git a/lib/server/CClientProxy1_3.cpp b/lib/server/CClientProxy1_3.cpp index f68b550..a875af1 100644 --- a/lib/server/CClientProxy1_3.cpp +++ b/lib/server/CClientProxy1_3.cpp @@ -12,6 +12,8 @@ * GNU General Public License for more details. */ +#include <string.h> + #include "CClientProxy1_3.h" #include "CProtocolUtil.h" #include "CLog.h" diff --git a/lib/server/CConfig.cpp b/lib/server/CConfig.cpp index a502fe7..9b2e606 100644 --- a/lib/server/CConfig.cpp +++ b/lib/server/CConfig.cpp @@ -12,6 +12,7 @@ * GNU General Public License for more details. */ +#include "CLog.h" #include "CConfig.h" #include "CServer.h" #include "CKeyMap.h" @@ -427,6 +428,7 @@ CConfig::endAll() const bool CConfig::isScreen(const CString& name) const { + LOG(( CLOG_NOTE "count: %i", m_nameToCanonicalName.size() )); return (m_nameToCanonicalName.count(name) > 0); } diff --git a/lib/server/CConfigXml.cpp b/lib/server/CConfigXml.cpp new file mode 100644 index 0000000..1d52e43 --- /dev/null +++ b/lib/server/CConfigXml.cpp @@ -0,0 +1,267 @@ +/* + * synergy -- mouse and keyboard sharing utility + * Copyright (C) 2007 Daniel Gollub + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file COPYING that should have accompanied this file. + * + * This package 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. + */ + +#include <string.h> + +#include "CLog.h" +#include "CConfigXml.h" + +CConfigXml::CConfigXml() : CConfig(), doc(NULL), root(NULL) +{ +} + +CConfigXml::~CConfigXml() +{ + xmlFreeDoc(doc); +} + +bool CConfigXml::load(const CString &pathname) { + + doc = xmlParseFile(pathname.c_str()); + if (!doc) { + LOG((CLOG_ERR "cannot read configuration \"%s\"", + pathname.c_str())); + return false; + } + + if (!validate()) + return false; + + root = xmlDocGetRootElement(doc); + if (!root) { + LOG((CLOG_ERR "cannot read configuration, config looks empty")); + xmlFreeDoc(doc); + return false; + } + + xmlNodePtr cur = root->children; + + cur = cur->next; + + cur = cur->children; + cur = getNextElement(cur); + + + for (; cur; cur = cur->next) { + if (cur->children && !strcmp("Environment", (char *) cur->name)) + getEnvironment(cur); + } + + return true; +} + +bool CConfigXml::validate() { + + int ret = 0; + xmlSchemaParserCtxtPtr schemaParser; + xmlSchemaPtr xmlSchema; + xmlSchemaValidCtxtPtr schemaValid; + + if (m_schema.empty()) + m_schema = SYNERGY_CONFIGDIR "/" SYNERGYD_SCHEMA; + + schemaParser = xmlSchemaNewParserCtxt(m_schema.c_str()); + if (!schemaParser) { + LOG((CLOG_ERR "Cannot read configuration schema.")); + return false; + } + + xmlSchema = xmlSchemaParse(schemaParser); + if (!xmlSchema) { + LOG((CLOG_ERR "Cannot parse schema.")); + xmlSchemaFreeParserCtxt(schemaParser); + return false; + } + + xmlSchemaFreeParserCtxt(schemaParser); + + schemaValid = xmlSchemaNewValidCtxt(xmlSchema); + if (!schemaValid) { + LOG((CLOG_ERR "Cannot create new xmlSchemaValidCtx object.")); + xmlSchemaFree(xmlSchema); + return false; + } + + ret = xmlSchemaValidateDoc(schemaValid, doc); + + xmlSchemaFree(xmlSchema); + xmlSchemaFreeValidCtxt(schemaValid); + + if (ret) + LOG((CLOG_ERR "Config is not valid.")); + + return !ret; +} + +void CConfigXml::getEnvironment(xmlNodePtr cur) +{ + assert(cur); + + bool server; + xmlChar *role = NULL; + + cur = cur->children; + cur = getNextElement(cur); + + assert(!strcmp("Role", (char*) cur->name)); + assert(cur->children); + + // Role + role = xmlNodeGetContent(cur->children); + if (!strcmp("SERVER", (char *) role)) { + server = true; + } else { + server = false; + } + + xmlFree(role); + + cur = getNextElement(cur); + + // Screens + assert(!strcmp("Screens", (char*) cur->name)); + + // Clients MUST only have one single host entry in Screens section + // The single entry is the server. + if (server) + getScreens(cur); + else + addHost(cur); + +} + +bool CConfigXml::connectScreens(xmlNodePtr cur, CString configprop, EDirection dir) +{ + xmlChar *prop, *host; + + if (!(prop = xmlGetProp(cur, (xmlChar *) configprop.c_str()))) + return false; + + host = xmlNodeGetContent(cur); + assert(host); + + connect((char *) host, dir, 0.0f, 1.0f, (char *) prop, 0.0f, 1.0f); + + xmlFree(prop); + xmlFree(host); + return true; +} + +void CConfigXml::getScreenLinks(xmlNodePtr cur) +{ + connectScreens(cur, "Left", kLeft); + connectScreens(cur, "Right", kRight); + connectScreens(cur, "Top", kTop); + connectScreens(cur, "Bottom", kBottom); +} + +void CConfigXml::addHost(xmlNodePtr cur) +{ + + cur = cur->children; + cur = getNextElement(cur); + assert(cur); + + xmlChar *host = xmlNodeGetContent(cur->children); + assert(host); + m_environment.insert(std::make_pair((char *)host, (char *)host)); + xmlFree(host); +} + +bool CConfigXml::isHost(const CString &host) +{ + return !!m_environment.count(host); +} + +void CConfigXml::getScreens(xmlNodePtr cur) +{ + + for (cur = getNextElement(cur->children); cur; cur = getNextElement(cur)) { + + xmlChar *screen = xmlNodeGetContent(cur); + + + // verify validity of screen name + if (!isValidScreenName((char *) screen)) { + //throw XConfigXml(this, "invalid screen name \"%{1}\"", screen); + // TODO + xmlFree(screen); + return; + } + + // add the screen to the configuration + LOG(( CLOG_DEBUG "Adding screen: %s", screen )); + if (!addScreen((char *) screen)) { + //throw XConfigXml(this, "duplicate screen name \"%{1}\"", screen); + // TODO + xmlFree(screen); + return; + } + + + xmlFree(screen); + + getScreenLinks(cur); + + } + +} + +xmlNodePtr CConfigXml::getNextElement(xmlNodePtr cur) +{ + cur = cur->next; + + while (cur) { + if (cur->type == XML_ELEMENT_NODE) + return cur; + + cur = cur->next; + } + + return NULL; +} + +// +// CConfigXml I/O exceptions +// + +/* +XConfigXml::XConfigXml(const CConfigXml& context, + const CString& error) : + m_error(CStringUtil::print("line %p: %s", + context.getCurrentNode(), error.c_str())) +{ + // do nothing +} + +XConfigXml::XConfigXml(const CConfigXml& context, + const char* errorFmt, const CString& arg) : + m_error(CStringUtil::print("line %p: ", context.getCurrentNode()) + + CStringUtil::format(errorFmt, arg.c_str())) +{ + // do nothing +} + +XConfigXml::~XConfigXml() +{ + // do nothing +} + +CString +XConfigXml::getWhat() const throw() +{ + return format("XConfigXml", "read error: %{1}", m_error.c_str()); +} +*/ + diff --git a/lib/server/CConfigXml.h b/lib/server/CConfigXml.h new file mode 100644 index 0000000..aec81d0 --- /dev/null +++ b/lib/server/CConfigXml.h @@ -0,0 +1,82 @@ +/* synergy -- mouse and keyboard sharing utility + * Copyright (C) 2007 Daniel Gollub + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file COPYING that should have accompanied this file. + * + * This package 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. + */ + +#ifndef CCONFIGXML_H +#define CCONFIGXML_H + +#include <libxml/xmlschemas.h> +#include <libxml/xmlmemory.h> +#include <libxml/parser.h> +#include <libxml/tree.h> + +#include "CConfig.h" +#define SYNERGYD_SCHEMA "synergy.xsd" + + +typedef std::map<CString, CString, CStringUtil::CaselessCmp> CEnvMap; + +//! Zeroconf support +/*! +This class represent the XML Synergy configuration +*/ +class CConfigXml : public CConfig { + public: + CConfigXml(); + ~CConfigXml(); + + + //! Load a XML configuration file + /*! + This is loading the configuration from given path. + Before the actually loading it get checked by the XML Schema validation. + If the validation fails, the configuration get not parsed and this function + returns FALSE. + */ + bool load(const CString &pathname); + + //! Check if host is known and configured. + /*! + Returns TRUE if the service description OR hostname is a configured service instance. + */ + bool isHost(const CString&); + + //! Set location of XML Schema. + /*! + Overwrites the default location of XML Validation Schema. + Default is SYNERGYD_SCHEMA in synergy sysconfdir. + */ + void setXMLSchema(const CString &schema) { m_schema = schema; }; + + //! Get location of XML Schema + /*! + */ + const CString& getXMLSchema() { return m_schema; }; + + private: + bool validate(); + + void addHost(xmlNodePtr); + void getScreens(xmlNodePtr); + void getEnvironment(xmlNodePtr); + void getScreenLinks(xmlNodePtr); + + bool connectScreens(xmlNodePtr, CString, EDirection); + xmlNodePtr getNextElement(xmlNodePtr cur); + + xmlDocPtr doc; + xmlNodePtr root; + CString m_schema; + CEnvMap m_environment; +}; + +#endif // CCONFIGXML_H diff --git a/lib/server/CServer.cpp b/lib/server/CServer.cpp index ab7a7ad..9e5141c 100644 --- a/lib/server/CServer.cpp +++ b/lib/server/CServer.cpp @@ -29,6 +29,7 @@ #include "TMethodEventJob.h" #include "CArch.h" #include <string.h> +#include <stdlib.h> // // CServer @@ -824,6 +825,7 @@ CServer::isSwitchOkay(CBaseClientProxy* newScreen, // are we in a locked corner? first check if screen has the option set // and, if not, check the global options. + /* const CConfig::CScreenOptions* options = m_config.getOptions(getName(m_active)); if (options == NULL || options->count(kOptionScreenSwitchCorners) == 0) { @@ -855,6 +857,7 @@ CServer::isSwitchOkay(CBaseClientProxy* newScreen, preventSwitch = true; stopSwitch(); } + */ return !preventSwitch; } @@ -1936,9 +1939,11 @@ CServer::closeClients(const CConfig& config) CRemovedClients removed; for (CClientList::iterator index = m_clients.begin(); index != m_clients.end(); ++index) { + /* if (!config.isCanonicalName(index->first)) { removed.insert(index->second); } + */ } // don't close the primary client diff --git a/lib/server/CServer.h b/lib/server/CServer.h index c05d138..b5ec785 100644 --- a/lib/server/CServer.h +++ b/lib/server/CServer.h @@ -389,7 +389,7 @@ private: SInt32 m_xDelta2, m_yDelta2; // current configuration - CConfig m_config; + CConfig m_config; // input filter (from m_config); CInputFilter* m_inputFilter; diff --git a/lib/server/Makefile.am b/lib/server/Makefile.am index e03d9b7..25a56b4 100644 --- a/lib/server/Makefile.am +++ b/lib/server/Makefile.am @@ -13,28 +13,35 @@ ## Process this file with automake to produce Makefile.in NULL = +synergyconfigdir = $(sysconfdir)/synergy + +synergyconfig_DATA = \ + synergy.xsd \ + $(NULL) + EXTRA_DIST = \ Makefile.win \ $(NULL) -MAINTAINERCLEANFILES = \ - Makefile.in \ +MAINTAINERCLEANFILES = \ + Makefile.in \ $(NULL) noinst_LIBRARIES = libserver.a -libserver_a_SOURCES = \ - CBaseClientProxy.cpp \ +libserver_a_SOURCES = \ + CBaseClientProxy.cpp \ CClientListener.cpp \ CClientProxy.cpp \ CClientProxy1_0.cpp \ CClientProxy1_1.cpp \ CClientProxy1_2.cpp \ CClientProxy1_3.cpp \ - CClientProxyUnknown.cpp \ - CConfig.cpp \ + CClientProxyUnknown.cpp \ + CConfigXml.cpp \ + CConfig.cpp \ CInputFilter.cpp \ CPrimaryClient.cpp \ - CServer.cpp \ + CServer.cpp \ CBaseClientProxy.h \ CClientListener.h \ CClientProxy.h \ @@ -42,12 +49,19 @@ libserver_a_SOURCES = \ CClientProxy1_1.h \ CClientProxy1_2.h \ CClientProxy1_3.h \ - CClientProxyUnknown.h \ - CConfig.h \ + CClientProxyUnknown.h \ + CConfigXml.h \ + CConfig.h \ CInputFilter.h \ CPrimaryClient.h \ - CServer.h \ + CServer.h \ $(NULL) + +libserver_a_CXXFLAGS = \ + $(LIBXML2_CFLAGS) \ + -DSYNERGY_CONFIGDIR=\"$(synergyconfigdir)\" \ + $(NULL) + INCLUDES = \ -I$(top_srcdir)/lib/common \ -I$(top_srcdir)/lib/arch \ diff --git a/lib/server/synergy.xsd b/lib/server/synergy.xsd new file mode 100644 index 0000000..3c69631 --- /dev/null +++ b/lib/server/synergy.xsd @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.0"> + + <xsd:element name="synergy"> + <xsd:complexType> + <xsd:sequence> + <xsd:element maxOccurs="1" name="Environments" type="Environments"/> + <!-- TODO: Further generic synergy options --> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + + <xsd:complexType name="Environments"> + <xsd:sequence> + <xsd:element minOccurs="0" maxOccurs="unbounded" name="Environment" type="Environment"/> + </xsd:sequence> + </xsd:complexType> + + <!-- Zeroconf support for "multi-homing": + RFC3927 - 3. Considerations for Multiple Interfaces --> + <xsd:complexType name="Environment"> + <xsd:sequence> + <xsd:element minOccurs="1" maxOccurs="1" name="Role" type="Role"/> + <xsd:element minOccurs="1" maxOccurs="1" name="Screens" type="Screens"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:simpleType name="Role"> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="CLIENT"/> + <xsd:enumeration value="SERVER"/> + </xsd:restriction> + </xsd:simpleType> + + <xsd:complexType name="Screens"> + <xsd:sequence> + <xsd:element minOccurs="1" maxOccurs="unbounded" name="Host" type="Host"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:complexType name="Host"> + <xsd:simpleContent> + <xsd:extension base="xsd:string"> + <xsd:attribute name="Left" type="xsd:string"/> + <xsd:attribute name="Right" type="xsd:string"/> + <xsd:attribute name="Top" type="xsd:string"/> + <xsd:attribute name="Bottom" type="xsd:string"/> + </xsd:extension> + </xsd:simpleContent> + </xsd:complexType> + +</xsd:schema> diff --git a/lib/synergy/CPacketStreamFilter.cpp b/lib/synergy/CPacketStreamFilter.cpp index 4aad9c0..558eaa9 100644 --- a/lib/synergy/CPacketStreamFilter.cpp +++ b/lib/synergy/CPacketStreamFilter.cpp @@ -12,6 +12,7 @@ * GNU General Public License for more details. */ +#include <string.h> #include "CPacketStreamFilter.h" #include "IEventQueue.h" #include "CLock.h" diff --git a/lib/synergy/IKeyState.cpp b/lib/synergy/IKeyState.cpp index 28cd331..889a541 100644 --- a/lib/synergy/IKeyState.cpp +++ b/lib/synergy/IKeyState.cpp @@ -14,6 +14,7 @@ #include "IKeyState.h" #include <string.h> +#include <stdlib.h> // // IKeyState diff --git a/lib/synergy/IPrimaryScreen.cpp b/lib/synergy/IPrimaryScreen.cpp index 71b103f..0417de1 100644 --- a/lib/synergy/IPrimaryScreen.cpp +++ b/lib/synergy/IPrimaryScreen.cpp @@ -13,6 +13,7 @@ */ #include "IPrimaryScreen.h" +#include <stdlib.h> // // IPrimaryScreen diff --git a/lib/zeroconf/CZeroConf.cpp b/lib/zeroconf/CZeroConf.cpp new file mode 100644 index 0000000..de173ad --- /dev/null +++ b/lib/zeroconf/CZeroConf.cpp @@ -0,0 +1,48 @@ +/* + * synergy -- mouse and keyboard sharing utility + * Copyright (C) 2007 Daniel Gollub + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file COPYING that should have accompanied this file. + * + * This package 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. + */ + +#include "config.h" +#include "CString.h" +#include "CZeroConf.h" + +#undef ZEROCONF + +#if HAVE_AVAHI +# include "CZeroConfAvahi.h" +#elif HAVE_BONJOUR +# include "CZeroConfBonjour.h" +#endif + +#if !defined(ZEROCONF) +# error no supported ZeroConf selected +#endif + +CZeroConf* CZeroConf::s_instance = NULL; + +CZeroConf::CZeroConf() { + + assert(s_instance == NULL); + s_instance = this; + + m_zeroconf = new ZEROCONF; + +} + +CZeroConf::~CZeroConf() { + + //delete m_zeroconf; + + s_instance = NULL; +} + diff --git a/lib/zeroconf/CZeroConf.h b/lib/zeroconf/CZeroConf.h new file mode 100644 index 0000000..99b1f9a --- /dev/null +++ b/lib/zeroconf/CZeroConf.h @@ -0,0 +1,89 @@ +/* + * synergy -- mouse and keyboard sharing utility + * Copyright (C) 2007 Daniel Gollub + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file COPYING that should have accompanied this file. + * + * This package 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. + */ + +#ifndef CZEROCONF_H +#define CZEROCONF_H + +#include "IZeroConf.h" + +//! Zeroconf support +/*! +This class represent an abstraction for Zeroconf support +*/ +class CZeroConf { + public: + + /*! + Constructs the Zeroconf component + */ + CZeroConf(); + ~CZeroConf(); + + //! Register Synergy Zeroconf Service + /*! + This announces the Synergy Service via DNS-SD via the Zeroconf specific implementation. + */ + bool registerService() { return m_zeroconf->registerService(); }; + + //! Unregister Synergy Zeroconf Service + /*! + This unregisteres the Synergy Service via DNS-SD via the Zeroconf specific implementation. + */ + void unregisterService() { m_zeroconf->unregisterService(); }; + + //! Start Discovery + /*! + */ + bool startDiscover() { return m_zeroconf->startDiscover(); }; + + //! Stop Discovery + /*! + */ + void stopDiscover() { m_zeroconf->stopDiscover(); }; + + //! Get mDNS hostname + /*! + Returns the mDNS hostname. + */ + CString getHostname() { return m_zeroconf->getHostname(); }; + + //! Get Zeroconf (DNS-SD) Service Name + /*! + Returns the Zeroconf (DNS-SD) Service Name. + */ + CString getServicename() { return m_zeroconf->getServicename(); }; + + //! Set "New Service" Callback Function + /*! + This callback gets called everytime a synergy service gets discovered. + */ + void setNewServiceCb(ZeroConfNewServiceCb cb) { m_zeroconf->setNewServiceCb(cb); }; + + //! Set "All for now" Callback Function + /*! + This callback gets called when the initial discovery finished. This requires to trigger + a discovery process with startDiscover(). This should be used to avoid race conditions and to time + "role" (client/server) conditions. + */ + void setBrowseAllForNowCb(ZeroConfBrowseAllForNowCb cb) { m_zeroconf->setBrowseAllForNowCb(cb); }; + + private: + static CZeroConf *getInstance() { return s_instance; }; + + IZeroConf *m_zeroconf; + static CZeroConf *s_instance; + +}; + +#endif // CZEROCONF_H diff --git a/lib/zeroconf/CZeroConfAvahi.cpp b/lib/zeroconf/CZeroConfAvahi.cpp new file mode 100644 index 0000000..a34823a --- /dev/null +++ b/lib/zeroconf/CZeroConfAvahi.cpp @@ -0,0 +1,409 @@ +/* + * synergy -- mouse and keyboard sharing utility + * Copyright (C) 2007 Daniel Gollub + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file COPYING that should have accompanied this file. + * + * This package 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. + */ + +#include "CLog.h" +#include "CNetworkAddress.h" +#include "CZeroConfAvahi.h" + +#include <pwd.h> +#include <sys/types.h> + +#include <avahi-common/alternative.h> +#include <avahi-common/thread-watch.h> +#include <avahi-common/domain.h> +#include <avahi-common/malloc.h> +#include <avahi-common/error.h> + +static AvahiThreadedPoll *threaded_poll = NULL; + +static AvahiEntryGroup *group = NULL; +static AvahiServiceBrowser *sb = NULL; + +static CZeroConfAvahi* self = NULL; + +CZeroConfAvahi::CZeroConfAvahi() : client(NULL) +{ + int error = 0; + self = this; + + m_connectCb = NULL; + m_disconnectCb = NULL; + m_newServiceCb = NULL; + m_browseAllForNowCb = NULL; + + /* TODO: Is there a synergy platform abstraction for this? */ + CString user = getpwuid(getuid())->pw_name; + + if (!(threaded_poll = avahi_threaded_poll_new())) + goto fail; + + /* Allocate a new avahi client */ + client = avahi_client_new(avahi_threaded_poll_get(threaded_poll), + (AvahiClientFlags) 0, client_callback, NULL, &error); + + if (!client) + goto fail; + + m_hostname = avahi_client_get_host_name_fqdn(client); + if (m_hostname.empty()) + goto fail; + + /* Create service identifier string - the human-readable-one */ + m_servicedesc = user + "@" + m_hostname; + + if (avahi_threaded_poll_start(threaded_poll) < 0) + goto fail; + + LOG(( CLOG_DEBUG1 "Avahi Client is running..." )); + return; +fail: + + if (error) + LOG(( CLOG_ERR "Avahi Error: %s", avahi_strerror(error))); + + if (client) + avahi_client_free(client); + + if (threaded_poll) + avahi_threaded_poll_stop(threaded_poll); +} + +CZeroConfAvahi::~CZeroConfAvahi() +{ + if (threaded_poll) + avahi_threaded_poll_stop(threaded_poll); + + if (client) + avahi_client_free(client); + + if (threaded_poll) + avahi_threaded_poll_free(threaded_poll); +} + +void CZeroConfAvahi::entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata) { + assert(g == group || group == NULL); + + /* Called whenever the entry group state changes */ + + switch (state) { + case AVAHI_ENTRY_GROUP_ESTABLISHED : + /* The entry group has been established successfully */ + LOG((CLOG_DEBUG1 "Service '%s' successfully established.", self->m_servicedesc.c_str())); + break; + + case AVAHI_ENTRY_GROUP_COLLISION : { + char *n; + + /* A service name collision happened. Let's pick a new name */ + n = avahi_alternative_service_name(self->m_servicedesc.c_str()); + self->m_servicedesc = n; + + LOG(( CLOG_ERR "Service name collision, renaming service to '%s'", self->m_servicedesc.c_str())); + + /* And recreate the services */ + if (!create_services(avahi_entry_group_get_client(g))) { + LOG(( CLOG_ERR "Creating service failed: %s", avahi_strerror(avahi_client_errno(avahi_entry_group_get_client(g))))); + avahi_threaded_poll_quit(threaded_poll); + } + + break; + } + + case AVAHI_ENTRY_GROUP_FAILURE : + + LOG(( CLOG_ERR "Entry group failure: %s", avahi_strerror(avahi_client_errno(avahi_entry_group_get_client(g))))); + + /* Some kind of failure happened while we were registering our services */ + avahi_threaded_poll_quit(threaded_poll); + + break; + + case AVAHI_ENTRY_GROUP_UNCOMMITED: + case AVAHI_ENTRY_GROUP_REGISTERING: + ; + } +} + +bool CZeroConfAvahi::startDiscover() +{ + if (!self->m_newServiceCb) + return false; + + if (!client) + return false; + + browse_service(client); + return true; +} + +void CZeroConfAvahi::stopDiscover() +{ + avahi_service_browser_free(sb); + sb = NULL; +} + +void CZeroConfAvahi::browse_service(AvahiClient *client) +{ + assert(client); + + if (!(sb = avahi_service_browser_new(client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, SYNERGY_ZEROCONF_SERVICE, NULL, (AvahiLookupFlags) 0, browse_callback, client))) { + LOG(( CLOG_ERR, "Failed to create service browser: %s\n", avahi_strerror(avahi_client_errno(client)) )); + return; + } + +} + +bool CZeroConfAvahi::registerService() +{ + AvahiClient *c = NULL; + + if (!group) + group = self->register_group(); + + if (!group) + goto fail; + + if (!(c = avahi_entry_group_get_client(group))) + goto fail; + + if (!create_services(c)) + goto fail; + + return true; + +fail: + LOG(( CLOG_ERR "Failed to register Synergy Service" )); + return false; +} + +void CZeroConfAvahi::unregisterService() +{ + if (group) { + avahi_entry_group_free(group); + group = NULL; + } + +} + +AvahiEntryGroup* CZeroConfAvahi::register_group() +{ + + /* If this is the first time we're called, let's create a new entry group */ + if (!group) { + if (!(group = avahi_entry_group_new(client, entry_group_callback, NULL))) { + LOG(( CLOG_ERR "Creating new Avahi Service Entry failed: %s", avahi_strerror(avahi_client_errno(client)) )); + goto fail; + } + } + + return group; + +fail: + avahi_threaded_poll_quit(threaded_poll); + return NULL; +} + + +bool CZeroConfAvahi::create_services(AvahiClient *c) { + int ret; + assert(c); + + if (!group) + group = self->register_group(); + + LOG(( CLOG_DEBUG1 "Adding Avahi service '%s'", self->m_servicedesc.c_str())); + + if ((ret = avahi_entry_group_add_service(group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, (AvahiPublishFlags) 0, self->m_servicedesc.c_str(), SYNERGY_ZEROCONF_SERVICE, NULL, NULL, SYNERGY_ZEROCONF_SERVICE_PORT, NULL)) < 0) { + LOG(( CLOG_ERR "Failed to create \"%s\" Service Record: %s", SYNERGY_ZEROCONF_SERVICE, avahi_strerror(ret))); + return false; + } + + /* Tell the server to register the service */ + if ((ret = avahi_entry_group_commit(group)) < 0) { + LOG(( CLOG_ERR "Failed to register the Service: %s", avahi_strerror(ret))); + return false; + } + + return true; +} + +void CZeroConfAvahi::client_callback(AvahiClient *c, AvahiClientState state, void * userdata) { + assert(c); + + /* Called whenever the client or server state changes */ + + LOG(( CLOG_DEBUG1 "Avahi Client Cb: %i", state )); + + switch (state) { + case AVAHI_CLIENT_S_RUNNING: + + /* XXX: Don't register/announce any service here! + + Avoid race and wait until server got started. + Use registerService(), when the server instance is ready. + Otherwise the remote synergy client instance try immidetaily + to connect to this annound synergy service instance, even + if the server isn't ready. + */ + break; + + case AVAHI_CLIENT_FAILURE: + + LOG(( CLOG_ERR "Client failure: %s", avahi_strerror(avahi_client_errno(c)))); + avahi_threaded_poll_quit(threaded_poll); + + break; + + case AVAHI_CLIENT_S_COLLISION: + + /* Let's drop our registered services. When the server is back + * in AVAHI_SERVER_RUNNING state we will register them + * again with the new host name. */ + self->unregisterService(); + break; + + case AVAHI_CLIENT_S_REGISTERING: + + /* The server records are now being established. This + * might be caused by a host name change. We need to wait + * for our own records to register until the host name is + * properly esatblished. */ + + if (group) + avahi_entry_group_reset(group); + + break; + + case AVAHI_CLIENT_CONNECTING: + ; + } +} + +void CZeroConfAvahi::resolve_callback( + AvahiServiceResolver *r, + AVAHI_GCC_UNUSED AvahiIfIndex interface, + AVAHI_GCC_UNUSED AvahiProtocol protocol, + AvahiResolverEvent event, + const char *name, + const char *type, + const char *domain, + const char *host_name, + const AvahiAddress *address, + uint16_t port, + AvahiStringList *txt, + AvahiLookupResultFlags flags, + AVAHI_GCC_UNUSED void* userdata) { + + assert(r); + + /* Called whenever a service has been resolved successfully or timed out */ + + switch (event) { + case AVAHI_RESOLVER_FAILURE: + LOG(( CLOG_WARN "Failed to resolve service '%s' of type '%s' in domain '%s': %s\n", + name, type, domain, avahi_strerror(avahi_client_errno(avahi_service_resolver_get_client(r))) )); + + break; + + case AVAHI_RESOLVER_FOUND: { + char a[AVAHI_ADDRESS_STR_MAX], *t; + + LOG(( CLOG_DEBUG1 "Service '%s' of type '%s' in domain '%s':\n", name, type, domain )); + + avahi_address_snprint(a, sizeof(a), address); + t = avahi_string_list_to_string(txt); + LOG(( CLOG_DEBUG1 + "\t%s:%u (%s)\n" + "\tTXT=%s\n" + "\tcookie is %u\n" + "\tis_local: %i\n" + "\tour_own: %i\n" + "\twide_area: %i\n" + "\tmulticast: %i\n" + "\tcached: %i\n", + host_name, port, a, + t, + avahi_string_list_get_service_cookie(txt), + !!(flags & AVAHI_LOOKUP_RESULT_LOCAL), + !!(flags & AVAHI_LOOKUP_RESULT_OUR_OWN), + !!(flags & AVAHI_LOOKUP_RESULT_WIDE_AREA), + !!(flags & AVAHI_LOOKUP_RESULT_MULTICAST), + !!(flags & AVAHI_LOOKUP_RESULT_CACHED) )); + + if (!(flags & AVAHI_LOOKUP_RESULT_OUR_OWN)) { + CNetworkAddress caddress(host_name, port); + caddress.resolve(); + + self->m_newServiceCb(caddress, name); + } + + avahi_free(t); + } + } + + avahi_service_resolver_free(r); +} + +void CZeroConfAvahi::browse_callback( + AvahiServiceBrowser *b, + AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiBrowserEvent event, + const char *name, + const char *type, + const char *domain, + AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, + void* userdata) { + + AvahiClient *c = (AvahiClient *) userdata; + assert(b); + + /* Called whenever a new services becomes available on the LAN or is removed from the LAN */ + switch (event) { + case AVAHI_BROWSER_FAILURE: + + LOG(( CLOG_DEBUG1 "%s\n", avahi_strerror(avahi_client_errno(avahi_service_browser_get_client(b))) )); + avahi_threaded_poll_quit(threaded_poll); + return; + + case AVAHI_BROWSER_NEW: + LOG(( CLOG_DEBUG1 "NEW: service '%s' of type '%s' in domain '%s'\n", name, type, domain)); + + /* We ignore the returned resolver object. In the callback + function we free it. If the server is terminated before + the callback function is called the server will free + the resolver for us. */ + + if ( !(avahi_service_resolver_new(c, interface, protocol, name, type, domain, + AVAHI_PROTO_UNSPEC, (AvahiLookupFlags) 0, resolve_callback, c)) ) { + LOG(( CLOG_ERR "Failed to resolve Service '%s': %s\n", name, avahi_strerror(avahi_client_errno(c)))); + } + + break; + + case AVAHI_BROWSER_REMOVE: + LOG(( CLOG_DEBUG1 "REMOVE: service '%s' of type '%s' in domain '%s'\n", name, type, domain)); + break; + + case AVAHI_BROWSER_ALL_FOR_NOW: + LOG(( CLOG_DEBUG1 "ALL FOR NOW")); + self->m_browseAllForNowCb(); + break; + + case AVAHI_BROWSER_CACHE_EXHAUSTED: + LOG(( CLOG_DEBUG1 "CACHE_EXHAUSTED")); + break; + } +} + diff --git a/lib/zeroconf/CZeroConfAvahi.h b/lib/zeroconf/CZeroConfAvahi.h new file mode 100644 index 0000000..03932f7 --- /dev/null +++ b/lib/zeroconf/CZeroConfAvahi.h @@ -0,0 +1,55 @@ +/* synergy -- mouse and keyboard sharing utility + * Copyright (C) 2007 Daniel Gollub + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file COPYING that should have accompanied this file. + * + * This package 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. + */ + +#ifndef CZEROCONFAVAHI_H +#define CZEROCONFAVAHI_H + +#include <avahi-client/client.h> +#include <avahi-client/publish.h> +#include <avahi-client/lookup.h> +#include "IZeroConf.h" + +#define ZEROCONF CZeroConfAvahi + +class CZeroConfAvahi : public virtual IZeroConf { + public: + CZeroConfAvahi(); + virtual ~CZeroConfAvahi(); + bool registerService(); + void unregisterService(); + bool startDiscover(); + void stopDiscover(); + CString getHostname() { return m_hostname; }; + CString getServicename() { return m_servicedesc; }; + private: + AvahiEntryGroup *register_group(); + static bool create_services(AvahiClient *c); + static void browse_service(AvahiClient *c); + static void resolve_callback(AvahiServiceResolver *r, AvahiIfIndex interface, + AvahiProtocol protocol, + AvahiResolverEvent event, const char *name, const char *type, const char *domain, + const char *host_name, const AvahiAddress *address, uint16_t port, + AvahiStringList *txt, AvahiLookupResultFlags flags, void* userdata); + static void browse_callback(AvahiServiceBrowser *b, AvahiIfIndex interface, + AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, + const char *type, const char *domain, AvahiLookupResultFlags flags, + void* userdata); + static void client_callback(AvahiClient *c, AvahiClientState state, void *); + static void entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state, + void *userdata) ; + AvahiClient *client; + CString m_hostname; + CString m_servicedesc; +}; + +#endif // CZEROCONFAVAHI_H diff --git a/lib/zeroconf/CZeroConfBonjour.cpp b/lib/zeroconf/CZeroConfBonjour.cpp new file mode 100644 index 0000000..6c889f4 --- /dev/null +++ b/lib/zeroconf/CZeroConfBonjour.cpp @@ -0,0 +1,239 @@ +/* + * synergy -- mouse and keyboard sharing utility + * Copyright (C) 2007 Daniel Gollub + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file COPYING that should have accompanied this file. + * + * This package 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. + */ + +#include "CLog.h" +#include "CNetworkAddress.h" +#include "CArch.h" +#include "CZeroConfBonjour.h" + +#include <sys/types.h> +#include <pwd.h> + +static CZeroConfBonjour* self = NULL; + +CZeroConfBonjour::CZeroConfBonjour() +{ + int error = 0; + self = this; + + ARCH; + + m_connectCb = NULL; + m_disconnectCb = NULL; + m_newServiceCb = NULL; + m_browseAllForNowCb = NULL; + + /* TODO: Is there a synergy platform abstraction for this? */ + CString user = getpwuid(getuid())->pw_name; + + if (user.empty()) + goto fail; + + shutdown = false; + + LOG(( CLOG_DEBUG1 "Bonjour Client is running...: %s", user.c_str() )); + return; +fail: + + if (error) + LOG(( CLOG_ERR "Bonjour Error: %s", strerror(error))); +} + +CZeroConfBonjour::~CZeroConfBonjour() +{ + shutdown = true; + + if (browse_thread) + pthread_join(browse_thread, NULL); + + stopDiscover(); +} + + +bool CZeroConfBonjour::registerService() +{ + int ret; + + LOG(( CLOG_DEBUG1 "Register service." )); + + ret = DNSServiceRegister(&serviceRef, 0, 0, NULL, SYNERGY_ZEROCONF_SERVICE, NULL, NULL, SYNERGY_ZEROCONF_SERVICE_PORT, 0, NULL, service_callback, self); + if (ret != kDNSServiceErr_NoError) + return false; + + self->service_socket_fd = DNSServiceRefSockFD(serviceRef); + + DNSServiceProcessResult(serviceRef); + + return true; + +} + +void CZeroConfBonjour::unregisterService() +{ + DNSServiceRefDeallocate(serviceRef); +} + +void CZeroConfBonjour::service_callback(DNSServiceRef sdRef, DNSServiceFlags flags, DNSServiceErrorType errorCode, const char *name, const char *regtype, const char *domain, void *context) +{ + + if (errorCode != kDNSServiceErr_NoError) { + LOG(( CLOG_ERR "Couldn't register service: %i", errorCode )); + } + +} + +void *CZeroConfBonjour::resolveLoop(void *) +{ + int ret; + struct timeval time; + time.tv_sec = 1; + time.tv_usec = 0; + + while ((ret = select(self->resolve_socket_fd, NULL, NULL, NULL, &time) != -1)) + { + if (DNSServiceProcessResult(self->resolveRef)) { + LOG(( CLOG_ERR "browse process error" )); + break; + } + + if (self->shutdown) { + LOG(( CLOG_DEBUG1 "shutting down" )); + break; + } + + } + + pthread_exit((void *)0); +} + + +void *CZeroConfBonjour::discoveryLoop(void *) +{ + int ret; + struct timeval time; + time.tv_sec = 1; + time.tv_usec = 0; + + while ((ret = select(self->browse_socket_fd, NULL, NULL, NULL, &time) != -1)) + { + if (DNSServiceProcessResult(self->browseRef)) { + LOG(( CLOG_ERR "browse process error" )); + break; + } + + if (self->shutdown) { + LOG(( CLOG_DEBUG1 "shutting down" )); + break; + } + + } + + pthread_exit((void *)0); +} + +bool CZeroConfBonjour::startDiscover() +{ + int ret; + + LOG(( CLOG_DEBUG1 "Start Discovery" )); + + ret = DNSServiceBrowse(&browseRef, 0, 0, SYNERGY_ZEROCONF_SERVICE, NULL, browse_callback, self); + + if (ret != kDNSServiceErr_NoError) { + LOG(( CLOG_DEBUG1 "Discovery failed" )); + + return false; + } + + self->browse_socket_fd = DNSServiceRefSockFD(browseRef); + + pthread_create(&(self->browse_thread), NULL, discoveryLoop, NULL); + + LOG(( CLOG_DEBUG1 "Discovery started." )); + return true; +} +void CZeroConfBonjour::stopDiscover() +{ + DNSServiceRefDeallocate(browseRef); +} + +void CZeroConfBonjour::resolve_callback(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char *fullname, const char *hosttarget, uint16_t port, uint16_t txtLen, const char *txtRecord, void *context) +{ + LOG(( CLOG_DEBUG1 "service resolved - fullname: %s hosttarget: %s port: %i", fullname, hosttarget, port )); + +// CNetworkAddress caddress(hosttarget, port); + + // HACK HACK HACK port is wrong !!!!! + CNetworkAddress caddress(hosttarget, SYNERGY_ZEROCONF_SERVICE_PORT); +// CNetworkAddress caddress("sugga.local", port); + caddress.resolve(); + + char service[64]; + /* tux\032kroetes\032Computer._synergy._tcp.local. */ + /* Chop the fullname down to the service name */ + char *service_offset = strstr(fullname, "._synergy"); + if (!service_offset) + return; + + strncpy(service, fullname, (service_offset - fullname)); + int i, j, len = (service_offset - fullname); + char *unescaped_service = (char *) malloc(len); + memset(unescaped_service, 0, len+1); + + for (j=i=0; i < len ; i++) { + if (service[i] == '\\' && service[i+1] == '.') + continue; + + unescaped_service[j] = service[i]; + j++; + } + + unescaped_service[i] = '\0'; + + LOG(( CLOG_DEBUG "seeeerevicE: %s !!!!!!!!!!!!! %i", unescaped_service, (service_offset - fullname))); + + self->m_newServiceCb(caddress, unescaped_service); + free(unescaped_service); + + +} + +void CZeroConfBonjour::browse_callback(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char *serviceName, const char *regtype, const char *replyDomain, void *context) +{ + LOG(( CLOG_DEBUG1 "service: %s regtype: %s flags: %i", serviceName, regtype, flags )); + + DNSServiceResolve(&(self->resolveRef), 0, 0, serviceName, regtype, replyDomain, resolve_callback, self); + + self->resolve_socket_fd = DNSServiceRefSockFD(self->resolveRef); + + pthread_create(&(self->resolve_thread), NULL, resolveLoop, NULL); + + + if (flags & kDNSServiceFlagsAdd) { + LOG(( CLOG_DEBUG1 "service flag: ADDED" )); + // TODO resolve! + + } else { + LOG(( CLOG_DEBUG1 "service flag: GONE?!" )); + // TODO resolve! + } + + /* All for now! */ + if (!(flags & kDNSServiceFlagsMoreComing)) { + LOG(( CLOG_DEBUG1 "all for now ...")); + self->m_browseAllForNowCb(); + } + +} + diff --git a/lib/zeroconf/CZeroConfBonjour.h b/lib/zeroconf/CZeroConfBonjour.h new file mode 100644 index 0000000..aa5fb87 --- /dev/null +++ b/lib/zeroconf/CZeroConfBonjour.h @@ -0,0 +1,67 @@ +/* synergy -- mouse and keyboard sharing utility + * Copyright (C) 2007 Daniel Gollub + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file COPYING that should have accompanied this file. + * + * This package 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. + */ + +#ifndef CZEROCONFBONJOUR_H +#define CZEROCONFBONJOUR_H + +#include <dns_sd.h> +#include <pthread.h> + +#include "IZeroConf.h" + +#define ZEROCONF CZeroConfBonjour + +class CZeroConfBonjour : public virtual IZeroConf { + public: + CZeroConfBonjour(); + virtual ~CZeroConfBonjour(); + bool registerService(); + void unregisterService(); + bool startDiscover(); + void stopDiscover(); + CString getHostname() { return m_hostname; }; + CString getServicename() { return m_servicedesc; }; + private: + CString m_hostname; + CString m_servicedesc; + + DNSServiceRef serviceRef; + DNSServiceRef browseRef; + DNSServiceRef resolveRef; + + int service_socket_fd; + int browse_socket_fd; + int resolve_socket_fd; + + pthread_t browse_thread; + pthread_t resolve_thread; + + bool shutdown; + + static void *discoveryLoop(void *); + + static void *resolveLoop(void *); + + static void service_callback(DNSServiceRef, DNSServiceFlags, DNSServiceErrorType, + const char *, const char *, const char *, void *); + + static void resolve_callback(DNSServiceRef, DNSServiceFlags, uint32_t, DNSServiceErrorType, const char *, const char *, uint16_t, uint16_t, const char *, void *); + + static void browse_callback(DNSServiceRef, DNSServiceFlags, uint32_t, + DNSServiceErrorType, const char*, const char*, + const char*, void*); + + +}; + +#endif // CZEROCONFBONJOUR_H diff --git a/lib/zeroconf/IZeroConf.h b/lib/zeroconf/IZeroConf.h new file mode 100644 index 0000000..8dd55c1 --- /dev/null +++ b/lib/zeroconf/IZeroConf.h @@ -0,0 +1,50 @@ +/* synergy -- mouse and keyboard sharing utility + * Copyright (C) 2007 Daniel Gollub + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file COPYING that should have accompanied this file. + * + * This package 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. + */ + +#ifndef IZERCONF_H +#define IZERCONF_H + +#include "CNetworkAddress.h" +#include "ProtocolTypes.h" + +#define SYNERGY_ZEROCONF_SERVICE "_synergy._tcp" +#define SYNERGY_ZEROCONF_SERVICE_PORT kDefaultPort + +typedef bool (*ZeroConfConnectCb) (const CNetworkAddress &); +typedef void (*ZeroConfDisconnectCb) (const CNetworkAddress &); +typedef void (*ZeroConfNewServiceCb) (const CNetworkAddress &, const CString &); +typedef void (*ZeroConfBrowseAllForNowCb) (); + +class IZeroConf { + public: + virtual bool registerService() = 0; + virtual void unregisterService() = 0; + virtual bool startDiscover() = 0; + virtual void stopDiscover() = 0; + virtual CString getHostname() = 0; + virtual CString getServicename() = 0; + + void setConnectCb(ZeroConfConnectCb cb) { m_connectCb = cb; }; + void setDisconnectCb(ZeroConfDisconnectCb cb) { m_disconnectCb = cb; }; + void setNewServiceCb(ZeroConfNewServiceCb cb) { m_newServiceCb = cb; }; + void setBrowseAllForNowCb(ZeroConfBrowseAllForNowCb cb) { m_browseAllForNowCb = cb; }; + + protected: + ZeroConfConnectCb m_connectCb; + ZeroConfDisconnectCb m_disconnectCb; + ZeroConfNewServiceCb m_newServiceCb; + ZeroConfBrowseAllForNowCb m_browseAllForNowCb; + +}; + +#endif // IZERCONF_H diff --git a/lib/zeroconf/Makefile.am b/lib/zeroconf/Makefile.am new file mode 100644 index 0000000..92daadd --- /dev/null +++ b/lib/zeroconf/Makefile.am @@ -0,0 +1,64 @@ +# synergy -- mouse and keyboard sharing utility +# Copyright (C) 2002 Chris Schoeneman +# Copyright (C) 2007 Daniel Gollub +# +# This package is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# found in the file COPYING that should have accompanied this file. +# +# This package 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. + +## Process this file with automake to produce Makefile.in +NULL = + +if AVAHI +AVAHI_SOURCE_FILES = \ + CZeroConfAvahi.cpp \ + CZeroConfAvahi.h +endif + +if BONJOUR +BONJOUR_SOURCE_FILES = \ + CZeroConfBonjour.cpp \ + CZeroConfBonjour.h +endif + + +COMMON_SOURCE_FILES = \ + CZeroConf.cpp \ + CZeroConf.h \ + IZeroConf.h + +ZEROCONF_SOURCE_FILES = \ + $(AVAHI_SOURCE_FILES) \ + $(BONJOUR_SOURCE_FILES) \ + $(NULL) + +EXTRA_DIST = \ + $(COMMON_SOURCE_FILES) \ + $(AVAHI_SOURCE_FILES) \ + $(BONJOUR_SOURCE_FILES) \ + $(NULL) + +MAINTAINERCLEANFILES = \ + Makefile.in \ + $(NULL) + +noinst_LIBRARIES = libzeroconf.a + +libzeroconf_a_SOURCES = \ + $(AVAHI_SOURCE_FILES) \ + $(BONJOUR_SOURCE_FILES) \ + $(COMMON_SOURCE_FILES) \ + $(NULL) + +INCLUDES = \ + -I$(top_srcdir)/lib/arch \ + -I$(top_srcdir)/lib/base \ + -I$(top_srcdir)/lib/common \ + -I$(top_srcdir)/lib/net \ + -I$(top_srcdir)/lib/synergy \ + $(NULL)
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor