From 98423875ef4e86b8e18001ea6f2b6673131cffc3 Mon Sep 17 00:00:00 2001 From: Scott Rifenbark Date: Mon, 4 Jun 2018 15:36:27 -0700 Subject: sdk-manual: Updated the Autotools workflow example. Did a re-write of this section with better explanations. I also pulled the bit about passing parameters to the configure script into the step that talks about that. (From yocto-docs rev: 778e566100450cce15808f80ace2b92f811001a7) Signed-off-by: Scott Rifenbark Signed-off-by: Richard Purdie --- documentation/sdk-manual/sdk-working-projects.xml | 332 +++++++++++----------- 1 file changed, 167 insertions(+), 165 deletions(-) (limited to 'documentation') diff --git a/documentation/sdk-manual/sdk-working-projects.xml b/documentation/sdk-manual/sdk-working-projects.xml index 2e232a5041..7aa43b3921 100644 --- a/documentation/sdk-manual/sdk-working-projects.xml +++ b/documentation/sdk-manual/sdk-working-projects.xml @@ -21,202 +21,204 @@ Once you have a suitable cross-development toolchain - installed, it is very easy to develop a project outside of the + installed, it is very easy to develop a project using the + GNU Autotools-based + workflow, which is 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 + + The following figure presents a simple Autotools workflow. + + - - Follow these steps to create a simple - GNU Autotools-based - project: - - - Create Your Directory: - Create a clean directory for your project and then make - that directory your working location: - + + Follow these steps to create a simple Autotools-based + "Hello World" project: + + For more information on the GNU Autotools workflow, + see the same example on the + GNOME Developer + site. + + + + Create a Working Directory and Populate It: + 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.ac files as follows: - - - For hello.c, include - these lines: - + + After setting up the directory, populate it with three + simple files needed for the flow. + You need a project source file, a file to help with + configuration, and a file to help create the Makefile: + hello.c, + configure.ac, and + Makefile.am, respectively: + + + hello.c: + #include <stdio.h> main() { printf("Hello World!\n"); } - - - - For Makefile.am, - include these lines: - - bin_PROGRAMS = hello - hello_SOURCES = hello.c - - - - For configure.ac, - include these lines: - + + + + configure.ac: + AC_INIT(hello,0.1) AM_INIT_AUTOMAKE([foreign]) AC_PROG_CC AC_CONFIG_FILES(Makefile) AC_OUTPUT - - - - - - Source the Cross-Toolchain - Environment Setup File: - As described earlier in the manual, installing the - cross-toolchain creates a cross-toolchain - environment setup script in the directory that the SDK - was installed. - 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 that sources a script from the - default SDK installation directory that uses the - 32-bit Intel x86 Architecture and the - &DISTRO_NAME; Yocto Project release: - + + + + Makefile.am: + + bin_PROGRAMS = hello + hello_SOURCES = hello.c + + + + + + Source the Cross-Toolchain + Environment Setup File: + As described earlier in the manual, installing the + cross-toolchain creates a cross-toolchain + environment setup script in the directory that the SDK + was installed. + 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". + For this example, the command sources a script from the + default SDK installation directory that uses the + 32-bit Intel x86 Architecture and 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: - + + + + Generate the Local aclocal.m4 Files: + The following command generates the local + aclocal.m4 files, which are used + later with the autoconf command: + $ aclocal + + + + Create the configure Script: + The following command creates the + configure script: + $ 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: - + + + + 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 ChangeLog - - - - Generate the Configure File: - This command generates the - configure: - + + + + Generate the Makefile.in File: + This command generates the + Makefile.in, which is used later + during cross-compilation: + $ automake -a - - - - Cross-Compile the Project: - This command compiles the project using the - cross-compiler. - The - CONFIGURE_FLAGS - environment variable provides the minimal arguments for - GNU configure: - + + + + Cross-Compile the Project: + This command compiles the project using the + cross-compiler. + The + CONFIGURE_FLAGS + environment variable provides the minimal arguments for + GNU configure: + $ ./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 found in the directory in which you - installed the cross-toolchain. - 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 to update your project and - rebuild it using the appropriate cross-toolchain tools: - + + 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 found in the directory in which you + installed the cross-toolchain. + 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 to update your project + and rebuild it using the appropriate cross-toolchain tools: + $ ./configure --host=armv5te-poky-linux-gnueabi \ --with-libtool-sysroot=sysroot_dir - - - If the 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 run the script again: - + + + If the 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 run the script again: + $ libtoolize --automake $ aclocal -I ${OECORE_TARGET_SYSROOT}/usr/share/aclocal [-I dir_containing_your_project-specific_m4_macros] $ autoconf $ autoheader $ automake -a + + + + + Make and Install the Project: + These two commands generate and install the project + into the destination directory: + + $ make + $ make install DESTDIR=./tmp - - -
+ This next 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. + + +
-- cgit v1.2.3-54-g00ecf