Building Linux kernel in Xenomai tree.
RFC 1/1 Building Linux kernel in Xenomai tree.
Hi,
attached is a patch of Xenomai trunk build system to allow building Linux kernel as part of Xenomai build process. This way, typing make install builds and installs the Linux kernel, kernel modules and Xenomai.
The patch is a bit young and still has a few drawbacks, but before spending to much time on it, I would like to know if anyone is opposed to the idea of building Linux in Xenomai build tree.
To try this patch, apply and run the bootstrap script.
3 options are then added to configure :
--enable-linux-build Build Linux in Xenomai build tree
--with-linux-srcdir specify the path to Linux sources. Default is to
use, if not cross-compiling, the source of the running kernel or /usr/src/linux.
--with-adeos-patch specify the path to the Adeos patch. Default is to
infer the patch name from Linux kernel version.
When using the --enable-linux-build option, configure creates a linux tree in Xenomai build tree, and run the prepare-kernel.sh script for this tree. Typing "make" re-runs prepare-kernel.sh (in case some changes occured in Xenomai sources) and run make in the kernel tree.
Known limitations are:
- it is not very well tested, so, maybe some error cases are not handled correctly ;
- it is not tested with Linux 2.4 ;
- for an unknown reason, xenomai modules are built every time prepare-kernel.sh is run ;
- the cross-compilation prefix is inferred from the CC variable, it should work in most situations, but not all.
Happy new year.
Signature · 1 line
Gilles Chanteperdrix.
build-kernel/Makefile.am renamed from Makefile.am +44 -1
@@ -2,7 +2,9 @@ ACLOCAL_AMFLAGS=-I config SUDO=sudo -SUBDIRS = src include config @XENO_MAYBE_DOCDIR@ scripts +# Do not include sim subdirectory in source tarball. +DIST_SUBDIRS = src include config @XENO_MAYBE_DOCDIR@ scripts +SUBDIRS = $(DIST_SUBDIRS) $(subdirs) EXTRA_DIST = CREDITS README.INSTALL TROUBLESHOOTING ksrc
@@ -51,3 +53,44 @@ install-exec-local: devices install-nodev: $(MAKE) SUDO=false install + +if XENO_BUILD_LINUX +linux/%: + $(top_srcdir)/scripts/prepare-kernel.sh \ + --adeos="$(ADEOS_PATCH)" --linux=linux \ + --arch=$(XENO_TARGET_ARCH) && \ + cross=`expr $CC : '\(.*\)gcc' || :` && \ + cd linux && $(MAKE) $* \ + ARCH=$(XENO_TARGET_ARCH) \ + CROSS_COMPILE=$$cross + +linux/.xenomai-prepared: config.status + ./config.status linux + +linux/install: + @sudo=; if test x`id -u` != x0 && test \! "x`type $(SUDO)`" = x; then \ + sudo=$(SUDO); fi && \ + cross=`expr $CC : '\(.*\)gcc' || :` && \ + $$sudo $(mkinstalldirs) $(DESTDIR)/boot && \ + cd linux && $$sudo $(MAKE) modules_install install \ + ARCH=$(XENO_TARGET_ARCH) \ + CROSS_COMPILE=$$cross \ + INSTALL_PATH=$(DESTDIR)/boot \ + INSTALL_MOD_PATH=$(DESTDIR) + +config oldconfig mconfig menuconfig gconfig xconfig: + $(MAKE) linux/$@ + +all-local: linux/all + +clean-local: linux/clean + +distclean-local: + @test -e linux/.config && \ + mv linux/.config linux/.config.saved.xenomai; \ + $(MAKE) linux/distclean; \ + test -e linux/.config.saved.xenomai && \ + mv linux/.config.saved.xenomai linux/.config + +install-data-local: linux/install +endif
build-kernel/configure.in renamed from configure.in +178 -0
203 lines not on this page · raw message
Quoted 4 lines · Gilles Chanteperdrix
Known limitations are:
(...)
- for an unknown reason, xenomai modules are built every timeprepare-kernel.shis run ;
The reason for this limitation is that prepare-kernel.sh remove directories before re-creating them and before creating symbolic links.
The previous patch was also incorrect when trying to cross-compile the Linux kernel or building it for ppc. The attached patch fixes these issues.
Signature · 1 line
Gilles Chanteperdrix.
build-kernel/Makefile.am renamed from Makefile.am +46 -1
@@ -2,7 +2,9 @@ ACLOCAL_AMFLAGS=-I config SUDO=sudo -SUBDIRS = src include config @XENO_MAYBE_DOCDIR@ scripts +# Do not include sim subdirectory in source tarball. +DIST_SUBDIRS = src include config @XENO_MAYBE_DOCDIR@ scripts +SUBDIRS = $(DIST_SUBDIRS) $(subdirs) EXTRA_DIST = CREDITS README.INSTALL TROUBLESHOOTING ksrc
@@ -51,3 +53,46 @@ install-exec-local: devices install-nodev: $(MAKE) SUDO=false install + +if XENO_BUILD_LINUX +linux/%: linux/.xenomai-prepared + $(top_srcdir)/scripts/prepare-kernel.sh \ + --adeos="$(ADEOS_PATCH)" --linux=linux \ + --arch=$(XENO_LINUX_ARCH) && \ + cross=`expr $(CC) : '\(.*\)gcc' || :` && \ + cd linux && $(MAKE) $* \ + ARCH=$(XENO_LINUX_ARCH) \ + CROSS_COMPILE=$$cross + +linux/.xenomai-prepared: config.status + ./config.status linux + +linux/install: linux/all + @sudo=; if test x`id -u` != x0 && test \! "x`type $(SUDO)`" = x; then \ + sudo=$(SUDO); fi && \ + cross=`expr $(CC) : '\(.*\)gcc' || :` && \ + $$sudo $(mkinstalldirs) $(DESTDIR)/boot && \ + cd linux && $$sudo $(MAKE) modules_install install \ + ARCH=$(XENO_LINUX_ARCH) \ + CROSS_COMPILE=$$cross \ + INSTALL_PATH=$(DESTDIR)/boot \ + INSTALL_MOD_PATH=$(DESTDIR) + +distclean-linux: + @test -e linux/.config && \ + mv linux/.config linux/.config.saved.xenomai; \ + $(MAKE) linux/distclean; \ + test -e linux/.config.saved.xenomai && \ + mv linux/.config.saved.xenomai linux/.config + +config oldconfig mconfig menuconfig gconfig xconfig: + $(MAKE) linux/$@ + +all-recursive: linux/all + +clean-recursive: linux/clean + +distclean-recursive: distclean-linux + +install-recursive: linux/install +endif
build-kernel/configure.in renamed from configure.in +186 -0
220 lines not on this page · raw message
Quoted 9 lines · Gilles Chanteperdrix
Quoted 4 lines · Gilles Chanteperdrix
Known limitations are:
(...)
- for an unknown reason, xenomai modules are built every timeprepare-kernel.shis run ;The reason for this limitation is that
prepare-kernel.shremove directories before re-creating them and before creating symbolic links.
At this chance, something from my private whish list: :)
"unprepare-kernel.sh" or so, i.e. turning the kernel in its original vanilla state again.
This is helpful when applying/reversing third-party kernel patches which also touch the modified Makefiles. I think on some 2.4 kernel, even reverting ipipe collides with the xeno-preparation.
Quoted 4 lines
The previous patch was also incorrect when trying to cross-compile the Linux kernel or building it for ppc. The attached patch fixes these issues.
Regarding your general idea, I'm just trying to imagine the new build
process: you prepare and build the kernel + the userspace stuff again in one step?. But you still have to configure both parts separately.
The question for me is now if this simplifies the situation expecially for beginners. So far, the separation was clearly visible, now it /may/ become blurred (but I'm not a beginner...).
Can you provide a rough comparision of the workflows? Sorry, but I'm too lazy, I mean busy to give it a try.
Jan
Quoted 9 lines · Jan Kiszka
Quoted 4 lines
The previous patch was also incorrect when trying to cross-compile the Linux kernel or building it for ppc. The attached patch fixes these issues.
Regarding your general idea, I'm just trying to imagine the new build
process: you prepare and build the kernel + the userspace stuff again in one step?. But you still have to configure both parts separately.
Quoted 6 lines
The question for me is now if this simplifies the situation expecially for beginners. So far, the separation was clearly visible, now it /may/ become blurred (but I'm not a beginner...).
Can you provide a rough comparision of the workflows? Sorry, but I'm too lazy, I mean busy to give it a try.
configure --enable-linux-build
make xconfig
make install
If you already have a .config file, the "make xconfig" step becomes optional.
Note that the --enable-linux-build flag is optional too.
The simplification is mainly for developping xenomai itself, not for its users. Because with the current scheme, after some modifications, you have to recompile and reinstall both the kernel-space modules and user-space libraries.
If you let configure select the proper adeos patch, you are warned when the adeos patch changed in the source directory (after an svn update, for example), and just have to type:
rm linux/.xenomai-prepared (Ok, this step is a bit awkward, we may find
something better)
make install
And a new kernel will be built and installed, using the new adeos patch and the same .config.
Signature · 1 line
Gilles Chanteperdrix.
Quoted 14 lines · Gilles Chanteperdrix
Quoted 13 lines · Jan Kiszka
Quoted 4 lines
The previous patch was also incorrect when trying to cross-compile the Linux kernel or building it for ppc. The attached patch fixes these issues.
Regarding your general idea, I'm just trying to imagine the new build
process: you prepare and build the kernel + the userspace stuff again in one step?. But you still have to configure both parts separately.The question for me is now if this simplifies the situation expecially for beginners. So far, the separation was clearly visible, now it /may/ become blurred (but I'm not a beginner...).
Quoted 7 lines
Quoted 2 lines
Can you provide a rough comparision of the workflows? Sorry, but I'm too lazy, I mean busy to give it a try.
configure --enable-linux-build
make xconfig
make install
I'm starting to like this!
Quoted 17 lines
If you already have a .config file, the "make xconfig" step becomes optional.
Note that the --enable-linux-build flag is optional too.
The simplification is mainly for developping xenomai itself, not for its users. Because with the current scheme, after some modifications, you have to recompile and reinstall both the kernel-space modules and user-space libraries.
If you let configure select the proper adeos patch, you are warned when the adeos patch changed in the source directory (after an svn update, for example), and just have to type:
rm linux/.xenomai-prepared (Ok, this step is a bit awkward, we may find
something better)
make install
Quoted 3 lines
And a new kernel will be built and installed, using the new adeos patch and the same .config.
Hmm, what about this: Instead of leaving some (probably empty) xenomai-prepared in the kernel tree, better create an xenomai-uninstall script in the same place. It a) can serve as an indication for a prepared kernel and b) can be used to upgrade that tree by first running it and then applying the usual steps on the kernel again.
I often forget to save my old adeos patch before updating the xenomai tree, thus I will then have to download the old patch again, reverse-apply it, and can finally run the prepare script for the update. Automating this would be REALLY, REALLY GREAT!
Jan
Quoted 17 lines · Jan Kiszka
Quoted 10 lines
If you let configure select the proper adeos patch, you are warned when the adeos patch changed in the source directory (after an svn update, for example), and just have to type:
rm linux/.xenomai-prepared (Ok, this step is a bit awkward, we may find
something better)
make installAnd a new kernel will be built and installed, using the new adeos patch and the same .config.
Hmm, what about this: Instead of leaving some (probably empty) xenomai-prepared in the kernel tree, better create an xenomai-uninstall script in the same place. It a) can serve as an indication for a prepared kernel and b) can be used to upgrade that tree by first running it and then applying the usual steps on the kernel again.
Quoted 4 lines
I often forget to save my old adeos patch before updating the xenomai tree, thus I will then have to download the old patch again, reverse-apply it, and can finally run the prepare script for the update. Automating this would be REALLY, REALLY GREAT!
The current approach try and achieve a similar goal by first copying (it is not a real copy, only symbolic links to the source tree, a bit like lndir would do) an unpatched kernel in Xenomai build tree, and preparing it there. This way, when compilation with a new patch is needed, there is no need to "unprepare" the kernel, only erase, copy again and prepare the fresh copy, using the new patch. And that is what the current patch automates.
unpreparing seems harder.
Signature · 1 line
Gilles Chanteperdrix.
Quoted 11 lines · Gilles Chanteperdrix
Hi,
attached is a patch of Xenomai trunk build system to allow building Linux kernel as part of Xenomai build process. This way, typing make install builds and installs the Linux kernel, kernel modules and Xenomai.
The patch is a bit young and still has a few drawbacks, but before spending to much time on it, I would like to know if anyone is opposed to the idea of building Linux in Xenomai build tree.
Quoted 6 lines
To try this patch, apply and run the bootstrap script.
3 options are then added to configure :
--enable-linux-build Build Linux in Xenomai build tree
--with-linux-srcdir specify the path to Linux sources. Default is to
use, if not cross-compiling, the source of the running kernel or/usr/src/linux.
--enable-linux-build=<linux-tree> ?
Quoted 27 lines
--with-adeos-patch specify the path to the Adeos patch. Default is to
infer the patch name from Linux kernel version.When using the --enable-linux-build option, configure creates a linux tree in Xenomai build tree, and run the
prepare-kernel.shscript for this tree. Typing "make" re-runsprepare-kernel.sh(in case some changes occured in Xenomai sources) and run make in the kernel tree.Known limitations are:
- it is not very well tested, so, maybe some error cases are not handled correctly ;
- it is not tested with Linux 2.4 ;
- for an unknown reason, xenomai modules are built every timeprepare-kernel.shis run ;
- the cross-compilation prefix is inferred from the CC variable, it should work in most situations, but not all.Happy new year.
------------------------------------------------------------------------
_______________________________________________
Xenomai-core mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-core
Signature · 1 line
Philippe.
Quoted 12 lines · Philippe Gerum
Quoted 11 lines · Gilles Chanteperdrix
Hi,
attached is a patch of Xenomai trunk build system to allow building Linux kernel as part of Xenomai build process. This way, typing make install builds and installs the Linux kernel, kernel modules and Xenomai.
The patch is a bit young and still has a few drawbacks, but before spending to much time on it, I would like to know if anyone is opposed to the idea of building Linux in Xenomai build tree.
Quoted 8 lines
Quoted 6 lines
To try this patch, apply and run the bootstrap script.
3 options are then added to configure :
--enable-linux-build Build Linux in Xenomai build tree
--with-linux-srcdir specify the path to Linux sources. Default is to
use, if not cross-compiling, the source of the running kernel or/usr/src/linux.--enable-linux-build=<linux-tree> ?
The current approach is to use the sources of the running kernel if the only option specified is --enable-linux-build. Do you mean you find this feature superfluous ?
Signature · 1 line
Gilles Chanteperdrix.
Quoted 20 lines · Gilles Chanteperdrix
Quoted 19 lines · Philippe Gerum
Quoted 17 lines · Gilles Chanteperdrix
Hi,
attached is a patch of Xenomai trunk build system to allow building Linux kernel as part of Xenomai build process. This way, typing make install builds and installs the Linux kernel, kernel modules and Xenomai.
The patch is a bit young and still has a few drawbacks, but before spending to much time on it, I would like to know if anyone is opposed to the idea of building Linux in Xenomai build tree.
To try this patch, apply and run the bootstrap script.
3 options are then added to configure :
--enable-linux-build Build Linux in Xenomai build tree
--with-linux-srcdir specify the path to Linux sources. Default is to
use, if not cross-compiling, the source of the running kernel or/usr/src/linux.
Quoted 6 lines
Quoted 1 line
--enable-linux-build=<linux-tree> ?
The current approach is to use the sources of the running kernel if the only option specified is --enable-linux-build. Do you mean you find this feature superfluous ?
If $enableval is "y", then no path has been specified, so you can default to the running kernel in such a case.
Signature · 1 line
Philippe.
Quoted 8 lines · Philippe Gerum
Quoted 4 lines · Gilles Chanteperdrix
The current approach is to use the sources of the running kernel if the only option specified is --enable-linux-build. Do you mean you find this feature superfluous ?
If $enableval is "y", then no path has been specified, so you can default to the running kernel in such a case.
Here is a third version of the patch, where :
* the --enable-sim option is removed
* the --with-linux-srcdir option is removed
* the CC variable is passed to kernel build system
* prepare-kernel.sh no longer removes target directories before creating symbolic links.
Signature · 1 line
Gilles Chanteperdrix.
build-kernel/Makefile.am renamed from Makefile.am +41 -0
@@ -51,3 +51,44 @@ install-exec-local: devices install-nodev: $(MAKE) SUDO=false install + +if XENO_BUILD_LINUX +linux/%: linux/.xenomai-prepared + $(top_srcdir)/scripts/prepare-kernel.sh \ + --adeos="$(ADEOS_PATCH)" --linux=linux \ + --arch=$(XENO_LINUX_ARCH) && \ + cross=`expr $(CC) : '\(.*\)gcc' || :` && \ + cd linux && $(MAKE) $* \ + ARCH=$(XENO_LINUX_ARCH) CC=$(CC) CROSS_COMPILE=$$cross + +linux/.xenomai-prepared: config.status + ./config.status linux + +linux/install: linux/all + @sudo=; if test x`id -u` != x0 && test \! "x`type $(SUDO)`" = x; then \ + sudo=$(SUDO); fi && \ + cross=`expr $(CC) : '\(.*\)gcc' || :` && \ + $$sudo $(mkinstalldirs) $(DESTDIR)/boot && \ + cd linux && $$sudo $(MAKE) modules_install install \ + ARCH=$(XENO_LINUX_ARCH) CC=$(CC) CROSS_COMPILE=$$cross \ + INSTALL_PATH=$(DESTDIR)/boot \ + INSTALL_MOD_PATH=$(DESTDIR) + +distclean-linux: + @test -e linux/.config && \ + mv linux/.config linux/.config.saved.xenomai; \ + $(MAKE) linux/distclean; \ + test -e linux/.config.saved.xenomai && \ + mv linux/.config.saved.xenomai linux/.config + +config oldconfig mconfig menuconfig gconfig xconfig: + $(MAKE) linux/$@ + +all-recursive: linux/all + +clean-recursive: linux/clean + +distclean-recursive: distclean-linux + +install-recursive: linux/install +endif
build-kernel/configure.in renamed from configure.in +156 -0
186 lines not on this page · raw message
build-kernel/scripts/prepare-kernel.sh renamed from scripts/prepare-kernel.sh +7 -3
@@ -2,12 +2,16 @@ set -e do_links() { - rm -fr $2 - ( cd $1 && + ( cd $2 && + find . \( -name Makefile -o -name $config_file -o -name '*.[chS]' \) | + while read f; do + if test ! -e $1/$f; then rm -f $f; fi + done && + cd $1 && find . \( -name Makefile -o -name $config_file -o -name '*.[chS]' \) | while read f; do d=`dirname $f` - mkdir -p $2/$d && ln -s $1/$f $2/$f + mkdir -p $2/$d && ln -sf $1/$f $2/$f done ) }
Quoted 10 lines · Gilles Chanteperdrix
Quoted 8 lines · Philippe Gerum
Quoted 4 lines · Gilles Chanteperdrix
The current approach is to use the sources of the running kernel if the only option specified is --enable-linux-build. Do you mean you find this feature superfluous ?
If $enableval is "y", then no path has been specified, so you can default to the running kernel in such a case.
Quoted 8 lines
Here is a third version of the patch, where :
* the --enable-sim option is removed
* the --with-linux-srcdir option is removed
* the CC variable is passed to kernel build system
*prepare-kernel.shno longer removes target directories before creating symbolic links.
This is needed for creating links in a new kernel for the fist time:
prepare-kernel.sh 2006-01-08 20:19:41.000000000 +0100 renamed from prepare-kernel.sh~ 2006-01-08 20:14:05.000000000 +0100 +3 -2
@@ -2,11 +2,12 @@ set -e do_links() { - ( cd $2 && + ( if test -x $2; then + cd $2 && find . \( -name Makefile -o -name $config_file -o -name '*.[chS]' \) | while read f; do if test ! -e $1/$f; then rm -f $f; fi - done && + done; else true; fi && cd $1 && find . \( -name Makefile -o -name $config_file -o -name '*.[chS]' \) | while read f; do
Signature · 1 line
Philippe.
Quoted 20 lines · Philippe Gerum
Quoted 10 lines · Gilles Chanteperdrix
Quoted 8 lines · Philippe Gerum
Quoted 4 lines · Gilles Chanteperdrix
The current approach is to use the sources of the running kernel if the only option specified is --enable-linux-build. Do you mean you find this feature superfluous ?
If $enableval is "y", then no path has been specified, so you can default to the running kernel in such a case.
Quoted 8 lines
Here is a third version of the patch, where :
* the --enable-sim option is removed
* the --with-linux-srcdir option is removed
* the CC variable is passed to kernel build system
*prepare-kernel.shno longer removes target directories before creating symbolic links.
Quoted 1 line
This is needed for creating links in a new kernel for the fist time:
Sorry... Here is the 4th patch.
Signature · 1 line
Gilles Chanteperdrix.
build-kernel/Makefile.am renamed from Makefile.am +41 -0
@@ -51,3 +51,44 @@ install-exec-local: devices install-nodev: $(MAKE) SUDO=false install + +if XENO_BUILD_LINUX +linux/%: linux/.xenomai-prepared + $(top_srcdir)/scripts/prepare-kernel.sh \ + --adeos="$(ADEOS_PATCH)" --linux=linux \ + --arch=$(XENO_LINUX_ARCH) && \ + cross=`expr $(CC) : '\(.*\)gcc' || :` && \ + cd linux && $(MAKE) $* \ + ARCH=$(XENO_LINUX_ARCH) CC=$(CC) CROSS_COMPILE=$$cross + +linux/.xenomai-prepared: config.status + ./config.status linux + +linux/install: linux/all + @sudo=; if test x`id -u` != x0 && test \! "x`type $(SUDO)`" = x; then \ + sudo=$(SUDO); fi && \ + cross=`expr $(CC) : '\(.*\)gcc' || :` && \ + $$sudo $(mkinstalldirs) $(DESTDIR)/boot && \ + cd linux && $$sudo $(MAKE) modules_install install \ + ARCH=$(XENO_LINUX_ARCH) CC=$(CC) CROSS_COMPILE=$$cross \ + INSTALL_PATH=$(DESTDIR)/boot \ + INSTALL_MOD_PATH=$(DESTDIR) + +distclean-linux: + @test -e linux/.config && \ + mv linux/.config linux/.config.saved.xenomai; \ + $(MAKE) linux/distclean; \ + test -e linux/.config.saved.xenomai && \ + mv linux/.config.saved.xenomai linux/.config + +config oldconfig mconfig menuconfig gconfig xconfig: + $(MAKE) linux/$@ + +all-recursive: linux/all + +clean-recursive: linux/clean + +distclean-recursive: distclean-linux + +install-recursive: linux/install +endif
build-kernel/configure.in renamed from configure.in +156 -0
186 lines not on this page · raw message
build-kernel/scripts/prepare-kernel.sh renamed from scripts/prepare-kernel.sh +8 -3
@@ -2,12 +2,17 @@ set -e do_links() { - rm -fr $2 - ( cd $1 && + ( if test -x $2; then + cd $2 && + find . \( -name Makefile -o -name $config_file -o -name '*.[chS]' \) | + while read f; do + if test ! -e $1/$f; then rm -f $f; fi + done; else true; fi && + cd $1 && find . \( -name Makefile -o -name $config_file -o -name '*.[chS]' \) | while read f; do d=`dirname $f` - mkdir -p $2/$d && ln -s $1/$f $2/$f + mkdir -p $2/$d && ln -sf $1/$f $2/$f done ) }
Quoted 21 lines · Gilles Chanteperdrix
Quoted 20 lines · Philippe Gerum
Quoted 18 lines · Gilles Chanteperdrix
Quoted 8 lines · Philippe Gerum
Quoted 4 lines · Gilles Chanteperdrix
The current approach is to use the sources of the running kernel if the only option specified is --enable-linux-build. Do you mean you find this feature superfluous ?
If $enableval is "y", then no path has been specified, so you can default to the running kernel in such a case.
Here is a third version of the patch, where :
* the --enable-sim option is removed
* the --with-linux-srcdir option is removed
* the CC variable is passed to kernel build system
*prepare-kernel.shno longer removes target directories before creating symbolic links.
Quoted 4 lines
Quoted 1 line
This is needed for creating links in a new kernel for the fist time:
Sorry... Here is the 4th patch.
Ok, looks like fairly local and non-intrusive. I'm merged this patch into the main trunk eventually, so that it gets more exposure and testing.
Signature · 1 line
Philippe.