[OpenBIOS] [Patch] Allow building on Mac OS X

Programmingkid programmingkidx at gmail.com
Fri Apr 10 22:25:43 CEST 2015


This patch allows OpenBIOS to be built on Mac OS X.

Notes:
I had to disable the -Werror flag because the file usbohci.c produces a lot of warnings when compiling. Here is what I see: "usbohci.c:230: warning: dereferencing type-punned pointer will break strict-aliasing rules". This warning is repeated many times in this file. Since I don't use usb, I'm not worried about these warnings.

The uname -m option does not work properly on Mac OS X. It incorrectly reports i386 when it should report amd64. That is why it can't be counted on. Another command is used instead to determine the correct architecture type.

The ppc-elf-gcc compiler is available from here: http://awos.wilcox-tech.com/downloads/AWOS-CC.bz2. It is quick and easy to download. It gives the user a gcc compiler that can make elf executables on Mac OS X. It is the reason why I added ppc-elf to the select_prefix() function. 

Index: Makefile.target
===================================================================
--- Makefile.target	(revision 1334)
+++ Makefile.target	(working copy)
@@ -29,7 +29,7 @@
 CFLAGS+= -Wall -Wredundant-decls -Wshadow -Wpointer-arith
 CFLAGS+= -Wstrict-prototypes -Wmissing-declarations -Wundef -Wendif-labels
 CFLAGS+= -Wstrict-aliasing -Wwrite-strings -Wmissing-prototypes -Wnested-externs
-CFLAGS+= -Werror
+# CFLAGS+= -Werror
 # Flags for dependency generation
 CFLAGS+= -MMD -MP -MT $@ -MF '$(*D)/$(*F).d'
 INCLUDES := -I$(SRCDIR)/include -I$(SRCDIR)/kernel/include -I$(ODIR)/target/include
Index: config/scripts/switch-arch
===================================================================
--- config/scripts/switch-arch	(revision 1334)
+++ config/scripts/switch-arch	(working copy)
@@ -97,9 +97,30 @@
 	-e "s/Power Macintosh/ppc/"`
 }
 
+archname()
+ {
+    OS_NAME=`uname`
+    
+    # If running on Mac OS X
+    # uname -m is inncorrect on Mac OS X so we can't depend on it
+	if test "$OS_NAME" = "Darwin"; then
+		IS_64BIT=`sysctl hw.cpu64bit_capable`
+		if test "$IS_64BIT" = "hw.cpu64bit_capable: 1"; then
+			HOSTARCH="amd64"
+		else
+			HOSTARCH="x86"
+		fi
+	else
+		 HOSTARCH=`uname -m | sed -e s/i.86/x86/ -e s/i86pc/x86/ \
+		-e s/sun4u/sparc64/ -e s/sparc$/sparc32/ \
+		-e s/arm.*/arm/ -e s/sa110/arm/ -e s/x86_64/amd64/ \
+		-e "s/Power Macintosh/ppc/"`
+	fi
+}
+
 select_prefix()
 {
-    for TARGET in ${1}-unknown-linux-gnu- ${1}-linux-gnu- ${1}-linux- ${1}-elf- ${1}-eabi-
+    for TARGET in ${1}-unknown-linux-gnu- ${1}-linux-gnu- ${1}-linux- ${1}-elf- ${1}-eabi- ppc-elf-
     do
         if type ${TARGET}gcc > /dev/null 2>&1
         then


More information about the OpenBIOS mailing list