From: ramsdell@mitre.org (John D. Ramsdell) Subject: [REVISED PATCH] Allow use of a C library in Mini-OS Date: 26 May 2006 06:58:55 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir.Fraser@cl.cam.ac.uk Cc: ramsdell@mitre.org, xen-devel@lists.xensource.com, gm281@cam.ac.uk List-Id: xen-devel@lists.xenproject.org --=-=-= 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 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=have_libc.patch Content-Description: Allow use of a C library in Mini-OS diff -ur oxen-unstable/extras/mini-os/lib/printf.c xen-unstable/extras/mini-os/lib/printf.c --- oxen-unstable/extras/mini-os/lib/printf.c 2006-05-25 01:02:20.000000000 -0400 +++ xen-unstable/extras/mini-os/lib/printf.c 2006-05-25 07:41:49.000000000 -0400 @@ -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 #include #include @@ -789,4 +791,4 @@ return i; } - +#endif diff -ur oxen-unstable/extras/mini-os/lib/string.c xen-unstable/extras/mini-os/lib/string.c --- oxen-unstable/extras/mini-os/lib/string.c 2006-05-25 01:02:20.000000000 -0400 +++ xen-unstable/extras/mini-os/lib/string.c 2006-05-25 07:41:49.000000000 -0400 @@ -18,6 +18,8 @@ **************************************************************************** */ +#if !defined HAVE_LIBC + #include #include #include @@ -153,3 +155,5 @@ } return NULL; } + +#endif diff -ur oxen-unstable/extras/mini-os/Makefile xen-unstable/extras/mini-os/Makefile --- oxen-unstable/extras/mini-os/Makefile 2006-05-25 01:02:20.000000000 -0400 +++ xen-unstable/extras/mini-os/Makefile 2006-05-26 06:39:43.000000000 -0400 @@ -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 $@.elf +$(TARGET): libminios.a $(HEAD) + $(LD) $(LDFLAGS) $(HEAD) $(LDLIBS) -o $@.elf gzip -f -9 -c $@.elf >$@.gz .PHONY: clean Only in xen-unstable/extras/mini-os: Makefile~ --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=-=-=--