From b15903d61b40f43b29b2a8cf24ec6fb449e53d32 Mon Sep 17 00:00:00 2001 From: Scott Rifenbark Date: Thu, 7 Jun 2018 09:26:41 -0700 Subject: sdk-manual: Updates to the "Makefile-Based Projects" section. I wrote the section to include a flow diagram using "make" and provided a working example highlighting how to override environment variables. (From yocto-docs rev: 00e8e09a51a1f0305317f38975a9d7695c92bdb5) Signed-off-by: Scott Rifenbark Signed-off-by: Richard Purdie --- documentation/sdk-manual/sdk-working-projects.xml | 129 ++++++++++++++++------ 1 file changed, 96 insertions(+), 33 deletions(-) (limited to 'documentation/sdk-manual') diff --git a/documentation/sdk-manual/sdk-working-projects.xml b/documentation/sdk-manual/sdk-working-projects.xml index 44b010db6d..d1249b83a9 100644 --- a/documentation/sdk-manual/sdk-working-projects.xml +++ b/documentation/sdk-manual/sdk-working-projects.xml @@ -233,56 +233,118 @@ Makefile-Based Projects - For Makefile-based projects, the cross-toolchain environment - variables established by running the cross-toolchain environment - setup script are subject to general make - rules. + Simple Makefile-based projects use and interact with the + cross-toolchain environment variables established when you run + the cross-toolchain environment setup script. + The environment variables are subject to general + make rules. - To illustrate this, consider the following four cross-toolchain - environment variables: - - CC="i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/&DISTRO;/sysroots/i586-poky-linux" - LD="i586-poky-linux-ld --sysroot=/opt/poky/&DISTRO;/sysroots/i586-poky-linux" - CFLAGS="-O2 -pipe -g -feliminate-unused-debug-types" - CXXFLAGS="-O2 -pipe -g -feliminate-unused-debug-types" - - Now, consider the following three cases: + This section presents a simple Makefile development flow and + provides an example that lets you see how you can use + cross-toolchain environment variables to replace or override + variables used in your Makefile. + + + + + The main point of this section is to explain the following three + cases regarding variable behavior: Case 1 - No Variables Set in the - Makefile: - Because these variables are not specifically set in the + Makefile that Map to Equivalent + Environment Variables Set in the SDK Setup Script: + Because matching variables are not specifically set in the Makefile, the variables retain their - values based on the environment. + values based on the environment setup script. - Case 2 - Variables Set in the - Makefile: - Specifically setting variables in the + Case 2 - Variables Are Set in the Makefile that + Map to Equivalent Environment Variables from the SDK + Setup Script: + Specifically setting matching variables in the Makefile during the build results in the environment settings of the variables being overwritten. + In this case, the variables you set in the + Makefile are used. - Case 3 - Variables Set when the - Makefile is Executed from the - Command Line: + Case 3 - Variables Are Set Using the Command Line + that Map to Equivalent Environment Variables from the + SDK Setup Script: Executing the Makefile from the - command-line results in the variables being overwritten - with command-line content regardless of what is being set - in the Makefile. - In this case, environment variables are not considered - unless you use the "-e" flag during the build: - - $ make -e file - - If you use this flag, then the environment values of the - variables override any variables specifically set in the - Makefile. + command line results in the environment settings of the + variables being overwritten. + In this case, the command-line content is used. + + The one exception to this is if you use the following + command-line option: + + $ make -e target + + Using the "-e" option with make + causes the environment variables to be used during + the build. + + + + + The remainder of this section presents a simple Makefile example + that demonstrates these variable behaviors. + + + + In a new shell environment variables are not established for the + SDK until you run the setup script. + For example, the following commands show null values for four + variables that are set when you run the SDK environment 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: + + $ echo ${CC} + + $ echo ${LD} + + $ echo ${CFLAGS} + + $ echo ${CXXFLAGS} + + Running the setup script and then echoing the variables shows the + values established for the SDK: + + $ source /opt/poky/2.5/environment-setup-i586-poky-linux + $ echo ${CC} + i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux + $ echo ${LD} + i586-poky-linux-ld --sysroot=/opt/poky/2.5/sysroots/i586-poky-linux + $ echo ${CFLAGS} + -O2 -pipe -g -feliminate-unused-debug-types + $ echo ${CXXFLAGS} + -O2 -pipe -g -feliminate-unused-debug-types + + + + + NEED REST OF THE EXAMPLE. + WORKING ON GETTING IT TO WORK PROPERLY. + + +