HOWTO: cross-compile the Linux kernel on Cygwin

Yaakov (Cygwin/X) yselkowitz@users.sourceforge.net
Tue Jun 12 03:32:00 GMT 2012


Prerequisites:

* Cygwin snapshot 1.7.16s/20120611 or newer (DLL and headers)
* Cygwin gcc4-core 4.5 or newer, make, perl
* Cygwin gettext, libelf-devel, libgmp-devel, libmpc-devel, 
libmpfr-devel, zlib-devel
* (for make menuconfig) libncurses-devel or libncursesw-devel
* (for make nconfig) libncurses-devel
* (for make gconfig) libglade2.0-devel
* (for make xconfig) libQt3Support4-devel
* (for make gconfig/xconfig) X server running and DISPLAY variable set
* the attached patches

Directions:

(where ARCH=i386 TARGET=i686-pc-linux-gnu, or ARCH=x86_64 
TARGET=x86_64-pc-linux-gnu, or ARCH=arm 
TARGET=armv5tel-unknown-linux-gnueabi etc.)

1. cross-binutils

(linux-i686-binutils and linux-x86_64-binutils are available in Ports. 
Otherwise you can build this yourself:)
a. Download binutils-2.22 or newer from 
http://ftpmirror.gnu.org/binutils/ or 
http://www.kernel.org/pub/linux/devel/binutils/
b. Unpack and apply config-rpath.patch.
c. ./configure --target=$TARGET --with-sysroot=/usr/$TARGET/sys-root
d. make [-jN]
e. make install DESTDIR=$PWD/DESTDIR
f. rm -fr DESTDIR/usr/lib/ DESTDIR/usr/share/{info,locale}
g. cp -r DESTDIR/usr /

2. cross-gcc

(linux-i686-gcc-core and linux-x86_64-gcc-core are available in Ports.
Otherwise you can easily build a gcc which will suffice for building the 
kernel yourself:)
a. Download gcc-4.5.x or newer from http://ftpmirror.gnu.org/gcc/
b. Unpack and apply config-rpath.patch.
c. ./configure --target=$TARGET --enable-languages=c 
--enable-version-specific-runtime-libs --disable-shared 
--disable-threads --disable-libgomp --disable-libitm 
--disable-libmudflap --disable-libquadmath --disable-libssp 
--with-dwarf2 --with-system-zlib
d. make [-jN]
e. make install DESTDIR=$PWD/DESTDIR
f. rm -fr DESTDIR/usr/lib/libiberty.a 
DESTDIR/usr/share/{gcc-*,info,locale,man/man7}
g. cp -r DESTDIR/usr /

3. kernel

a. Download a kernel from http://www.kernel.org/pub/linux/kernel/ .
b. Unpack and apply patch 0001.
c. For 3.3 or newer kernels, apply patch 0002.
d. For make xconfig, apply patch 0003.
e. For make nconfig, apply patch 0004.
f. mkdir _build
g. make ARCH=$ARCH CROSS_COMPILE=$TARGET- O=_build 
[defconfig|menuconfig|nconfig|gconfig|xconfig|...]
h. Edit _build/.config if necessary.
i. make ARCH=$ARCH CROSS_COMPILE=$TARGET- O=_build [-jN]
j. mkdir -p DESTDIR/boot
k. make ARCH=$ARCH CROSS_COMPILE=$TARGET- O=_build 
INSTALL_PATH=$PWD/DESTDIR/boot  install
l. make ARCH=$ARCH CROSS_COMPILE=$TARGET- O=_build 
INSTALL_MOD_PATH=$PWD/DESTDIR modules_install
m. make ARCH=$ARCH CROSS_COMPILE=$TARGET- O=_build 
INSTALL_HDR_PATH=$PWD/DESTDIR/usr headers_install
n. find DESTDIR/usr/include -name '*.install*' -delete
o. tar Jcf kernel.tar.xz -C DESTDIR boot lib
p. tar Jcf kernel-headers.tar.xz -C DESTDIR usr/include

HTH,


Yaakov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: config-rpath.patch
Type: application/x-itunes-itlp
Size: 284 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20120612/442bb07a/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-fbdev-make-scripts-pnmtologo-dependency-portable.patch
Type: application/x-itunes-itlp
Size: 1108 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20120612/442bb07a/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-tools-include-use-stdint-types-for-user-space-bytesh.patch
Type: application/x-itunes-itlp
Size: 6178 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20120612/442bb07a/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-xconfig-use-pkgconfig-to-find-moc.patch
Type: application/x-itunes-itlp
Size: 1253 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20120612/442bb07a/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-kconfig-nconf-fix-compile-with-ncurses-reentrant-API.patch
Type: application/x-itunes-itlp
Size: 1119 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20120612/442bb07a/attachment-0004.bin>
-------------- next part --------------
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


More information about the Cygwin mailing list