<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>7133</bug_id>
          
          <creation_ts>2015-01-13 15:20:20 +0000</creation_ts>
          <short_desc>Document environment file usage</short_desc>
          <delta_ts>2015-08-20 04:29:11 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>9</classification_id>
          <classification>Documentation</classification>
          <product>ADT Manual</product>
          <component>SDK</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>VERIFIED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard>15 June 2015: Checking documentation changes</status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>1.9 M3</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Mark Hatle">mark.hatle</reporter>
          <assigned_to name="Costin">costin.c.constantin</assigned_to>
          <cc>alexandru.c.georgescu</cc>
    
    <cc>bluelightning</cc>
    
    <cc>costin.c.constantin</cc>
    
    <cc>poky.doc.watcher</cc>
    
    <cc>poky.watcher</cc>
    
    <cc>richard.purdie</cc>
    
    <cc>srifenbark</cc>
          
          <qa_contact name="Costin">costin.c.constantin</qa_contact>
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Done (doc changes complete)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>47887</commentid>
    <comment_count>0</comment_count>
    <who name="Mark Hatle">mark.hatle</who>
    <bug_when>2015-01-13 15:20:20 +0000</bug_when>
    <thetext>The ADT documentation lists how to source the environment file, but not what to do with the now available environment variables.

Something like:

Once the environment file is sources, a number of environment variables are now defined:

SDKROOT - path to the installed SDK
SDKTARGETSYSROOT - path to the sysroot that will be used for cross compilation
PKG_CONFIG_PATH - path to pkg-config files for the target
CONFIG_SITE - a gnu autoconf site file preconfigured for the target
CC - minimum command and arguments to run the C compiler
CXX - minimum command and arguments to run the C++ compiler
CPP - minimum command and arguments to run the C preprocessor
AS - minimum command and arguments to run the assembler
LD - minimum command and arguments to run the linker
GDB - minimum command and arguments to run the GNU Debugger
STRIP - minimum command and arguments to run &apos;strip&apos; (strip symbols)
RANLIB - minimum command and arguments to run &apos;ranlib&apos;
OBJCOPY - minimum command and arguments to run &apos;objcopy&apos;
OBJDUMP - minimum command and arguments to run &apos;objdump&apos;
AR - minimum command and arguments to run &apos;ar&apos;
NM - minimum command and arguments to run &apos;nm&apos;
TARGET_PREFIX - toolchain binary prefix for the target tools
CROSS_COMPILE - (same as TARGET_PREFIX)
CONFIGURE_FLAGS - minimum arguments for GNU configure
CFLAGS - suggested C flags
CXXFLAGS - suggested C++ flags
LDFLAGS - suggested linker flags (when using CC to link)
CPPFLAGS - suggested preprocessor flags

To use the above, on the command line, to compile a simple hello_world.c and hello_world.cc, or the GNU version of hello world you would do the following:

(source the environment file as noted above)

Compile a simple C application:
$ $CC hello_world.c -o hello

Compile a simple CXX application:
$ $CXX hello_world.cxx -o hello_cxx

Configure and compile a GNU autoconf application
$ ./configure $CONFIGURE_FLAGS
$ make</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48083</commentid>
    <comment_count>1</comment_count>
    <who name="Paul Eggleton">bluelightning</who>
    <bug_when>2015-01-20 15:54:06 +0000</bug_when>
    <thetext>I&apos;ve talked to Scott about this offline. However, we don&apos;t seem to have a reference to SDKROOT anywhere I can find. Mark, is this something specific to your setup?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48088</commentid>
    <comment_count>2</comment_count>
    <who name="Mark Hatle">mark.hatle</who>
    <bug_when>2015-01-20 16:05:04 +0000</bug_when>
    <thetext>You are correct.  The SDKROOT is what was implemented in the meta-mingw patch that I submitted to the Yocto Project. (Not yet merged.)  It&apos;s not in the default Linux SDK.

So it likely should be documented.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48257</commentid>
    <comment_count>3</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2015-01-23 18:29:51 +0000</bug_when>
    <thetext>Hi, 

I have gone through the entire adt-manual and addressed this issue.  The result was &quot;feathering&quot; in text to more fully describe the use and role for the cross-toolchain environment variables that are established when one runs the cross-toolchain environment setup script.  

Additionally, many new variables were added to the ref-manual to support the changes.  I would like the stuff reviewed and notified of any further changes or issues.  Note that the descriptions for the new variables are very brief and are based soley on the short descriptions provided in the bug.  If you want to expand on them, give me some more details and I will.

