diff -urN links-2.8.org/acconfig.h links-2.8/acconfig.h
--- links-2.8.org/acconfig.h	2013-08-03 18:22:59.028311552 +0200
+++ links-2.8/acconfig.h	2013-12-12 20:39:35.528744448 +0100
@@ -179,6 +179,9 @@
 #undef GRDRV_ATHEOS
 
 /* */
+#undef GRDRV_HAIKU
+
+/* */
 #undef GRDRV_GRX
 
 /* */
diff -urN links-2.8.org/beos.c links-2.8/beos.c
--- links-2.8.org/beos.c	2013-01-23 05:52:02.030670848 +0100
+++ links-2.8/beos.c	2013-12-12 19:10:01.005242880 +0100
@@ -3,7 +3,7 @@
  * This file is a part of the Links program, released under GPL
  */
 
-#if defined(__BEOS__) || defined(__HAIKU__)
+#if defined(__BEOS__)
 
 #include "com-defs.h"
 
diff -urN links-2.8.org/configure.in links-2.8/configure.in
--- links-2.8.org/configure.in	2013-09-17 02:11:46.046137344 +0200
+++ links-2.8/configure.in	2013-12-13 00:05:02.135004160 +0100
@@ -13,7 +13,7 @@
 AUTOHEADER="./missing autoheader"
 image_formats="GIF PNG XBM"
 
-AM_CONFIG_HEADER(config.h)
+AC_CONFIG_HEADER(config.h)
 
 dnl Checks for programs.
 AC_PROG_CC
@@ -577,10 +577,10 @@
 
 AC_CHECK_FUNC(socket, cf_result=yes, cf_result=no)
 if test "$cf_result" = no; then
-	AC_CHECK_LIB(socket, socket)
-	if test "$ac_cv_lib_socket_socket" = no; then
-		AC_CHECK_LIB(network, socket)
-		if test "$ac_cv_lib_network_socket" = no; then
+	AC_CHECK_LIB(network, socket)
+	if test "$ac_cv_lib_network_socket" = no; then
+		AC_CHECK_LIB(socket, socket)
+		if test "$ac_cv_lib_socket_socket" = no; then
 			AC_CHECK_LIB(watt, socket)
 			if test "$ac_cv_lib_watt_socket" = no; then
 				AC_ERROR([socket function not present])
@@ -722,6 +722,7 @@
 	AC_DEFINE(HAVE_BEGINTHREAD)
 fi
 AC_CHECK_HEADERS(atheos/threads.h)
+AC_CHECK_HEADERS(kernel/OS.h)
 AC_HAVE_FUNCS(spawn_thread)
 AC_HAVE_FUNCS(resume_thread)
 
@@ -876,6 +877,7 @@
 
 
 cf_have_atheos=no
+cf_have_haiku=no
 
 if test "$cf_use_graphics" != no; then
 	AC_DEFINE(G)
@@ -888,6 +890,7 @@
 AC_ARG_WITH(pmshell, [  --without-pmshell       compile without PMShell graphics driver],[if test "$withval" = no; then disable_pmshell=yes; else disable_pmshell=no; fi])
 AC_ARG_WITH(windows, [  --without-windows       compile without Windows graphics driver],[if test "$withval" = no; then disable_windows=yes; else disable_windows=no; fi])
 AC_ARG_WITH(atheos, [  --without-atheos        compile without Atheos graphics driver],[if test "$withval" = no; then disable_atheos=yes; else disable_atheos; fi])
+AC_ARG_WITH(haiku, [  --without-haiku         compile without Haiku/BeOS graphics driver],[if test "$withval" = no; then disable_haiku=yes; else disable_haiku=no; fi])
 AC_ARG_WITH(grx, [  --without-grx           compile without DOS GRX graphics driver],[if test "$withval" = no; then disable_grx=yes; else disable_grx; fi])
 
 	drivers=""
@@ -1124,6 +1127,31 @@
 	fi
 fi
 
+if test "$disable_haiku" != yes ; then
+	old_ext="$ac_ext"
+	ac_ext=cpp
+	AC_CHECK_HEADERS(interface/View.h)
+	AC_CHECK_HEADERS(interface/Window.h)
+	AC_CHECK_HEADERS(interface/Screen.h)
+	AC_CHECK_HEADERS(interface/Bitmap.h)
+	AC_CHECK_HEADERS(support/Locker.h)
+	AC_CHECK_HEADERS(app/Application.h)
+	ac_ext="$old_ext"
+
+	if test "$ac_cv_header_kernel_OS_h" = yes &&
+	   test "$ac_cv_header_interface_View_h" = yes &&
+	   test "$ac_cv_header_interface_Window_h" = yes &&
+	   test "$ac_cv_header_interface_Screen_h" = yes &&
+	   test "$ac_cv_header_interface_Bitmap_h" = yes &&
+	   test "$ac_cv_header_support_Locker_h" = yes &&
+	   test "$ac_cv_header_app_Application_h" = yes; then
+		AC_PROG_CXX
+		AC_DEFINE(GRDRV_HAIKU)
+		drivers="$drivers HAIKU"
+		cf_have_haiku=yes
+	fi
+fi
+
 if test "$disable_grx" != yes -a "$ac_cv_have_djgpp" = yes; then
 	LIBS_X="$LIBS"
 	AC_CHECK_HEADERS(grx20.h)
@@ -1230,6 +1258,7 @@
 
 
 AM_CONDITIONAL(ATHEOS_GR, test "$cf_have_atheos" = yes)
+AM_CONDITIONAL(HAIKU_GR, test "$cf_have_haiku" = yes)
 
 test "$ac_cv_have_emx" = yes && LDFLAGS="$LDFLAGS -Zexe"
 
diff -urN links-2.8.org/drivers.c links-2.8/drivers.c
--- links-2.8.org/drivers.c	2013-08-12 23:15:36.026214400 +0200
+++ links-2.8/drivers.c	2013-12-12 20:42:12.595329024 +0100
@@ -31,6 +31,9 @@
 #ifdef GRDRV_ATHEOS
 extern struct graphics_driver atheos_driver;
 #endif
+#ifdef GRDRV_HAIKU
+extern struct graphics_driver haiku_driver;
+#endif
 #ifdef GRDRV_GRX
 extern struct graphics_driver grx_driver;
 #endif
@@ -51,6 +54,9 @@
 #ifdef GRDRV_ATHEOS
 	&atheos_driver,
 #endif
+#ifdef GRDRV_HAIKU
+	&haiku_driver,
+#endif
 #ifndef SPAD
 #ifdef GRDRV_X
 	&x_driver,
