diff options
author | jmbills <jason.m.bills@intel.com> | 2021-08-03 01:45:08 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-03 01:45:08 +0300 |
commit | 10ad77d5bc86709d8ff7f95e7040e39f1c153903 (patch) | |
tree | 307cedb87f4c0a329740c55ac364ed489d1d8fc2 /poky/documentation/sdk-manual/working-projects.rst | |
parent | c6b1c6ba7a01b7987d65d61c262c44c320193108 (diff) | |
parent | 67327ddc580cb9a85219a534844832a1682780d4 (diff) | |
download | openbmc-10ad77d5bc86709d8ff7f95e7040e39f1c153903.tar.xz |
Update
Diffstat (limited to 'poky/documentation/sdk-manual/working-projects.rst')
-rw-r--r-- | poky/documentation/sdk-manual/working-projects.rst | 75 |
1 files changed, 27 insertions, 48 deletions
diff --git a/poky/documentation/sdk-manual/working-projects.rst b/poky/documentation/sdk-manual/working-projects.rst index f880cbe0d..276daa9bb 100644 --- a/poky/documentation/sdk-manual/working-projects.rst +++ b/poky/documentation/sdk-manual/working-projects.rst @@ -45,16 +45,14 @@ project: respectively. Use the following command to create an empty README file, which is - required by GNU Coding Standards: - :: + required by GNU Coding Standards:: $ touch README Create the remaining three files as follows: - - ``hello.c``: - :: + - ``hello.c``:: #include <stdio.h> @@ -63,8 +61,7 @@ project: printf("Hello World!\n"); } - - ``configure.ac``: - :: + - ``configure.ac``:: AC_INIT(hello,0.1) AM_INIT_AUTOMAKE([foreign]) @@ -72,8 +69,7 @@ project: AC_CONFIG_FILES(Makefile) AC_OUTPUT - - ``Makefile.am``: - :: + - ``Makefile.am``:: bin_PROGRAMS = hello hello_SOURCES = hello.c @@ -87,8 +83,7 @@ project: 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; Yocto - Project release: - :: + Project release:: $ source /opt/poky/&DISTRO;/environment-setup-i586-poky-linux @@ -113,8 +108,7 @@ project: the cross-compiler. The :term:`CONFIGURE_FLAGS` environment variable provides the minimal arguments for GNU - configure: - :: + configure:: $ ./configure ${CONFIGURE_FLAGS} @@ -127,14 +121,12 @@ project: ``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: - :: + the appropriate cross-toolchain tools:: $ ./configure --host=armv5te-poky-linux-gnueabi --with-libtool-sysroot=sysroot_dir 5. *Make and Install the Project:* These two commands generate and - install the project into the destination directory: - :: + install the project into the destination directory:: $ make $ make install DESTDIR=./tmp @@ -143,9 +135,8 @@ project: To learn about environment variables established when you run the cross-toolchain environment setup script and how they are used or - overridden when the Makefile, see the " - Makefile-Based Projects - " section. + overridden by the Makefile, see the + :ref:`sdk-manual/working-projects:makefile-based projects` section. This next command is a simple way to verify the installation of your project. Running the command prints the architecture on which the @@ -157,8 +148,7 @@ project: 6. *Execute Your Project:* To execute the project, you would need to run it on your target hardware. If your target hardware happens to be - your build host, you could run the project as follows: - :: + your build host, you could run the project as follows:: $ ./tmp/usr/local/bin/hello @@ -203,8 +193,7 @@ regarding variable behavior: .. note:: Regardless of how you set your variables, if you use the "-e" option - with ``make``, the variables from the SDK setup script take precedence: - :: + with ``make``, the variables from the SDK setup script take precedence:: $ make -e target @@ -226,8 +215,7 @@ Running the SDK setup script for a 64-bit build host and an i586-tuned target architecture for a ``core-image-sato`` image using the current &DISTRO; Yocto Project release and then echoing that variable shows the value -established through the script: -:: +established through the script:: $ source /opt/poky/&DISTRO;/environment-setup-i586-poky-linux $ echo ${CC} @@ -252,8 +240,7 @@ example: Create the three files as follows: - - ``main.c``: - :: + - ``main.c``:: #include "module.h" void sample_func(); @@ -263,14 +250,12 @@ example: return 0; } - - ``module.h``: - :: + - ``module.h``:: #include <stdio.h> void sample_func(); - - ``module.c``: - :: + - ``module.c``:: #include "module.h" void sample_func() @@ -288,17 +273,15 @@ example: 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: - :: + Project release:: $ source /opt/poky/&DISTRO;/environment-setup-i586-poky-linux 3. *Create the Makefile:* For this example, the Makefile contains - two lines that can be used to set the ``CC`` variable. One line is + two lines that can be used to set the :term:`CC` variable. One line is identical to the value that is set when you run the SDK environment - setup script, and the other line sets ``CC`` to "gcc", the default - GNU compiler on the build host: - :: + setup script, and the other line sets :term:`CC` to "gcc", the default + GNU compiler on the build host:: # CC=i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux # CC="gcc" @@ -314,9 +297,8 @@ example: 4. *Make the Project:* Use the ``make`` command to create the binary output file. Because variables are commented out in the Makefile, the - value used for ``CC`` is the value set when the SDK environment setup - file was run: - :: + value used for :term:`CC` is the value set when the SDK environment setup + file was run:: $ make i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c main.c @@ -324,10 +306,10 @@ example: i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux main.o module.o -o target_bin From the results of the previous command, you can see that - the compiler used was the compiler established through the ``CC`` + the compiler used was the compiler established through the :term:`CC` variable defined in the setup script. - You can override the ``CC`` environment variable with the same + You can override the :term:`CC` environment variable with the same variable as set from the Makefile by uncommenting the line in the Makefile and running ``make`` again. :: @@ -351,8 +333,7 @@ example: variable as part of the command line. Go into the Makefile and re-insert the comment character so that running ``make`` uses the established SDK compiler. However, when you run ``make``, use a - command-line argument to set ``CC`` to "gcc": - :: + command-line argument to set :term:`CC` to "gcc":: $ make clean rm -rf *.o @@ -376,8 +357,7 @@ example: environment variable. In this last case, edit Makefile again to use the "gcc" compiler but - then use the "-e" option on the ``make`` command line: - :: + then use the "-e" option on the ``make`` command line:: $ make clean rm -rf *.o @@ -402,8 +382,7 @@ example: Makefile. 5. *Execute Your Project:* To execute the project (i.e. ``target_bin``), - use the following command: - :: + use the following command:: $ ./target_bin Hello World! |