All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-core] [rfc] Building Linux kernel in Xenomai tree.
@ 2006-01-07 11:30 Gilles Chanteperdrix
  2006-01-07 18:04 ` Gilles Chanteperdrix
  2006-01-08 12:08 ` Philippe Gerum
  0 siblings, 2 replies; 13+ messages in thread
From: Gilles Chanteperdrix @ 2006-01-07 11:30 UTC (permalink / raw)
  To: xenomai

[-- Attachment #1: message body and .signature --]
[-- Type: text/plain, Size: 1594 bytes --]


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.

-- 


					    Gilles Chanteperdrix.

[-- Attachment #2: xeno-build-kernel.diff --]
[-- Type: application/octet-stream, Size: 9625 bytes --]

diff -Nurp --exclude .svn --exclude '*~' --exclude Makefile.in --exclude configure --exclude aclocal.m4 --exclude autom4te.cache trunk/Makefile.am branches/build-kernel/Makefile.am
--- trunk/Makefile.am	2006-01-04 18:39:12.000000000 +0100
+++ branches/build-kernel/Makefile.am	2006-01-07 11:28:55.000000000 +0100
@@ -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
diff -Nurp --exclude .svn --exclude '*~' --exclude Makefile.in --exclude configure --exclude aclocal.m4 --exclude autom4te.cache trunk/configure.in branches/build-kernel/configure.in
--- trunk/configure.in	2006-01-07 11:46:12.000000000 +0100
+++ branches/build-kernel/configure.in	2006-01-07 12:16:08.000000000 +0100
@@ -48,15 +48,19 @@ AC_MSG_CHECKING([for target architecture
 case "$host" in
  i*86*-*)
 	XENO_TARGET_ARCH=i386
+	arch_have_sim=y
         ;;
  powerpc-*|ppc-*)
 	XENO_TARGET_ARCH=powerpc
+	arch_have_sim=y
         ;;
  powerpc64-*|ppc64-*)
 	XENO_TARGET_ARCH=powerpc
+	arch_have_sim=y
         ;;
  ia64-*)
 	XENO_TARGET_ARCH=ia64
+	arch_have_sim=y
         ;;
  bfin-*|bfinnommu-*|blackfin-*)
 	XENO_TARGET_ARCH=blackfin
@@ -150,6 +154,176 @@ if test $XENO_TARGET_ARCH = i386; then
   AC_MSG_RESULT(${CONFIG_X86_TSC:-no})
 fi
 
