Index: freebsd-to-rtems.py
===================================================================
--- freebsd-to-rtems.py	(revision 294ae20eca88446f8d980a2f764185cac9ab809b)
+++ freebsd-to-rtems.py	(revision 63e8969169451deb088c400336653d78e94746f1)
@@ -1,2 +1,4 @@
+#! /usr/bin/python
+#
 #  Copyright (c) 2009-2011 embedded brains GmbH.  All rights reserved.
 #
@@ -6,4 +8,7 @@
 #   Germany
 #   <info@embedded-brains.de>
+#
+#  Copyright (c) 2012.
+#  Modifications by OAR Corporation. All rights reserved.
 #
 #  Redistribution and use in source and binary forms, with or without
@@ -33,14 +38,16 @@
 import os
 import re
+import sys
 
 PREFIX = 'rtems/freebsd'
 
-OUTPUT_DIRECTORY = '/home/kirspelk/sandbox/opti_touch/libbsd-8.2'
+# the program name and the file name
+if len(sys.argv) != 2:
+  sys.exit("Must provide an output directory")
+
+OUTPUT_DIRECTORY = sys.argv[1]
+print "Generating into", OUTPUT_DIRECTORY
 
 REVERT_DIRECTORY = '.'
-
-BSP = '/home/kirspelk/sandbox/opti_touch/b_rtems_arm/arm-rtems/c/lpc3250/make'
-
-INSTALL_BASE = '/home/kirspelk/sandbox/opti_touch/b_rtems_arm/arm-rtems/lpc3250/lib'
 
 def mapContribPath(path):
@@ -168,13 +175,11 @@
 
 	def createMakefile(self):
-		data = 'RTEMS_MAKEFILE_PATH = ' + BSP + '\n' \
-			'INSTALL_BASE = ' + INSTALL_BASE + '\n' \
+		data = 'include config.inc\n' \
 			'\n' \
 			'include $(RTEMS_MAKEFILE_PATH)/Makefile.inc\n' \
 			'include $(RTEMS_CUSTOM)\n' \
 			'include $(PROJECT_ROOT)/make/leaf.cfg\n' \
-			'include $(PROJECT_ROOT)/make/target.cfg\n' \
 			'\n' \
-			'CFLAGS += -ffreestanding -I . -I contrib/altq -I contrib/pf -B $(INSTALL_BASE) -w -std=gnu99\n' \
+			'CFLAGS += -ffreestanding -I . -I rtemsbsd -I contrib/altq -I contrib/pf -B $(INSTALL_BASE) -w -std=gnu99\n' \
 			'\n'
 		data += 'C_FILES ='
@@ -184,4 +189,7 @@
 				f = mapContribPath(f)
 				data += ' \\\n\t' + f
+		for f in rtems_sourceFiles:
+			f = 'rtemsbsd/src/' + f
+			data += ' \\\n\t' + f
 
 		data += '\nC_O_FILES = $(C_FILES:%.c=%.o)\n' \
@@ -196,10 +204,10 @@
 			'\n' \
 			'lib_usb:\n' \
-			'\texport PATH=$(PATH):/usr/local/gcc-4.5.2/bin ; \\\n' \
 			'\tmake $(LIB)\n' \
 			'\n' \
 			'install: $(LIB)\n' \
             '\tinstall -c -m 644 $(LIB) $(INSTALL_BASE)\n' \
-            '\tfor i in `find . -name \'*.h\'` ; do install -c -m 644 -D "$$i" "$(INSTALL_BASE)/include/$$i" ; done\n' \
+            '\tfor i in `find . -name \'*.h\'` ; do \\\n' \
+            '\t  install -c -m 644 -D "$$i" "$(INSTALL_BASE)/include/$$i" ; done\n' \
 			'\n' \
 			'clean:\n' \
@@ -228,77 +236,75 @@
 		self.dependencies.append(dep)
 
-print( "1\n" )
 mm = ModuleManager()