diff -urN links-2.8.org/haiku.cpp links-2.8/haiku.cpp
--- links-2.8.org/haiku.cpp	1970-01-01 01:00:00.000000000 +0100
+++ links-2.8/haiku.cpp	2013-12-13 00:23:09.939786240 +0100
@@ -0,0 +1,890 @@
+/* haiku.cpp
+ * (c) 2007 François Revol
+ * This file is a part of the Links program, released under GPL
+ */
+
+#if defined __BEOS__ || defined __HAIKU__
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <kernel/OS.h>
+
+/*
+ * GUI code
+ */
+
+/*
+ * TODO:
+ * - BeOS doesn't handle BView::DrawBitmap() with RGB24, and links doesn't seem to handle RGB32,
+ *   so the colorspace is forced into 16bpp for now.
+ * - more paste handling ?
+ * - more DnD (maybe check if in menu or not and prepend "g" ?)
+ * - handle DnD of Net+ bookmarks
+ */
+
+extern "C" {
+#include "cfg.h"
+}
+
+#ifdef GRDRV_HAIKU
+
+extern "C" {
+#include "links.h"
+}
+#undef B_ENTER
+
+#include <app/Application.h>
+#include <app/Clipboard.h>
+#include <interface/Bitmap.h>
+#include <interface/Region.h>
+#include <interface/Screen.h>
+#include <interface/View.h>
+#include <interface/Window.h>
+#include <storage/Entry.h>
+#include <storage/File.h>
+#include <storage/Path.h>
+#include <support/Locker.h>
+#include <support/String.h>
+
+//#define DBG(l...) fprintf(stderr, l);
+#define DBG(l...) {}
+
+/*
+#ifdef debug
+#undef debug
+#endif
+#define debug(x)
+#define fprintf(x, y)
+*/
+
+extern "C" struct graphics_driver haiku_driver;
+
+class LinksApplication : public BApplication {
+	public:
+	LinksApplication():BApplication("application/x-vnd.links"){}
+	virtual void RefsReceived(BMessage *message);
+	virtual bool QuitRequested();
+};
+
+class LinksView;
+
+class LinksWindow : public BWindow {
+	public:
+	LinksWindow(BRect r);
+	~LinksWindow();
+	virtual void FrameResized(float width, float height);
+	virtual bool QuitRequested();
+	int resized;
+	LinksView *view;
+};
+
+class LinksView : public BView {
+	public:
+	LinksView(LinksWindow *w);
+	~LinksView();
+	virtual void Draw(BRect r);
+	virtual void MouseDown(BPoint p);
+	virtual void MouseUp(BPoint p);
+	virtual void MouseMoved(BPoint p, uint32 transit, const BMessage *dragmsg);
+	virtual void KeyDown(const char *s, int32 numBytes);
+	virtual void MessageReceived(BMessage *msg);
+	LinksWindow *win;
+	struct graphics_device *dev;
+	void d_flush();
+	int flushing;
+	int last_x, last_y;
+};
+
+#define lv(dev) ((LinksView *)(dev)->driver_data)
+
+#define lock_dev(dev) do { if (!lv(dev)->win->Lock()) return; } while (0)
+#define lock_dev0(dev) do { if (!lv(dev)->win->Lock()) return 0; } while (0)
+#define unlock_dev(dev) do { lv(dev)->win->Unlock(); } while (0)
+
+void be_get_size(struct graphics_device *dev);
+
+#define detach_message(dev) \
+	BMessage *current = Looper()->DetachCurrentMessage(); \
+	if (current) { \
+		current->AddPointer("linksdev", dev); \
+	}
+
+#define pipe_message(dev) \
+	if (current) { \
+		write(wpipe, &current, sizeof(current)); \
+	}
+
+#define detach_and_pipe_message(dev) do { \
+	BMessage *current = Looper()->DetachCurrentMessage(); \
+	if (current) { \
+		current->AddPointer("linksdev", dev); \
+		write(wpipe, &current, sizeof(current)); \
+	} \
+} while (0)
+
+LinksApplication *be_links_app;
+BLocker *be_lock = NULL;
+
+int msg_pipe[2];
+
+thread_id be_app_thread_id;
+
+#define rpipe (msg_pipe[0])
+#define wpipe (msg_pipe[1])
+
+#define small_color (sizeof(rgb_color) <= sizeof(long))
+#define get_color32(c, rgb) rgb_color c((rgb_color){(rgb >> 16) & 255, (rgb >> 8) & 255, rgb & 255, 255})
+
+color_space be_cs_desktop, be_cs_bmp;
+
+int be_x_size, be_y_size;
+
+int be_win_x_size, be_win_y_size;
+int be_win_x_pos, be_win_y_pos;
+
+static BMessage *initial_refs_msg;
+
+void LinksApplication::RefsReceived(BMessage *message)
+{
+	entry_ref ref;
+	//if (!IsLaunching())
+	//	return;
+	BMessenger msgr(WindowAt(0));
+	BMessage *m = new BMessage(*message);
+	m->AddSpecifier("View", (long)0);
+	//m->what = B_SIMPLE_DATA;
+	if (msgr.IsValid()) {
+		msgr.SendMessage(m);
+	} else
+		initial_refs_msg = m;
+}
+
+bool LinksApplication::QuitRequested()
+{
+	BApplication::QuitRequested();
+	//printf("qc: %ld\n", CountWindows());
+	return true;
+}
+
+LinksWindow::LinksWindow(BRect r):BWindow(r, "Links", B_DOCUMENT_WINDOW, 0)
+{
+	DBG("LINKSWINDOW\n");
+	resized = 0;
+	view = NULL;
+}
+
+LinksWindow::~LinksWindow()
+{
+	view = NULL;
+	DBG("~LINKSWINDOW\n");
+}
+
+void LinksWindow::FrameResized(float width, float height)
+{
+	resized = 1;
+}
+
+bool LinksWindow::QuitRequested()
+{
+	detach_and_pipe_message(view->dev);
+	return false;
+}
+
+void do_flush(void *p_dev)
+{
+	struct graphics_device *dev = (struct graphics_device *)p_dev;
+	LinksView *v = lv(dev);
+	v->win->Lock();
+	v->win->Flush();
+	v->win->Unlock();
+	v->flushing = 0;
+}
+
+LinksView::LinksView(LinksWindow *w):BView(w->Bounds(), "Links", B_FOLLOW_ALL, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_NAVIGABLE)
+{
+	DBG("LINKSVIEW\n");
+	(win = w)->AddChild(this);
+	SetViewColor(B_TRANSPARENT_32_BIT);
+	MakeFocus();
+	w->view = this;
+	flushing = 0;
+	last_x = last_y = 0;
+}
+
+LinksView::~LinksView()
+{
+	win->view = NULL;
+	DBG("~LINKSVIEW\n");
+}
+
+void LinksView::d_flush()
+{
+	if (flushing) return;
+	register_bottom_half(do_flush, this->dev);
+	flushing = 1;
+}
+
+#undef select
+
+int be_loop_select(int n, fd_set *r, fd_set *w, fd_set *e, struct timeval *t)
+{
+	int v;
+	v = select(n, r, w, e, t);
+	check_bottom_halves();
+	return v;
+}
+
+void be_paste_string(struct graphics_device *dev, const char *str)
+{
+	unsigned char *s = (unsigned char *)str;
+	int c, i;
+	while (s && *s) {
+		GET_UTF_8(s, c);
+		if (dev) dev->keyboard_handler(dev, c, 0);
+	}
+}
+
+void be_get_event(void *dummy)
+{
+	BMessage *msg;
+	LinksView *view = NULL;
+	LinksWindow *win = NULL;
+	struct graphics_device *dev;
+	read(rpipe, &msg, sizeof(msg));
+	DBG("GETE\n");
+	if (!msg)
+		return;
+	if (msg->FindPointer("linksdev", (void **)&dev) < B_OK)
+		return;
+	if (dev) {
+		view = lv(dev);
+		if (view)
+			win = dynamic_cast<LinksWindow *>(view->Window());
+	}
+	switch (msg->what) {
+	case B_QUIT_REQUESTED:
+		if (dev)
+			dev->keyboard_handler(dev, KBD_CTRL_C, 0);
+		break;
+	case _UPDATE_:
+	{
+		BRect r;
+		if (msg->FindRect("updateRect", &r) < B_OK)
+			return;
+		struct rect rr;
+		rr.x1 = (int)r.left;
+		rr.x2 = (int)r.right + 1;
+		rr.y1 = (int)r.top;
+		rr.y2 = (int)r.bottom + 1;
+		/*DBG("paint: %d %d %d %d\n", rr.x1, rr.x2, rr.y1, rr.y2);*/
+		if (dev) {
+			if (!win->resized) dev->redraw_handler(dev, &rr);
+			else {
+				be_get_size(dev);
+				win->resized = 0;
+				dev->resize_handler(dev);
+			}
+		}
+		check_bottom_halves();
+	}
+		break;
+	case B_MOUSE_DOWN:
+	{
+		BPoint where;
+		int32 buttons;
+		int btn = B_LEFT;
+		if (msg->FindInt32("buttons", &buttons) != B_OK)
+			return;
+		if (msg->FindPoint("where", &where) != B_OK)
+			return;
+		if (buttons & B_PRIMARY_MOUSE_BUTTON)
+			btn = B_LEFT;
+		else if (buttons & B_SECONDARY_MOUSE_BUTTON)
+			btn = B_RIGHT;
+		else if (buttons & B_TERTIARY_MOUSE_BUTTON)
+			btn = B_MIDDLE;
+		else if (buttons & (B_TERTIARY_MOUSE_BUTTON << 1))
+			btn = B_FOURTH;
+		else if (buttons & (B_TERTIARY_MOUSE_BUTTON << 2))
+			btn = B_FIFTH;
+		else if (buttons & (B_TERTIARY_MOUSE_BUTTON << 3))
+			btn = B_SIXTH;
+		if (dev) dev->mouse_handler(dev, view->last_x = (int)where.x, view->last_y = (int)where.y, B_DOWN | btn);
+	}
+		break;
+	case B_MOUSE_UP:
+	{
+		BPoint where;
+		int32 buttons;
+		int btn = B_LEFT;
+		if (msg->FindInt32("buttons", &buttons) != B_OK)
+			return;
+		if (msg->FindPoint("where", &where) != B_OK)
+			return;
+		if (buttons & ~B_PRIMARY_MOUSE_BUTTON == 0)
+			btn = B_LEFT;
+		else if (buttons & ~B_SECONDARY_MOUSE_BUTTON == 0)
+			btn = B_RIGHT;
+		else if (buttons & ~B_TERTIARY_MOUSE_BUTTON == 0)
+			btn = B_MIDDLE;
+		else if (buttons & ~(B_TERTIARY_MOUSE_BUTTON << 1) == 0)
+			btn = B_FOURTH;
+		else if (buttons & ~(B_TERTIARY_MOUSE_BUTTON << 2) == 0)
+			btn = B_FIFTH;
+		else if (buttons & ~(B_TERTIARY_MOUSE_BUTTON << 3) == 0)
+			btn = B_SIXTH;
+		if (dev) dev->mouse_handler(dev, view->last_x = (int)where.x, view->last_y = (int)where.y, B_UP | btn);
+	}
+		break;
+	case B_MOUSE_MOVED:
+	{
+		BPoint where;
+		int32 buttons;
+		int btn = B_LEFT;
+		if (msg->FindInt32("buttons", &buttons) != B_OK)
+			return;
+		if (msg->FindPoint("where", &where) != B_OK)
+			return;
+		if (buttons & B_PRIMARY_MOUSE_BUTTON)
+			btn = B_LEFT;
+		else if (buttons & B_SECONDARY_MOUSE_BUTTON)
+			btn = B_RIGHT;
+		else if (buttons & B_TERTIARY_MOUSE_BUTTON)
+			btn = B_MIDDLE;
+		else if (buttons & (B_TERTIARY_MOUSE_BUTTON << 1))
+			btn = B_FOURTH;
+		else if (buttons & (B_TERTIARY_MOUSE_BUTTON << 2))
+			btn = B_FIFTH;
+		else if (buttons & (B_TERTIARY_MOUSE_BUTTON << 3))
+			btn = B_SIXTH;
+		if (dev) dev->mouse_handler(dev, view->last_x = (int)where.x, view->last_y = (int)where.y, !buttons ? B_MOVE : B_DRAG | btn);
+	}
+		break;
+	case B_KEY_DOWN:
+	{
+		int32 modifiers;
+		int32 numBytes;
+		const char *bytes;
+		int c;
+		int mods = 0;
+		if (msg->FindInt32("modifiers", &modifiers) != B_OK)
+			return;
+		if (msg->FindString("bytes", &bytes) != B_OK)
+			return;
+		unsigned char buf[4] = { 0, 0, 0, 0 };
+		unsigned char *ss;
+		if (modifiers & (B_LEFT_CONTROL_KEY | B_RIGHT_CONTROL_KEY | B_LEFT_COMMAND_KEY | B_RIGHT_COMMAND_KEY)) {
+			int32 raw;
+			if (msg->FindInt32("raw_char", &raw) != B_OK)
+				return;
+			buf[0] = (unsigned char)raw;
+			ss = buf;
+		} else
+			ss = (unsigned char *)bytes;
+
+		GET_UTF_8(ss, c);
+		switch (c) {
+			case B_BACKSPACE: c = KBD_BS; break;
+			case B_ENTER: c = KBD_ENTER; break;
+			case B_SPACE: c = ' '; break;
+			case B_TAB: c = KBD_TAB; break;
+			case B_ESCAPE: c = KBD_ESC; break;
+			case B_LEFT_ARROW: c = KBD_LEFT; break;
+			case B_RIGHT_ARROW: c = KBD_RIGHT; break;
+			case B_UP_ARROW: c = KBD_UP; break;
+			case B_DOWN_ARROW: c = KBD_DOWN; break;
+			case B_INSERT: c = KBD_INS; break;
+			case B_DELETE: c = KBD_DEL; break;
+			case B_HOME: c = KBD_HOME; break;
+			case B_END: c = KBD_END; break;
+			case B_PAGE_UP: c = KBD_PAGE_UP; break;
+			case B_PAGE_DOWN: c = KBD_PAGE_DOWN; break;
+			default: if (c < 32) c = 0;
+				 else modifiers &= ~(B_LEFT_SHIFT_KEY|B_RIGHT_SHIFT_KEY);
+				 break;
+		}
+		if (modifiers & (B_LEFT_SHIFT_KEY|B_RIGHT_SHIFT_KEY))
+			mods |= KBD_SHIFT;
+		if (modifiers & (B_LEFT_CONTROL_KEY|B_RIGHT_CONTROL_KEY))
+			mods |= KBD_CTRL;
+		if (modifiers & (B_LEFT_COMMAND_KEY|B_RIGHT_COMMAND_KEY))
+			mods |= KBD_ALT;
+		if (c) if (dev) dev->keyboard_handler(dev, c, mods);
+	}
+		break;
+	case B_MOUSE_WHEEL_CHANGED:
+	{
+		float delta_x, delta_y;
+		if (msg->FindFloat("be:wheel_delta_x", &delta_x) != B_OK)
+			delta_x = 0;
+		if (msg->FindFloat("be:wheel_delta_y", &delta_y) != B_OK)
+			delta_y = 0;
+		if (delta_y) if (dev) dev->mouse_handler(dev, view->last_x, view->last_y, B_MOVE | (delta_y > 0 ? B_WHEELDOWN : B_WHEELUP));
+		if (delta_x) if (dev) dev->mouse_handler(dev, view->last_x, view->last_y, B_MOVE | (delta_x < 0 ? B_WHEELLEFT : B_WHEELRIGHT));
+	}
+		break;
+	case B_PASTE:
+		if (be_clipboard->Lock()) {
+			BMessage *data = be_clipboard->Data();
+			if (data) {
+				const char *text_plain;
+				ssize_t len;
+				//data->PrintToStream();
+				if (data->FindData("text/plain", B_MIME_TYPE, (const void **)&text_plain, &len) == B_OK) {
+					be_paste_string(dev, text_plain);
+				}
+			}
+			be_clipboard->Unlock();
+		}
+		break;
+	case B_REFS_RECEIVED:
+		if (dev)
+			be_paste_string(dev, "\033\ng");
+		/* FALLTHROUGH */
+	case B_SIMPLE_DATA:
+	{
+		/* something got dropped */
+		entry_ref ref;
+		const char *text_plain;
+		ssize_t len;
+		//msg->PrintToStream();
+		/* try find a file path to paste */
+		if (msg->FindRef("refs", &ref) == B_OK) {
+			BPath path(&ref);
+			if (path.InitCheck() == B_OK) {
+				BFile f(path.Path(), B_READ_ONLY);
+				BString url;
+				if (f.InitCheck() == B_OK && f.ReadAttrString("META:url", &url) >= B_OK) {
+					be_paste_string(dev, url.String());
+				} else
+					be_paste_string(dev, path.Path());
+			}
+		} else if (msg->FindData("text/plain", B_MIME_TYPE, (const void **)&text_plain, &len) == B_OK) {
+			be_paste_string(dev, text_plain);
+		}
+	}
+		break;
+	default:
+		msg->PrintToStream();
+		break;
+	}
+	delete msg;
+}
+
+void be_get_size(struct graphics_device *dev)
+{
+	BRect r;
+	lock_dev(dev);
+	r = lv(dev)->Bounds();
+	unlock_dev(dev);
+	dev->size.x1 = dev->size.y1 = 0;
+	dev->size.x2 = (int)r.Width() + 1;
+	dev->size.y2 = (int)r.Height() + 1;
+}
+
+void LinksView::Draw(BRect r)
+{
+	detach_message(dev);
+	current->AddRect("updateRect", r);
+	pipe_message(dev);
+}
+
+
+void LinksView::MouseDown(BPoint p)
+{
+	detach_and_pipe_message(dev);
+}
+
+void LinksView::MouseUp(BPoint p)
+{
+	detach_and_pipe_message(dev);
+}
+
+void LinksView::MouseMoved(BPoint p, uint32 transit, const BMessage *dragmsg)
+{
+	detach_and_pipe_message(dev);
+}
+
+void LinksView::MessageReceived(BMessage *msg)
+{
+	switch (msg->what) {
+	case B_REFS_RECEIVED:
+	case B_MOUSE_WHEEL_CHANGED:
+	case B_PASTE:
+	case B_SIMPLE_DATA:
+		detach_and_pipe_message(dev);
+		break;
+	default:
+		BView::MessageReceived(msg);
+	}
+}
+
+void LinksView::KeyDown(const char *s, int32 numBytes)
+{
+	detach_and_pipe_message(dev);
+}
+
+unsigned char *be_get_driver_param(void)
+{
+	return NULL;
+}
+
+int32 be_app_thread(void *p)
+{
+	be_links_app->Lock();
+	be_links_app->Run();
+	delete be_links_app;
+	return 0;
+}
+
+unsigned char *be_init_driver(unsigned char *param, unsigned char *display)
+{
+	be_links_app = new LinksApplication();
+	if (!be_links_app) {
+		return stracpy((unsigned char *)"Unable to allocate Application object.\n");
+	}
+	if (c_pipe(msg_pipe)) {
+		delete be_links_app;
+		return stracpy((unsigned char *)"Could not create pipe.\n");
+	}
+	fcntl(rpipe, F_SETFL, O_NONBLOCK);
+	fcntl(wpipe, F_SETFL, O_NONBLOCK);
+	set_handlers(rpipe, be_get_event, NULL, NULL, NULL);
+	be_app_thread_id = spawn_thread(be_app_thread, "links_app", B_NORMAL_PRIORITY, NULL);
+	resume_thread(be_app_thread_id);
+	be_links_app->Unlock();
+	be_cs_desktop = B_NO_COLOR_SPACE;
+	be_x_size = 640;
+	be_y_size = 480;
+	BScreen d;
+	if (d.IsValid()) {
+		be_cs_desktop = d.ColorSpace();
+		be_x_size = (int)d.Frame().Width() + 1;
+		be_y_size = (int)d.Frame().Height() + 1;
+	}
+	be_win_y_size = be_y_size * 9 / 10;
+	be_win_x_size = be_win_y_size;
+	/*
+	DBG("%d %d\n", be_x_size, be_y_size);
+	DBG("%d %d\n", be_win_x_size, be_win_y_size);
+	*/
+	be_win_y_pos = (be_y_size - be_win_y_size) / 2;
+	be_win_x_pos = be_x_size - be_win_x_size - be_win_y_pos;
+	if (/*be_cs_desktop == B_RGB32 ||*/ be_cs_desktop == B_RGB24 || be_cs_desktop == B_RGB16 || be_cs_desktop == B_RGB15)
+		be_cs_bmp = be_cs_desktop;
+	else if (be_cs_desktop == B_RGB32 || be_cs_desktop == B_RGBA32) be_cs_bmp = B_RGB24;
+	else be_cs_bmp = B_RGB15;
+	be_cs_bmp = B_RGB16; // XXX: DEBUG
+	switch (be_cs_bmp) {
+		case B_RGB24:
+			haiku_driver.depth = 0xc3;
+			break;
+		case B_RGB16:
+			haiku_driver.depth = 0x82;
+			break;
+		case B_RGB15:
+			haiku_driver.depth = 0x7a;
+			break;
+		default:
+			internal("unknown depth");
+	}
+	return NULL;
+}
+
+void be_shutdown_driver()
+{
+	status_t ret;
+	//debug((unsigned char *)"D");
+	close(rpipe);
+	close(wpipe);
+	set_handlers(rpipe, NULL, NULL, NULL, NULL);
+	//debug((unsigned char *)"DD");
+	be_links_app->PostMessage(B_QUIT_REQUESTED);
+	//debug((unsigned char *)"E");
+	wait_for_thread(be_app_thread_id, &ret);
+	//debug((unsigned char *)"F");
+}
+
+struct graphics_device *be_init_device()
+{
+	LinksView *view;
+	LinksWindow *win;
+	struct graphics_device *dev = (struct graphics_device *)mem_calloc(sizeof(struct graphics_device));
+	if (!dev) return NULL;
+	//dev->drv = &haiku_driver;
+	//debug((unsigned char *)"1");
+	win = new LinksWindow(BRect(be_win_x_pos, be_win_y_pos, be_win_x_pos + be_win_x_size, be_win_y_pos + be_win_y_size));
+	//debug((unsigned char *)"2");
+	if (!win) {
+		mem_free(dev);
+		return NULL;
+	}
+	//debug((unsigned char *)"3");
+	view = new LinksView(win);
+	if (!view) {
+		delete win;
+		mem_free(dev);
+		return NULL;
+	}
+	view->dev = dev;
+	dev->driver_data = view;
+	be_get_size(dev);
+	memcpy(&dev->clip, &dev->size, sizeof(struct rect));
+	//debug((unsigned char *)"4");
+	win->Show();
+	win->Lock();
+	view->MakeFocus();
+	win->Unlock();
+	//debug((unsigned char *)"5");
+	if (initial_refs_msg) {
+		BMessenger msgr(win);
+		if (msgr.IsValid()) {
+			msgr.SendMessage(initial_refs_msg);
+			initial_refs_msg = NULL;
+		}
+	}
+	return dev;
+}
+
+void be_shutdown_device(struct graphics_device *dev)
+{
+	LinksWindow *win = lv(dev)->win;
+	unregister_bottom_half(do_flush, dev);
+	lv(dev)->dev = NULL;
+	win->PostMessage(B_QUIT_REQUESTED);
+	mem_free(dev);
+}
+
+void be_set_title(struct graphics_device *dev, unsigned char *title)
+{
+	LinksWindow *win = lv(dev)->win;
+	lock_dev(dev);
+	win->SetTitle((const char *)title);
+	lv(dev)->d_flush();
+	unlock_dev(dev);
+}
+
+/*
+int be_get_filled_bitmap(struct bitmap *bmp, long color)
+{
+	internal((unsigned char *)"nedopsano");
+	return 0;
+}
+*/
+
+int be_get_empty_bitmap(struct bitmap *bmp)
+{
+	DBG("bmp\n");
+//DBG("bmp (%d, %d) cs %08x\n", bmp->x, bmp->y, be_cs_bmp);
+	BRect r(0, 0, bmp->x - 1, bmp->y - 1);
+	BBitmap *b = new BBitmap(r, /*B_RGB32*/be_cs_bmp);
+	if (!b) {
+		bmp->data = NULL;
+DBG("%s: error 1\n", __FUNCTION__);
+		return 0;
+	}
+	if (!b->IsValid()) {
+		bmp->data = NULL;
+		delete b;
+DBG("%s: error 2\n", __FUNCTION__);
+		return 0;
+	}
+	if (b->LockBits() < B_OK) {
+		bmp->data = NULL;
+		delete b;
+DBG("%s: error 3\n", __FUNCTION__);
+		return 0;
+	}
+	bmp->data = b->Bits();
+	bmp->skip = b->BytesPerRow();
+	bmp->flags = b;
+//DBG("bmp: data %p, skip %d, flags %p\n", bmp->data, bmp->skip, bmp->flags);
+	return 0;
+}
+
+void be_register_bitmap(struct bitmap *bmp)
+{
+	BBitmap *b = (BBitmap *)bmp->flags;
+	b->UnlockBits();
+}
+
+void *be_prepare_strip(struct bitmap *bmp, int top, int lines)
+{
+	DBG("preps\n");
+	BBitmap *b = (BBitmap *)bmp->flags;
+	if (b->LockBits() < B_OK)
+		return NULL;
+	bmp->data = b->Bits();
+	bmp->skip = b->BytesPerRow();
+	return ((char *)bmp->data) + bmp->skip * top;
+}
+
+void be_commit_strip(struct bitmap *bmp, int top, int lines)
+{
+	BBitmap *b = (BBitmap *)bmp->flags;
+	b->UnlockBits();
+}
+
+void be_unregister_bitmap(struct bitmap *bmp)
+{
+	DBG("unb\n");
+	BBitmap *b = (BBitmap *)bmp->flags;
+	delete b;
+}
+
+void be_draw_bitmap(struct graphics_device *dev, struct bitmap *bmp, int x, int y)
+{
+	DBG("drawb\n");
+	BBitmap *b = (BBitmap *)bmp->flags;
+	lock_dev(dev);
+	lv(dev)->DrawBitmap(b, b->Bounds(), BRect(x, y, x + bmp->x - 1, y + bmp->y - 1));
+	lv(dev)->d_flush();
+	unlock_dev(dev);
+}
+
+/*
+void be_draw_bitmaps(struct graphics_device *dev, struct bitmap **bmp, int n, int x, int y)
+{
+	LinksView *lvv = lv(dev);
+	lock_dev(dev);
+	while (n--) {
+		BBitmap *b = (BBitmap *)(*bmp)->flags;
+		lvv->DrawBitmap(b, b->Bounds(), BRect(x, y, x + (*bmp)->x, y + (*bmp)->y));
+		x += (*bmp)->x;
+		bmp++;
+	}
+	lv(dev)->d_flush();
+	unlock_dev(dev);
+}
+*/
+
+long be_get_color(int rgb)
+{
+	if (small_color) {
+		get_color32(c, rgb);
+		return *(long *)(void *)&c;
+	} else return rgb & 0xffffff;
+}
+
+void be_fill_area(struct graphics_device *dev, int x1, int y1, int x2, int y2, long color)
+{
+	DBG("fill\n");
+	if (x1 >= x2 || y1 >= y2) return;
+	lock_dev(dev);
+	if (small_color)
+		lv(dev)->SetHighColor(*(rgb_color *)(void *)&color);
+	else
+		lv(dev)->SetHighColor(get_color32(, color));
+	lv(dev)->FillRect(BRect(x1, y1, x2 - 1, y2 - 1));
+	lv(dev)->d_flush();
+	unlock_dev(dev);
+}
+
+void be_draw_hline(struct graphics_device *dev, int x1, int y, int x2, long color)
+{
+	DBG("hline\n");
+	if (x1 >= x2) return;
+	lock_dev(dev);
+	if (small_color)
+		lv(dev)->SetHighColor(*(rgb_color *)(void *)&color);
+	else
+		lv(dev)->SetHighColor(get_color32(, color));
+	lv(dev)->StrokeLine(BPoint(x1, y), BPoint(x2 - 1, y));
+	lv(dev)->d_flush();
+	unlock_dev(dev);
+}
+
+void be_draw_vline(struct graphics_device *dev, int x, int y1, int y2, long color)
+{
+	DBG("vline\n");
+	if (y1 >= y2) return;
+	lock_dev(dev);
+	if (small_color)
+		lv(dev)->SetHighColor(*(rgb_color *)(void *)&color);
+	else
+		lv(dev)->SetHighColor(get_color32(, color));
+	lv(dev)->StrokeLine(BPoint(x, y1), BPoint(x, y2 - 1));
+	lv(dev)->d_flush();
+	unlock_dev(dev);
+}
+
+int be_hscroll(struct graphics_device *dev, struct rect_set **ignore, int sc)
+{
+	DBG("hscroll\n");
+	if (dev->clip.x1 >= dev->clip.x2 || dev->clip.y1 >= dev->clip.y2) return 0;
+	if (sc <= dev->clip.x1 - dev->clip.x2) return 1;
+	if (sc >= dev->clip.x2 - dev->clip.x1) return 1;
+	lock_dev0(dev);
+	if (sc > 0) lv(dev)->CopyBits(BRect(dev->clip.x1, dev->clip.y1, dev->clip.x2 - sc - 1, dev->clip.y2 - 1), BRect(dev->clip.x1 + sc, dev->clip.y1, dev->clip.x2 - 1, dev->clip.y2 - 1));
+	else lv(dev)->CopyBits(BRect(dev->clip.x1 - sc, dev->clip.y1, dev->clip.x2 - 1, dev->clip.y2 - 1), BRect(dev->clip.x1, dev->clip.y1, dev->clip.x2 + sc - 1, dev->clip.y2 - 1));
+	lv(dev)->d_flush();
+	unlock_dev(dev);
+	return 1;
+}
+
+int be_vscroll(struct graphics_device *dev, struct rect_set **ignore, int sc)
+{
+	DBG("vscroll\n");
+	if (!sc || dev->clip.x1 >= dev->clip.x2 || dev->clip.y1 >= dev->clip.y2) return 0;
+	if (sc <= dev->clip.y1 - dev->clip.y2) return 1;
+	if (sc >= dev->clip.y2 - dev->clip.y1) return 1;
+	lock_dev0(dev);
+	if (sc > 0) lv(dev)->CopyBits(BRect(dev->clip.x1, dev->clip.y1, dev->clip.x2 - 1, dev->clip.y2 - sc - 1), BRect(dev->clip.x1, dev->clip.y1 + sc, dev->clip.x2 - 1, dev->clip.y2 - 1));
+	else lv(dev)->CopyBits(BRect(dev->clip.x1, dev->clip.y1 - sc, dev->clip.x2 - 1, dev->clip.y2 - 1), BRect(dev->clip.x1, dev->clip.y1, dev->clip.x2 - 1, dev->clip.y2 + sc - 1));
+	lv(dev)->d_flush();
+	unlock_dev(dev);
+	return 1;
+}
+
+void be_set_clip_area(struct graphics_device *dev, struct rect *r)
+{
+	DBG("setc\n");
+	memcpy(&dev->clip, r, sizeof(struct rect));
+	lock_dev(dev);
+	BRegion clip(BRect(r->x1, r->y1, r->x2 - 1, r->y2 - 1));
+	lv(dev)->ConstrainClippingRegion(&clip);
+	unlock_dev(dev);
+}
+
+struct graphics_driver haiku_driver = {
+	(unsigned char *)"haiku",
+	be_init_driver,
+	be_init_device,
+	be_shutdown_device,
+	be_shutdown_driver,
+	dummy_emergency_shutdown,
+	be_get_driver_param,
+	be_get_empty_bitmap,
+	be_register_bitmap,
+	be_prepare_strip,
+	be_commit_strip,
+	be_unregister_bitmap,
+	be_draw_bitmap,
+	be_get_color,
+	be_fill_area,
+	be_draw_hline,
+	be_draw_vline,
+	be_hscroll,
+	be_vscroll,
+	be_set_clip_area,
+	dummy_block,
+	dummy_unblock,
+	be_set_title,
+	NULL,				/* exec */
+	NULL, /* set_clipboard_text */
+	NULL, /* get_clipboard_text */
+	0,				/* depth */
+	0, 0,				/* size */
+	0,				/* flags */
+	0,				/* codepage */
+	NULL,				/* shell */
+};
+
+#endif /* GRDRV_HAIKU */
+
+#endif
diff -urN links-2.8.org/links-haiku.rdef links-2.8/links-haiku.rdef
--- links-2.8.org/links-haiku.rdef	1970-01-01 01:00:00.000000000 +0100
+++ links-2.8/links-haiku.rdef	2013-12-13 00:23:34.395313152 +0100
@@ -0,0 +1,125 @@
+/*
+** links-haiku.rdef
+**
+** Automatically generated by BResourceParser on
+** Thursday, December 13, 2007 at 23:46:45.
+**
+*/
+
+resource(1, "BEOS:APP_FLAGS") (#'APPF') $"01000000";
+
+resource(1, "BEOS:APP_VERSION") #'APPV' array {
+	$"02000000010000000000000000000000210000006C696E6B7320322E31707265"
+	$"3333000000000000000000000000000000000000000000000000000000000000"
+	$"00000000000000000000000000000000000000004C696E6B732062726F777365"
+	$"7220322E31707265333300000000000000000000000000000000000000000000"
+	$"0000000000000000000000000000000000000000000000000000000000000000"
+	$"0000000000000000000000000000000000000000000000000000000000000000"
+	$"0000000000000000000000000000000000000000000000000000000000000000"
+	$"0000000000000000000000000000000000000000000000000000000000000000"
+	$"0000000000000000000000000000000000000000000000000000000000000000"
+	$"0000000000000000000000000000000000000000000000000000000000000000"
+	$"0000000000000000000000000000000000000000000000000000000000000000"
+	$"0000000000000000000000000000000000000000000000000000000000000000"
+	$"0000000000000000000000000000000000000000000000000000000000000000"
+	$"0000000000000000000000000000000000000000000000000000000000000000"
+	$"0000000000000000000000000000000000000000000000000000000000000000"
+	$"0000000000000000000000000000000000000000000000000000000000000000"
+	$"0000000000000000000000000000000000000000000000000000000000000000"
+	$"0000000000000000000000000000000000000000000000000000000000000000"
+	$"0000000000000000000000000000000000000000000000000000000000000000"
+	$"0000000000000000000000000000000000000000000000000000000000000000"
+	$"0000000000000000000000000000000000000000000000000000000000000000"
+	$"0000000000000000"
+};
+
+resource(101, "BEOS:L:STD_ICON") #'ICON' array {
+	$"2A2A2A2A2A2A2A2A2A2A2A2A2A2A2C0000363434343434343434343434343434"
+	$"2A2A2A2A2A2A2A2A2A2A2A2A2A2A2C0000363434343434343434343434343434"
+	$"2A2A2A2B2B2B2B2B2B2B2B2B2B2B2C0000363434343434343434343434343434"
+	$"2A2A2A3200000000000000000000000000363434343434343434343434343434"
+	$"2A2A2A2FF1313200000000000131310000363434343434343434343434343434"
+	$"2A2A2A2A2A2A2A30000000002B2A2C0000363434343434343434343434343434"
+	$"2A2A2A2A2A2A2A2F000000002A2A2C0000363434343434343434343434343434"
+	$"2A2A2A2A2A2A2A2F000000002A2A2C0000363434343434343434343434343434"
+	$"2A2A2A2A2A2A2A2F000000002A2A2C0000363434343434343434343434343434"
+	$"2A2A2A2A2A2A2A2F000000002A2A2C0000363434343434343434343434343434"
+	$"2A2A2A2A2A2A2A2F000000002A2A2C0000363434343434343434343434343434"
+	$"2A2A2A2A2A2A2A2F000000002A2A2C0000363434343434343434343434343434"
+	$"2A2A2A2A2A2A2A2F000000002A2A2C0000363434343434343434343434343434"
+	$"2A2A2A2A2A2A2A2F000000002A2A2C0000363434343434343434343434343434"
+	$"2C2C2C2C2C2C2C30000000002C2C2D0000373636363636363636363636363636"
+	$"0000000000000000000000000000000000000000000000000000000000000000"
+	$"0000000000000000000000000000000000000000000000000000000000000000"
+	$"2222222222222226000000002222230000151A1A1A1A1A1A1A1A1A1A1A1A1A1A"
+	$"20202020202020250000000020202200001A3F3F3F3F3F3F3F3F3F3F3F3F3F3F"
+	$"20202020202020250000000020202200001A3F3F3F3F3F3F3F1501113F3F3F3F"
+	$"20202020202020250000000020202200001A3F3F3F3F3F3F3F0E00133F3F3F3F"
+	$"20202020202020250000000020202200001A3F3F3F3F3F3F3F0500163F3F3F3F"
+	$"20202020202020250000000020202200001A3F3F3F3F3F3F1A0000193F3F3F3F"
+	$"20202020202020250000000020202200001A3F3F3F3F3F3F0C00001B3F3F3F3F"
+	$"20202020202020250000000020202200001A3F3F3F3F3F190000001E3F3F3F3F"
+	$"20202020202020250000000020202200001A3F3F3F3F1A030000013F3F3F3F3F"
+	$"20202020202020270000000023202200001A3F1E170C00000000043F3F3F3F3F"
+	$"2020202628292900000000000029290000040300000000000000063F3F3F3F3F"
+	$"20202027292929292929292929292900000203030303030303030B3F3F3F3F3F"
+	$"20202020202020202020202020202200001A3F3F3F3F3F3F3F3F3F3F3F3F3F3F"
+	$"20202020202020202020202020202200001A3F3F3F3F3F3F3F3F3F3F3F3F3F3F"
+	$"20202020202020202020202020202200001A3F3F3F3F3F3F3F3F3F3F3F3F3F3F"
+};
+
+resource(101, "BEOS:M:STD_ICON") #'MICN' array {
+	$"2A2A2A2A2A2A2A303A34343434343434"
+	$"2A2C3030303030F73A34343434343434"
+	$"2A2B2D300000EB323A34343434343434"
+	$"2A2A2A2C00002A303A34343434343434"
+	$"2A2A2A2C00002A303A34343434343434"
+	$"2A2A2A2C00002A303A34343434343434"
+	$"2A2A2A2C00002A303A34343434343434"
+	$"303030310000F1333D3A3A3A3A3A3A3A"
+	$"2626262700002629050D0D0D0D0D0D0D"
+	$"20202022000020260D3F3F3F1D143F3F"
+	$"20202022000020260D3F3F3F140A3F3F"
+	$"20202022000020260D3F3F3F090D3F3F"
+	$"20202022000020260D3F3F16000F3F3F"
+	$"20222427000026280710090000123F3F"
+	$"202225252525252807111111111A3F3F"
+	$"20202020202020260D3F3F3F3F3F3F3F"
+};
+
+resource(101, "BEOS:ICON") #'VICN' array {
+	$"6E6369661305000200060237E670B8880E39469D39AE144A52234B0D2500C6D7"
+	$"F5FF6B94DD03EC6666020006023B2B47BB18653D0FA53D225148297046CA1900"
+	$"00FF00FFA9FF00020016023B2B47BB18653D0FA53D225148297046CA1900FFFF"
+	$"8A020006023B3049396B0ABA90833C646E4A101543299500FFFFFFFF52FF5202"
+	$"0016023B3049396B0ABA90833C646E4A101543299500FFFFC9020006023C71E3"
+	$"3A0C78BA15E43C7D2149055549455700E3EDFFFF9EC2FF020006023CD8653068"
+	$"26B065D13CD5A34A6E4A46E21900FFDCDCFFDA5858020006023A1DA6393F04BB"
+	$"B5BC3C6B074AEA364809110087CA05FF026802020016023C00913B1266BB9E06"
+	$"3C5B934A01F04914EC00FFFF4E03003CB00200060230B31E3A09B9BB024238A1"
+	$"2F4BAB534AFF0B00A3043CFFFFDCE603CD4D4D030D296402000602BD498B3E11"
+	$"59BF219BBE7D2F4BE71F4AB31300C13E3EFFE27A7A040174020016023F2938BB"
+	$"F60A3BA9823EEC25C40E6348C15D0099FF00020016023E8FA33A7B71BA9D783E"
+	$"B2C049F7BAC28CE500C8FF00130A06322E323E42464C3C4C2C3D260A04322E32"
+	$"3E424642350A04322E42354C2C3D260A04423542464C3C4C2C0A0338423C4D3C"
+	$"440A08335C395C41544F5C555C6051594D3E510A0422422252325A32490A0422"
+	$"4232493C402D3A0A043249325A3C503C400A043E424E495840493A0A043E524E"
+	$"5A4E493E420A1243C97243C375BF66C2A93F503C5133C4F03330342F3830382D"
+	$"2927292A2C2C2D2E2DC2F2B7B1C3BEB5E1C358B5E1C4AA0A042C252927382D3B"
+	$"2B0A04364B334D3E5241500A0442463F48434A46480A042A4727492B4B2E490A"
+	$"04382D38303B2E3B2B0A04434A4358465646480A04332F334D364B362D160A10"
+	$"01052020230A1001052022120A00010030103701178400040A0101012010370A"
+	$"0B01032010370A0E0104201D250A0101072020230A00010030101C0117840004"
+	$"0A02010A2004080A0C010320101C0A0801092004080A00010030283901178400"
+	$"040A0401012028390A0601022028390A0A01032028390A000100302A20011784"
+	$"00040A030101202A200A050102202A200A090103202A200A12040C0D0E0F000A"
+	$"0003101211000A11010B00"
+};
+
+resource(1, "BEOS:APP_SIG") (#'MIMS') "application/x-vnd.links";
+
+resource(1, "BEOS:FILE_TYPES") message {
+	"types" = "text/html",
+	"types" = "application/x-vnd.Be-bookmark",
+	"types" = "application/x-vnd.Be.URL.http"
+};
diff -urN links-2.8.org/Makefile.am links-2.8/Makefile.am
--- links-2.8.org/Makefile.am	2013-09-20 22:37:39.031457280 +0200
+++ links-2.8/Makefile.am	2013-12-12 23:23:13.554172416 +0100
@@ -4,7 +4,7 @@
 
 man_MANS=links.1
 
-EXTRA_DIST=$(man_MANS) atheos.cpp BRAILLE_HOWTO KEYS SITES descrip.mms *.opt PATCH-gpm-1.20.0-smooth-cursor PATCH-libpng-1.2.18 mailcap.pl rebuild Links_logo.png Unicode/*.cp Unicode/[!C]* intl/[!C]* graphics/*.c graphics/arrow.png graphics/gen graphics/system_font/*.png graphics/font/century_extensions-medium-roman-serif-vari/*.png graphics/font/century_school-bold-roman-serif-vari/*.png graphics/font/century_school-medium-roman-serif-vari/*.png graphics/font/courier-medium-roman-serif-mono/*.png graphics/font/japanese-medium-roman-sans-mono/*.png graphics/font/symbol-medium-roman-sans-vari/*.png graphics/font/century_school-bold-roman-serif-vari/aliases graphics/font/century_school-medium-roman-serif-vari/aliases graphics/font/japanese-medium-roman-sans-mono/aliases graphics/font/symbol-medium-roman-sans-vari/aliases doc/links_cal/*.png doc/links_cal/*.html graphics/Makefile graphics/Fontmap graphics/clip.c graphics/links.xpm graphics/makefont graphics/pdf2html graphics/spacer.png pkg-config.m4 *.xpm *.ico *.rc mk-release-os2 mk-release-win mk-dos links.wis *.nsi
+EXTRA_DIST=$(man_MANS) atheos.cpp haiku.cpp BRAILLE_HOWTO KEYS SITES descrip.mms *.opt PATCH-gpm-1.20.0-smooth-cursor PATCH-libpng-1.2.18 mailcap.pl rebuild Links_logo.png Unicode/*.cp Unicode/[!C]* intl/[!C]* graphics/*.c graphics/arrow.png graphics/gen graphics/system_font/*.png graphics/font/century_extensions-medium-roman-serif-vari/*.png graphics/font/century_school-bold-roman-serif-vari/*.png graphics/font/century_school-medium-roman-serif-vari/*.png graphics/font/courier-medium-roman-serif-mono/*.png graphics/font/japanese-medium-roman-sans-mono/*.png graphics/font/symbol-medium-roman-sans-vari/*.png graphics/font/century_school-bold-roman-serif-vari/aliases graphics/font/century_school-medium-roman-serif-vari/aliases graphics/font/japanese-medium-roman-sans-mono/aliases graphics/font/symbol-medium-roman-sans-vari/aliases doc/links_cal/*.png doc/links_cal/*.html graphics/Makefile graphics/Fontmap graphics/clip.c graphics/links.xpm graphics/makefont graphics/pdf2html graphics/spacer.png pkg-config.m4 *.xpm *.ico *.rc mk-release-os2 mk-release-win mk-dos links.wis *.nsi links-haiku.rdef
 
 bin_PROGRAMS=links
 
@@ -13,6 +13,17 @@
 else
 endif
 
+if HAIKU_GR
+links_LDADD=haiku.o -lbe
+EXTRA_links_DEPENDENCIES=links-haiku.rsrc
+# automake will not let us touch the binary after link
+# and install will not copy the attributes anyway... so do it after install
+install-exec-hook:
+	xres -o $(DESTDIR)$(bindir)/links$(EXEEXT) links-haiku.rsrc
+	mimeset $(DESTDIR)$(bindir)/links$(EXEEXT)
+else
+endif
+
 links_SOURCES=af_unix.c auth.c beos.c bfu.c block.c bookmark.c cache.c charsets.c compress.c connect.c cookies.c data.c default.c dip.c directfb.c dither.c dns.c dos.c drivers.c error.c file.c finger.c fn_impl.c font_inc.c framebuf.c ftp.c gif.c grx.c hpux.c html.c html_gr.c html_r.c html_tbl.c http.c https.c img.c imgcache.c jpeg.c jsint.c kbd.c language.c links_ic.c listedit.c lru.c mailto.c main.c memory.c menu.c objreq.c os_dep.c pmshell.c png.c sched.c select.c session.c smb.c string.c svgalib.c terminal.c tiff.c types.c url.c view.c view_gr.c vms.c x.c xbm.c beos.h bits.h cfg.h codepage.h com-defs.h config-vms.h dfb_cur.h hpux.h language.h links.h os_dep.h os_depx.h setup.h arrow.inc codepage.inc entity.inc fbcommon.inc language.inc uni_7b.inc upcase.inc vpipe.inc
 
 dist-hook:
@@ -33,6 +44,12 @@
 atheos.o: atheos.cpp
 	$(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c atheos.cpp
 
+haiku.o: haiku.cpp
+	$(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -o $@ -c $<
+
+links-haiku.rsrc: links-haiku.rdef
+	rc -o $@ $<
+
 datadir = $(prefix)/@DATADIRNAME@
 LIBS = @LIBS@
 
diff -urN links-2.8.org/os_dep.c links-2.8/os_dep.c
--- links-2.8.org/os_dep.c	2013-09-20 23:16:38.037748736 +0200
+++ links-2.8/os_dep.c	2013-12-12 21:48:36.256638976 +0100
@@ -307,7 +307,7 @@
 
 #endif
 
-#if defined(UNIX) || defined(WIN32) || defined(INTERIX) || defined(BEOS) || defined(RISCOS) || defined(ATHEOS) || defined(SPAD) || defined(OPENVMS)
+#if defined(UNIX) || defined(WIN32) || defined(INTERIX) || defined(BEOS) || defined(RISCOS) || defined(ATHEOS) || defined(SPAD) || defined(OPENVMS) || defined(HAIKU)
 
 #ifdef SIGWINCH
 static void sigwinch(void *s)
@@ -573,7 +573,7 @@
 	return xt;
 }
 
-#elif defined(BEOS) || defined(ATHEOS) || defined(DOS)
+#elif defined(BEOS) || defined(ATHEOS) || defined(DOS) || defined(HAIKU)
 
 int is_xterm(void)
 {
@@ -656,6 +656,12 @@
 	if (!GetConsoleCP())
 		force_g = 1;
 #endif
+#ifdef HAIKU
+	if (getenv("TERM") == NULL) {
+		/* probably launched from Tracker or Deskbar, force graphics mode */
+		force_g = 1;
+	}
+#endif
 }
 #endif
 