You can see the changes at:

  http://www.yoctoproject.org/docs/1.8/adt-manual/adt-manual.html (it would be good to check out most of the document - several areas were changed).

  http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#var-SDKROOT
  http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#var-SDKTARGETSYSROOT
  http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#var-PKG_CONFIG_PATH
  http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#var-CONFIG_SITE
  http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#var-CC
  http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#var-CXX
  http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#var-CPP
  http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#var-AS
  http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#var-LD
  http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#var-GDB
  http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#var-STRIP
  http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#var-RANLIB
  http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#var-OBJCOPY
  http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#var-OBJDUMP
  http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#var-AR
  http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#var-NM
  http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#var-TARGET_PREFIX
  http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#var-CROSS_COMPILE
    http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#var-CONFIGURE_FLAGS
    http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#var-CFLAGS
    http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#var-CXXFLAGS
    http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#var-LDFLAGS
    http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#var-CPPFLAGS

Thanks, 
Scott</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48265</commentid>
    <comment_count>4</comment_count>
    <who name="Mark Hatle">mark.hatle</who>
    <bug_when>2015-01-23 19:51:36 +0000</bug_when>
    <thetext>Comments.. ADT section 5.2 is incorrect:

5.2. Makefile-Based Projects¶

For Makefile-based projects, you make sure your Makefile has statements that ensure proper use of the cross-toolchain. For example, the following statements inside a Makefile ensure the C compiler, linker, flags passed to the C compiler, and flags passed to the C++ compiler are specifically defined for the build:

     CC=arm-poky-linux-gnueabi-gcc
     LD=arm-poky-linux-gnueabi-ld
     CFLAGS=”${CFLAGS} --sysroot=&lt;sysroot-dir&gt;”
     CXXFLAGS=”${CXXFLAGS} --sysroot=&lt;sysroot-dir&gt;”
        

When using the cross compiler, the environment will set the CC and LD arguments to their appropriate values, including the --sysroot= value.

So the Makefile should either NOT have CC, CXX, LD, CFLAGS, CXXFLAGS set -- or if set should be overridden by the environment.

As for the other references.. they look to be correct in most cases.  However, &quot;SDKROOT&quot; was something I added specifically for meta-mingw and should NOT be in the documentation.  So please remove references to SDKROOT.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48270</commentid>
    <comment_count>5</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2015-01-23 23:37:53 +0000</bug_when>
    <thetext>Hi Mark, 

I re-wrote that last section on the Makefile stuff.  See http://www.yoctoproject.org/docs/1.8/adt-manual/adt-manual.html#makefile-based-projects.  Tell me if I captured it okay. 

Also, &quot;SDKROOT&quot; has been eradicated from the YP manual set. 

Thanks, 
Scott</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49502</commentid>
    <comment_count>6</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2015-03-17 18:24:18 +0000</bug_when>
    <thetext>Hi, 

No more feedback on this so I am marking it RESOLVED. Doc flag set to &quot;Done&quot;.

Thanks, 
Scott</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50204</commentid>
    <comment_count>7</comment_count>
    <who name="Costin">costin.c.constantin</who>
    <bug_when>2015-04-09 18:08:29 +0000</bug_when>
    <thetext>Hi Mark, Scott,

I just tested this enhancement and I think there is some confusing info in the added/modified chapter of the ADT manual. 
Downwards are steps i took in order to check/test/verify:

1) downloaded last toolchain available (and installed it after):
http://autobuilder.yoctoproject.org/pub/releases/yocto-1.8_m4.rc2/toolchain/x86_64/

2) sourced the environment: 
autobuilder@sstate1:/opt/poky/1.8$ pwd
/opt/poky/1.8
autobuilder@sstate1: . ./environment-setup-i586-poky-linux 

3) checked for few variables as described in the manual:
autobuilder@sstate1:/opt/poky/1.8$ echo $CC
i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/1.8/sysroots/i586-poky-linux
autobuilder@sstate1:/opt/poky/1.8$ echo $CXX
i586-poky-linux-g++ -m32 -march=i586 --sysroot=/opt/poky/1.8/sysroots/i586-poky-linux
autobuilder@sstate1:/opt/poky/1.8$ echo $CFLAGS
-O2 -pipe -g -feliminate-unused-debug-types

4) created a Makefile for both a small helloworld.c and an helloworld.cxx. This file contains for both CC and CXX variables a wrong option (-t), meaning that if they are overridden(according to manual), there should be no problem:
autobuilder@sstate1:/opt/poky/1.8/tests_dir$ cat Makefile

buildc:
        CC=gcc -t
        $(CC) hello.c -o hello.o

buildcpp:
        CXX=g++ -t
        $(CXX) hello.cxx -o hellocxx.o

5) tried the Makefile:
autobuilder@sstate1:/opt/poky/1.8/tests_dir$ sudo make buildc
CC=gcc -t
/bin/sh: 1: -t: not found
make: *** [buildc] Error 127

autobuilder@sstate1:/opt/poky/1.8$ sudo make buildcpp
CXX=g++ -t
/bin/sh: 1: -t: not found
make: *** [buildcpp] Error 127