-print( "2\n" )
-
-rtems = Module('rtems')
-rtems.addHeaderFiles(
-	[
-		'rtems/machine/atomic.h',
+
+rtems_headerFiles = [
+	'rtems/machine/atomic.h',
         'rtems/machine/_bus.h',
-		'rtems/machine/bus.h',
-		'rtems/machine/bus_dma.h',
+	'rtems/machine/bus.h',
+	'rtems/machine/bus_dma.h',
         'rtems/machine/rtems-bsd-config.h',
         'rtems/machine/clock.h',
-		'rtems/machine/cpufunc.h',
-		'rtems/machine/endian.h',
-		'rtems/machine/_limits.h',
-		'rtems/machine/_align.h',
-		'rtems/machine/mutex.h',
-		'rtems/machine/param.h',
-		'rtems/machine/pcpu.h',
+	'rtems/machine/cpufunc.h',
+	'rtems/machine/endian.h',
+	'rtems/machine/_limits.h',
+	'rtems/machine/_align.h',
+	'rtems/machine/mutex.h',
+	'rtems/machine/param.h',
+	'rtems/machine/pcpu.h',
         #'rtems/machine/pmap.h',
-		'rtems/machine/proc.h',
-		'rtems/machine/resource.h',
-		'rtems/machine/runq.h',
-		'rtems/machine/signal.h',
-		'rtems/machine/stdarg.h',
-		'rtems/machine/_stdint.h',
-		'rtems/machine/_types.h',
-		'rtems/machine/ucontext.h',
-		'rtems/machine/rtems-bsd-symbols.h',
-		'rtems/machine/rtems-bsd-cache.h',
-		'rtems/machine/rtems-bsd-sysinit.h',
+	'rtems/machine/proc.h',
+	'rtems/machine/resource.h',
+	'rtems/machine/runq.h',
+	'rtems/machine/signal.h',
+	'rtems/machine/stdarg.h',
+	'rtems/machine/_stdint.h',
+	'rtems/machine/_types.h',
+	'rtems/machine/ucontext.h',
+	'rtems/machine/rtems-bsd-symbols.h',
+	'rtems/machine/rtems-bsd-cache.h',
+	'rtems/machine/rtems-bsd-sysinit.h',
         'rtems/machine/rtems-bsd-select.h',
         #'rtems/machine/vm.h',
-		'bsd.h',
-	]
-)
-rtems.addSourceFiles(
-	[
-		'rtems/rtems-bsd-cam.c',
-		'rtems/rtems-bsd-nexus.c',
-		'rtems/rtems-bsd-autoconf.c',
-        'rtems/rtems-bsd-delay.c',
-		'rtems/rtems-bsd-mutex.c',
-		'rtems/rtems-bsd-thread.c',
-		'rtems/rtems-bsd-condvar.c',
-        'rtems/rtems-bsd-lock.c',
-		'rtems/rtems-bsd-sx.c',
-        'rtems/rtems-bsd-rwlock.c',
-        'rtems/rtems-bsd-generic.c',
-        'rtems/rtems-bsd-panic.c',
-        'rtems/rtems-bsd-synch.c',
-		'rtems/rtems-bsd-signal.c',
-		'rtems/rtems-bsd-callout.c',
-		'rtems/rtems-bsd-init.c',
-        'rtems/rtems-bsd-init-with-irq.c',
-		'rtems/rtems-bsd-assert.c',
-        'rtems/rtems-bsd-prot.c',
-        'rtems/rtems-bsd-resource.c',
-        'rtems/rtems-bsd-jail.c',
-		'rtems/rtems-bsd-shell.c',
-        'rtems/rtems-bsd-syscalls.c',
-        #'rtems/rtems-bsd-socket.c',
-        #'rtems/rtems-bsd-mbuf.c',
-		'rtems/rtems-bsd-malloc.c',
-        'rtems/rtems-bsd-support.c',
-		'rtems/rtems-bsd-bus-dma.c',
-        'rtems/rtems-bsd-sysctl.c',
-        'rtems/rtems-bsd-sysctlbyname.c',
-        'rtems/rtems-bsd-sysctlnametomib.c',
-        'rtems/rtems-bsd-uma.c',
-	]
-)
+	'bsd.h',
+	]
+rtems_sourceFiles = [
+	'rtems-bsd-cam.c',
+	'rtems-bsd-nexus.c',
+	'rtems-bsd-autoconf.c',
+        'rtems-bsd-delay.c',
+	'rtems-bsd-mutex.c',
+	'rtems-bsd-thread.c',
+	'rtems-bsd-condvar.c',
+        'rtems-bsd-lock.c',
+	'rtems-bsd-sx.c',
+        'rtems-bsd-rmlock.c',
+        'rtems-bsd-rwlock.c',
+        'rtems-bsd-generic.c',
+        'rtems-bsd-panic.c',
+        'rtems-bsd-synch.c',
+	'rtems-bsd-signal.c',
+	'rtems-bsd-callout.c',
+	'rtems-bsd-init.c',
+        'rtems-bsd-init-with-irq.c',
+	'rtems-bsd-assert.c',
+        'rtems-bsd-prot.c',
+        'rtems-bsd-resource.c',
+        'rtems-bsd-jail.c',
+	'rtems-bsd-shell.c',
+        'rtems-bsd-syscalls.c',
+        #rtems-bsd-socket.c',
+        #rtems-bsd-mbuf.c',
+	'rtems-bsd-malloc.c',
+        'rtems-bsd-support.c',
+	'rtems-bsd-bus-dma.c',
+        'rtems-bsd-sysctl.c',
+        'rtems-bsd-sysctlbyname.c',
+        'rtems-bsd-sysctlnametomib.c',
+        'rtems-bsd-uma.c',
+	]
+# RTEMS files handled separately from modules
+# rtems = Module('rtems')
+# rtems.addHeaderFiles( rtems_headerFiles )
+# rtems.addSourceFiles( rtems_sourceFiles )
 
 local = Module('local')
@@ -1549,5 +1555,5 @@
 mm.addModule(devNet)
 
-mm.addModule(rtems)
+# mm.addModule(rtems)
 mm.addModule(local)
 mm.addModule(devUsbBase)
@@ -1564,2 +1570,3 @@
 mm.copyFiles()
 mm.createMakefile()
+