@@ -958,7 +964,7 @@
 #endif
 
 
-#if defined(UNIX) || defined(INTERIX) || defined(BEOS) || defined(RISCOS) || defined(ATHEOS) || defined(SPAD) || defined(OPENVMS) || defined(DOS)
+#if defined(UNIX) || defined(INTERIX) || defined(BEOS) || defined(RISCOS) || defined(ATHEOS) || defined(SPAD) || defined(OPENVMS) || defined(DOS) || defined(HAIKU)
 
 #if defined(BEOS) && defined(HAVE_SETPGID)
 
@@ -1710,7 +1716,7 @@
 
 #endif
 
-#if defined(UNIX) || defined(OS2) || defined(WIN32) || defined(INTERIX) || defined(RISCOS) || defined(ATHEOS) || defined(SPAD)
+#if defined(UNIX) || defined(OS2) || defined(WIN32) || defined(INTERIX) || defined(RISCOS) || defined(ATHEOS) || defined(SPAD) || defined(HAIKU)
 
 void terminate_osdep(void)
 {
@@ -1727,7 +1733,7 @@
 
 #if defined(BEOS)
 
-#include <be/kernel/OS.h>
+#include <kernel/OS.h>
 
 static int thr_sem_init = 0;
 static sem_id thr_sem;
@@ -2466,6 +2472,13 @@
 	return 0;
 }
 