+dnl Flags for building Linux in Xenomai build tree.
+AC_MSG_CHECKING(whether building Linux in Xenomai build tree)
+AC_ARG_ENABLE(linux-build,
+        AS_HELP_STRING([--enable-linux-build], [Build Linux in Xenomai build tree]),
+	[case "$enableval" in
+	y | yes) XENO_BUILD_LINUX=y ;;
+	*) unset XENO_BUILD_LINUX ;;
+	esac])
+AC_MSG_RESULT(${XENO_BUILD_LINUX:-no})
+AM_CONDITIONAL(XENO_BUILD_LINUX, [test x"$XENO_BUILD_LINUX" = xy])
+
+if test x"$XENO_BUILD_LINUX" = xy; then
+  AC_MSG_CHECKING(for Linux sources)
+  unset XENO_LINUX_SRCDIR
+  AC_ARG_WITH(linux-srcdir,
+        AS_HELP_STRING([--with-linux-srcdir],[specify the path to Linux
+sources. Default is to use, if not cross-compiling, the sources of the running
+kernel or /usr/src/linux.]),
+        [XENO_LINUX_SRCDIR="`/bin/bash -c \"echo $withval\"`"])
+  if test x"$XENO_LINUX_SRCDIR" = x && test x"$cross_compiling" = xno; then
+        XENO_LINUX_SRCDIR=/lib/modules/`uname -r`/source
+        if test ! -r $XENO_LINUX_SRCDIR/Makefile; then
+           XENO_LINUX_SRCDIR=/usr/src/linux
+        fi
+  fi
+  if test x"$XENO_LINUX_SRCDIR" = x || test ! -r $XENO_LINUX_SRCDIR/Makefile; then
+     if test -e linux/.xenomai-prepared; then
+        AC_MSG_RESULT(not found)
+        unset XENO_LINUX_SRCDIR
+     else
+        AC_MSG_ERROR([Unable to find Linux kernel sources tree, please use --with-linux-srcdir])
+     fi
+  fi
+
+  if test x"$XENO_LINUX_SRCDIR" != x; then
+     unset linux_EXTRAVERSION
+     unset linux_PATCHLEVEL
+     unset linux_SUBLEVEL
+     unset linux_VERSION
+
+     eval linux_`grep '^EXTRAVERSION =' $XENO_LINUX_SRCDIR/Makefile | sed -e 's, ,,g'`
+     eval linux_`grep '^PATCHLEVEL =' $XENO_LINUX_SRCDIR/Makefile | sed -e 's, ,,g'`
+     eval linux_`grep '^SUBLEVEL =' $XENO_LINUX_SRCDIR/Makefile | sed -e 's, ,,g'`
+     eval linux_`grep '^VERSION =' $XENO_LINUX_SRCDIR/Makefile | sed -e 's, ,,g'`
+
+     linux_base_version="$linux_VERSION.$linux_PATCHLEVEL.$linux_SUBLEVEL"
+     linux_full_version="$linux_base_version$linux_EXTRAVERSION"
+
+     if test x"$linux_PATCHLEVEL" = x -o x"$linux_SUBLEVEL" = x || 
+        test x"$linux_VERSION" = x; then
+        if test -e linux/.xenomai-prepared; then
+           AC_MSG_RESULT(Unknown version)
+           unset linux_base_version
+        else
+           AC_MSG_ERROR([Unable to get version of $XENO_LINUX_SRCDIR, aborting.])
+        fi
+     else
+        AC_MSG_RESULT([$XENO_LINUX_SRCDIR (kernel ${linux_full_version})])
+     fi
+  fi
+
+  AC_MSG_CHECKING(for Adeos patch)
+  unset ADEOS_PATCH
+  AC_ARG_WITH(adeos-patch,
+        AS_HELP_STRING([--with-adeos-patch],[specify the path to the Adeos
+patch. Default is to infer the patch name from Linux kernel version.]),
+        [ADEOS_PATCH="`/bin/bash -c \"echo $withval\"`"])
+
+  if test x"$ADEOS_PATCH" = x && test x"$linux_base_version" != x; then
+        set -- $srcdir/ksrc/arch/$XENO_TARGET_ARCH/patches/adeos-*$linux_base_version*
+        ADEOS_PATCH=$1
+  fi
+  if test x"$ADEOS_PATCH" = x || test ! -e $ADEOS_PATCH; then
+     if test -e linux/.xenomai-prepared; then
+        AC_MSG_RESULT(not found)
+        unset ADEOS_PATCH
+     else
+        AC_MSG_ERROR([Unable to find Adeos patch, please use --with-adeos-patch])
+     fi
+  else
+     AC_MSG_RESULT([$ADEOS_PATCH])
+  fi
+  AC_SUBST(ADEOS_PATCH)
+
+  AC_CONFIG_COMMANDS(linux, [
+     if test -e linux/.xenomai-prepared; then
+        . linux/.xenomai-prepared
+        if test x"$XENO_LINUX_SRCDIR" != x"$PREPARED_LINUX_SRCDIR" ||
+           test x"$ADEOS_PATCH" != x"$PREPARED_ADEOS_PATCH"; then
+           echo "*** Warning: built version of linux and requested versions are "
+           echo "*** different. If you want to build the requested version of "
+           echo "*** linux, remove the file: linux/.xenomai-prepared."
+        fi
+     else
+           set -e
+           if test -e linux; then
+               test -e linux/.config && mv linux/.config .xenomai.config
+               rm -Rf linux
+           fi
+           mkdir linux
+           echo $ECHO_N "Making linux a shadow copy of $XENO_LINUX_SRCDIR... $ECHO_C" 
+           targetdir=$PWD/linux
+           cd $XENO_LINUX_SRCDIR
+           find . -! -type d | while read f; do
+                d=$targetdir/`dirname $f`
+                mkdir -p $d && ln -sf $XENO_LINUX_SRCDIR/$f $d/`basename $f`
+           done
+           echo "${ECHO_T}done."
+           cd $targetdir
+
+           if test -e $XENO_LINUX_SRCDIR/.config; then
+              . $XENO_LINUX_SRCDIR/.config
+              test x"$CONFIG_X86" = xy && cfg_arch=i386 || :
+              test x"$CONFIG_PPC" = xy && cfg_arch=ppc || :
+              test x"$CONFIG_IA64" = xy && cfg_arch=ia64 || :
+              test x"$CONFIG_PPC64" = xy && cfg_arch=ppc64 || :
+              if test $cfg_arch = $XENO_TARGET_ARCH; then
+                 cp $LINUX_SRCDIR/.config .config
+                 cp $LINUX_SRCDIR/.config .xenomai.config
+              fi
+              make ARCH=$cfg_arch distclean
+              test -e .xenomai.config && mv .xenomai.config .config
+           fi
+           cd ..
+           $srcdir/scripts/prepare-kernel.sh \
+             --adeos="$ADEOS_PATCH" --linux=linux --arch=$XENO_TARGET_ARCH
+           test -e .xenomai.config && mv .xenomai.config linux/.config || :
+           echo "PREPARED_LINUX_SRCDIR=$XENO_LINUX_SRCDIR" > linux/.xenomai-prepared.tmp
+           echo "PREPARED_ADEOS_PATCH=$ADEOS_PATCH" >> linux/.xenomai-prepared.tmp
+           mv linux/.xenomai-prepared.tmp linux/.xenomai-prepared
+     fi
+        ],[XENO_LINUX_SRCDIR=$XENO_LINUX_SRCDIR
+           XENO_TARGET_ARCH=$XENO_TARGET_ARCH
+         ADEOS_PATCH=$ADEOS_PATCH])
+fi
+
+
+dnl Catch sub-package flags
+
+AC_MSG_CHECKING(for simulator)
+AC_ARG_ENABLE(sim,
+	AS_HELP_STRING([--enable-sim], [Build simulator]),
+	[case "$enableval" in
+	y | yes) CONFIG_XENO_MVM=y ;;
+	*) unset CONFIG_XENO_MVM ;;
+	esac])
+
+unset XENO_MAYBE_SIMDIR
+if test \! -d $srcdir/sim; then
+    if test x$CONFIG_XENO_MVM = xy; then
+        AC_MSG_ERROR([simulator is missing.])
+    fi
+    AC_MSG_RESULT([not present])
+else
+    if test x$CONFIG_XENO_MVM = xy; then
+	export CONFIG_XENO_MVM_DEBUG
+    	export CONFIG_XENO_MVM_GCC_TARBALL
+    	export CONFIG_XENO_MVM_ATOMIC_CORE
+	export CONFIG_XENO_OPT_DEBUG
+	export CONFIG_XENO_OPT_STATS
+    else
+	XENO_MAYBE_SIMDIR=sim
+    fi
+    AC_MSG_RESULT(${CONFIG_XENO_MVM:-no})
+fi
+if test x$arch_have_sim = x -a x$CONFIG_XENO_MVM = xy; then
+   AC_MSG_ERROR([simulator is not available on this architecture.])
+fi
+AC_SUBST(XENO_MAYBE_SIMDIR)
+
 dnl Documentation package.
 
 if test \! -d $srcdir/doc; then 
@@ -421,4 +595,8 @@ if test \! x$XENO_MAYBE_DOCDIR = x; then
       ])
 fi
 
+if test x$CONFIG_XENO_MVM = xy; then
+   AC_CONFIG_SUBDIRS(sim)
+fi
+
 AC_OUTPUT()

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2006-01-08 21:39 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-07 11:30 [Xenomai-core] [rfc] Building Linux kernel in Xenomai tree Gilles Chanteperdrix
2006-01-07 18:04 ` Gilles Chanteperdrix
2006-01-07 18:38   ` Jan Kiszka
2006-01-07 19:32     ` Gilles Chanteperdrix
2006-01-07 19:58       ` Jan Kiszka
2006-01-07 21:24         ` Gilles Chanteperdrix
2006-01-08 12:08 ` Philippe Gerum
2006-01-08 13:08   ` Gilles Chanteperdrix
2006-01-08 14:17     ` Philippe Gerum
2006-01-08 16:55       ` Gilles Chanteperdrix
2006-01-08 19:23         ` Philippe Gerum
2006-01-08 20:22           ` Gilles Chanteperdrix
2006-01-08 21:39             ` Philippe Gerum

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.