Resources
| Sourcery G++ Data Sheet | |
| Register for a Sourcery G++ Evaluation | |
| Buy Sourcery G++ Today! |
Mailing Lists
| Announcements | |
| Discuss |
How do I use Sourcery G++ to build the Linux (or uClinux) kernel on Windows?
Question
How do I use Sourcery G++ to build the Linux (or uClinux) kernel on Windows?Answer
- Upgrade to Sourcery G++ 4.2-9 or later.
-
Download and install Cygwin from:
Install all the development tools and libraries.
-
Download
uClinux-dist-20070130.tar.bz2from: -
Copy
uClinux-dist-20070130.tar.bz2to your Cygwin home directoryc:\cygwin\home\user, whereuseris your Cygwin user name. -
Start a Cygwin shell. All subsequent steps assume you are in a Cygwin shell.
-
Change to your home directory:
> cd $HOME
-
Unpack uClinux-dist:
> tar jxf uClinux-dist-20070130.tar.bz2
-
Enter the uClinux-dist directory.
> cd uClinux-dist
-
Set CYGPATH as instructed in the Sourcery G++
Getting Started
guide. See the related knowledge base entry Using Sourcery G++ Without Cygwin for additional information. -
Build uClinux following the procedure in the uClinux README.
e.g.
> make xconfig > make dep > make
Notes:
-
Unpacking uClinux-dist-20070130 with verification enabled will report errors. There are files in the the uClinux-dist archive which cannot be created on a Windows file system.
-
In uClinux-dist-20070130 when building the linux-2.6.x kernel for m68knommu, the
drivers/mtd/chips/jedec_probe.csource file fails to compile becauseMTD_UADDR_0x1554_0x0AAAis undefined. Remove the following support from your kernel to continue building:e.g. For m68knommu:
> cd linux-2.6.x/ > make ARCH=m68knommu CROSS_COMPILE=m68k-linux-gnu- menuconfig
Remove support for "Detect non-CFI AMD/JEDEC-compatible flash chips". Located under: "Device Drivers --->", "Memory Technology Devices (MTD) --->", and "RAM/ROM/Flash Chip drivers --->".
Patch against uClinux-dist-20070130:
diff -urN linux-2.6.x/arch/arm/boot/compressed/Makefile linux-2.6.x/arch/arm/boot/compressed/Makefile
--- linux-2.6.x/arch/arm/boot/compressed/Makefile 2006-11-29 18:02:59.000000000 -0800
+++ linux-2.6.x/arch/arm/boot/compressed/Makefile 2007-04-24 08:55:50.742375000 -0700
@@ -104,7 +104,7 @@
LDFLAGS_vmlinux += --defsym params_phys=$(PARAMS_PHYS)
endif
LDFLAGS_vmlinux += -p --no-undefined -X \
- $(shell $(CC) $(CFLAGS) --print-libgcc-file-name) -T
+ "$(shell $(CC) $(CFLAGS) --print-libgcc-file-name)" -T
# Don't allow any static data in misc.o, which
# would otherwise mess up our GOT table
diff -urN linux-2.6.x/arch/powerpc/boot/Makefile linux-2.6.x/arch/powerpc/boot/Makefile
--- linux-2.6.x/arch/powerpc/boot/Makefile 2006-11-29 15:28:12.000000000 -0800
+++ linux-2.6.x/arch/powerpc/boot/Makefile 2007-04-24 09:09:03.367375000 -0700
@@ -24,7 +24,7 @@
HOSTCC := gcc
BOOTCFLAGS := $(HOSTCFLAGS) -fno-builtin -nostdinc -isystem \
- $(shell $(CROSS32CC) -print-file-name=include) -fPIC
+ "$(shell $(CROSS32CC) -print-file-name=include)" -fPIC
BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc
ifeq ($(call cc-option-yn, -fstack-protector),y)
@@ -77,10 +77,10 @@
$(obj)/empty.c
quiet_cmd_bootcc = BOOTCC $@
- cmd_bootcc = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $<
+ cmd_bootcc = $(CROSS32CC) -Wp,-MMD,$(depfile) $(BOOTCFLAGS) -c -o $@ $<
quiet_cmd_bootas = BOOTAS $@
- cmd_bootas = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
+ cmd_bootas = $(CROSS32CC) -Wp,-MMD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
quiet_cmd_bootar = BOOTAR $@
cmd_bootar = $(CROSS32AR) -cr $@.$$$$ $^; mv $@.$$$$ $@
diff -urN linux-2.6.x/scripts/Kbuild.include linux-2.6.x/scripts/Kbuild.include
--- linux-2.6.x/scripts/Kbuild.include 2006-11-29 15:28:19.000000000 -0800
+++ linux-2.6.x/scripts/Kbuild.include 2007-04-24 08:53:29.679875000 -0700
@@ -160,7 +160,8 @@
if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \
@set -e; \
$(echo-cmd) $(cmd_$(1)); \
- scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\
+ dos2unix $(depfile); \
+ scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' | unix2dos > $(dot-target).tmp;\
rm -f $(depfile); \
mv -f $(dot-target).tmp $(dot-target).cmd)
diff -urN linux-2.6.x/scripts/Makefile.build linux-2.6.x/scripts/Makefile.build
--- linux-2.6.x/scripts/Makefile.build 2006-11-29 15:28:19.000000000 -0800
+++ linux-2.6.x/scripts/Makefile.build 2007-04-24 08:53:29.711125000 -0700
@@ -190,8 +190,9 @@
define rule_cc_o_c
$(call echo-cmd,checksrc) $(cmd_checksrc) \
$(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \
+ dos2unix $(depfile); \
$(cmd_modversions) \
- scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \
+ scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' | unix2dos > \
$(dot-target).tmp; \
rm -f $(depfile); \
mv -f $(dot-target).tmp $(dot-target).cmd
diff -urN linux-2.6.x/scripts/Makefile.host linux-2.6.x/scripts/Makefile.host
--- linux-2.6.x/scripts/Makefile.host 2006-11-29 15:28:19.000000000 -0800
+++ linux-2.6.x/scripts/Makefile.host 2007-04-24 11:13:08.273625000 -0700
@@ -168,3 +168,4 @@
targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
$(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
+HOST_LOADLIBES := -lintl -lncurses
diff -urN linux-2.6.x/scripts/Makefile.lib linux-2.6.x/scripts/Makefile.lib
--- linux-2.6.x/scripts/Makefile.lib 2006-10-08 17:02:05.000000000 -0700
+++ linux-2.6.x/scripts/Makefile.lib 2007-04-24 08:53:29.773625000 -0700
@@ -108,14 +108,14 @@
__cpp_flags = $(call flags,_cpp_flags)
endif
-c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \
+c_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \
$(__c_flags) $(modkern_cflags) \
-D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
-a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \
+a_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \
$(__a_flags) $(modkern_aflags)
-cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(__cpp_flags)
+cpp_flags = -Wp,-MMD,$(depfile) $(NOSTDINC_FLAGS) $(__cpp_flags)
ld_flags = $(LDFLAGS) $(EXTRA_LDFLAGS)
diff -urN linux-2.6.x/scripts/mkcompile_h linux-2.6.x/scripts/mkcompile_h
--- linux-2.6.x/scripts/mkcompile_h 2005-10-27 21:39:22.000000000 -0700
+++ linux-2.6.x/scripts/mkcompile_h 2007-04-24 08:53:29.773625000 -0700
@@ -58,7 +58,7 @@
echo \#define LINUX_COMPILE_DOMAIN
fi
- echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | tail -n 1`\"
+ echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | dos2unix | tail -n 1 `\"
) > .tmpcompile
# Only replace the real compile.h if the new one is different,
diff -urN linux-2.6.x/scripts/mod/file2alias.c linux-2.6.x/scripts/mod/file2alias.c
--- linux-2.6.x/scripts/mod/file2alias.c 2006-11-29 15:28:19.000000000 -0800
+++ linux-2.6.x/scripts/mod/file2alias.c 2007-04-24 08:53:29.789250000 -0700
@@ -29,7 +29,11 @@
#include <ctype.h>
+#ifdef __CYGWIN__
+typedef __uint32_t __u32;
+#else
typedef uint32_t __u32;
+#endif
typedef uint16_t __u16;
typedef unsigned char __u8;
diff -urN linux-2.6.x/scripts/mod/modpost.h linux-2.6.x/scripts/mod/modpost.h
--- linux-2.6.x/scripts/mod/modpost.h 2006-10-08 17:02:05.000000000 -0700
+++ linux-2.6.x/scripts/mod/modpost.h 2007-04-24 08:53:29.804875000 -0700
@@ -9,6 +9,11 @@
#include <unistd.h>
#include <elf.h>
+#ifdef __CYGWIN__
+typedef uint16_t Elf32_Section;
+typedef uint16_t Elf64_Section;
+#endif
+
#include "elfconfig.h"
#if KERNEL_ELFCLASS == ELFCLASS32
diff -urN linux-2.6.x/scripts/mod/sumversion.c linux-2.6.x/scripts/mod/sumversion.c
--- linux-2.6.x/scripts/mod/sumversion.c 2006-06-18 16:30:49.000000000 -0700
+++ linux-2.6.x/scripts/mod/sumversion.c 2007-04-24 08:53:29.820500000 -0700
@@ -7,6 +7,7 @@
#include <ctype.h>
#include <errno.h>
#include <string.h>
+#include <limits.h>
#include "modpost.h"
/*
This entry was last updated on 4 October 2009.