As a result of the above, i believe that there is an error in the manual, since local Makefile variables are not overridden by the environment ones. I also tried other variables (CFLAGS) and behavior is the same. I also tried without -t option and everything is fine, meaning OS gcc and g++ are used.     
  
Costin</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50205</commentid>
    <comment_count>8</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2015-04-09 18:14:59 +0000</bug_when>
    <thetext>Hey Costin, 

So thanks for looking at this.  What would you say the fix is here for the docs?  Should we remove that part about the running the cross-toolchain environment setup script overriding any settings you might have in your Makefile?

Scott</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50261</commentid>
    <comment_count>9</comment_count>
    <who name="Costin">costin.c.constantin</who>
    <bug_when>2015-04-13 08:42:23 +0000</bug_when>
    <thetext>Hi Scott,

I realized I made a small mistake in my previous comment, but I will correct it here. Also, in my opinion the section for Makefile stuff should look something like:

For Makefile-based projects, the cross-toolchain environment variables established by running the cross-toolchain environment 
setup script are subject to general make rules. Suppose the resulted environment variables look like this, 3 cases apply:

     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	
	 
Case 1: None of these variables are set in the Makefile
The result will be that make considers the variables as set from environment.
eg. of Makefile content:
build:
    echo $(CC)
    echo $(LD)
    echo $(CFLAGS)
    echo $(CXXFLAGS)
	
Case 2: Variables are set in Makefile:
The result will be that these variables override the content of those from environment.
eg. of Makefile content:
CC=gcc
LD=ld
CFLAGS=-g
CXXFLAGS=$(CFLAGS) -O
build:
        echo $(CC)
        echo $(LD)
        echo $(CFLAGS)
        echo $(CXXFLAGS)
		
Case 3: Variables are set when make is executed from command line:
The result is that no matter what the Makefile contains, the respective variable will be overridden with the command line content.
In this case, also environment variables are not considered. The content of Makefile is the same as on case 2.
eg.: make CFLAGS=&apos;-p&apos; build

If the desired behavior is to override any Makefile variable with the content of those from environment, then the &quot;-e&quot; flag for make should be used.  
eg.:  make -e build


Thank you,
Costin</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50266</commentid>
    <comment_count>10</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2015-04-13 14:31:30 +0000</bug_when>
    <thetext>Costin, 

I updated that section based on your suggestions.  Note that I did not provide example output as your explanation did.  I think the points for the three cases can be make without those.

You can see the modified section at http://www.yoctoproject.org/docs/1.8/adt-manual/adt-manual.html#makefile-based-projects.  Please let me know of any issues or changes that might still be needed.

Note - I am setting the target for this bug to 1.9 M1 as the deadline for doc changes to 1.8 has passed.

Thanks,
Scott</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50765</commentid>
    <comment_count>11</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2015-05-04 21:17:01 +0000</bug_when>
    <thetext>Setting status to RESOLVED as I have had no feedback on it.  Assuming it is okay.

Scott</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51698</commentid>
    <comment_count>12</comment_count>
    <who name="Costin">costin.c.constantin</who>
    <bug_when>2015-06-15 09:56:24 +0000</bug_when>
    <thetext>Hi Scott,

I think there is a small mistake in the manual:

As it is now:
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: 

Should be:
For Makefile-based projects, the cross-toolchain environment variables established by running the cross-toolchain environment setup script are overridden by those in your Makefile. For example, if you had settings such as the following in your Makefile, the environment variables defined by the script would be overridden: 
...

Thank you,

Costin</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51699</commentid>
    <comment_count>13</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2015-06-15 12:31:36 +0000</bug_when>
    <thetext>Hi Costin, 

Since this change was made in the 1.8 manual as noted in Comment 10, further work has been done to that section for the upcoming YP release.  Could you look at that new work and see if that addresses your concerns?  You can see the changes here - http://www.yoctoproject.org/docs/1.9/adt-manual/adt-manual.html#makefile-based-projects.

If this section in the 1.9 manual is okay, then I can push it into the fido tree for the latest 1.8 manuals online.  

Thanks, 
Scott</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>52557</commentid>
    <comment_count>14</comment_count>
    <who name="Stephen K Jolley">sjolley.yp.pm</who>
    <bug_when>2015-07-23 14:54:33 +0000</bug_when>
    <thetext>Costin,   Please reply to Scott&apos;s comment.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>52628</commentid>
    <comment_count>15</comment_count>
    <who name="Costin">costin.c.constantin</who>
    <bug_when>2015-07-27 14:34:10 +0000</bug_when>
    <thetext>Hi,

Yes, looks fine now. 

Cositn</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>52629</commentid>
    <comment_count>16</comment_count>
    <who name="Costin">costin.c.constantin</who>
    <bug_when>2015-07-27 14:34:47 +0000</bug_when>
    <thetext>Marking as verified.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>