Index: emc2/src/Makefile
===================================================================
--- emc2.orig/src/Makefile	2009-10-11 21:35:01.000000000 +0200
+++ emc2/src/Makefile	2009-10-11 21:40:04.000000000 +0200
@@ -52,8 +52,10 @@
 # The "modules" target is the gateway to the kernel module build.
 default: configs userspace modules
 ifeq ($(RUN_IN_PLACE),yes)
-ifeq "$(filter sim linux,$(BUILD_SYS))" ""
-	@if [ -f ../bin/emc_module_helper ]; then if ! [ `stat -c %u ../bin/emc_module_helper` -eq 0 -a -u ../bin/emc_module_helper ]; then $(VECHO) "You now need to run 'sudo make setuid' in order to run in place."; fi; fi
+ifneq ($(RUN_IN_PLACE),sim)
+	@for file in rtapi_app emc_module_helper bfload pci_write; do \
+	if [ -f ../bin/$$file -a \( `stat -c %u ../bin/$$file` -eq 0 -a -u ../bin/$$file \) ]; then \
+		$(VECHO) "You now need to run 'sudo make setuid' in order to run in place"; break; fi; done
 endif
 endif
 
@@ -361,19 +363,31 @@
 # So that nothing is built as root, this rule does not depend on the touched
 # files (Note that files in depends/ might be rebuilt, and there's little that
 # can be done about it)
-ifneq "$(filter sim linux,$(BUILD_SYS))" ""
+ifeq ($(BUILD_SYS),sim)
 setuid:
-	@echo "'make setuid' is not needed for the simulator/linux-rt"
+	@echo "'make setuid' is not needed for the simulator"
 else
 setuid:
-	chown root ../bin/emc_module_helper
-	chmod 4750 ../bin/emc_module_helper
-	chown root ../bin/bfload
-	chmod 4750 ../bin/bfload
-	chown root ../bin/pci_write
-	chmod 4750 ../bin/pci_write
-	chown root ../bin/pci_read
-	chmod 4750 ../bin/pci_read
+	if test -f ../bin/rtapi_app; then\
+	  chown root ../bin/rtapi_app;\
+	  chmod 4750 ../bin/rtapi_app;\
+	fi
+	if test -f ../bin/emc_module_helper; then\
+	  chown root ../bin/emc_module_helper;\
+	  chmod 4750 ../bin/emc_module_helper;\
+	fi
+	if test -f ../bin/bfload; then\
+	  chown root ../bin/bfload;\
+	  chmod 4750 ../bin/bfload;\
+	fi
+	if test -f ../bin/pci_write; then\
+	  chown root ../bin/pci_write;\
+	  chmod 4750 ../bin/pci_write;\
+	fi
+	if test -f ../bin/pci_read; then\
+	  chown root ../bin/pci_read;\
+	  chmod 4750 ../bin/pci_read;\
+	fi
 endif
 
 # These rules allows a header file from this directory to be installed into
@@ -626,9 +640,10 @@
 sampler-objs := hal/components/sampler.o $(MATHSTUB)
 
 # Subdirectory: hal/drivers
-ifeq "$(filter sim linux,$(BUILD_SYS))" ""
+ifneq ($(BUILD_SYS),sim)
 obj-$(CONFIG_HAL_PARPORT) += hal_parport.o
 hal_parport-objs := hal/drivers/hal_parport.o $(MATHSTUB)
+ifneq ($(BUILD_SYS),linux)
 obj-$(CONFIG_PCI_8255) += pci_8255.o
 pci_8255-objs := hal/drivers/pci_8255.o
 obj-$(CONFIG_HAL_TIRO) += hal_tiro.o
@@ -676,6 +691,7 @@
 probe_parport-objs := hal/drivers/probe_parport.o $(MATHSTUB)
 endif
 endif
+endif
 
 obj-$(CONFIG_CLASSICLADDER_RT) += classicladder_rt.o
 classicladder_rt-objs := hal/classicladder/module_hal.o $(MATHSTUB)
Index: emc2/src/configure.in
===================================================================
--- emc2.orig/src/configure.in	2009-10-11 21:35:01.000000000 +0200
+++ emc2/src/configure.in	2009-10-11 21:40:04.000000000 +0200
@@ -1421,7 +1421,7 @@
 if test "xyes" = "x$RUN_IN_PLACE"; then
 echo "#   Next compile by typing                                           #"
 echo "#         make                                                       #"