+#elif defined(HAIKU)
+
+int get_system_env(void)
+{
+	return ENV_BE;
+}
+
 #elif defined(WIN32)
 
 int get_system_env(void)
@@ -2588,6 +2601,14 @@
 }
 #endif
 
+#ifdef HAIKU
+static int open_in_new_haiku(struct terminal *term, unsigned char *exe, unsigned char *param)
+{
+	exec_new_links(term, cast_uchar "Terminal", exe, param);
+	return 0;
+}
+#endif
+
 #ifdef G
 static int open_in_new_g(struct terminal *term, unsigned char *exe, unsigned char *param)
 {
@@ -2637,6 +2658,9 @@
 #ifdef BEOS
 	{ENV_BE, open_in_new_be, TEXT_(T_BEOS_TERMINAL), TEXT_(T_HK_BEOS_TERMINAL)},
 #endif
+#ifdef HAIKU
+	{ENV_BE, open_in_new_haiku, TEXT_(T_BEOS_TERMINAL), TEXT_(T_HK_BEOS_TERMINAL)},
+#endif
 #ifdef G
 	{ENV_G, open_in_new_g, TEXT_(T_WINDOW), TEXT_(T_HK_WINDOW)},
 #endif
@@ -2685,6 +2709,9 @@
 #ifdef BEOS
 	if (!(environment & ENV_BE)) return 0;
 #endif
+#ifdef HAIKU
+	if (!(environment & ENV_BE)) return 0;
+#endif
 #ifdef G
 	if (F && drv->flags & GD_NO_OS_SHELL) return 0;
 #endif
diff -urN links-2.8.org/os_dep.h links-2.8/os_dep.h
--- links-2.8.org/os_dep.h	2013-09-17 02:11:47.030932992 +0200
+++ links-2.8/os_dep.h	2013-12-12 21:29:28.176685056 +0100
@@ -29,7 +29,7 @@
 #define WIN32
 #elif defined(__INTERIX)
 #define INTERIX
-#elif defined(__BEOS__) || defined(__HAIKU__)
+#elif defined(__BEOS__)
 #define BEOS
 #elif defined(__riscos__)
 #define RISCOS
@@ -41,6 +41,8 @@
 #define OPENVMS
 #elif defined(__DJGPP)
 #define DOS
+#elif defined(__HAIKU__)
+#define HAIKU
 #else
 #define UNIX
 #endif
@@ -158,6 +160,25 @@
 
 #include "beos.h"
 
+#elif defined(HAIKU)
+
+static inline int dir_sep(unsigned char x) { return x == '/'; }
+#define NEWLINE "\n"
+#define NO_ASYNC_LOOKUP /* async lookup works on BeOS but crashes the Haiku kernel */
+#define FS_UNIX_RIGHTS
+#define FS_UNIX_SOFTLINKS
+#define FS_UNIX_USERS
+/* TODO: allocate new SYS_* or replace SYS_BEOS */
+#define SYSTEM_ID SYS_BEOS
+#define SYSTEM_NAME "Haiku"
+#define DEFAULT_SHELL "/bin/sh"
+#define GETSHELL getenv("SHELL")
+#define NO_CTRL_Z
+#define SET_WINDOW_TITLE_UTF_8
+#define SHARED_CONFIG_DIR "/etc/"
+#define NO_FORK_ON_EXIT
+#define ASSOC_BLOCK
+
 #elif defined(RISCOS)
 
 static inline int dir_sep(unsigned char x) { return x == '/' || x == '\\'; }
diff -urN links-2.8.org/os_depx.h links-2.8/os_depx.h
--- links-2.8.org/os_depx.h	2013-08-25 13:07:50.033030144 +0200
+++ links-2.8/os_depx.h	2013-12-12 21:35:09.725614592 +0100
@@ -184,6 +184,10 @@
 #endif
 #endif
 
+#ifdef HAIKU
+/* nothing so far */
+#endif
+
 #ifdef OPENVMS
 #if defined(__INITIAL_POINTER_SIZE)
 #if __INITIAL_POINTER_SIZE == 64
@@ -340,6 +344,9 @@
 #elif defined(GRDRV_ATHEOS)
 #define loop_select ath_select
 int ath_select(int n, fd_set *r, fd_set *w, fd_set *e, struct timeval *t);
+#elif defined(GRDRV_HAIKU)
+#define loop_select be_loop_select
+int be_loop_select(int n, fd_set *r, fd_set *w, fd_set *e, struct timeval *t);
 #else
 #define loop_select select
 #endif
