diff options
Diffstat (limited to 'documentation/sdk-manual/sdk-working-projects.rst')
| -rw-r--r-- | documentation/sdk-manual/sdk-working-projects.rst | 294 |
1 files changed, 213 insertions, 81 deletions
diff --git a/documentation/sdk-manual/sdk-working-projects.rst b/documentation/sdk-manual/sdk-working-projects.rst index df216175c9..2c20a1ec57 100644 --- a/documentation/sdk-manual/sdk-working-projects.rst +++ b/documentation/sdk-manual/sdk-working-projects.rst | |||
| @@ -10,8 +10,7 @@ projects. | |||
| 10 | Autotools-Based Projects | 10 | Autotools-Based Projects |
| 11 | ======================== | 11 | ======================== |
| 12 | 12 | ||
| 13 | Once you have a suitable `cross-development | 13 | Once you have a suitable :ref:`sdk-manual/sdk-intro:the cross-development toolchain` |
| 14 | toolchain <&YOCTO_DOCS_REF_URL;#cross-development-toolchain>`__ | ||
| 15 | installed, it is very easy to develop a project using the `GNU | 14 | installed, it is very easy to develop a project using the `GNU |
| 16 | Autotools-based <https://en.wikipedia.org/wiki/GNU_Build_System>`__ | 15 | Autotools-based <https://en.wikipedia.org/wiki/GNU_Build_System>`__ |
| 17 | workflow, which is outside of the :term:`OpenEmbedded Build System`. | 16 | workflow, which is outside of the :term:`OpenEmbedded Build System`. |
| @@ -33,24 +32,51 @@ project: | |||
| 33 | 32 | ||
| 34 | 1. *Create a Working Directory and Populate It:* Create a clean | 33 | 1. *Create a Working Directory and Populate It:* Create a clean |
| 35 | directory for your project and then make that directory your working | 34 | directory for your project and then make that directory your working |
| 36 | location. $ mkdir $HOME/helloworld $ cd $HOME/helloworld After | 35 | location. |
| 37 | setting up the directory, populate it with files needed for the flow. | 36 | :: |
| 37 | |||
| 38 | $ mkdir $HOME/helloworld | ||
| 39 | $ cd $HOME/helloworld | ||
| 40 | |||
| 41 | After setting up the directory, populate it with files needed for the flow. | ||
| 38 | You need a project source file, a file to help with configuration, | 42 | You need a project source file, a file to help with configuration, |
| 39 | and a file to help create the Makefile, and a README file: | 43 | and a file to help create the Makefile, and a README file: |
| 40 | ``hello.c``, ``configure.ac``, ``Makefile.am``, and ``README``, | 44 | ``hello.c``, ``configure.ac``, ``Makefile.am``, and ``README``, |
| 41 | respectively. | 45 | respectively. |
| 42 | 46 | ||
| 43 | Use the following command to create an empty README file, which is | 47 | Use the following command to create an empty README file, which is |
| 44 | required by GNU Coding Standards: $ touch README Create the remaining | 48 | required by GNU Coding Standards: |
| 49 | :: | ||
| 50 | |||
| 51 | $ touch README | ||
| 52 | |||
| 53 | Create the remaining | ||
| 45 | three files as follows: | 54 | three files as follows: |
| 46 | 55 | ||
| 47 | - *``hello.c``:* #include <stdio.h> main() { printf("Hello | 56 | - ``hello.c``: |
| 48 | World!\n"); } | 57 | :: |
| 58 | |||
| 59 | #include <stdio.h> | ||
| 49 | 60 | ||
| 50 | - *``configure.ac``:* AC_INIT(hello,0.1) AM_INIT_AUTOMAKE([foreign]) | 61 | main() |
| 51 | AC_PROG_CC AC_CONFIG_FILES(Makefile) AC_OUTPUT | 62 | { |
| 63 | printf("Hello World!\n"); | ||
| 64 | } | ||
| 52 | 65 | ||
| 53 | - *``Makefile.am``:* bin_PROGRAMS = hello hello_SOURCES = hello.c | 66 | - ``configure.ac``: |
| 67 | :: | ||
| 68 | |||
| 69 | AC_INIT(hello,0.1) | ||
| 70 | AM_INIT_AUTOMAKE([foreign]) | ||
| 71 | AC_PROG_CC | ||
| 72 | AC_CONFIG_FILES(Makefile) | ||
| 73 | AC_OUTPUT | ||
| 74 | |||
| 75 | - ``Makefile.am``: | ||
| 76 | :: | ||
| 77 | |||
| 78 | bin_PROGRAMS = hello | ||
| 79 | hello_SOURCES = hello.c | ||
| 54 | 80 | ||
| 55 | 2. *Source the Cross-Toolchain Environment Setup File:* As described | 81 | 2. *Source the Cross-Toolchain Environment Setup File:* As described |
| 56 | earlier in the manual, installing the cross-toolchain creates a | 82 | earlier in the manual, installing the cross-toolchain creates a |
| @@ -60,12 +86,19 @@ project: | |||
| 60 | the string "environment-setup" and contains the machine architecture, | 86 | the string "environment-setup" and contains the machine architecture, |
| 61 | which is followed by the string "poky-linux". For this example, the | 87 | which is followed by the string "poky-linux". For this example, the |
| 62 | command sources a script from the default SDK installation directory | 88 | command sources a script from the default SDK installation directory |
| 63 | that uses the 32-bit Intel x86 Architecture and the DISTRO_NAME Yocto | 89 | that uses the 32-bit Intel x86 Architecture and the 3.1.2 Yocto |
| 64 | Project release: $ source | 90 | Project release: |
| 65 | /opt/poky/DISTRO/environment-setup-i586-poky-linux | 91 | :: |
| 92 | |||
| 93 | $ source /opt/poky/3.1.2/environment-setup-i586-poky-linux | ||
| 66 | 94 | ||
| 67 | 3. *Create the ``configure`` Script:* Use the ``autoreconf`` command to | 95 | 3. *Create the configure Script:* Use the ``autoreconf`` command to |
| 68 | generate the ``configure`` script. $ autoreconf The ``autoreconf`` | 96 | generate the ``configure`` script. |
| 97 | :: | ||
| 98 | |||
| 99 | $ autoreconf | ||
| 100 | |||
| 101 | The ``autoreconf`` | ||
| 69 | tool takes care of running the other Autotools such as ``aclocal``, | 102 | tool takes care of running the other Autotools such as ``aclocal``, |
| 70 | ``autoconf``, and ``automake``. | 103 | ``autoconf``, and ``automake``. |
| 71 | 104 | ||
| @@ -83,7 +116,12 @@ project: | |||
| 83 | the cross-compiler. The | 116 | the cross-compiler. The |
| 84 | :term:`CONFIGURE_FLAGS` | 117 | :term:`CONFIGURE_FLAGS` |
| 85 | environment variable provides the minimal arguments for GNU | 118 | environment variable provides the minimal arguments for GNU |
| 86 | configure: $ ./configure ${CONFIGURE_FLAGS} For an Autotools-based | 119 | configure: |
| 120 | :: | ||
| 121 | |||
| 122 | $ ./configure ${CONFIGURE_FLAGS} | ||
| 123 | |||
| 124 | For an Autotools-based | ||
| 87 | project, you can use the cross-toolchain by just passing the | 125 | project, you can use the cross-toolchain by just passing the |
| 88 | appropriate host option to ``configure.sh``. The host option you use | 126 | appropriate host option to ``configure.sh``. The host option you use |
| 89 | is derived from the name of the environment setup script found in the | 127 | is derived from the name of the environment setup script found in the |
| @@ -92,12 +130,17 @@ project: | |||
| 92 | ``armv5te-poky-linux-gnueabi``. You will notice that the name of the | 130 | ``armv5te-poky-linux-gnueabi``. You will notice that the name of the |
| 93 | script is ``environment-setup-armv5te-poky-linux-gnueabi``. Thus, the | 131 | script is ``environment-setup-armv5te-poky-linux-gnueabi``. Thus, the |
| 94 | following command works to update your project and rebuild it using | 132 | following command works to update your project and rebuild it using |
| 95 | the appropriate cross-toolchain tools: $ ./configure | 133 | the appropriate cross-toolchain tools: |
| 96 | --host=armv5te-poky-linux-gnueabi --with-libtool-sysroot=sysroot_dir | 134 | :: |
| 135 | |||
| 136 | $ ./configure --host=armv5te-poky-linux-gnueabi --with-libtool-sysroot=sysroot_dir | ||
| 97 | 137 | ||
| 98 | 5. *Make and Install the Project:* These two commands generate and | 138 | 5. *Make and Install the Project:* These two commands generate and |
| 99 | install the project into the destination directory: $ make $ make | 139 | install the project into the destination directory: |
| 100 | install DESTDIR=./tmp | 140 | :: |
| 141 | |||
| 142 | $ make | ||
| 143 | $ make install DESTDIR=./tmp | ||
| 101 | 144 | ||
| 102 | .. note:: | 145 | .. note:: |
| 103 | 146 | ||
| @@ -110,14 +153,19 @@ project: | |||
| 110 | This next command is a simple way to verify the installation of your | 153 | This next command is a simple way to verify the installation of your |
| 111 | project. Running the command prints the architecture on which the | 154 | project. Running the command prints the architecture on which the |
| 112 | binary file can run. This architecture should be the same | 155 | binary file can run. This architecture should be the same |
| 113 | architecture that the installed cross-toolchain supports. $ file | 156 | architecture that the installed cross-toolchain supports. |
| 114 | ./tmp/usr/local/bin/hello | 157 | :: |
| 158 | |||
| 159 | $ file ./tmp/usr/local/bin/hello | ||
| 115 | 160 | ||
| 116 | 6. *Execute Your Project:* To execute the project, you would need to run | 161 | 6. *Execute Your Project:* To execute the project, you would need to run |
| 117 | it on your target hardware. If your target hardware happens to be | 162 | it on your target hardware. If your target hardware happens to be |
| 118 | your build host, you could run the project as follows: $ | 163 | your build host, you could run the project as follows: |
| 119 | ./tmp/usr/local/bin/hello As expected, the project displays the | 164 | :: |
| 120 | "Hello World!" message. | 165 | |
| 166 | $ ./tmp/usr/local/bin/hello | ||
| 167 | |||
| 168 | As expected, the project displays the "Hello World!" message. | ||
| 121 | 169 | ||
| 122 | Makefile-Based Projects | 170 | Makefile-Based Projects |
| 123 | ======================= | 171 | ======================= |
| @@ -137,7 +185,7 @@ variables and Makefile variables during development. | |||
| 137 | The main point of this section is to explain the following three cases | 185 | The main point of this section is to explain the following three cases |
| 138 | regarding variable behavior: | 186 | regarding variable behavior: |
| 139 | 187 | ||
| 140 | - *Case 1 - No Variables Set in the ``Makefile`` Map to Equivalent | 188 | - *Case 1 - No Variables Set in the Makefile Map to Equivalent |
| 141 | Environment Variables Set in the SDK Setup Script:* Because matching | 189 | Environment Variables Set in the SDK Setup Script:* Because matching |
| 142 | variables are not specifically set in the ``Makefile``, the variables | 190 | variables are not specifically set in the ``Makefile``, the variables |
| 143 | retain their values based on the environment setup script. | 191 | retain their values based on the environment setup script. |
| @@ -163,8 +211,8 @@ regarding variable behavior: | |||
| 163 | , the variables from the SDK setup script take precedence: | 211 | , the variables from the SDK setup script take precedence: |
| 164 | :: | 212 | :: |
| 165 | 213 | ||
| 166 | $ make -e target | 214 | $ make -e target |
| 167 | 215 | ||
| 168 | 216 | ||
| 169 | The remainder of this section presents a simple Makefile example that | 217 | The remainder of this section presents a simple Makefile example that |
| 170 | demonstrates these variable behaviors. | 218 | demonstrates these variable behaviors. |
| @@ -172,21 +220,36 @@ demonstrates these variable behaviors. | |||
| 172 | In a new shell environment variables are not established for the SDK | 220 | In a new shell environment variables are not established for the SDK |
| 173 | until you run the setup script. For example, the following commands show | 221 | until you run the setup script. For example, the following commands show |
| 174 | a null value for the compiler variable (i.e. | 222 | a null value for the compiler variable (i.e. |
| 175 | :term:`CC`). $ echo ${CC} $ Running the | 223 | :term:`CC`). |
| 224 | :: | ||
| 225 | |||
| 226 | $ echo ${CC} | ||
| 227 | |||
| 228 | $ | ||
| 229 | |||
| 230 | Running the | ||
| 176 | SDK setup script for a 64-bit build host and an i586-tuned target | 231 | SDK setup script for a 64-bit build host and an i586-tuned target |
| 177 | architecture for a ``core-image-sato`` image using the current DISTRO | 232 | architecture for a ``core-image-sato`` image using the current 3.1.2 |
| 178 | Yocto Project release and then echoing that variable shows the value | 233 | Yocto Project release and then echoing that variable shows the value |
| 179 | established through the script: $ source | 234 | established through the script: |
| 180 | /opt/poky/DISTRO/environment-setup-i586-poky-linux $ echo ${CC} | 235 | :: |
| 181 | i586-poky-linux-gcc -m32 -march=i586 | 236 | |
| 182 | --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux | 237 | $ source /opt/poky/3.1.2/environment-setup-i586-poky-linux |
| 238 | $ echo ${CC} | ||
| 239 | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/3.1.2/sysroots/i586-poky-linux | ||
| 183 | 240 | ||
| 184 | To illustrate variable use, work through this simple "Hello World!" | 241 | To illustrate variable use, work through this simple "Hello World!" |
| 185 | example: | 242 | example: |
| 186 | 243 | ||
| 187 | 1. *Create a Working Directory and Populate It:* Create a clean | 244 | 1. *Create a Working Directory and Populate It:* Create a clean |
| 188 | directory for your project and then make that directory your working | 245 | directory for your project and then make that directory your working |
| 189 | location. $ mkdir $HOME/helloworld $ cd $HOME/helloworld After | 246 | location. |
| 247 | :: | ||
| 248 | |||
| 249 | $ mkdir $HOME/helloworld | ||
| 250 | $ cd $HOME/helloworld | ||
| 251 | |||
| 252 | After | ||
| 190 | setting up the directory, populate it with files needed for the flow. | 253 | setting up the directory, populate it with files needed for the flow. |
| 191 | You need a ``main.c`` file from which you call your function, a | 254 | You need a ``main.c`` file from which you call your function, a |
| 192 | ``module.h`` file to contain headers, and a ``module.c`` that defines | 255 | ``module.h`` file to contain headers, and a ``module.c`` that defines |
| @@ -194,13 +257,32 @@ example: | |||
| 194 | 257 | ||
| 195 | Create the three files as follows: | 258 | Create the three files as follows: |
| 196 | 259 | ||
| 197 | - *``main.c``:* #include "module.h" void sample_func(); int main() { | 260 | - ``main.c``: |
| 198 | sample_func(); return 0; } | 261 | :: |
| 262 | |||
| 263 | #include "module.h" | ||
| 264 | void sample_func(); | ||
| 265 | int main() | ||
| 266 | { | ||
| 267 | sample_func(); | ||
| 268 | return 0; | ||
| 269 | } | ||
| 270 | |||
| 271 | - ``module.h``: | ||
| 272 | :: | ||
| 199 | 273 | ||
| 200 | - *``module.h``:* #include <stdio.h> void sample_func(); | 274 | #include <stdio.h> |
| 275 | void sample_func(); | ||
| 201 | 276 | ||
| 202 | - *``module.c``:* #include "module.h" void sample_func() { | 277 | - ``module.c``: |
| 203 | printf("Hello World!"); printf("\n"); } | 278 | :: |
| 279 | |||
| 280 | #include "module.h" | ||
| 281 | void sample_func() | ||
| 282 | { | ||
| 283 | printf("Hello World!"); | ||
| 284 | printf("\n"); | ||
| 285 | } | ||
| 204 | 286 | ||
| 205 | 2. *Source the Cross-Toolchain Environment Setup File:* As described | 287 | 2. *Source the Cross-Toolchain Environment Setup File:* As described |
| 206 | earlier in the manual, installing the cross-toolchain creates a | 288 | earlier in the manual, installing the cross-toolchain creates a |
| @@ -211,38 +293,62 @@ example: | |||
| 211 | which is followed by the string "poky-linux". For this example, the | 293 | which is followed by the string "poky-linux". For this example, the |
| 212 | command sources a script from the default SDK installation directory | 294 | command sources a script from the default SDK installation directory |
| 213 | that uses the 32-bit Intel x86 Architecture and the DISTRO_NAME Yocto | 295 | that uses the 32-bit Intel x86 Architecture and the DISTRO_NAME Yocto |
| 214 | Project release: $ source | 296 | Project release: |
| 215 | /opt/poky/DISTRO/environment-setup-i586-poky-linux | 297 | :: |
| 298 | |||
| 299 | $ source /opt/poky/DISTRO/environment-setup-i586-poky-linux | ||
| 216 | 300 | ||
| 217 | 3. *Create the ``Makefile``:* For this example, the Makefile contains | 301 | 3. *Create the Makefile:* For this example, the Makefile contains |
| 218 | two lines that can be used to set the ``CC`` variable. One line is | 302 | two lines that can be used to set the ``CC`` variable. One line is |
| 219 | identical to the value that is set when you run the SDK environment | 303 | identical to the value that is set when you run the SDK environment |
| 220 | setup script, and the other line sets ``CC`` to "gcc", the default | 304 | setup script, and the other line sets ``CC`` to "gcc", the default |
| 221 | GNU compiler on the build host: # CC=i586-poky-linux-gcc -m32 | 305 | GNU compiler on the build host: |
| 222 | -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux # | 306 | :: |
| 223 | CC="gcc" all: main.o module.o ${CC} main.o module.o -o target_bin | 307 | |
| 224 | main.o: main.c module.h ${CC} -I . -c main.c module.o: module.c | 308 | # CC=i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux |
| 225 | module.h ${CC} -I . -c module.c clean: rm -rf \*.o rm target_bin | 309 | # CC="gcc" |
| 310 | all: main.o module.o | ||
| 311 | ${CC} main.o module.o -o target_bin | ||
| 312 | main.o: main.c module.h | ||
| 313 | ${CC} -I . -c main.c | ||
| 314 | module.o: module.c | ||
| 315 | module.h ${CC} -I . -c module.c | ||
| 316 | clean: | ||
| 317 | rm -rf *.o | ||
| 318 | rm target_bin | ||
| 226 | 319 | ||
| 227 | 4. *Make the Project:* Use the ``make`` command to create the binary | 320 | 4. *Make the Project:* Use the ``make`` command to create the binary |
| 228 | output file. Because variables are commented out in the Makefile, the | 321 | output file. Because variables are commented out in the Makefile, the |
| 229 | value used for ``CC`` is the value set when the SDK environment setup | 322 | value used for ``CC`` is the value set when the SDK environment setup |
| 230 | file was run: $ make i586-poky-linux-gcc -m32 -march=i586 | 323 | file was run: |
| 231 | --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c main.c | 324 | :: |
| 232 | i586-poky-linux-gcc -m32 -march=i586 | 325 | |
| 233 | --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c module.c | 326 | $ make |
| 234 | i586-poky-linux-gcc -m32 -march=i586 | 327 | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c main.c |
| 235 | --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux main.o module.o -o | 328 | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c module.c |
| 236 | target_bin From the results of the previous command, you can see that | 329 | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux main.o module.o -o target_bin |
| 330 | |||
| 331 | From the results of the previous command, you can see that | ||
| 237 | the compiler used was the compiler established through the ``CC`` | 332 | the compiler used was the compiler established through the ``CC`` |
| 238 | variable defined in the setup script. | 333 | variable defined in the setup script. |
| 239 | 334 | ||
| 240 | You can override the ``CC`` environment variable with the same | 335 | You can override the ``CC`` environment variable with the same |
| 241 | variable as set from the Makefile by uncommenting the line in the | 336 | variable as set from the Makefile by uncommenting the line in the |
| 242 | Makefile and running ``make`` again. $ make clean rm -rf \*.o rm | 337 | Makefile and running ``make`` again. |
| 243 | target_bin # # Edit the Makefile by uncommenting the line that sets | 338 | :: |
| 244 | CC to "gcc" # $ make gcc -I . -c main.c gcc -I . -c module.c gcc | 339 | |
| 245 | main.o module.o -o target_bin As shown in the previous example, the | 340 | $ make clean |
| 341 | rm -rf *.o | ||
| 342 | rm target_bin | ||
| 343 | # | ||
| 344 | # Edit the Makefile by uncommenting the line that sets CC to "gcc" | ||
| 345 | # | ||
| 346 | $ make | ||
| 347 | gcc -I . -c main.c | ||
| 348 | gcc -I . -c module.c | ||
| 349 | gcc main.o module.o -o target_bin | ||
| 350 | |||
| 351 | As shown in the previous example, the | ||
| 246 | cross-toolchain compiler is not used. Rather, the default compiler is | 352 | cross-toolchain compiler is not used. Rather, the default compiler is |
| 247 | used. | 353 | used. |
| 248 | 354 | ||
| @@ -250,36 +356,62 @@ example: | |||
| 250 | variable as part of the command line. Go into the Makefile and | 356 | variable as part of the command line. Go into the Makefile and |
| 251 | re-insert the comment character so that running ``make`` uses the | 357 | re-insert the comment character so that running ``make`` uses the |
| 252 | established SDK compiler. However, when you run ``make``, use a | 358 | established SDK compiler. However, when you run ``make``, use a |
| 253 | command-line argument to set ``CC`` to "gcc": $ make clean rm -rf | 359 | command-line argument to set ``CC`` to "gcc": |
| 254 | \*.o rm target_bin # # Edit the Makefile to comment out the line | 360 | :: |
| 255 | setting CC to "gcc" # $ make i586-poky-linux-gcc -m32 -march=i586 | 361 | |
| 256 | --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c main.c | 362 | $ make clean |
| 257 | i586-poky-linux-gcc -m32 -march=i586 | 363 | rm -rf *.o |
| 258 | --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c module.c | 364 | rm target_bin |
| 259 | i586-poky-linux-gcc -m32 -march=i586 | 365 | # |
| 260 | --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux main.o module.o -o | 366 | # Edit the Makefile to comment out the line setting CC to "gcc" |
| 261 | target_bin $ make clean rm -rf \*.o rm target_bin $ make CC="gcc" gcc | 367 | # |
| 262 | -I . -c main.c gcc -I . -c module.c gcc main.o module.o -o target_bin | 368 | $ make |
| 369 | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c main.c | ||
| 370 | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c module.c | ||
| 371 | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux main.o module.o -o target_bin | ||
| 372 | $ make clean | ||
| 373 | rm -rf *.o | ||
| 374 | rm target_bin | ||
| 375 | $ make CC="gcc" | ||
| 376 | gcc -I . -c main.c | ||
| 377 | gcc -I . -c module.c | ||
| 378 | gcc main.o module.o -o target_bin | ||
| 379 | |||
| 263 | In the previous case, the command-line argument overrides the SDK | 380 | In the previous case, the command-line argument overrides the SDK |
| 264 | environment variable. | 381 | environment variable. |
| 265 | 382 | ||
| 266 | In this last case, edit Makefile again to use the "gcc" compiler but | 383 | In this last case, edit Makefile again to use the "gcc" compiler but |
| 267 | then use the "-e" option on the ``make`` command line: $ make clean | 384 | then use the "-e" option on the ``make`` command line: |
| 268 | rm -rf \*.o rm target_bin # # Edit the Makefile to use "gcc" # $ make | 385 | :: |
| 269 | gcc -I . -c main.c gcc -I . -c module.c gcc main.o module.o -o | 386 | |
| 270 | target_bin $ make clean rm -rf \*.o rm target_bin $ make -e | 387 | $ make clean |
| 271 | i586-poky-linux-gcc -m32 -march=i586 | 388 | rm -rf *.o |
| 272 | --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c main.c | 389 | rm target_bin |
| 273 | i586-poky-linux-gcc -m32 -march=i586 | 390 | # |
| 274 | --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c module.c | 391 | # Edit the Makefile to use "gcc" |
| 275 | i586-poky-linux-gcc -m32 -march=i586 | 392 | # |
| 276 | --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux main.o module.o -o | 393 | $ make |
| 277 | target_bin In the previous case, the "-e" option forces ``make`` to | 394 | gcc -I . -c main.c |
| 395 | gcc -I . -c module.c | ||
| 396 | gcc main.o module.o -o target_bin | ||
| 397 | $ make clean | ||
| 398 | rm -rf *.o | ||
| 399 | rm target_bin | ||
| 400 | $ make -e | ||
| 401 | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c main.c | ||
| 402 | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c module.c | ||
| 403 | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux main.o module.o -o target_bin | ||
| 404 | |||
| 405 | In the previous case, the "-e" option forces ``make`` to | ||
| 278 | use the SDK environment variables regardless of the values in the | 406 | use the SDK environment variables regardless of the values in the |
| 279 | Makefile. | 407 | Makefile. |
| 280 | 408 | ||
| 281 | 5. *Execute Your Project:* To execute the project (i.e. ``target_bin``), | 409 | 5. *Execute Your Project:* To execute the project (i.e. ``target_bin``), |
| 282 | use the following command: $ ./target_bin Hello World! | 410 | use the following command: |
| 411 | :: | ||
| 412 | |||
| 413 | $ ./target_bin | ||
| 414 | Hello World! | ||
| 283 | 415 | ||
| 284 | .. note:: | 416 | .. note:: |
| 285 | 417 | ||
