summaryrefslogtreecommitdiff
path: root/games/kaid
diff options
context:
space:
mode:
authorBrian Feldman <green@FreeBSD.org>2005-04-02 15:25:49 +0000
committerBrian Feldman <green@FreeBSD.org>2005-04-02 15:25:49 +0000
commitc2859edecb3704239d53a3554873fd0ea74c8594 (patch)
tree479fd14a1574dbfa41ac4adb1acec2402b87775f /games/kaid
parentUpdate to 2.01 (diff)
Add kaid 7.0.0.4b, XLink Kai tunneling server.
Notes
Notes: svn path=/head/; revision=132203
Diffstat (limited to 'games/kaid')
-rw-r--r--games/kaid/Makefile37
-rw-r--r--games/kaid/distinfo1
-rw-r--r--games/kaid/files/kaid.sh27
-rw-r--r--games/kaid/files/patch-ConfigFile.cc33
-rw-r--r--games/kaid/files/patch-ConfigFile.h12
-rw-r--r--games/kaid/files/patch-KaiEngine.cc107
-rw-r--r--games/kaid/files/patch-Kaid.cc28
-rw-r--r--games/kaid/files/patch-Kaid.h35
-rw-r--r--games/kaid/files/patch-Makefile101
-rw-r--r--games/kaid/files/patch-OrbDgramThread.cc43
-rw-r--r--games/kaid/files/patch-PktSnifferThread.cc30
-rw-r--r--games/kaid/files/patch-kaid.conf13
-rw-r--r--games/kaid/files/patch-libpcap__pcap-bpf.c11
-rw-r--r--games/kaid/files/patch-pthreadcc__Makefile71
-rw-r--r--games/kaid/files/patch-socketcc__Makefile71
-rw-r--r--games/kaid/pkg-descr8
-rw-r--r--games/kaid/pkg-plist3
17 files changed, 631 insertions, 0 deletions
diff --git a/games/kaid/Makefile b/games/kaid/Makefile
new file mode 100644
index 000000000000..6408e2e6c84b
--- /dev/null
+++ b/games/kaid/Makefile
@@ -0,0 +1,37 @@
+# New ports collection makefile for: kaid
+# Date created: 18 Feb 2005
+# Whom: Sebastiaan van Erk
+#
+# $FreeBSD$
+#
+
+PORTNAME= kaid
+PORTVERSION= 7.0.0.4b
+CATEGORIES= games net
+MASTER_SITES= http://www.teamxlink.co.uk/binary/
+MASTER_SITE_SUBDIR=
+DISTNAME= ${PORTNAME}_tree_${PORTVERSION}
+EXTRACT_SUFX= .zip
+
+MAINTAINER= sebster-kaid@sebster.com
+COMMENT= XLink Kai tunneling server
+
+NO_WRKSUBDIR= yes
+USE_GMAKE= yes
+USE_BISON= yes
+USE_ZIP= yes
+CC= gcc
+CPP= g++
+MAKE_ARGS= PREFIX="${PREFIX}" SYSTEM_CFLAGS="${CFLAGS}"
+
+NO_PACKAGE= contains compile time path info, ignores cc cxx
+
+post-patch:
+ @${GMAKE} -C ${WRKSRC} dist-clean
+
+do-install:
+ ${INSTALL_PROGRAM} ${WRKSRC}/kaid ${PREFIX}/sbin
+ ${INSTALL_DATA} ${WRKSRC}/kaid.conf ${PREFIX}/etc/kaid.conf.sample
+ ${INSTALL_SCRIPT} ${FILESDIR}/kaid.sh ${PREFIX}/etc/rc.d
+
+.include <bsd.port.mk>
diff --git a/games/kaid/distinfo b/games/kaid/distinfo
new file mode 100644
index 000000000000..b91ffcd6c7e9
--- /dev/null
+++ b/games/kaid/distinfo
@@ -0,0 +1 @@
+MD5 (kaid_tree_7.0.0.4b.zip) = 670c34bea44a69216449a5a1488351f5
diff --git a/games/kaid/files/kaid.sh b/games/kaid/files/kaid.sh
new file mode 100644
index 000000000000..d08dfabb017d
--- /dev/null
+++ b/games/kaid/files/kaid.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# PROVIDE: kaid
+# REQUIRE: NETWORKING
+# KEYWORD: FreeBSD shutdown
+
+#
+# Add the following lines to /etc/rc.conf to enable kaid:
+#
+# kaid_enable="YES"
+#
+kaid_enable="NO"
+
+. /etc/rc.subr
+
+name=kaid
+rcvar=`set_rcvar`
+
+command=/usr/local/sbin/${name}
+command_args=-d
+required_files=/usr/local/etc/kaid.conf
+
+load_rc_config ${name}
+run_rc_command "$1"
diff --git a/games/kaid/files/patch-ConfigFile.cc b/games/kaid/files/patch-ConfigFile.cc
new file mode 100644
index 000000000000..fb63c75189b9
--- /dev/null
+++ b/games/kaid/files/patch-ConfigFile.cc
@@ -0,0 +1,33 @@
+--- ConfigFile.cc Sun Feb 6 16:43:31 2005
+--- ConfigFile.cc Wed Mar 2 08:58:22 2005
+@@ -3,6 +3,9 @@
+ #ifdef OPENWRT
+ #include <utility>
+ #else
++#ifdef PLATFORM_freebsd
++#include <sys/types.h>
++#endif
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
+@@ -44,6 +47,9 @@
+
+ OrbPort = 34525;
+ UseIPv6 = false;
++#ifdef PLATFORM_freebsd
++ User = "";
++#endif
+
+ UIBind = "";
+ UIIP = "";
+@@ -175,6 +181,10 @@
+ {
+ XBoxHomebrew = ((val == "1") || (val == "on") || (val == "true") ||
+ (val == "yes") || (val == "yay") || (val == "foshizzle"));
++ }
++ else if (fld == "user")
++ {
++ User = m_vsValues[i];
+ }
+ else
+ {
diff --git a/games/kaid/files/patch-ConfigFile.h b/games/kaid/files/patch-ConfigFile.h
new file mode 100644
index 000000000000..e7c8fc68ae84
--- /dev/null
+++ b/games/kaid/files/patch-ConfigFile.h
@@ -0,0 +1,12 @@
+--- ConfigFile.h Sun Feb 6 10:40:17 2005
+--- ConfigFile.h Sun Feb 27 06:50:15 2005
+@@ -20,6 +20,9 @@
+ int OrbPort;
+ int Verbosity;
+ bool UseIPv6;
++#ifdef PLATFORM_freebsd
++ string User;
++#endif
+
+ string UIBind;
+ string UIIP;
diff --git a/games/kaid/files/patch-KaiEngine.cc b/games/kaid/files/patch-KaiEngine.cc
new file mode 100644
index 000000000000..d8b23aa5a0cf
--- /dev/null
+++ b/games/kaid/files/patch-KaiEngine.cc
@@ -0,0 +1,107 @@
+--- KaiEngine.cc.orig Wed Feb 9 19:26:59 2005
++++ KaiEngine.cc Sat Mar 5 20:53:51 2005
+@@ -14,9 +14,14 @@
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ #include <arpa/inet.h>
++#include <errno.h>
++#include <pwd.h>
++#ifdef PLATFORM_freebsd
++# include <login_cap.h>
++# include <netinet/in.h>
++#endif
+
+-#ifdef PLATFORM_macosx_jaguar
+-# include <sys/socket.h>
++#ifdef PLATFORM_bsd
+ # include <netinet/in_systm.h>
+ # include <netinet/if_ether.h>
+ # include <netinet/ip.h>
+@@ -80,6 +85,32 @@
+ {
+ m_bTerminate = false;
+ m_cSniffer = new CPktSnifferThread (this, m_cConf);
++ // After we have the networking set up, we no longer need
++ // the privileges that we are started with.
++ if(! m_cConf->User.empty()) {
++ const struct passwd *pwd = getpwnam(m_cConf->User.c_str());
++ if(pwd == 0) {
++ string err = "Unknown switch-to User: ";
++ err += m_cConf->User;
++ debuglog("KAID",err);
++ throw ThreadException(ThreadException::errUnknown);
++ }
++#if defined(PLATFORM_freebsd)
++ login_cap_t *lc = login_getpwclass(pwd);
++ if(lc == 0 ||
++ setusercontext(lc, pwd, pwd->pw_uid, LOGIN_SETALL) != 0) {
++#else
++ if(initgroups(m_cConf->User.c_str(), pwd->pw_gid) != 0 ||
++ setuid(pwd->pw_uid) != 0) {
++#endif
++ string err = "Unable to switch to User: ";
++ err += m_cConf->User;
++ err += ": ";
++ err += strerror(errno);
++ debuglog("KAID",err);
++ throw ThreadException(ThreadException::errUnknown);
++ }
++ }
+ m_cTOrb = new COrbStreamThread (this, m_cConf);
+ m_cUOrb = new COrbDgramThread (this, m_cConf);
+
+@@ -142,9 +173,10 @@
+ }
+ catch(SocketException & excep)
+ {
+- }
+- catch(...)
+- {
++ string err = "Failed to bind UI socket: ";
++ err += (const char *)excep;
++ debuglog("KAID",err);
++ throw ThreadException(ThreadException::errUnknown);
+ }
+
+ string mlm = "Manual";
+@@ -1425,6 +1457,11 @@
+ srcaddy = (struct ether_addr *) ep->ether_shost;
+ dstaddy = (struct ether_addr *) ep->ether_dhost;
+
++#if defined(PLATFORM_bsd) && \
++ !(defined(PLATFORM_macosx_1) || defined(PLATFORM_macosx_jaguar))
++#define ether_addr_octet octet
++#endif
++
+ // Get source MAC
+ sprintf (aux, "%02X%02X%02X%02X%02X%02X",
+ srcaddy->ether_addr_octet[0], srcaddy->ether_addr_octet[1],
+@@ -1447,7 +1484,7 @@
+ sizeof (struct ether_header) +
+ ((my_ip->ip_hl) << 2));
+ // Platform depend
+- #ifdef PLATFORM_macosx_jaguar
++ #ifdef PLATFORM_bsd
+ srcport = ntohs (my_packetheader->uh_sport);
+ dstport = ntohs (my_packetheader->uh_dport);
+ #else
+@@ -1745,10 +1782,12 @@
+ // Set byte 0 of outgoing based on console
+ if (console=="0050F2" || console=="000D3A")
+ Opcode = m_sCurrentArena.empty () ? 'X' : 'R'; // Box
+- if (console=="0009BF")
++ else if (console=="0009BF")
+ Opcode = m_sCurrentArena.empty () ? 'Y' : 'S'; // Cube
+- if (console=="00041F" || console=="00014A")
++ else if (console=="00041F" || console=="00014A")
+ Opcode = m_sCurrentArena.empty () ? 'p' : 'q'; // PS2 / PSP
++ else
++ return;
+
+ memcpy (newbuf + 2, packet, packet_size);
+ newbuf[0] = Opcode;
+@@ -2321,4 +2360,3 @@
+ }
+ m_bSeenAllDevices = !IsAnyDeviceMissing;
+ }
+-
diff --git a/games/kaid/files/patch-Kaid.cc b/games/kaid/files/patch-Kaid.cc
new file mode 100644
index 000000000000..48daa3eddb51
--- /dev/null
+++ b/games/kaid/files/patch-Kaid.cc
@@ -0,0 +1,28 @@
+--- Kaid.cc Sun Feb 6 00:18:03 2005
+--- Kaid.cc Wed Mar 2 08:52:16 2005
+@@ -8,7 +8,11 @@
+ #include <sys/time.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
++#ifndef PLATFORM_freebsd
+ #include <getopt.h>
++#else
++#include <unistd.h>
++#endif
+
+ #include "Kaid.h"
+ #include "KaiDaemon.h"
+@@ -196,12 +200,8 @@
+ openlog("kaid", LOG_PID, LOG_DAEMON);
+ try
+ {
+- while(1)
++ while((c = getopt (argc, argv, "c:dho:sf:V")) != -1)
+ {
+- if (c == -1)
+- break;
+-
+- c = getopt (argc, argv, "c:dho:sf:V");
+ switch(c)
+ {
+ case 'h':
diff --git a/games/kaid/files/patch-Kaid.h b/games/kaid/files/patch-Kaid.h
new file mode 100644
index 000000000000..e913f38a9232
--- /dev/null
+++ b/games/kaid/files/patch-Kaid.h
@@ -0,0 +1,35 @@
+--- Kaid.h Sat Feb 5 22:05:08 2005
+--- Kaid.h Wed Mar 2 08:54:08 2005
+@@ -4,23 +4,24 @@
+ #include <vector>
+ #include <string>
+ #include <iterator>
++#ifndef PLATFORM_freebsd
+ #include <locale>
++#endif
+ #include <string>
+ #include <algorithm>
+ #include <cctype>
+
+ #include <sys/time.h>
+
+-#define CONFIG_FILE "kaid.conf"
+ #define AUTHOR "Mineiro"
+-#ifndef PLATFORM_macosx_jaguar
+- #ifdef OPENWRT
+- #define PLATFORM "KaiStation"
+- #else
+- #define PLATFORM "Linux"
+- #endif
+-#else
++#if defined(PLATFORM_macosx_jaguar)
+ #define PLATFORM "Mac OSX"
++#elif defined(PLATFORM_freebsd)
++#define PLATFORM "FreeBSD"
++#elif defined(OPENWRT)
++#define PLATFORM "KaiStation"
++#else
++#define PLATFORM "Linux"
+ #endif
+
+ using namespace std;
diff --git a/games/kaid/files/patch-Makefile b/games/kaid/files/patch-Makefile
new file mode 100644
index 000000000000..4972af0a7fcd
--- /dev/null
+++ b/games/kaid/files/patch-Makefile
@@ -0,0 +1,101 @@
+--- Makefile Thu Feb 3 12:22:35 2005
+--- Makefile Sun Feb 27 12:24:50 2005
+@@ -4,16 +4,16 @@
+ #
+ #
+ VERSION = 7.0.0.4
+-ARCH = x86
+-PLATFORM = macosx_jaguar
++PLATFORM = freebsd
+ #OPENWRT = /home/luis/devel/Kai/buildroot/build_mipsel/staging_dir
+ #OPENWRT = /home/luis/devel/buildroot/build_mipsel/staging_dir
+ #CC=i386-uclibc-linux-gcc
+ #CXX=i386-linux-g++-3.4
++#PREFIX=
+ IPKG = /home/luis/devel/Kai/ipkg
+ PRE_CFLAGS = -D_REENTRANT -DPLATFORM_$(PLATFORM) -DVERSION=\"$(VERSION)\"
+ #STATIC = -static
+-CFLAGS = $(PRE_CFLAGS) -g -Wall -Ipthreadcc/src -Isocketcc/src -Ilibpcap $(STATIC)
++CFLAGS = $(SYSTEM_CFLAGS) $(PRE_CFLAGS) -g -Wall -Ipthreadcc/src -Isocketcc/src -Ilibpcap $(STATIC) -DCONFIG_FILE="\"$(PREFIX)/etc/kaid.conf\""
+ ifneq ($(strip $(OPENWRT)),)
+ #PRE_CFLAGS += -nostdinc
+ PRE_CFLAGS += -DOPENWRT -static
+@@ -30,6 +30,16 @@
+ CXXFLAGS += $(CFLAGS)
+ PWD = /home/luis/devel/Kai/kaid
+
++ifeq ($(strip $(PLATFORM)),macosx_jaguar)
++BSD = true
++endif
++ifeq ($(strip $(PLATFORM)),freebsd)
++BSD = true
++endif
++ifdef BSD
++PRE_CFLAGS += -DPLATFORM_bsd
++endif
++
+ PCAP = libpcap/pcap.o \
+ libpcap/inet.o \
+ libpcap/gencode.o \
+@@ -41,7 +51,7 @@
+ libpcap/grammar.o \
+ libpcap/scanner.o
+
+-ifeq ($(strip $(PLATFORM)),macosx_jaguar)
++ifdef BSD
+ PCAP += libpcap/pcap-bpf.o
+ else
+ PCAP += libpcap/pcap-linux.o
+@@ -63,7 +73,12 @@
+ PTCC = pthreadcc/obj/*.o
+ SOCC = socketcc/obj/*.o
+
++ifeq ($(strip $(PLATFORM)),freebsd)
++LIBS = -pthread -lutil
++else
+ LIBS = -lpthread
++endif
++
+ SRCS = Api.cc \
+ ConfigFile.cc \
+ KaiDaemon.cc \
+@@ -108,9 +123,25 @@
+
+ all: kaid
+
++ifeq ($(strip $(PLATFORM)),freebsd)
++libpcap:
++ ${MAKE} -C libpcap all
++
++pthreadcc:
++ ${MAKE} -C pthreadcc all
++
++socketcc:
++ ${MAKE} -C socketcc all
++
++install:
++.PHONY: libpcap pthreadcc socketcc install
++
++kaid: libpcap pthreadcc socketcc ${OBJS}
++else
+ kaid: ${OBJS}
++endif
+ @echo -n "Linking... "
+- ${CXX} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${PCAP} ${PTCC} ${SOCC} ${LIBS}
++ ${CXX} ${CFLAGS} ${LDFLAGS} -o $@ ${OBJS} ${PCAP} ${PTCC} ${SOCC} ${LIBS}
+ @echo "Done!"
+
+ GENDEPS=${CXX} ${CXXFLAGS} -MM -o $@ $<
+@@ -161,9 +192,9 @@
+ @echo "Cleaning binary and dist files..."
+ @rm -rf dist/
+ @rm -f ${OBJS} ${DEPS} kaid *~ *.o
+- make -C libpcap clean
+- make -C pthreadcc clean
+- make -C socketcc clean
++ ${MAKE} -C libpcap clean
++ ${MAKE} -C pthreadcc clean
++ ${MAKE} -C socketcc clean
+
+ REL=1
+ BUILDDIR=/tmp/kaid-dist
diff --git a/games/kaid/files/patch-OrbDgramThread.cc b/games/kaid/files/patch-OrbDgramThread.cc
new file mode 100644
index 000000000000..62a6ecda8067
--- /dev/null
+++ b/games/kaid/files/patch-OrbDgramThread.cc
@@ -0,0 +1,43 @@
+--- OrbDgramThread.cc Wed Feb 9 19:28:14 2005
+--- OrbDgramThread.cc Sun Feb 27 15:01:40 2005
+@@ -27,6 +27,8 @@
+ m_cParent->verbositylog(2,"THREAD","Datagram server thread started...");
+ m_cConf = cConf;
+ m_cListeningSocket = NULL;
++ m_iMyPort = 0;
++ m_iSourcePort = 0;
+ m_bOrbFound = false;
+ }
+
+@@ -136,12 +138,13 @@
+
+ IPAddress& COrbDgramThread::FindNearestOrb()
+ {
++ const size_t BUFFER_SIZE = 65535;
+ m_bOrbFound=false;
+ if (!m_cListeningSocket) return m_cNearestOrb;
+
+ unsigned int i;
+ int iBytesTransferred, iSrcPort;
+- char pcBuffer[65535];
++ char *pcBuffer = new char[BUFFER_SIZE];
+ IPAddress pcAddr;
+ vector<string> vsOrbs;
+ vector<string> vsSegments;
+@@ -169,7 +172,7 @@
+ m_cConf->OrbPort);
+ }
+
+- iBytesTransferred = m_cListeningSocket->ReceiveDatagram(pcBuffer, sizeof(pcBuffer) - 1,
++ iBytesTransferred = m_cListeningSocket->ReceiveDatagram(pcBuffer, BUFFER_SIZE - 1,
+ m_cNearestOrb, iSrcPort);
+
+ pcBuffer[iBytesTransferred] = 0;
+@@ -191,6 +194,7 @@
+ catch (...)
+ {
+ }
++ delete pcBuffer;
+
+ return m_cNearestOrb;
+ }
diff --git a/games/kaid/files/patch-PktSnifferThread.cc b/games/kaid/files/patch-PktSnifferThread.cc
new file mode 100644
index 000000000000..372fd77639dc
--- /dev/null
+++ b/games/kaid/files/patch-PktSnifferThread.cc
@@ -0,0 +1,30 @@
+--- PktSnifferThread.cc Wed Feb 9 13:29:04 2005
+--- PktSnifferThread.cc Sun Feb 27 06:17:28 2005
+@@ -2,6 +2,12 @@
+ #include <iostream>
+
+ #include <unistd.h>
++#ifdef PLATFORM_freebsd
++#include <sys/time.h>
++#include <sys/types.h>
++#include <sys/ioctl.h>
++#include <net/bpf.h>
++#endif
+ #include "libpcap/pcap.h"
+ #include "libpcap/pcap-bpf.h"
+ #include "PktSnifferThread.h"
+@@ -111,6 +117,14 @@
+
+ if(!m_ptHandle)
+ throw errInvalidDevice;
++
++#ifdef PLATFORM_freebsd
++ int one = 1;
++ if(ioctl(pcap_fileno(m_ptHandle), BIOCSHDRCMPLT, &one) == -1) {
++ pcap_close(m_ptHandle);
++ throw errFatalError;
++ }
++#endif
+
+ #ifdef PLATFORM_macosx_jaguar
+ injectFD = openRawSocket(&mySocket);
diff --git a/games/kaid/files/patch-kaid.conf b/games/kaid/files/patch-kaid.conf
new file mode 100644
index 000000000000..52912d56865d
--- /dev/null
+++ b/games/kaid/files/patch-kaid.conf
@@ -0,0 +1,13 @@
+--- kaid.conf Thu Feb 10 18:21:20 2005
+--- kaid.conf Sun Feb 27 14:11:45 2005
+@@ -16,6 +16,10 @@
+ # for diagnosing segfaults etc.
+ Verbosity = 0
+
++# User : Specifies which system user to switch to after having
++# allocated necessary privileged resources.
++User = daemon
++
+ # UIBind : Specifies which ip/port kaid will use to listen for controller
+ # UIs
+ # Ex.: 192.168.0.138, 10.0.0.1:34522, :34522 (default)
diff --git a/games/kaid/files/patch-libpcap__pcap-bpf.c b/games/kaid/files/patch-libpcap__pcap-bpf.c
new file mode 100644
index 000000000000..e25858d146b2
--- /dev/null
+++ b/games/kaid/files/patch-libpcap__pcap-bpf.c
@@ -0,0 +1,11 @@
+--- libpcap/pcap-bpf.c.orig Fri Nov 21 19:06:28 2003
++++ libpcap/pcap-bpf.c Thu Mar 3 13:03:28 2005
+@@ -467,7 +467,7 @@
+ */
+ do {
+ (void)snprintf(device, sizeof(device), "/dev/bpf%d", n++);
+- fd = open(device, O_RDONLY);
++ fd = open(device, O_RDWR);
+ } while (fd < 0 && errno == EBUSY);
+
+ /*
diff --git a/games/kaid/files/patch-pthreadcc__Makefile b/games/kaid/files/patch-pthreadcc__Makefile
new file mode 100644
index 000000000000..b69423ed4bc7
--- /dev/null
+++ b/games/kaid/files/patch-pthreadcc__Makefile
@@ -0,0 +1,71 @@
+--- pthreadcc/Makefile.orig Fri Dec 31 06:52:25 2004
++++ pthreadcc/Makefile Thu Mar 10 12:40:04 2005
+@@ -50,7 +50,7 @@
+ LIB_DIR = /usr/lib
+ HEAD_DIR = /usr/include
+ LIB_HEADERS = pthreadcc.h
+-PLATFORM = macosx_jaguar
++PLATFORM = freebsd
+ PRE_CFLAGS = -DPLATFORM_$(PLATFORM)
+ #OPENWRT = /home/luis/devel/Kai/buildroot/build_mipsel/staging_dir
+
+@@ -81,7 +81,7 @@
+ LD = $(OPENWRT)/bin/mipsel-linux-ld
+ else
+ CC = gcc
+-CFLAGS = -I$/usr/include -Wall -O2 -fPIC
++CFLAGS = -I$/usr/include -Wall -O2
+ LD = gcc
+ LDFLAGS = -lpthread -shared -Wl,-soname,$(LIB_SONAME)
+ endif
+@@ -97,7 +97,7 @@
+ ################################################################################
+ ifeq ($(PLATFORM), solaris)
+ CC = cc
+-CFLAGS = -I$/usr/include -XO2 -KPIC
++CFLAGS = -I$/usr/include -XO2
+ LIB_NAME = libpthreadcc.so
+ LIB_SONAME = $(LIB_NAME).$(MAJ_VER)
+ LIB_TARGET = $(LIB_SONAME).$(MIN_VER)
+@@ -112,7 +112,7 @@
+ ################################################################################
+ ifeq ($(PLATFORM), freebsd)
+ CC = gcc
+-CFLAGS = -I$/usr/include -Wall -Wstrict-prototypes -O2 -fPIC
++CFLAGS = $(SYSTEM_CFLAGS)
+ LIB_NAME = libpthreadcc.so
+ LIB_SONAME = $(LIB_NAME).$(MAJ_VER)
+ LIB_TARGET = $(LIB_SONAME).$(MIN_VER)
+@@ -127,7 +127,7 @@
+ ################################################################################
+ ifeq ($(PLATFORM), macosx_1)
+ CC = g++
+-CFLAGS = -I$/usr/include -Wall -Wstrict-prototypes -O2 -fPIC
++CFLAGS = -I$/usr/include -Wall -Wstrict-prototypes -O2
+ LIB_NAME = libpthreadcc.dylib
+ LIB_SONAME = libpthreadcc.$(MAJ_VER).dylib
+ LIB_TARGET = libpthreadcc.$(MAJ_VER).$(MIN_VER).dylib
+@@ -142,7 +142,7 @@
+ ################################################################################
+ ifeq ($(PLATFORM), macosx_jaguar)
+ CC = g++
+-CFLAGS = -I$/usr/include -Wall -Wstrict-prototypes -O2 -fPIC
++CFLAGS = -I$/usr/include -Wall -Wstrict-prototypes -O2
+ LIB_NAME = libpthreadcc.dylib
+ LIB_SONAME = libpthreadcc.$(MAJ_VER).dylib
+ LIB_TARGET = libpthreadcc.$(MAJ_VER).$(MIN_VER).dylib
+@@ -180,10 +180,12 @@
+ # make all and make library perform the same task of resolving to making the #
+ # target libary file. #
+ ################################################################################
+-all: library
+- @echo Run \'make install\' to use this library with other projects...
++all: static
++
++static: pre-compile-info objects
+
+ library: pre-compile-info $(LIB_TARGET)
++ @echo Run \'make install\' to use this library with other projects...
+
+ ################################################################################
+ # make pre-compile-info echos pre-compilation information to the screen. #
diff --git a/games/kaid/files/patch-socketcc__Makefile b/games/kaid/files/patch-socketcc__Makefile
new file mode 100644
index 000000000000..3b166b353e86
--- /dev/null
+++ b/games/kaid/files/patch-socketcc__Makefile
@@ -0,0 +1,71 @@
+--- socketcc/Makefile.orig Fri Dec 31 06:52:56 2004
++++ socketcc/Makefile Thu Mar 10 12:40:39 2005
+@@ -51,7 +51,7 @@
+ LIB_DIR = /usr/lib
+ HEAD_DIR = /usr/include
+ LIB_HEADERS = socketcc.h
+-PLATFORM = macosx_jaguar
++PLATFORM = freebsd
+ PRE_CFLAGS = -DPLATFORM_$(PLATFORM)
+ #OPENWRT = /home/luis/devel/Kai/buildroot/build_mipsel/staging_dir
+
+@@ -82,7 +82,7 @@
+ LDFLAGS = -L../pthreadcc/src -lpthreadcc -shared
+ else
+ CC = g++
+-CFLAGS = -I$/usr/include -I../pthreadcc/src -Wall -O2 -fPIC
++CFLAGS = -I$/usr/include -I../pthreadcc/src -Wall -O2
+ LD = g++
+ LDFLAGS = -lpthreadcc -shared -Wl,-soname,$(LIB_SONAME)
+ endif
+@@ -98,7 +98,7 @@
+ ################################################################################
+ ifeq ($(PLATFORM), freebsd)
+ CC = g++
+-CFLAGS = -I/usr/include -I/usr/local/include -Wall -Wstrict-prototypes -O2 -fPIC
++CFLAGS = $(SYSTEM_CFLAGS) -I../pthreadcc/src
+ LIB_NAME = libsocketcc.so
+ LIB_SONAME = $(LIB_NAME).$(MAJ_VER)
+ LIB_TARGET = $(LIB_SONAME).$(MIN_VER)
+@@ -113,7 +113,7 @@
+ ################################################################################
+ ifeq ($(PLATFORM), solaris)
+ CC = cc
+-CFLAGS = -I$/usr/include -XO2 -KPIC
++CFLAGS = -I$/usr/include -XO2
+ LIB_NAME = libsocketcc.so
+ LIB_SONAME = $(LIB_NAME).$(MAJ_VER)
+ LIB_TARGET = $(LIB_SONAME).$(MIN_VER)
+@@ -128,7 +128,7 @@
+ ################################################################################
+ ifeq ($(PLATFORM), macosx_1)
+ CC = c++
+-CFLAGS = -I$/usr/include -Wall -Wstrict-prototypes -O2 -fPIC
++CFLAGS = -I$/usr/include -Wall -Wstrict-prototypes -O2
+ LIB_NAME = libsocketcc.dylib
+ LIB_SONAME = libsocketcc.$(MAJ_VER).dylib
+ LIB_TARGET = libsocketcc.$(MAJ_VER).$(MIN_VER).dylib
+@@ -143,7 +143,7 @@
+ ################################################################################
+ ifeq ($(PLATFORM), macosx_jaguar)
+ CC = g++
+-CFLAGS = -I$/usr/include -Wall -Wstrict-prototypes -O2 -fPIC
++CFLAGS = -I$/usr/include -Wall -Wstrict-prototypes -O2
+ LIB_NAME = libsocketcc.dylib
+ LIB_SONAME = libsocketcc.$(MAJ_VER).dylib
+ LIB_TARGET = libsocketcc.$(MAJ_VER).$(MIN_VER).dylib
+@@ -181,10 +181,12 @@
+ # make all and make library perform the same task of resolving to making the #
+ # target libary file. #
+ ################################################################################
+-all: library
+- @echo Run \'make install\' to use this library with other projects...
++all: static
++
++static: pre-compile-info objects
+
+ library: pre-compile-info $(LIB_TARGET)
++ @echo Run \'make install\' to use this library with other projects...
+
+ ################################################################################
+ # make pre-compile-info echos pre-compilation information to the screen. #
diff --git a/games/kaid/pkg-descr b/games/kaid/pkg-descr
new file mode 100644
index 000000000000..c7156164ab04
--- /dev/null
+++ b/games/kaid/pkg-descr
@@ -0,0 +1,8 @@
+XLink Kai is a global gaming network - bringing together XBox,
+Playstation 2, Gamecube and PSP users, in one integrated community.
+It is software running on your PC or Macintosh that allows you to
+play system-link enabled games online for free. Kai is the only
+service that is not console specific, and boasts one of the friendliest
+communites available. This is the FreeBSD port of the Kai server.
+
+WWW: http://www.teamxlink.co.uk/
diff --git a/games/kaid/pkg-plist b/games/kaid/pkg-plist
new file mode 100644
index 000000000000..a19fa28a08fa
--- /dev/null
+++ b/games/kaid/pkg-plist
@@ -0,0 +1,3 @@
+etc/kaid.conf.sample
+etc/rc.d/kaid.sh
+sbin/kaid