summaryrefslogtreecommitdiffstats
path: root/documentation/sdk-manual/working-projects.rst
diff options
context:
space:
mode:
Diffstat (limited to 'documentation/sdk-manual/working-projects.rst')
-rw-r--r--documentation/sdk-manual/working-projects.rst60
1 files changed, 20 insertions, 40 deletions
diff --git a/documentation/sdk-manual/working-projects.rst b/documentation/sdk-manual/working-projects.rst
index f880cbe0d5..ad84ce2b87 100644
--- a/documentation/sdk-manual/working-projects.rst
+++ b/documentation/sdk-manual/working-projects.rst
@@ -45,16 +45,14 @@ project:
45 respectively. 45 respectively.
46 46
47 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
48 required by GNU Coding Standards: 48 required by GNU Coding Standards::
49 ::
50 49
51 $ touch README 50 $ touch README
52 51
53 Create the remaining 52 Create the remaining
54 three files as follows: 53 three files as follows:
55 54
56 - ``hello.c``: 55 - ``hello.c``::
57 ::
58 56
59 #include <stdio.h> 57 #include <stdio.h>
60 58
@@ -63,8 +61,7 @@ project:
63 printf("Hello World!\n"); 61 printf("Hello World!\n");
64 } 62 }
65 63
66 - ``configure.ac``: 64 - ``configure.ac``::
67 ::
68 65
69 AC_INIT(hello,0.1) 66 AC_INIT(hello,0.1)
70 AM_INIT_AUTOMAKE([foreign]) 67 AM_INIT_AUTOMAKE([foreign])
@@ -72,8 +69,7 @@ project:
72 AC_CONFIG_FILES(Makefile) 69 AC_CONFIG_FILES(Makefile)
73 AC_OUTPUT 70 AC_OUTPUT
74 71
75 - ``Makefile.am``: 72 - ``Makefile.am``::
76 ::
77 73
78 bin_PROGRAMS = hello 74 bin_PROGRAMS = hello
79 hello_SOURCES = hello.c 75 hello_SOURCES = hello.c
@@ -87,8 +83,7 @@ project:
87 which is followed by the string "poky-linux". For this example, the 83 which is followed by the string "poky-linux". For this example, the
88 command sources a script from the default SDK installation directory 84 command sources a script from the default SDK installation directory
89 that uses the 32-bit Intel x86 Architecture and the &DISTRO; Yocto 85 that uses the 32-bit Intel x86 Architecture and the &DISTRO; Yocto
90 Project release: 86 Project release::
91 ::
92 87
93 $ source /opt/poky/&DISTRO;/environment-setup-i586-poky-linux 88 $ source /opt/poky/&DISTRO;/environment-setup-i586-poky-linux
94 89
@@ -113,8 +108,7 @@ project:
113 the cross-compiler. The 108 the cross-compiler. The
114 :term:`CONFIGURE_FLAGS` 109 :term:`CONFIGURE_FLAGS`
115 environment variable provides the minimal arguments for GNU 110 environment variable provides the minimal arguments for GNU
116 configure: 111 configure::
117 ::
118 112
119 $ ./configure ${CONFIGURE_FLAGS} 113 $ ./configure ${CONFIGURE_FLAGS}
120 114
@@ -127,14 +121,12 @@ project:
127 ``armv5te-poky-linux-gnueabi``. You will notice that the name of the 121 ``armv5te-poky-linux-gnueabi``. You will notice that the name of the
128 script is ``environment-setup-armv5te-poky-linux-gnueabi``. Thus, the 122 script is ``environment-setup-armv5te-poky-linux-gnueabi``. Thus, the
129 following command works to update your project and rebuild it using 123 following command works to update your project and rebuild it using
130 the appropriate cross-toolchain tools: 124 the appropriate cross-toolchain tools::
131 ::
132 125
133 $ ./configure --host=armv5te-poky-linux-gnueabi --with-libtool-sysroot=sysroot_dir 126 $ ./configure --host=armv5te-poky-linux-gnueabi --with-libtool-sysroot=sysroot_dir
134 127
1355. *Make and Install the Project:* These two commands generate and 1285. *Make and Install the Project:* These two commands generate and
136 install the project into the destination directory: 129 install the project into the destination directory::
137 ::
138 130
139 $ make 131 $ make
140 $ make install DESTDIR=./tmp 132 $ make install DESTDIR=./tmp
@@ -157,8 +149,7 @@ project:
157 149
1586. *Execute Your Project:* To execute the project, you would need to run 1506. *Execute Your Project:* To execute the project, you would need to run
159 it on your target hardware. If your target hardware happens to be 151 it on your target hardware. If your target hardware happens to be
160 your build host, you could run the project as follows: 152 your build host, you could run the project as follows::
161 ::
162 153
163 $ ./tmp/usr/local/bin/hello 154 $ ./tmp/usr/local/bin/hello
164 155
@@ -203,8 +194,7 @@ regarding variable behavior:
203.. note:: 194.. note::
204 195
205 Regardless of how you set your variables, if you use the "-e" option 196 Regardless of how you set your variables, if you use the "-e" option
206 with ``make``, the variables from the SDK setup script take precedence: 197 with ``make``, the variables from the SDK setup script take precedence::
207 ::
208 198
209 $ make -e target 199 $ make -e target
210 200
@@ -226,8 +216,7 @@ Running the
226SDK setup script for a 64-bit build host and an i586-tuned target 216SDK setup script for a 64-bit build host and an i586-tuned target
227architecture for a ``core-image-sato`` image using the current &DISTRO; 217architecture for a ``core-image-sato`` image using the current &DISTRO;
228Yocto Project release and then echoing that variable shows the value 218Yocto Project release and then echoing that variable shows the value
229established through the script: 219established through the script::
230::
231 220
232 $ source /opt/poky/&DISTRO;/environment-setup-i586-poky-linux 221 $ source /opt/poky/&DISTRO;/environment-setup-i586-poky-linux
233 $ echo ${CC} 222 $ echo ${CC}
@@ -252,8 +241,7 @@ example:
252 241
253 Create the three files as follows: 242 Create the three files as follows:
254 243
255 - ``main.c``: 244 - ``main.c``::
256 ::
257 245
258 #include "module.h" 246 #include "module.h"
259 void sample_func(); 247 void sample_func();
@@ -263,14 +251,12 @@ example:
263 return 0; 251 return 0;
264 } 252 }
265 253
266 - ``module.h``: 254 - ``module.h``::
267 ::
268 255
269 #include <stdio.h> 256 #include <stdio.h>
270 void sample_func(); 257 void sample_func();
271 258
272 - ``module.c``: 259 - ``module.c``::
273 ::
274 260
275 #include "module.h" 261 #include "module.h"
276 void sample_func() 262 void sample_func()
@@ -288,8 +274,7 @@ example:
288 which is followed by the string "poky-linux". For this example, the 274 which is followed by the string "poky-linux". For this example, the
289 command sources a script from the default SDK installation directory 275 command sources a script from the default SDK installation directory
290 that uses the 32-bit Intel x86 Architecture and the &DISTRO_NAME; Yocto 276 that uses the 32-bit Intel x86 Architecture and the &DISTRO_NAME; Yocto
291 Project release: 277 Project release::
292 ::
293 278
294 $ source /opt/poky/&DISTRO;/environment-setup-i586-poky-linux 279 $ source /opt/poky/&DISTRO;/environment-setup-i586-poky-linux
295 280
@@ -297,8 +282,7 @@ example:
297 two lines that can be used to set the ``CC`` variable. One line is 282 two lines that can be used to set the ``CC`` variable. One line is
298 identical to the value that is set when you run the SDK environment 283 identical to the value that is set when you run the SDK environment
299 setup script, and the other line sets ``CC`` to "gcc", the default 284 setup script, and the other line sets ``CC`` to "gcc", the default
300 GNU compiler on the build host: 285 GNU compiler on the build host::
301 ::
302 286
303 # CC=i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux 287 # CC=i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux
304 # CC="gcc" 288 # CC="gcc"
@@ -315,8 +299,7 @@ example:
3154. *Make the Project:* Use the ``make`` command to create the binary 2994. *Make the Project:* Use the ``make`` command to create the binary
316 output file. Because variables are commented out in the Makefile, the 300 output file. Because variables are commented out in the Makefile, the
317 value used for ``CC`` is the value set when the SDK environment setup 301 value used for ``CC`` is the value set when the SDK environment setup
318 file was run: 302 file was run::
319 ::
320 303
321 $ make 304 $ make
322 i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c main.c 305 i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux -I . -c main.c
@@ -351,8 +334,7 @@ example:
351 variable as part of the command line. Go into the Makefile and 334 variable as part of the command line. Go into the Makefile and
352 re-insert the comment character so that running ``make`` uses the 335 re-insert the comment character so that running ``make`` uses the
353 established SDK compiler. However, when you run ``make``, use a 336 established SDK compiler. However, when you run ``make``, use a
354 command-line argument to set ``CC`` to "gcc": 337 command-line argument to set ``CC`` to "gcc"::
355 ::
356 338
357 $ make clean 339 $ make clean
358 rm -rf *.o 340 rm -rf *.o
@@ -376,8 +358,7 @@ example:
376 environment variable. 358 environment variable.
377 359
378 In this last case, edit Makefile again to use the "gcc" compiler but 360 In this last case, edit Makefile again to use the "gcc" compiler but
379 then use the "-e" option on the ``make`` command line: 361 then use the "-e" option on the ``make`` command line::
380 ::
381 362
382 $ make clean 363 $ make clean
383 rm -rf *.o 364 rm -rf *.o
@@ -402,8 +383,7 @@ example:
402 Makefile. 383 Makefile.
403 384
4045. *Execute Your Project:* To execute the project (i.e. ``target_bin``), 3855. *Execute Your Project:* To execute the project (i.e. ``target_bin``),
405 use the following command: 386 use the following command::
406 ::
407 387
408 $ ./target_bin 388 $ ./target_bin
409 Hello World! 389 Hello World!