From d654160eb2ea03aabd77b4bbc7a202d4179bcca3 Mon Sep 17 00:00:00 2001 From: Scott Rifenbark Date: Tue, 14 Apr 2015 06:49:55 -0700 Subject: adt-manual: Updated the Makefile-based project section. Fixes [YOCTO #7133] Added more examples of how variables work in Makefile projects. (From yocto-docs rev: e8aa42f3609de3dfe94c022d957b855a4f7ef032) Signed-off-by: Scott Rifenbark Signed-off-by: Richard Purdie --- documentation/adt-manual/adt-command.xml | 66 ++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 21 deletions(-) (limited to 'documentation/adt-manual') diff --git a/documentation/adt-manual/adt-command.xml b/documentation/adt-manual/adt-command.xml index d6fa8ee4d4..5df6a6f621 100644 --- a/documentation/adt-manual/adt-command.xml +++ b/documentation/adt-manual/adt-command.xml @@ -210,31 +210,55 @@ Makefile-Based Projects - For Makefile-based projects, the cross-toolchain environment - variables established by running the cross-toolchain environment - setup script override any settings you might have in your - Makefile. - For example, if you had settings such as the following in your - Makefile, the environment variables defined - by the script would override them: + For Makefile-based projects, the cross-toolchain environment variables + established by running the cross-toolchain environment setup script + are subject to general make rules. + + + + To illustrate this, consider the following four cross-toolchain + environment variables: - CC=arm-poky-linux-gnueabi-gcc - LD=arm-poky-linux-gnueabi-ld - CFLAGS=”${CFLAGS} --sysroot=<sysroot-dir>” - CXXFLAGS=”${CXXFLAGS} --sysroot=<sysroot-dir>” + CC=i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/1.8/sysroots/i586-poky-linux + LD=i586-poky-linux-ld --sysroot=/opt/poky/1.8/sysroots/i586-poky-linux + CFLAGS=-O2 -pipe -g -feliminate-unused-debug-types + CXXFLAGS=-O2 -pipe -g -feliminate-unused-debug-types - Consequently, you should not set variables like - CC - and - LD - in your Makefile. - For the list of variables set up by the cross-toolchain environment - setup script, see the - "Setting Up the Cross-Development Environment" - section. + Now, consider the following three cases: + + Case 1 - No Variables Set in the Makefile: + Because these variables are not specifically set in the + Makefile, the variables retain their + values based on the environment. + + Case 2 - Variables Set in the Makefile: + Specifically setting variables in the + Makefile during the build results in the + environment settings of the variables being overwritten. + + Case 3 - Variables Set when the Makefile is Executed from the Command Line: + 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. + + + + For the list of variables set up by the cross-toolchain environment + setup script, see the + "Setting Up the Cross-Development Environment" + section. + -