-if test $SIMULATOR != yes -a $LINUX_REALTIME != yes; then
+if test $SIMULATOR != yes; then
 echo "#         sudo make setuid                                           #"
 fi
 echo "#                                                                    #"
Index: emc2/src/hal/drivers/hal_parport.c
===================================================================
--- emc2.orig/src/hal/drivers/hal_parport.c	2009-10-11 21:35:01.000000000 +0200
+++ emc2/src/hal/drivers/hal_parport.c	2009-10-12 17:37:00.000000000 +0200
@@ -95,6 +95,7 @@
     information, go to www.linuxcnc.org.
 */
 
+#include <config.h>
 #include "rtapi.h"		/* RTAPI realtime OS API */
 #include "rtapi_ctype.h"	/* isspace() */
 #include "rtapi_app.h"		/* RTAPI realtime module decls */
@@ -107,10 +108,14 @@
 */
 #define FASTIO
 
-#ifdef FASTIO
-#define rtapi_inb inb
-#define rtapi_outb outb
-#include <asm/io.h>
+#ifdef RTAPI_LINUX	/* Realtime-Linux */
+# include <string.h>
+#else			/* Realtime hypervisor */
+# ifdef FASTIO
+#  define rtapi_inb inb
+#  define rtapi_outb outb
+#  include <asm/io.h>
+# endif
 #endif
 
 #include "parport_common.h"
@@ -211,7 +216,7 @@
     int n, retval;
 
 
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0) &&0//FIXME
     // this calculation fits in a 32-bit unsigned 
     // as long as CPUs are under about 6GHz
     ns2tsc_factor = (cpu_khz << 6) / 15625ul;
Index: emc2/src/hal/drivers/parport_common.h
===================================================================
--- emc2.orig/src/hal/drivers/parport_common.h	2009-10-11 21:35:01.000000000 +0200
+++ emc2/src/hal/drivers/parport_common.h	2009-10-12 17:35:36.000000000 +0200
@@ -20,6 +20,7 @@
     struct parport *linux_port = 0;
     memset(port, 0, sizeof(hal_parport_t));
 
+#ifndef RTAPI_LINUX
     // I/O addresses 1..16 are assumed to be linux parport numbers
     if(base < 16) {
         linux_port = parport_find_number(base);
@@ -68,7 +69,9 @@
 
         port->base = linux_port->base;
         port->base_hi = linux_port->base_hi;
-    } else {
+    } else
+#endif /* RTAPI_LINUX */
+    {
         if(base_hi == 0) base_hi = base + 0x400;
 
         port->base = base;
@@ -105,6 +108,7 @@
 
 void hal_parport_release(hal_parport_t *port)
 {
+#ifndef RTAPI_LINUX
     if(port->linux_dev)
     {
         rtapi_print_msg(RTAPI_MSG_INFO,
@@ -113,6 +117,7 @@
         parport_release(port->linux_dev);
         parport_unregister_device(port->linux_dev);
     }
+#endif
     if(port->region) {
         rtapi_print_msg(RTAPI_MSG_INFO,
 	    "PARPORT: Releasing I/O region ioaddr=0x%x\n", port->base);
@@ -126,4 +131,5 @@
     }
     memset(port, 0, sizeof(hal_parport_t));
 }
+
 #endif
Index: emc2/src/rtapi/rtapi.h
===================================================================
--- emc2.orig/src/rtapi/rtapi.h	2009-10-11 21:35:01.000000000 +0200
+++ emc2/src/rtapi/rtapi.h	2009-10-11 21:40:04.000000000 +0200
@@ -725,7 +725,7 @@
 */
     extern unsigned char rtapi_inb(unsigned int port);
 
-#if defined(RTAPI) && !defined(SIM)
+#if (defined(RTAPI) && !defined(SIM)) || defined(RTAPI_LINUX)
 /** 'rtapi_request_region() reserves I/O memory starting at 'base',
     going for 'size' bytes, for component 'name'.
 
@@ -735,11 +735,13 @@
     a non-NULL value.
 */
 #include <linux/version.h>
-#include <linux/ioport.h>
+#ifndef RTAPI_LINUX
+# include <linux/ioport.h>
+#endif
 
     static __inline__ void *rtapi_request_region(unsigned long base,
             unsigned long size, const char *name) {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) && !defined(RTAPI_LINUX)
         return (void*)request_region(base, size, name);
 #else
         return (void*)-1;
@@ -753,7 +755,7 @@
 */
     static __inline__ void rtapi_release_region(unsigned long base,
             unsigned long int size) {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) && !defined(RTAPI_LINUX)
         release_region(base, size);
 #endif
     }
