diff --git a/x11-drivers/synaptics/Manifest b/x11-drivers/synaptics/Manifest
new file mode 100644
index 00000000..0a0a2e43
--- /dev/null
+++ b/x11-drivers/synaptics/Manifest
@@ -0,0 +1,20 @@
+AUX 11-x11-synaptics.fdi 460 RMD160 973e332bd506d0160e573a028115bf3c0924e334 SHA1 77cc42785faecc3fb9b33ffac0b433ba9ba03808 SHA256 51c0da7a8e7048a753afa83d2d81e62fa8b61e0a1718083a2cc110767a76a8a3
+AUX rc.conf 330 RMD160 75825d70b749ae4e8b59b4066428d73815b19d70 SHA1 639736e2b424fcd3d6a78d0e6a3f90bed49ee6f4 SHA256 1776915a739c2f1432ab1602717cac1ff2464160a9d33d20124853a93605f6a5
+AUX rc.init 440 RMD160 82c30d248ef010cdd41600e3b19878b9f2ea6ff0 SHA1 cfb299682f9ec85340950917cbfebe5387080b32 SHA256 314d7d7c7d20608a398b439427e9c74cfaf2521996abc50af8a7963f1e7f22b8
+AUX synaptics-0.14.4-r2-makefile-fpic.patch 681 RMD160 492189b170c19043e35e28d9d347d61d718eef0a SHA1 d784c87ef1d144bb863f5fb05f69b511c528bf8f SHA256 c8cbd624521f7490a04df72d8a2738c5bb586b57c560af0bb60b860f286658bc
+AUX synaptics-0.14.4-r2-makefile.patch 531 RMD160 64ac6a8bd06befe99f126a1cad08028c38714c8b SHA1 4bbc1f9bba91efdada4bedb7b4676dab0c42fccf SHA256 4797db102c69d06d56bdfb761308df5a2349bfa75c09383d3b67e3d6e4487ec9
+AUX synaptics-0.14.5-makefile-fpic.patch 604 RMD160 610b6f52382cab61d669c7ed126796a7ba0c96f2 SHA1 ff235d5ea1b20a4b19a5339fc31afeb88750f8d3 SHA256 bfe89f8ecae8a0af6e8b478ed29f5fe652bf3aa6016d6c41a7a678fc25f92c36
+AUX synaptics-0.14.5-xorg-7.1-compile-fix.patch 2249 RMD160 639955f8ae5162d4c3b4f527a6e6bb1cf4c0bb26 SHA1 0d59b2d11dbb94127ee843310e3badcaff6b61e1 SHA256 0de534613bd1df8b0b36f0387fcea858e463833bb6f4248b71c0975d7effae19
+AUX synaptics-0.14.6-configurable_polling_interval.patch 1880 RMD160 ca90cd33992df42c573547645633b30e377a146e SHA1 e3abb85af87ee6b3c356be635898840d42819c74 SHA256 f4ed2db4c2e20f703cebea778f8605187be0a84ba77fde0b69512c15462d697e
+AUX synaptics-0.14.6_p20070706-fixeventgrab.patch 3036 RMD160 c6b40e5e8827060a39e0dc64ac125f9b7306d7c1 SHA1 a4fcb3e8c3376f1fa0eab4e83a2f0a1994107555 SHA256 28640f58d83d5bdeadb713541e0ad521c2f705211a352bf1078c4f5f2509d416
+AUX synaptics-0.14.6_p20070706-input_api.patch 686 RMD160 67ecdecc01f255b4fec693e4237976a23a4e6a7a SHA1 7acb718d19a4870833dc86b6810f2af33aac56cd SHA256 829a3355fdd935ee6861687bfabe96d12efb37f13ccdc525c515dee43dc2e1f9
+AUX synaptics-0.14.x-gcc4-the-sentinels-have-attacked.patch 538 RMD160 aec4ddbe8c93439d2245aeea1909eeb0e9ee555f SHA1 985ee12c3b61cdb89c97d150a52da4df85e2f236 SHA256 81cd1a662faf37141ca1e731c0ef63ba493a99b2c794d8ceb9510a7367e4f97c
+AUX synaptics-fix-xf86_ansic.h.patch 3924 RMD160 4748823c9edf709ef9ec0bef42a96a151b4cada1 SHA1 8a4d180a73dc0f4cc9e1fdcaebfe905a62221211 SHA256 647d7ae2044b949cab4016eb985936b0ef6bb995105ec90dccc38fa03cdb85b3
+AUX synaptics-fix-xinerama.patch 602 RMD160 128bc48024c04d789cc1393462e81c2dbe6bae5c SHA1 225993afe0f2ec6be5df7e132f60a92db0c54815 SHA256 8feb3ca55e1c476b068dda6b411ad6a317ac8fa4d3569fe38a0e5af14b8cb1c7
+AUX synaptics-fixeventgrab.diff 2826 RMD160 0888ceb9cb2847d336be4c267ee8a4f6aee76a1d SHA1 38de7f5c4c94f89e5170b4ff6306cc6b1d7fac84 SHA256 90f49ad2885202a23ad70e3630d712dc26249c4d3035cff2e0094de2f806dab8
+AUX synaptics-install-so-exec.patch 337 RMD160 e9111545b7c04ab66bd1ff36d116d25baa205ef1 SHA1 c9f67efed41c5c4a1201b1261be0d72f912e4ab6 SHA256 227a147a0d7d0c9528d51ffec03506db530af8a6911c6f89f45e451fdc4d39eb
+AUX synaptics_input_api.diff 2181 RMD160 c7adda057b1591721abb4e2cba73e5fca1442361 SHA1 e0ac5c149a4a2899feacc1eaea27b78fa3c4a97b SHA256 0f415142a67a1a2cac51d9e67a33e7cadd9a20846b3f187db1ab5ff280b9c1f8
+DIST synaptics-0.14.6.tar.bz2 126833 RMD160 7a8b103aa314eb13dc512c663c501108cc24a574 SHA1 41443e253e73546657b40435c8c9bfa0a91662bc SHA256 f88b967258a0484b0aa02f26acfb31a70cc8afd4872608b7f81c44dc29ae8429
+DIST synaptics-0.14.6_p20070706.tar.bz2 129509 RMD160 bacf7f08c04a9164af2883133d479ace59f7a3ce SHA1 55077ecf4bba3ced44702aa516af7a23c5172c03 SHA256 a22e3995756ce2050832a9ee1a8b300dfa18101e00e940399e329e4f9e78cb90
+EBUILD synaptics-0.14.6-r10.ebuild 2857 RMD160 0341d67b524a20d67a0f7da3463bbe74abce8b29 SHA1 626e64cb03167b91bd1014c24fcb5cc91d4c92db SHA256 e884844dc7fd0a936b7cf28595271cf50f84d33b27bed23d6b990c596d1b0d23
+EBUILD synaptics-0.14.6_p20070706-r2.ebuild 2898 RMD160 0b6206e970a1e00ffd2ca6fb0373cafb278cf8ed SHA1 bc877acff7e31ec33581c89af071177ce9184542 SHA256 8a3cc60197641c278a27ddb49e7a73e17e74f9114b367e0e7de8c2ab0682e4b1
diff --git a/x11-drivers/synaptics/files/11-x11-synaptics.fdi b/x11-drivers/synaptics/files/11-x11-synaptics.fdi
new file mode 100644
index 00000000..05c84286
--- /dev/null
+++ b/x11-drivers/synaptics/files/11-x11-synaptics.fdi
@@ -0,0 +1,13 @@
+
+
+
+
+
+ synaptics
+
+
+ synaptics
+
+
+
+
diff --git a/x11-drivers/synaptics/files/rc.conf b/x11-drivers/synaptics/files/rc.conf
new file mode 100644
index 00000000..34ad81d8
--- /dev/null
+++ b/x11-drivers/synaptics/files/rc.conf
@@ -0,0 +1,8 @@
+# Copyright 1999-2003 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/x11-drivers/synaptics/files/rc.conf,v 1.1 2005/12/09 16:11:18 seemant Exp $
+
+# Config file for /etc/init.d/syndaemon
+
+# run `syndaemon --help` for valid cmdline options
+#SYNDAEMON_OPTS=""
diff --git a/x11-drivers/synaptics/files/rc.init b/x11-drivers/synaptics/files/rc.init
new file mode 100644
index 00000000..be2ac40b
--- /dev/null
+++ b/x11-drivers/synaptics/files/rc.init
@@ -0,0 +1,20 @@
+#!/sbin/runscript
+# Copyright 1999-2002 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/x11-drivers/synaptics/files/rc.init,v 1.2 2006/12/19 01:07:10 lu_zero Exp $
+
+depend() {
+ use localmount
+}
+
+start() {
+ ebegin "Starting syndaemon"
+ /usr/bin/syndaemon ${SYNDAEMON_OPTS}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping syndaemon"
+ kill `cat /var/run/syndaemon.pid`
+ eend $?
+}
diff --git a/x11-drivers/synaptics/files/synaptics-0.14.4-r2-makefile-fpic.patch b/x11-drivers/synaptics/files/synaptics-0.14.4-r2-makefile-fpic.patch
new file mode 100644
index 00000000..09ad3403
--- /dev/null
+++ b/x11-drivers/synaptics/files/synaptics-0.14.4-r2-makefile-fpic.patch
@@ -0,0 +1,14 @@
+--- Makefile.orig 2005-12-15 16:07:36.000000000 -0500
++++ Makefile 2005-12-15 16:08:45.000000000 -0500
+@@ -62,9 +62,9 @@
+
+ CCOPTIONS := -pedantic -Wall -Wpointer-arith
+ CCOPTIONS += $(call check_gcc,-fno-merge-constants,)
+-CCOPTIONS += $(call check_gcc,-fno-pic,)
++CCOPTIONS += $(call check_gcc,)
+ CDEBUGFLAGS = -O2
+-CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES) -DVERSION="\"$(VERSION)\"" -DVERSION_ID="$(VERSION_ID)"
++CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES) -DVERSION="\"$(VERSION)\"" -DVERSION_ID="$(VERSION_ID)" -fPIC
+ CFLAGSCLIENT = $(CDEBUGFLAGS) $(CCOPTIONS) -DVERSION="\"$(VERSION)\"" -DVERSION_ID="$(VERSION_ID)" -I$(X_INCLUDES_ROOT)/include
+
+ CC = gcc
diff --git a/x11-drivers/synaptics/files/synaptics-0.14.4-r2-makefile.patch b/x11-drivers/synaptics/files/synaptics-0.14.4-r2-makefile.patch
new file mode 100644
index 00000000..ba385cd2
--- /dev/null
+++ b/x11-drivers/synaptics/files/synaptics-0.14.4-r2-makefile.patch
@@ -0,0 +1,16 @@
+--- Makefile.orig 2005-12-15 16:07:36.000000000 -0500
++++ Makefile 2005-12-15 16:08:45.000000000 -0500
+@@ -7,10 +7,10 @@
+ # Define the TOP variable to build using include files from a local source tree.
+ #TOP = /usr/src/redhat/BUILD/XFree86-4.3.0/xc
+
+-INSTALLED_X = $(DESTDIR)/usr/X11R6
++INSTALLED_X = $(DESTDIR)/usr
+ LOCAL_X = Xincludes/usr/X11R6
+-BINDIR = $(DESTDIR)/usr/local/bin
+-MANDIR = $(DESTDIR)/usr/local/man
++BINDIR = $(DESTDIR)/usr/bin
++MANDIR = $(DESTDIR)/usr/share/man
+
+ ifeq ($(ARCH),)
+ ARCH = $(shell /bin/arch)
diff --git a/x11-drivers/synaptics/files/synaptics-0.14.5-makefile-fpic.patch b/x11-drivers/synaptics/files/synaptics-0.14.5-makefile-fpic.patch
new file mode 100644
index 00000000..edd36662
--- /dev/null
+++ b/x11-drivers/synaptics/files/synaptics-0.14.5-makefile-fpic.patch
@@ -0,0 +1,11 @@
+--- Makefile.orig 2006-06-04 09:50:43.000000000 +0100
++++ Makefile 2006-06-04 09:50:53.000000000 +0100
+@@ -81,7 +81,7 @@
+ CCOPTIONS := -pedantic -Wall -Wpointer-arith
+ CCOPTIONS += $(call check_gcc,-fno-merge-constants,)
+ CDEBUGFLAGS = -O2
+-CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES) -DVERSION="\"$(VERSION)\"" -DVERSION_ID="$(VERSION_ID)"
++CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES) -DVERSION="\"$(VERSION)\"" -DVERSION_ID="$(VERSION_ID)" -fPIC
+ CFLAGSCLIENT = $(CDEBUGFLAGS) $(CCOPTIONS) -DVERSION="\"$(VERSION)\"" -DVERSION_ID="$(VERSION_ID)" -I$(X_INCLUDES_ROOT)/include
+
+ CC = gcc
diff --git a/x11-drivers/synaptics/files/synaptics-0.14.5-xorg-7.1-compile-fix.patch b/x11-drivers/synaptics/files/synaptics-0.14.5-xorg-7.1-compile-fix.patch
new file mode 100644
index 00000000..0c2d9d10
--- /dev/null
+++ b/x11-drivers/synaptics/files/synaptics-0.14.5-xorg-7.1-compile-fix.patch
@@ -0,0 +1,97 @@
+
+
+
+
+Fix compile errors when using Xorg 7.1.
+
+From: Peter Osterlund
+
+Initial patch from VMiklos . Somewhat
+modified by me.
+---
+
+ eventcomm.c | 5 +++++
+ ps2comm.h | 1 +
+ psmcomm.c | 2 ++
+ psmcomm.h | 1 +
+ synaptics.c | 1 +
+ synproto.h | 1 +
+ 6 files changed, 11 insertions(+), 0 deletions(-)
+
+diff --git a/eventcomm.c b/eventcomm.c
+index 6f6de7f..1b0f8bc 100644
+--- a/eventcomm.c
++++ b/eventcomm.c
+@@ -18,6 +18,11 @@
+ */
+
+ #include "eventcomm.h"
++#include
++#include
++#include
++#include
++#include
+ #include "synproto.h"
+ #include "synaptics.h"
+ #include
+diff --git a/ps2comm.h b/ps2comm.h
+index d6f0a25..4a1a051 100644
+--- a/ps2comm.h
++++ b/ps2comm.h
+@@ -1,6 +1,7 @@
+ #ifndef _PS2COMM_H_
+ #define _PS2COMM_H_
+
++#include
+ #include
+ #include "xf86_OSproc.h"
+
+diff --git a/psmcomm.c b/psmcomm.c
+index e4df42b..257ec13 100644
+--- a/psmcomm.c
++++ b/psmcomm.c
+@@ -29,6 +29,8 @@
+ */
+
+ #include "psmcomm.h"
++#include
++#include
+ #include "synproto.h"
+ #include "synaptics.h"
+ #include "ps2comm.h" /* ps2_print_ident() */
+diff --git a/psmcomm.h b/psmcomm.h
+index 6d64df6..a3162a2 100644
+--- a/psmcomm.h
++++ b/psmcomm.h
+@@ -1,6 +1,7 @@
+ #ifndef _PSMCOMM_H_
+ #define _PSMCOMM_H_
+
++#include
+ #include
+ #include "freebsd_mouse.h"
+
+diff --git a/synaptics.c b/synaptics.c
+index 2a17f81..63edebb 100644
+--- a/synaptics.c
++++ b/synaptics.c
+@@ -59,6 +59,7 @@
+ * Standard Headers
+ ****************************************************************************/
+
++#include
+ #include
+ #include
+ #include
+diff --git a/synproto.h b/synproto.h
+index 8562a75..ecc4357 100644
+--- a/synproto.h
++++ b/synproto.h
+@@ -19,6 +19,7 @@
+ #ifndef _SYNPROTO_H_
+ #define _SYNPROTO_H_
+
++#include
+ #include
+ #include
+ #include
diff --git a/x11-drivers/synaptics/files/synaptics-0.14.6-configurable_polling_interval.patch b/x11-drivers/synaptics/files/synaptics-0.14.6-configurable_polling_interval.patch
new file mode 100644
index 00000000..8c6ea279
--- /dev/null
+++ b/x11-drivers/synaptics/files/synaptics-0.14.6-configurable_polling_interval.patch
@@ -0,0 +1,58 @@
+--- ./syndaemon.c 2006-04-16 21:31:43.000000000 +0200
++++ ./syndaemon.c 2007-10-16 13:40:02.000000000 +0200
+@@ -43,9 +43,11 @@
+ static void
+ usage()
+ {
+- fprintf(stderr, "Usage: syndaemon [-i idle-time] [-d] [-t] [-k]\n");
++ fprintf(stderr, "Usage: syndaemon [-i idle-time] [-m poll-delay] [-d] [-t] [-k]\n");
+ fprintf(stderr, " -i How many seconds to wait after the last key press before\n");
+ fprintf(stderr, " enabling the touchpad. (default is 2.0s)\n");
++ fprintf(stderr, " -m How many milli-seconds to wait until next poll.\n");
++ fprintf(stderr, " (default is 20ms)\n");
+ fprintf(stderr, " -d Start as a daemon, ie in the background.\n");
+ fprintf(stderr, " -p Create a pid file with the specified name.\n");
+ fprintf(stderr, " -t Only disable tapping and scrolling, not mouse movements.\n");
+@@ -159,9 +161,8 @@
+ }
+
+ static void
+-main_loop(Display *display, double idle_time)
++main_loop(Display *display, double idle_time, int poll_delay)
+ {
+- const int poll_delay = 20000; /* 20 ms */
+ double last_activity = 0.0;
+ double current_time;
+
+@@ -228,17 +229,21 @@
+ main(int argc, char *argv[])
+ {
+ double idle_time = 2.0;
++ int poll_delay = 20000; /* 20 ms */
+ Display *display;
+ int c;
+ int shmid;
+ int ignore_modifier_keys = 0;
+
+ /* Parse command line parameters */
+- while ((c = getopt(argc, argv, "i:dtp:kK?")) != EOF) {
++ while ((c = getopt(argc, argv, "i:m:dtp:kK?")) != EOF) {
+ switch(c) {
+ case 'i':
+ idle_time = atof(optarg);
+ break;
++ case 'm':
++ poll_delay = atoi(optarg) * 1000;
++ break;
+ case 'd':
+ background = 1;
+ break;
+@@ -314,7 +319,7 @@
+ setup_keyboard_mask(display, ignore_modifier_keys);
+
+ /* Run the main loop */
+- main_loop(display, idle_time);
++ main_loop(display, idle_time, poll_delay);
+
+ return 0;
+ }
diff --git a/x11-drivers/synaptics/files/synaptics-0.14.6_p20070706-fixeventgrab.patch b/x11-drivers/synaptics/files/synaptics-0.14.6_p20070706-fixeventgrab.patch
new file mode 100644
index 00000000..6ed8e68f
--- /dev/null
+++ b/x11-drivers/synaptics/files/synaptics-0.14.6_p20070706-fixeventgrab.patch
@@ -0,0 +1,82 @@
+diff -urN synaptics-0.14.6_p20070706.orig/eventcomm.c synaptics-0.14.6_p20070706/eventcomm.c
+--- synaptics-0.14.6_p20070706.orig/eventcomm.c 2008-08-29 09:34:11.000000000 +0200
++++ synaptics-0.14.6_p20070706/eventcomm.c 2008-08-29 10:23:04.000000000 +0200
+@@ -41,17 +41,25 @@
+ * Function Definitions
+ ****************************************************************************/
+
+-static void
++static Bool
++grab_event_device(int fd)
++{
++ int ret;
++ SYSCALL(ret = ioctl(fd, EVIOCGRAB, (pointer)1));
++ return !(ret < 0);
++}
++
++static Bool
+ EventDeviceOnHook(LocalDevicePtr local, SynapticsSHM *para)
+ {
+ if (para->grab_event_device) {
+ /* Try to grab the event device so that data don't leak to /dev/input/mice */
+- int ret;
+- SYSCALL(ret = ioctl(local->fd, EVIOCGRAB, (pointer)1));
+- if (ret < 0) {
++ if(!grab_event_device(local->fd)) {
+ xf86Msg(X_WARNING, "%s can't grab event device, errno=%d\n",
+ local->name, errno);
++ return FALSE;
+ }
++ return TRUE;
+ }
+ }
+
+@@ -273,6 +281,7 @@
+ char fname[64];
+ int fd = -1;
+ Bool is_touchpad;
++ Bool is_grabbable;
+
+ sprintf(fname, "%s/%s%d", DEV_INPUT_EVENT, EVENT_DEV_NAME, i);
+ SYSCALL(fd = open(fname, O_RDONLY));
+@@ -289,7 +298,14 @@
+ noent_cnt = 0;
+ have_evdev = TRUE;
+ is_touchpad = event_query_is_touchpad(fd);
+- if (is_touchpad) {
++ /**
++ * Check whether device can be grabbed. This means there is a race
++ * condition with EventDeviceOnHook, which can't be solved cleanly
++ * the way things are done with the current design. One possible
++ * solution would be to keep the file descriptor open.
++ */
++ is_grabbable = grab_event_device(fd);
++ if (is_touchpad && is_grabbable) {
+ xf86Msg(X_PROBED, "%s auto-dev sets device to %s\n",
+ local->name, fname);
+ xf86ReplaceStrOption(local->options, "Device", fname);
+diff -urN synaptics-0.14.6_p20070706.orig/synaptics.c synaptics-0.14.6_p20070706/synaptics.c
+--- synaptics-0.14.6_p20070706.orig/synaptics.c 2008-08-29 09:34:11.000000000 +0200
++++ synaptics-0.14.6_p20070706/synaptics.c 2008-08-29 10:26:01.000000000 +0200
+@@ -595,7 +595,8 @@
+ return !Success;
+ }
+
+- priv->proto_ops->DeviceOnHook(local, priv->synpara);
++ if(!priv->proto_ops->DeviceOnHook(local, priv->synpara))
++ return !Success;
+
+ priv->comm.buffer = XisbNew(local->fd, 64);
+ if (!priv->comm.buffer) {
+diff -urN synaptics-0.14.6_p20070706.orig/synproto.h synaptics-0.14.6_p20070706/synproto.h
+--- synaptics-0.14.6_p20070706.orig/synproto.h 2008-08-29 09:34:11.000000000 +0200
++++ synaptics-0.14.6_p20070706/synproto.h 2008-08-29 10:28:34.000000000 +0200
+@@ -77,7 +77,7 @@
+ struct CommData;
+
+ struct SynapticsProtocolOperations {
+- void (*DeviceOnHook)(LocalDevicePtr local, struct _SynapticsSHM *para);
++ Bool (*DeviceOnHook)(LocalDevicePtr local, struct _SynapticsSHM *para);
+ void (*DeviceOffHook)(LocalDevicePtr local);
+ Bool (*QueryHardware)(LocalDevicePtr local, struct SynapticsHwInfo *synhw);
+ Bool (*ReadHwState)(LocalDevicePtr local, struct SynapticsHwInfo *synhw,
diff --git a/x11-drivers/synaptics/files/synaptics-0.14.6_p20070706-input_api.patch b/x11-drivers/synaptics/files/synaptics-0.14.6_p20070706-input_api.patch
new file mode 100644
index 00000000..036147a4
--- /dev/null
+++ b/x11-drivers/synaptics/files/synaptics-0.14.6_p20070706-input_api.patch
@@ -0,0 +1,15 @@
+diff -urN synaptics-0.14.6_p20070706.orig/Makefile synaptics-0.14.6_p20070706/Makefile
+--- synaptics-0.14.6_p20070706.orig/Makefile 2008-08-29 09:34:11.000000000 +0200
++++ synaptics-0.14.6_p20070706/Makefile 2008-08-29 10:40:29.000000000 +0200
+@@ -34,10 +34,9 @@
+ LDCOMBINEFLAGS = -shared -lc
+ PICFLAG = $(call check_gcc,-fPIC,)
+ X_INCLUDES_ROOT = $(INSTALLED_X)
+- SDKDIR = $(shell pkg-config xorg-server --variable=sdkdir)
+ ALLINCLUDES = -I. -I$(INSTALLED_X)/include/X11 \
+ -I$(INSTALLED_X)/include/X11/extensions \
+- -I$(SDKDIR)
++ `pkg-config xorg-server --cflags`
+ else
+ INSTALLED_X = /usr/X11R6
+ INPUT_MODULE_DIR = $(DESTDIR)/$(INSTALLED_X)/$(LIBDIR)/modules/input
diff --git a/x11-drivers/synaptics/files/synaptics-0.14.x-gcc4-the-sentinels-have-attacked.patch b/x11-drivers/synaptics/files/synaptics-0.14.x-gcc4-the-sentinels-have-attacked.patch
new file mode 100644
index 00000000..c8d34ef6
--- /dev/null
+++ b/x11-drivers/synaptics/files/synaptics-0.14.x-gcc4-the-sentinels-have-attacked.patch
@@ -0,0 +1,16 @@
+--- Xincludes/usr/X11R6/include/X11/Xfuncproto.h.orig 2005-07-02 12:50:40.000000000 +0200
++++ Xincludes/usr/X11R6/include/X11/Xfuncproto.h 2005-07-25 08:13:46.000000000 +0200
+@@ -69,4 +69,12 @@
+ #endif
+ #endif /* _XFUNCPROTOBEGIN */
+
++#if defined(__GNUC__) && (__GNUC__ >= 4)
++# define _X_SENTINEL(x) __attribute__ ((__sentinel__(x)))
++# define _X_ATTRIBUTE_PRINTF(x,y) __attribute__((__format__(__printf__,x,y)))
++#else
++# define _X_SENTINEL(x)
++# define _X_ATTRIBUTE_PRINTF(x,y)
++#endif /* GNUC >= 4 */
++
+ #endif /* _XFUNCPROTO_H_ */
+
diff --git a/x11-drivers/synaptics/files/synaptics-fix-xf86_ansic.h.patch b/x11-drivers/synaptics/files/synaptics-fix-xf86_ansic.h.patch
new file mode 100644
index 00000000..69803772
--- /dev/null
+++ b/x11-drivers/synaptics/files/synaptics-fix-xf86_ansic.h.patch
@@ -0,0 +1,131 @@
+diff -Nur synaptics-0.14.6-org/synaptics.c synaptics-0.14.6-patched/synaptics.c
+--- synaptics-0.14.6-org/synaptics.c 2006-07-15 17:54:29.000000000 +0200
++++ synaptics-0.14.6-patched/synaptics.c 2008-06-28 17:52:54.000000000 +0200
+@@ -61,10 +61,18 @@
+
+ #include
+ #include
++#include
++#include
++#include
++#include
++#include
++#include
++#include
++#include
++#include
+ #include
+ #include
+ #define NEED_XF86_TYPES
+-#include
+ #include
+ #include
+ #include "mipointer.h"
+@@ -224,14 +232,14 @@
+ return TRUE; /* Already allocated */
+
+ if (priv->shm_config) {
+- if ((shmid = xf86shmget(SHM_SYNAPTICS, 0, 0)) != -1)
+- xf86shmctl(shmid, XF86IPC_RMID, NULL);
+- if ((shmid = xf86shmget(SHM_SYNAPTICS, sizeof(SynapticsSHM),
+- 0777 | XF86IPC_CREAT)) == -1) {
++ if ((shmid = shmget(SHM_SYNAPTICS, 0, 0)) != -1)
++ shmctl(shmid, IPC_RMID, NULL);
++ if ((shmid = shmget(SHM_SYNAPTICS, sizeof(SynapticsSHM),
++ 0777 | IPC_CREAT)) == -1) {
+ xf86Msg(X_ERROR, "%s error shmget\n", local->name);
+ return FALSE;
+ }
+- if ((priv->synpara = (SynapticsSHM*)xf86shmat(shmid, NULL, 0)) == NULL) {
++ if ((priv->synpara = (SynapticsSHM*)shmat(shmid, NULL, 0)) == NULL) {
+ xf86Msg(X_ERROR, "%s error shmat\n", local->name);
+ return FALSE;
+ }
+@@ -257,8 +265,8 @@
+ return;
+
+ if (priv->shm_config) {
+- if ((shmid = xf86shmget(SHM_SYNAPTICS, 0, 0)) != -1)
+- xf86shmctl(shmid, XF86IPC_RMID, NULL);
++ if ((shmid = shmget(SHM_SYNAPTICS, 0, 0)) != -1)
++ shmctl(shmid, IPC_RMID, NULL);
+ } else {
+ xfree(priv->synpara);
+ }
+@@ -272,7 +280,7 @@
+ char *str_par;
+ double value;
+ str_par = xf86FindOptionValue(options, optname);
+- if ((!str_par) || (xf86sscanf(str_par, "%lf", &value) != 1))
++ if ((!str_par) || (sscanf(str_par, "%lf", &value) != 1))
+ return default_value;
+ return value;
+ }
+@@ -437,8 +445,8 @@
+ priv->fifofd = -1;
+ if (repeater) {
+ /* create repeater fifo */
+- if ((xf86mknod(repeater, 666, XF86_S_IFIFO) != 0) &&
+- (xf86errno != xf86_EEXIST)) {
++ if ((mknod(repeater, 666, S_IFIFO) != 0) &&
++ (errno != EEXIST)) {
+ xf86Msg(X_ERROR, "%s can't create repeater fifo\n", local->name);
+ } else {
+ /* open the repeater fifo */
+@@ -447,7 +455,7 @@
+ xf86Msg(X_ERROR, "%s repeater device open failed\n", local->name);
+ }
+ }
+- xf86free(repeater);
++ free(repeater);
+ }
+
+ if (!QueryHardware(local)) {
+@@ -634,7 +642,7 @@
+ static int
+ move_distance(int dx, int dy)
+ {
+- return xf86sqrt(SQR(dx) + SQR(dy));
++ return sqrt(SQR(dx) + SQR(dy));
+ }
+
+ /*
+@@ -669,14 +677,14 @@
+ double xCenter = (priv->synpara->left_edge + priv->synpara->right_edge) / 2.0;
+ double yCenter = (priv->synpara->top_edge + priv->synpara->bottom_edge) / 2.0;
+
+- return xf86atan2(-(y - yCenter), x - xCenter);
++ return atan2(-(y - yCenter), x - xCenter);
+ }
+
+ /* return angle difference */
+ static double
+ diffa(double a1, double a2)
+ {
+- double da = xf86fmod(a2 - a1, 2 * M_PI);
++ double da = fmod(a2 - a1, 2 * M_PI);
+ if (da < 0)
+ da += 2 * M_PI;
+ if (da > M_PI)
+@@ -784,7 +792,7 @@
+ int c;
+ while ((c = XisbRead(priv->comm.buffer)) >= 0) {
+ unsigned char u = (unsigned char)c;
+- xf86write(priv->fifofd, &u, 1);
++ write(priv->fifofd, &u, 1);
+ if (++count >= 3)
+ break;
+ }
+@@ -1280,10 +1288,10 @@
+
+ /* save the fraction, report the integer part */
+ tmpf = dx * speed + x_edge_speed * dtime + priv->frac_x;
+- priv->frac_x = xf86modf(tmpf, &integral);
++ priv->frac_x = modf(tmpf, &integral);
+ dx = integral;
+ tmpf = dy * speed + y_edge_speed * dtime + priv->frac_y;
+- priv->frac_y = xf86modf(tmpf, &integral);
++ priv->frac_y = modf(tmpf, &integral);
+ dy = integral;
+ }
+
diff --git a/x11-drivers/synaptics/files/synaptics-fix-xinerama.patch b/x11-drivers/synaptics/files/synaptics-fix-xinerama.patch
new file mode 100644
index 00000000..7d97af69
--- /dev/null
+++ b/x11-drivers/synaptics/files/synaptics-fix-xinerama.patch
@@ -0,0 +1,16 @@
+--- synaptics-0.14.6.orig/synaptics.c 2008-01-18 23:32:59.000000000 -0500
++++ synaptics-0.14.6/synaptics.c 2008-01-18 23:32:15.000000000 -0500
+@@ -617,10 +617,10 @@
+ miPointerGetMotionBufferSize());
+
+ /* X valuator */
+- xf86InitValuatorAxisStruct(dev, 0, 0, -1, 1, 0, 1);
++ xf86InitValuatorAxisStruct(dev, 0, -1, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(dev, 0);
+ /* Y valuator */
+- xf86InitValuatorAxisStruct(dev, 1, 0, -1, 1, 0, 1);
++ xf86InitValuatorAxisStruct(dev, 1, -1, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(dev, 1);
+
+ xf86MotionHistoryAllocate(local);
+
diff --git a/x11-drivers/synaptics/files/synaptics-fixeventgrab.diff b/x11-drivers/synaptics/files/synaptics-fixeventgrab.diff
new file mode 100644
index 00000000..8a93988e
--- /dev/null
+++ b/x11-drivers/synaptics/files/synaptics-fixeventgrab.diff
@@ -0,0 +1,83 @@
+diff -urN synaptics-0.14.6.orig/eventcomm.c synaptics-0.14.6/eventcomm.c
+--- synaptics-0.14.6.orig/eventcomm.c 2006-07-15 17:54:29.000000000 +0200
++++ synaptics-0.14.6/eventcomm.c 2008-01-06 23:44:09.000000000 +0100
+@@ -40,16 +40,24 @@
+ * Function Definitions
+ ****************************************************************************/
+
+-static void
++static Bool
++grab_event_device(int fd)
++{
++ int ret;
++ SYSCALL(ret = ioctl(fd, EVIOCGRAB, (pointer)1));
++ return !(ret < 0);
++}
++
++static Bool
+ EventDeviceOnHook(LocalDevicePtr local)
+ {
+ /* Try to grab the event device so that data don't leak to /dev/input/mice */
+- int ret;
+- SYSCALL(ret = ioctl(local->fd, EVIOCGRAB, (pointer)1));
+- if (ret < 0) {
++ if(!grab_event_device(local->fd)) {
+ xf86Msg(X_WARNING, "%s can't grab event device, errno=%d\n",
+ local->name, errno);
++ return FALSE;
+ }
++ return TRUE;
+ }
+
+ static void
+@@ -247,6 +255,7 @@
+ char fname[64];
+ int fd = -1;
+ Bool is_touchpad;
++ Bool is_grabbable;
+
+ sprintf(fname, "%s/%s%d", DEV_INPUT_EVENT, EVENT_DEV_NAME, i);
+ SYSCALL(fd = open(fname, O_RDONLY));
+@@ -263,8 +272,16 @@
+ noent_cnt = 0;
+ have_evdev = TRUE;
+ is_touchpad = event_query_is_touchpad(fd);
++ /**
++ * Check whether device can be grabbed. This means there is a race
++ * condition with EventDeviceOnHook, which can't be solved cleanly
++ * the way things are done with the current design. One possible
++ * solution would be to keep the file descriptor open.
++ */
++ is_grabbable = grab_event_device(fd);
++
+ SYSCALL(close(fd));
+- if (is_touchpad) {
++ if (is_touchpad && is_grabbable) {
+ xf86Msg(X_PROBED, "%s auto-dev sets device to %s\n",
+ local->name, fname);
+ xf86ReplaceStrOption(local->options, "Device", fname);
+diff -urN synaptics-0.14.6.orig/synaptics.c synaptics-0.14.6/synaptics.c
+--- synaptics-0.14.6.orig/synaptics.c 2006-07-15 17:54:29.000000000 +0200
++++ synaptics-0.14.6/synaptics.c 2008-01-06 23:03:26.000000000 +0100
+@@ -543,7 +543,8 @@
+ return !Success;
+ }
+
+- priv->proto_ops->DeviceOnHook(local);
++ if(!priv->proto_ops->DeviceOnHook(local))
++ return !Success;
+
+ priv->comm.buffer = XisbNew(local->fd, 64);
+ if (!priv->comm.buffer) {
+diff -urN synaptics-0.14.6.orig/synproto.h synaptics-0.14.6/synproto.h
+--- synaptics-0.14.6.orig/synproto.h 2006-07-09 18:53:02.000000000 +0200
++++ synaptics-0.14.6/synproto.h 2008-01-06 22:31:19.000000000 +0100
+@@ -76,7 +76,7 @@
+ struct CommData;
+
+ struct SynapticsProtocolOperations {
+- void (*DeviceOnHook)(LocalDevicePtr local);
++ Bool (*DeviceOnHook)(LocalDevicePtr local);
+ void (*DeviceOffHook)(LocalDevicePtr local);
+ Bool (*QueryHardware)(LocalDevicePtr local, struct SynapticsHwInfo *synhw);
+ Bool (*ReadHwState)(LocalDevicePtr local, struct SynapticsHwInfo *synhw,
diff --git a/x11-drivers/synaptics/files/synaptics-install-so-exec.patch b/x11-drivers/synaptics/files/synaptics-install-so-exec.patch
new file mode 100644
index 00000000..c71f4d51
--- /dev/null
+++ b/x11-drivers/synaptics/files/synaptics-install-so-exec.patch
@@ -0,0 +1,11 @@
+--- synaptics-0.14.6/Makefile.orig 2008-04-01 16:10:04.000000000 -0400
++++ synaptics-0.14.6/Makefile 2008-04-01 16:10:23.000000000 -0400
+@@ -115,7 +115,7 @@
+ install -D $< $@
+
+ $(INPUT_MODULE_DIR)/$(SYNAPTICS_DRV) : $(SYNAPTICS_DRV)
+- install --mode=0644 -D $< $@
++ install --mode=0755 -D $< $@
+
+ $(SYNAPTICS_DRV): $(OBJS)
+ $(RM) $@
diff --git a/x11-drivers/synaptics/files/synaptics_input_api.diff b/x11-drivers/synaptics/files/synaptics_input_api.diff
new file mode 100644
index 00000000..f43cf0b3
--- /dev/null
+++ b/x11-drivers/synaptics/files/synaptics_input_api.diff
@@ -0,0 +1,62 @@
+diff -u synaptics-0.14.6.orig/Makefile synaptics-0.14.6/Makefile
+--- synaptics-0.14.6.orig/Makefile 2006-07-15 17:58:26.000000000 +0200
++++ synaptics-0.14.6/Makefile 2007-09-07 15:03:17.386179198 +0200
+@@ -34,10 +34,9 @@
+ LDCOMBINEFLAGS = -shared -lc
+ PICFLAG = $(call check_gcc,-fPIC,)
+ X_INCLUDES_ROOT = $(INSTALLED_X)
+- SDKDIR = $(shell pkg-config xorg-server --variable=sdkdir)
+ ALLINCLUDES = -I. -I$(INSTALLED_X)/include/X11 \
+ -I$(INSTALLED_X)/include/X11/extensions \
+- -I$(SDKDIR)
++ `pkg-config xorg-server --cflags`
+ else
+ INSTALLED_X = /usr/X11R6
+ INPUT_MODULE_DIR = $(DESTDIR)/$(INSTALLED_X)/$(LIBDIR)/modules/input
+diff -u synaptics-0.14.6.orig/synaptics.c synaptics-0.14.6/synaptics.c
+--- synaptics-0.14.6.orig/synaptics.c 2006-07-15 17:54:29.000000000 +0200
++++ synaptics-0.14.6/synaptics.c 2007-09-07 15:10:24.910542275 +0200
+@@ -321,7 +321,9 @@
+ local->private_flags = 0;
+ local->flags = XI86_POINTER_CAPABLE | XI86_SEND_DRAG_EVENTS;
+ local->conf_idev = dev;
++#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) == 0
+ local->motion_history_proc = xf86GetMotionEvents;
++#endif
+ local->history_size = 0;
+ local->always_core_feedback = 0;
+
+@@ -613,8 +615,17 @@
+
+ InitPointerDeviceStruct((DevicePtr)dev, map,
+ SYN_MAX_BUTTONS,
+- miPointerGetMotionEvents, SynapticsCtrl,
++#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) == 0
++ miPointerGetMotionEvents,
++#else
++ GetMotionHistory,
++#endif
++ SynapticsCtrl,
++#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) == 0
+ miPointerGetMotionBufferSize());
++#else
++ GetMotionHistorySize(), 2);
++#endif
+
+ /* X valuator */
+ xf86InitValuatorAxisStruct(dev, 0, 0, -1, 1, 0, 1);
+diff -u synaptics-0.14.6.orig/synaptics.h synaptics-0.14.6/synaptics.h
+--- synaptics-0.14.6.orig/synaptics.h 2006-07-15 17:54:29.000000000 +0200
++++ synaptics-0.14.6/synaptics.h 2007-09-07 15:10:12.409829887 +0200
+@@ -226,5 +226,11 @@
+
+ #endif /* SYNAPTICS_PRIVATE */
+
++/* Previously found in xf86Xinput.h */
++#ifdef DBG
++#undef DBG
++#endif
++
++#define DBG(lvl, f) {if ((lvl) <= xf86GetVerbosity()) f;}
+
+ #endif /* _SYNAPTICS_H_ */
diff --git a/x11-drivers/synaptics/synaptics-0.14.6_p20070706-r2.ebuild b/x11-drivers/synaptics/synaptics-0.14.6_p20070706-r2.ebuild
new file mode 100644
index 00000000..a3a513e9
--- /dev/null
+++ b/x11-drivers/synaptics/synaptics-0.14.6_p20070706-r2.ebuild
@@ -0,0 +1,104 @@
+# Copyright 1999-2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/x11-drivers/synaptics/synaptics-0.14.6_p20070706-r1.ebuild,v 1.1 2008/08/30 22:33:17 calchan Exp $
+
+inherit toolchain-funcs eutils linux-info
+
+IUSE="hal"
+
+DESCRIPTION="Driver for Synaptics touchpads"
+HOMEPAGE="http://w1.894.telia.com/~u89404340/touchpad/"
+SRC_URI="http://dev.gentoo.org/~calchan/distfiles/${P}.tar.bz2"
+
+SLOT="0"
+LICENSE="GPL-2"
+KEYWORDS="~amd64 ~ppc ~ppc64 ~x86"
+
+RDEPEND="x11-libs/libXext
+ hal? ( sys-apps/hal )"
+DEPEND="${RDEPEND}
+ x11-base/xorg-server
+ x11-proto/inputproto
+ >=sys-apps/sed-4"
+
+evdev-input_check() {
+ # Check kernel config for required event interface support (either
+ # built-in or as a module. Bug #134309.
+
+ ebegin "Checking kernel config for event device support"
+ linux_chkconfig_present INPUT_EVDEV
+ eend $?
+
+ if [[ $? -ne 0 ]] ; then
+ ewarn "Synaptics driver requires event interface support."
+ ewarn "Please enable the event interface in your kernel config."
+ ewarn "The option can be found at:"
+ ewarn
+ ewarn " Device Drivers"
+ ewarn " Input device support"
+ ewarn " -*- Generic input layer"
+ ewarn " <*> Event interface"
+ ewarn
+ ewarn "Then rebuild the kernel or install the module."
+ epause 5
+ fi
+}
+
+pkg_setup() {
+ linux-info_pkg_setup
+ evdev-input_check
+}
+
+src_unpack() {
+ unpack ${A} ; cd "${S}"
+
+ # Switch up the CC, CFLAGS and LDFLAGS stuff.
+ sed -i \
+ -e "s:CC = gcc:CC = $(tc-getCC) ${CFLAGS} ${LDFLAGS}:g" \
+ -e "/CC = / a\
+LD = \$(CC)" \
+ -e "s:\$(CDEBUGFLAGS)::g" \
+ "${S}"/Makefile
+
+ # Fix grabbing of event devices so it will not stop working together with
+ # packages which grab their devices at their own like sys-apps/inputd does.
+ epatch "${FILESDIR}"/${P}-fixeventgrab.patch
+
+ epatch "${FILESDIR}"/${P}-input_api.patch
+
+ # Patch the Makefile to install the library as executable. Bug #215323.
+ epatch "${FILESDIR}"/synaptics-install-so-exec.patch
+
+ # Fix to handle multiple screens through Xinerama properly. Bug #206614.
+ epatch "${FILESDIR}"/synaptics-fix-xinerama.patch
+
+ # Adds configurable polling interval. Patch from Novell. Bug #216679.
+ epatch "${FILESDIR}"/${PN}-0.14.6-configurable_polling_interval.patch
+
+ epatch "${FILESDIR}"/synaptics-fix-xf86_ansic.h.patch
+}
+
+src_compile() {
+ emake || die
+}
+
+src_install() {
+ make \
+ DESTDIR="${D}" \
+ PREFIX=/usr \
+ MANDIR="${D}"/usr/share/man \
+ install || die
+
+ dodoc script/usbmouse script/usbhid alps.patch trouble-shooting.txt
+ dodoc COMPATIBILITY FILES INSTALL* NEWS TODO README*
+
+ # Stupid new daemon, didn't work for me because of shm issues
+ newinitd "${FILESDIR}"/rc.init syndaemon
+ newconfd "${FILESDIR}"/rc.conf syndaemon
+
+ if use hal ; then
+ # Have HAL assign this driver to supported touchpads.
+ insinto /usr/share/hal/fdi/policy/10osvendor
+ doins "${FILESDIR}"/11-x11-synaptics.fdi
+ fi
+}