X-Git-Url: http://git.ozo.com/?a=blobdiff_plain;f=docs%2Fbuild.tex;h=03bd1a967585078c29ba4e11435b34486cb433f7;hb=1addd4cc9c4dd7605c9d3e6ed550b229dc6ebe05;hp=0449c08c73d3ab6db38d1d756ad2f99d3716f682;hpb=b9883aef07a63590217f00afe74f586c8ea78e26;p=openwrt-10.03%2F.git diff --git a/docs/build.tex b/docs/build.tex index 0449c08c7..03bd1a967 100644 --- a/docs/build.tex +++ b/docs/build.tex @@ -39,17 +39,17 @@ with the latest compilers, latest kernels and latest applications. So let's take a look at OpenWrt and see how this all works. -\subsubsection{Download openwrt} +\subsubsection{Download OpenWrt} This article refers to the "Kamikaze" branch of OpenWrt, which can be downloaded via subversion using the following command: \begin{Verbatim} -$ svn co https://svn.openwrt.org/openwrt/trunk kamikaze +$ svn checkout https://svn.openwrt.org/openwrt/trunk kamikaze \end{Verbatim} -Additionally, ther is a trac interface on \href{https://dev.openwrt.org/}{https://dev.openwrt.org/} -which can be used to monitor svn commits and browse the sources. +Additionally, there is a trac interface on \href{https://dev.openwrt.org/}{https://dev.openwrt.org/} +which can be used to monitor svn commits and browse the source repository. \subsubsection{The directory structure} @@ -83,7 +83,7 @@ features or removed to save space. Note that packages are also maintained outsid trunk and can be obtained from subversion at the following location: \begin{Verbatim} -$ svn co https://svn.openwrt.org/openwrt/packages ../packages +$ svn checkout https://svn.openwrt.org/openwrt/packages packages \end{Verbatim} Those packages can be used to extend the functionality of the build system and need to be @@ -96,17 +96,16 @@ kamikaze packages $ ln -s packages/net/nmap kamikaze/package/nmap \end{Verbatim} -To include all packages, issue the following command : +To include all packages, issue the following command: \begin{Verbatim} $ ln -s packages/*/* kamikaze/package/ \end{Verbatim} - \texttt{target} refers to the embedded platform, this contains items which are specific to a specific embedded platform. Of particular interest here is the "\texttt{target/linux}" -directory which is broken down by platform and contains the kernel config and patches -to the kernel for a particular platform. There's also the "\texttt{target/image}" directory +directory which is broken down by platform \textit{} and contains the patches to the +kernel, profile config, for a particular platform. There's also the "\texttt{target/image}" directory which describes how to package a firmware for a specific platform. Both the target and package steps will use the directory "\texttt{build\_\textit{}}" @@ -143,7 +142,15 @@ Similar to the linux kernel config, almost every option has three choices, \end{itemize} After you've finished with the menu configuration, exit and when prompted, save your -configuration changes. To begin compiling the firmware, type "\texttt{make}". By default +configuration changes. + +If you want, you can also modify the kernel config for the selected target system. +simply run "\texttt{make kernel\_menuconfig}" and the build system will unpack the kernel sources +(if necessary), run menuconfig inside of the kernel tree, and then copy the kernel config +to \texttt{target/linux/\textit{}/config} so that it is preserved over +"\texttt{make clean}" calls. + +To begin compiling the firmware, type "\texttt{make}". By default OpenWrt will only display a high level overview of the compile process and not each individual command. @@ -178,7 +185,7 @@ in OpenWrt you'll find two things: \begin{itemize} \item \texttt{package/\textit{}/Makefile} \item \texttt{package/\textit{}/patches} - \item \texttt{package/\textit{}/files} + \item \texttt{package/\textit{}/files} \end{itemize} The patches directory is optional and typically contains bug fixes or optimizations to @@ -291,7 +298,7 @@ directly as the Nth argument to \texttt{BuildPackage}. \item \texttt{SECTION} \\ The type of package (currently unused) \item \texttt{CATEGORY} \\ - Which menu it appears in menuconfig : Network, Sound, Utilities, Multimedia ... + Which menu it appears in menuconfig: Network, Sound, Utilities, Multimedia ... \item \texttt{TITLE} \\ A short description of the package \item \texttt{URL} \\ @@ -299,7 +306,9 @@ directly as the Nth argument to \texttt{BuildPackage}. \item \texttt{MAINTAINER} (optional) \\ Who to contact concerning the package \item \texttt{DEPENDS} (optional) \\ - Which packages must be built/installed before this package. To reference a dependency defined in the same Makefile, use \textit{}. If defined as an external package, use \textit{+}. For a kernel version dependency use: \textit{@LINUX\_2\_} + Which packages must be built/installed before this package. To reference a dependency defined in the + same Makefile, use \textit{}. If defined as an external package, use + \textit{+}. For a kernel version dependency use: \textit{@LINUX\_2\_} \end{itemize} \textbf{\texttt{Package/\textit{}/conffiles} (optional):} \\ @@ -313,10 +322,29 @@ directly as the Nth argument to \texttt{BuildPackage}. You can leave this undefined if the source doesn't use configure or has a normal config script, otherwise you can put your own commands here or use "\texttt{\$(call Build/Configure/Default,\textit{})}" as above to - pass in additional arguments for a standard configure script. The first list of arguments will be passed to the configure script like that : $--arg 1$ $--arg 2$. The second list contains arguments that should be defined before running the configure script such as autoconf or compiler specific variables. + pass in additional arguments for a standard configure script. The first list of arguments will be passed + to the configure script like that: \texttt{--arg 1} \texttt{--arg 2}. The second list contains arguments that should be + defined before running the configure script such as autoconf or compiler specific variables. + + To make it easier to modify the configure command line, you can either extend or completely override the following variables: + \begin{itemize} + \item \texttt{CONFIGURE\_ARGS} \\ + Contains all command line arguments (format: \texttt{--arg 1} \texttt{--arg 2}) + \item \texttt{CONFIGURE\_VARS} \\ + Contains all environment variables that are passed to ./configure (format: \texttt{NAME="value"}) + \end{itemize} \textbf{\texttt{Build/Compile} (optional):} \\ How to compile the source; in most cases you should leave this undefined. + + As with \texttt{Build/Configure} there are two variables that allow you to override + the make command line environment variables and flags: + \begin{itemize} + \item \texttt{MAKE\_FLAGS} \\ + Contains all command line arguments (typically variable overrides like \texttt{NAME="value"} + \item \texttt{MAKE\_VARS} \\ + Contains all environment variables that are passed to the make command + \end{itemize} \textbf{\texttt{Package/\textit{}/install}:} \\ A set of commands to copy files out of the compiled source and into the ipkg @@ -345,6 +373,59 @@ After you have created your \texttt{package/\textit{}/Makefile}, the new p will automatically show in the menu the next time you run "make menuconfig" and if selected will be built automatically the next time "\texttt{make}" is run. +\subsection{Creating kernel modules packages} + +The OpenWrt distribution makes the distinction between two kind of kernel modules, those coming along with the mainline kernel, and the others available as a separate project. We will see later that a common template is used for both of them. + +For kernel modules that are part of the mainline kernel source, the makefiles are located in \textit{package/kernel/modules/*.mk} and they appear under the section "Kernel modules" + +For external kernel modules, you can add them to the build system just like if they were software packages by defining a KernelPackage section in the package makefile. + +Here for instance the Makefile for the I2C subsytem kernel modules : + +\begin{Verbatim}[frame=single,numbers=left] +# +# Copyright (C) 2006 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +# $Id $ + +I2CMENU:=I2C Bus + +define KernelPackage/i2c-core + TITLE:=I2C support + DESCRIPTION:=Kernel modules for i2c support + SUBMENU:=$(I2CMENU) + KCONFIG:=$(CONFIG_I2C_CORE) \ + $(CONFIG_I2C_DEV) + FILES:=$(MODULES_DIR)/kernel/drivers/i2c/*.$(LINUX_KMOD_SUFFIX) + AUTOLOAD:=$(call AutoLoad,50,i2c-core i2c-dev) +endef +$(eval $(call KernelPackage,i2c-core)) +\end{Verbatim} + +To group kernel modules under a common description in menuconfig, you might want to define a \textit{MENU} variable on top of the kernel modules makefile. + +\begin{itemize} + \item \texttt{TITLE} \\ + The name of the module as seen via menuconfig + \item \texttt{DESCRIPTION} \\ + The description as seen via help in menuconfig + \item \texttt{SUBMENU} \\ + The sub menu under which this package will be seen + \item \texttt{KCONFIG} \\ + Kernel configuration option dependency. For external modules, remove it. + \item \texttt{FILES} \\ + Files you want to inlude to this kernel module package, separate with spaces. + \item \texttt{AUTOLOAD} \\ + Modules that will be loaded automatically on boot, the order you write them is the order they would be loaded. +\end{itemize} + +After you have created your \texttt{package/kernel/modules/\textit{}.mk}, the new kernel modules package +will automatically show in the menu under "Kernel modules" next time you run "make menuconfig" and if selected +will be built automatically the next time "\texttt{make}" is run. \subsection{Conventions}