From 55530d42e70ec1ceb8e68cbd4165fd96c358a29e Mon Sep 17 00:00:00 2001 From: Scott Rifenbark Date: Wed, 14 Nov 2012 11:36:19 -0800 Subject: documentation: adt-manual - autotools-based projects Fixes [YOCTO #2645] In the section that describes how to build a toolchain using bitbake meta-toolchain, I updated the note about the MACHINE and SDKMACHINE variables. These needed to be pointed out to the user as important variables for correct settings before generating the toolchain. I added a new section for the autotools-based programs that now includes a simple "Hello World" example. This section precedes the section that describes how to pass host options to configure.sh. (From yocto-docs rev: 9849e7b94d42a851f30f0fba8ae60916697956dd) Signed-off-by: Scott Rifenbark Signed-off-by: Richard Purdie --- documentation/adt-manual/adt-command.xml | 179 ++++++++++++++++++++++++++----- documentation/adt-manual/adt-prepare.xml | 16 ++- 2 files changed, 166 insertions(+), 29 deletions(-) (limited to 'documentation/adt-manual') diff --git a/documentation/adt-manual/adt-command.xml b/documentation/adt-manual/adt-command.xml index 4000c924c3..d010aad591 100644 --- a/documentation/adt-manual/adt-command.xml +++ b/documentation/adt-manual/adt-command.xml @@ -29,39 +29,168 @@ Autotools-Based Projects - For an Autotools-based project, you can use the cross-toolchain by just - passing the appropriate host option to configure.sh. - The host option you use is derived from the name of the environment setup - script in /opt/poky resulting from installation of the - cross-toolchain tarball. - For example, the host option for an ARM-based target that uses the GNU EABI - is armv5te-poky-linux-gnueabi. - Note that the name of the script is - environment-setup-armv5te-poky-linux-gnueabi. - Thus, the following command works: - + Once you have a suitable cross-toolchain installed, it is very easy to + develop a project outside of the OpenEmbedded build system. + This section presents a simple "Helloworld" example that shows how + to set up, compile, and run the project. + + +
+ Creating and Running a Project Based on GNU Autotools + + + Follow these steps to create a simple autotools-based project: + + Create your directory: + Create a clean directory for your project and then make + that directory your working location: + + $ mkdir $HOME/helloworld + $ cd $HOME/helloworld + + Populate the directory: + Create hello.c, Makefile.am, + and configure.in files as follows: + + For hello.c, include + these lines: + + #include <stdio.h> + + main() + { + printf("Hello World!\n"); + } + + For Makefile.am, + include these lines: + + bin_PROGRAMS = hello + hello_SOURCES = hello.c + + For configure.in, + include these lines: + + AC_INIT(hello.c) + AM_INIT_AUTOMAKE(hello,0.1) + AC_PROG_CC + AC_CONFIG_HEADERS(config.h) + AC_PROG_INSTALL + AC_OUTPUT(Makefile) + + + Source the cross-toolchain + environment setup file: + Installation of the cross-toolchain creates a cross-toolchain + environment setup script in /opt/poky/<release>. + Before you can use the tools to develop your project, you must + source this setup script. + The script begins with the string "environment-setup" and contains + the machine architecture, which is followed by the string + "poky-linux". + Here is an example for an environment setup using the + 32-bit Intel x86 Architecture and using the + &DISTRO_NAME; Yocto Project release: + + $ source /opt/poky/&DISTRO;/environment-setup-i586-poky-linux + + Generate the local aclocal.m4 + files and create the configure script: + The following GNU Autotools generate the local + aclocal.m4 files and create the + configure script: + + $ aclocal + $ autoconf + + Generate files needed by GNU + coding standards: + GNU coding standards require certain files in order for the + project to be compliant. + This command creates those files: + + $ touch NEWS README AUTHORS ChangLog + + Generate the configure + file: + This command generates the configure: + + $ automake -a + + Cross-compile the project: + This command compiles the project using the cross-compiler: + + $ ./configure ${CONFIGURE_FLAGS} + + Make and install the project: + These two commands generate and install the project into the + destination directory: + + $ make + $ make install DESTDIR=./tmp + + Verify the installation: + This command is a simple way to verify the installation + of your project. + Running the command prints the architecture on which + the binary file can run. + This architecture should be the same architecture that + the installed cross-toolchain supports. + + $ file ./tmp/usr/local/bin/hello + + Execute your project: + To execute the project in the shell, simply enter the name. + You could also copy the binary to the actual target hardware + and run the project there as well: + + $ ./hello + + As expected, the project displays the "Hello World!" message. + + + +
+ +
+ Passing Host Options + + + For an Autotools-based project, you can use the cross-toolchain by just + passing the appropriate host option to configure.sh. + The host option you use is derived from the name of the environment setup + script in /opt/poky resulting from installation of the + cross-toolchain tarball. + For example, the host option for an ARM-based target that uses the GNU EABI + is armv5te-poky-linux-gnueabi. + You will notice that the name of the script is + environment-setup-armv5te-poky-linux-gnueabi. + Thus, the following command works: + $ configure --host=armv5te-poky-linux-gnueabi \ --with-libtool-sysroot=<sysroot-dir> - - - - This single command updates your project and rebuilds it using the appropriate - cross-toolchain tools. - - - If configure script results in problems recognizing the - --with-libtool-sysroot=<sysroot-dir> option, - regenerate the script to enable the support by doing the following and then - re-running the script: - + + + + + This single command updates your project and rebuilds it using the appropriate + cross-toolchain tools. + + If configure script results in problems recognizing the + --with-libtool-sysroot=<sysroot-dir> option, + regenerate the script to enable the support by doing the following and then + re-running the script: + $ libtoolize --automake $ aclocal -I ${OECORE_NATIVE_SYSROOT}/usr/share/aclocal \ [-I <dir_containing_your_project-specific_m4_macros>] $ autoconf $ autoheader $ automake -a - - + + + +
diff --git a/documentation/adt-manual/adt-prepare.xml b/documentation/adt-manual/adt-prepare.xml index 3fd231c6a0..040618482f 100644 --- a/documentation/adt-manual/adt-prepare.xml +++ b/documentation/adt-manual/adt-prepare.xml @@ -18,7 +18,7 @@ The following list describes installation methods that set up varying degrees of tool - availabiltiy on your system. + availability on your system. Regardless of the installation method you choose, you must source the cross-toolchain environment setup script before you use a toolchain. @@ -258,9 +258,17 @@ bitbake meta-toolchain. Use the appropriate bitbake command only after you have sourced the &OE_INIT_PATH; script located in the Source - Directory. - When the bitbake command completes, the toolchain installer will - be in tmp/deploy/sdk in the Build Directory. + Directory and you have made sure your conf/local.conf + variables are correct. + In particular, you need to be sure the + MACHINE + variable matches the architecture for which you are building and that the + SDKMACHINE variable is correctly set if you are building + a toolchain for an architecture that differs from your current + development host machine. + When the bitbake command completes, the + toolchain installer will be in tmp/deploy/sdk in the + Build Directory. Once you have the installer, run it to install the toolchain. -- cgit v1.2.3-54-g00ecf