Skip to contentSkip to conversation

Allow use of a C library in Mini-OS

PATCH New John D. Ramsdell 1 participant 1 message May 26, 2006 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): E1FjHNO-0000Fc-PD@host-192-168-0-1-bcn-london

#1 lore raw

PATCH 1/1 Allow use of a C library in Mini-OS

Keir,

Enclosed is a revised patch that allows the use of a C library in Mini-OS without modifying Mini-OS source files. It incorporates Gregor's request that links no longer be a prerequisite of the target $(TARGET). A nice side-effect of Gregor's requested change is I had to look at the Makefile once again, and noticed the archive command was written using ar, rather than $(AR). AR is set by /../../Config.mk to $(CROSS_COMPILE)ar, so without this change, cross compilation can get confused. The revised patch fixes this problem too. The text with the origin patch request follows.

I'd like to make it so that the following command builds libminios.a using a cross-compiler that provides a full C library.

$ $PATH=${COMP_HOME}/bin:$PATH make CPPFLAGS=-DHAVE_LIBC libminios.a

The enclosed patch makes small changes to three files. The Makefile is changed so that the libminios.a target depends on the links target, and lib/printf.c and lib/string.c are changed so their content is omitted when HAVE_LIBC is defined.

John

extras/mini-os/lib/printf.c +3 -1
diff -ur oxen-unstable/extras/mini-os/lib/printf.c xen-unstable/extras/mini-os/lib/printf.c
@@ -54,6 +54,8 @@
  * $FreeBSD: src/sys/libkern/divdi3.c,v 1.6 1999/08/28 00:46:31 peter Exp $
  */
 
+#if !defined HAVE_LIBC
+
 #include <os.h>
 #include <types.h>
 #include <hypervisor.h>
@@ -789,4 +791,4 @@
 	return i;
 }
 
-
+#endif
extras/mini-os/lib/string.c +4 -0
diff -ur oxen-unstable/extras/mini-os/lib/string.c xen-unstable/extras/mini-os/lib/string.c
@@ -18,6 +18,8 @@
  ****************************************************************************
  */
 
+#if !defined HAVE_LIBC
+
 #include <os.h>
 #include <types.h>
 #include <lib.h>
@@ -153,3 +155,5 @@
         }
         return NULL;
 }
+
+#endif
extras/mini-os/Makefile +5 -4
diff -ur oxen-unstable/extras/mini-os/Makefile xen-unstable/extras/mini-os/Makefile
@@ -13,6 +13,7 @@
 override CPPFLAGS := -Iinclude $(CPPFLAGS)
 ASFLAGS = -D__ASSEMBLY__
 
+LDLIBS =  -L. -lminios
 LDFLAGS := -N -T minios-$(TARGET_ARCH).lds
 
 ifeq ($(TARGET_ARCH),x86_32)
@@ -55,11 +56,11 @@
 links:
 	[ -e include/xen ] || ln -sf ../../../xen/include/public include/xen
 
-libminios.a: $(OBJS) $(HEAD)
-	ar r libminios.a $(HEAD) $(OBJS)
+libminios.a: links $(OBJS) $(HEAD)
+	$(AR) r libminios.a $(HEAD) $(OBJS)
 
-$(TARGET): links libminios.a $(HEAD)
-	$(LD) $(LDFLAGS) $(HEAD) -L. -lminios -o [email protected]
+$(TARGET): libminios.a $(HEAD)
+	$(LD) $(LDFLAGS) $(HEAD) $(LDLIBS) -o [email protected]
 	gzip -f -9 -c [email protected] >[email protected]
 
 .PHONY: clean

Only in xen-unstable/extras/mini-os: Makefile~

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel