Bering-uClibc 5.x - Developer Guide - Compiling Source Code

From bering-uClibc
Revision as of 15:59, 21 November 2012 by Kapeka (Talk | contribs) (Overview)

Jump to: navigation, search
Compiling Source Code
Prev Bering-uClibc 5.x - Developer Guide Next


What is buildtool?

Buildtool is a set of Perl scripts and Perl modules to build LRP files (LEAF Packages) from source. Everything in the build process is automated, from extracting the sources and applying patches to configuring and building the source and creating the LRP Package.

Why bother?

In very early LEAF releases it was usual to compile the sources and build the Packages manually. This could be error-prone, and where upstream source upgrades happened regularly it was tedious to have to repeat builds for new versions manually.

The current practice is for every Package to be generated automatically according to simple configuration definitions. This means that no special knowledge is required to re-build a particular Package, because all of the steps are captured in the configuration files. Some effort is required to prepare the initial buildtool configuration but many Packages are fairly "standard" and it is often possible to adapt the configuration from a similar package quite quickly.

Buildtool usage


usage: ./ [option] command [pkgname|srcname] [...]

describe [pkgname|srcname]       shows descriptionlines of package
list [sourced|built]             shows a list of built/sourced packages and sources
dumpenv [pkgname|srcname]        dump the environment of buildtool and package
source [pkgname|srcname]         downloads, unpacks and patches
                                the wanted package/source
build [pkgname|srcname]          the same as source, but builds
                                and installs sources/packages also
pkglist [pkgname|srcname]        create a list with all dependencies
                                for the package given or all if no name given
buildclean [pkgname|srcname]     removes everything that is outside
                                the source dir
srcclean [pkgname|srcname]       same as buildclean + call make srcclean
remove [pkgname|srcname]         same as buildclean + remove everything from dldir
distclean                        remove everything
maketar                          make a tar for distribution
-v                               just print version and exit
-f                               allows you to force the command even if the internal
                                state of buildtool states it has nothing to do
-O                               Do not override default Server entries with the ones
                                found in package/source buildtool config
-D                               Download nothing, use files in Source dir (useful for devel)
-d                               Only to be used in conjunction with the "source" target. 
                                Only download files, don't invoke the source action on
-t toolchain                     Build using the specified toolchain
                                (or actually build that toolchain if srcname = "toolchain")
                                Value of "toolchain" is e.g. i486-unknown-linux-uclibc

Getting information about the sources that can be built

Buildtool can only build sources/packages that it has a configuration for (see the next section on how to create such a configuration). To get a listing of the sources that are configured for buildtool type:

 ./ describe

This will give you a list (and a short description) of all sources/packages that can be built. An example output looks like this:

 ./ describe

 The following packages and sources are available:

 openssh          openssh
 tcp_wrappers     Wietse Venema's TCP wrappers library
 helloworld       classical example
 openssl          Secure Sockets Layer and cryptography
                  libraries and tools
 zlib             zLib shared libraries
 linux            kernel source only package

 toolchain         this holds everything to build cross build env
 kernel           kernel pseudo package

The difference between sources and packages

You might be a bit confused why in the above output there are Sources and Packages. The main reason for having sources and packages separately is that there are some sources out there that produce programs used in several packages. Or in other words, it sometimes makes sense to just build the sources (like util-linux for example) only once and create several packages out of the resulting binaries. (Although the developer team did not strictly obey this idea in the past.)

Getting information about sources and packages that already has been built

The command

./ list

shows a list of already build packages/sources.

Downloading the sources for a package


./ source somepackageName

will cause the sources of somepackageName to be "downloaded" (and before that, all its dependencies, if there are any that haven't been downloaded yet). Upstream sources are now copied into the Bering-uClibc 5.x Git repository, since this avoids problems when upstream download sites go off-line and makes it easier to distribute copies of all the source code as required for compliance with some Open Source licenses. As a result, these sources are "downloaded" (from the Internet) when the Sourceforge-hosted Git repository is "cloned", but an important further step is to create symbolic links to the "local repository" (directory repo/) from the source/ directory, so this is what now happens when sources are "downloaded".

After that, the makefile for this source is executed for target source. This has the effect that the sources will be extracted, and patches (if there are any) are applied.

If all this is completed without error, the sources of somepackageName are ready to be compiled.

Compiling the sources for a package


./ build somepackageName

will cause buildtool to actually compile the source and install it to the build/ directory (and all its dependencies). After this is completed successfully, all binaries required for the lrp package (linked against uClibc) reside in the build/[toolchain] directory.

Note that [toolchain] in the example above will be replaced with the toolchain you choosed in conf/buildtool.conf as toolchain. By default it points to i486-unknown-linux-uclibc.

Creating buildtool sources/packages


For each package, three files control how it's built:

This file defines which files to include - usually the servers configuration file servers.cfg, local definitions in sources.local and all configuration files in the directory sources.d.
Defines the servers where the files for the packages are downloaded from. The most used "server" location is localrepo, which points to your local copy of LEAF's git repository. That way you can build the toolchain and the packages even if an upstream site is not available. Therefor, and because it's a requirement of Sourceforge, when hosting LEAF, that all sources have to be available, you usually don't have to touch this file. Instead add the sources along with the other files needed to build a package into the git repository.
New since Bering-uClibc 4.x is a fourth file conf/sources.local, which is "included" at the end of conf/sources.cfg and is used to define local sources/packages, typically those being developed and debugged and not yet ready to be loaded into the master repository.

Prev Up Next