<?xml version="1.0"?><rss version="2.0">
<channel>
  <title>Alan&#039;s Ramblings - gmake tag</title>
  <link>http://bleaklow.com:80/tags/gmake/</link>
  <description>My opinions may be incorrect, but they are my own</description>
  <language>en</language>
  <copyright>Alan Burlison</copyright>
  <lastBuildDate>Wed, 29 Feb 2012 20:50:00 GMT</lastBuildDate>
  <generator>Pebble (http://pebble.sourceforge.net)</generator>
  <docs>http://backend.userland.com/rss</docs>
  <image>
    <url>http://bleaklow.com/images/misc/logo.gif</url>
    <title>Alan&#039;s Ramblings</title>
    <link>http://bleaklow.com:80/</link>
  </image>
  <item>
    <title>Configuring NetBeans to use as an Arduino IDE</title>
    <link>http://bleaklow.com:80/2010/06/22/configuring_netbeans_to_use_as_an_arduino_ide.html</link>
    <description>
          As I&#039;ve said in an earlier post, I very quickly found the &lt;a href=&#034;http://www.arduino.cc/en/Guide/Environment&#034;&gt;Arduino IDE&lt;/a&gt; to be way too primitive for serious use, so I decided to switch to using &lt;a href=&#034;http://netbeans.org/&#034;&gt;NetBeans&lt;/a&gt; as an alternative.  First step was to create a &lt;a href=&#034;2010/06/04/a_makefile_for_arduino_sketches.html&#034;&gt;Makefile&lt;/a&gt;, once I had that done I needed to configure NetBeans to use the avg-gcc toolchain, which was pretty straightforward.  Ideally I&#039;d just be able export the relevant settings from NetBeans and provide a file you could download and install, but unfortunately NetBeans doesn&#039;t provide a way to do this for individual compilers, just all of them at once :-(
&lt;/p&gt;
&lt;p&gt;
First step is to set up a new compiler configuration, &lt;code&gt;Tools -&amp;gt; Options -&amp;gt; C/C++ -&amp;gt; Add&lt;/code&gt;.  Set the base directory to wherever you have avr-gcc installed, in my case this is under &lt;code&gt;/opt/arduino/hardware/tools/gcc-avr/avr/bin&lt;/code&gt;.  Set the compiler family to &lt;code&gt;GNU&lt;/code&gt; and save.
&lt;/p&gt;
&lt;a href=&#034;/images/2010/nb_setup_1.png&#034; onclick=&#034;window.open(&#039;/images/2010/nb_setup_1.png&#039;,&#039;popup&#039;,&#039;width=660,height=660,toolbar=no,directories=no,location=no,menubar=no,status=no&#039;); return false&#034; class=&#034;thumbnailLink&#034;&gt;&lt;img src=&#034;/images/2010/thumbnails/nb_setup_1.png&#034; alt=&#034;step 1&#034; class=&#034;thumbnailImage&#034;/&gt;&lt;/a&gt;
&lt;p&gt;
Then in the &lt;code&gt;Build Tools&lt;/code&gt; tab, set the paths for the C compiler, the C++ compiler and for the assembler, i.e. the full paths to the AVR versions of &lt;code&gt;gcc&lt;/code&gt;, &lt;code&gt;c++&lt;/code&gt; and &lt;code&gt;as&lt;/code&gt;.  Also set the path for &lt;code&gt;gmake&lt;/code&gt;.  Clicking on the &lt;code&gt;Versions&lt;/code&gt; button should display the versions of the tools.
&lt;/p&gt;
&lt;a href=&#034;/images/2010/nb_setup_2.png&#034; onclick=&#034;window.open(&#039;/images/2010/nb_setup_2.png&#039;,&#039;popup&#039;,&#039;width=660,height=660,toolbar=no,directories=no,location=no,menubar=no,status=no&#039;); return false&#034; class=&#034;thumbnailLink&#034;&gt;&lt;img src=&#034;/images/2010/thumbnails/nb_setup_2.png&#034; alt=&#034;step 2&#034; class=&#034;thumbnailImage&#034;/&gt;&lt;/a&gt;
&lt;p&gt;
Switch to the &lt;code&gt;Code Assistance&lt;/code&gt; tab, and for both the C and C++ compilers, click the &lt;code&gt;Reset Settings&lt;/code&gt; button.  This should fill in the default values, the include directories should be set to locations under your avr-gcc install tree.  You also need to manually add the directory containing the source of the Arduino libraries to each compiler configuration, in my case this is &lt;code&gt;/opt/arduino/hardware/cores/arduino&lt;/code&gt;, and them move it to the top of the include lists.
&lt;/p&gt;
&lt;a href=&#034;/images/2010/nb_setup_3.png&#034; onclick=&#034;window.open(&#039;/images/2010/nb_setup_3.png&#039;,&#039;popup&#039;,&#039;width=660,height=660,toolbar=no,directories=no,location=no,menubar=no,status=no&#039;); return false&#034; class=&#034;thumbnailLink&#034;&gt;&lt;img src=&#034;/images/2010/thumbnails/nb_setup_3.png&#034; alt=&#034;step 3&#034; class=&#034;thumbnailImage&#034;/&gt;&lt;/a&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;a href=&#034;/images/2010/nb_setup_4.png&#034; onclick=&#034;window.open(&#039;/images/2010/nb_setup_4.png&#039;,&#039;popup&#039;,&#039;width=660,height=660,toolbar=no,directories=no,location=no,menubar=no,status=no&#039;); return false&#034; class=&#034;thumbnailLink&#034;&gt;&lt;img src=&#034;/images/2010/thumbnails/nb_setup_4.png&#034; alt=&#034;step 4&#034; class=&#034;thumbnailImage&#034;/&gt;&lt;/a&gt;
&lt;p&gt;
Finally, switch to the &lt;code&gt;Other&lt;/code&gt; tab, and add &lt;code&gt;pde&lt;/code&gt; to the list of C++ file extensions, and save.  That&#039;s the tools set up.
&lt;/p&gt;
&lt;a href=&#034;/images/2010/nb_setup_5.png&#034; onclick=&#034;window.open(&#039;/images/2010/nb_setup_5.png&#039;,&#039;popup&#039;,&#039;width=660,height=660,toolbar=no,directories=no,location=no,menubar=no,status=no&#039;); return false&#034; class=&#034;thumbnailLink&#034;&gt;&lt;img src=&#034;/images/2010/thumbnails/nb_setup_5.png&#034; alt=&#034;step 5&#034; class=&#034;thumbnailImage&#034;/&gt;&lt;/a&gt;
&lt;p&gt;
The next steps apply when you are creating a new project and defining its properties.  Obviously you need to choose the avr-gcc toolchain to compile the project, and provide a &lt;a href=&#034;2010/06/04/a_makefile_for_arduino_sketches.html&#034;&gt;Makefile&lt;/a&gt; to build it with - don&#039;t use the standard NetBeans one, it won&#039;t work.
&lt;/p&gt;
&lt;p&gt;
The &lt;code&gt;Code Assistance&lt;/code&gt; sections for both the C and C++ compilers need setting up to refer to any additional library directories you are using, and if you want code completion to work properly you also need to define the requisite preprocessor macros.  Do this by setting up a new Configuration for each board type you use, and within that define the macros.  I have duemilanove and mega boards, so my settings are:
&lt;/p&gt;
&lt;h4&gt;duemilanove&lt;/h4&gt;
&lt;pre&gt;__AVR_ATmega328P__
F_CPU=16000000L
&lt;/pre&gt;
&lt;h4&gt;mega&lt;/h4&gt;
&lt;pre&gt;__AVR_ATmega1280__
F_CPU=16000000L
&lt;/pre&gt;
&lt;a href=&#034;/images/2010/nb_setup_6.png&#034; onclick=&#034;window.open(&#039;/images/2010/nb_setup_6.png&#039;,&#039;popup&#039;,&#039;width=660,height=660,toolbar=no,directories=no,location=no,menubar=no,status=no&#039;); return false&#034; class=&#034;thumbnailLink&#034;&gt;&lt;img src=&#034;/images/2010/thumbnails/nb_setup_6.png&#034; alt=&#034;step 6&#034; class=&#034;thumbnailImage&#034;/&gt;&lt;/a&gt;
&lt;p&gt;
If you have different boards you&#039;ll have to figure out the correct &lt;code&gt;__AVR_ATXXX__&lt;/code&gt; and &lt;code&gt;F_CPU&lt;/code&gt; #defines.  First find &lt;code&gt;boards.txt&lt;/code&gt; in your Arduino install tree and find the section for your board.  The &lt;code&gt;f_cpu&lt;/code&gt; value is what you need for &lt;code&gt;F_CPU&lt;/code&gt;, the other setting is a little more fiddly to find.  Get the &lt;code&gt;mcu&lt;/code&gt; value, then look that up in the second table on &lt;a href=&#034;http://www.nongnu.org/avr-libc/user-manual/using__tools.html&#034;&gt;this page&lt;/a&gt; to find the corresponding macro that needs to be defined.
&lt;/p&gt;
&lt;p&gt;
As the generated code needs to be run on the Arduino, the normal &lt;code&gt;Run&lt;/code&gt; settings don&#039;t actually make much sense, but we can re-purpose them for our needs.  In the &lt;code&gt;Make&lt;/code&gt; section, set the &lt;code&gt;Build Result&lt;/code&gt; value to the path of your gmake executable, then in the &lt;code&gt;Run&lt;/code&gt; section, set the command-line argument to &lt;code&gt;upload&lt;/code&gt;.  By doing this, when you run the project with F6, NetBeans will run the &lt;code&gt;upload&lt;/code&gt; Makefile target which will build the project and upload it to the board.  If you want to build, upload and run the serial monitor, set the argument to &lt;code&gt;upload_monitor&lt;/code&gt; instead,.
&lt;/p&gt;
&lt;a href=&#034;/images/2010/nb_setup_7.png&#034; onclick=&#034;window.open(&#039;/images/2010/nb_setup_7.png&#039;,&#039;popup&#039;,&#039;width=660,height=660,toolbar=no,directories=no,location=no,menubar=no,status=no&#039;); return false&#034; class=&#034;thumbnailLink&#034;&gt;&lt;img src=&#034;/images/2010/thumbnails/nb_setup_7.png&#034; alt=&#034;step 7&#034; class=&#034;thumbnailImage&#034;/&gt;&lt;/a&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;a href=&#034;/images/2010/nb_setup_8.png&#034; onclick=&#034;window.open(&#039;/images/2010/nb_setup_8.png&#039;,&#039;popup&#039;,&#039;width=660,height=660,toolbar=no,directories=no,location=no,menubar=no,status=no&#039;); return false&#034; class=&#034;thumbnailLink&#034;&gt;&lt;img src=&#034;/images/2010/thumbnails/nb_setup_8.png&#034; alt=&#034;step 8&#034; class=&#034;thumbnailImage&#034;/&gt;&lt;/a&gt;
&lt;p&gt;
With all that in place you should be able to use NetBeans as your IDE for developing for the Arduino, including all the nice features such as cross-referencing and code completion.  The setup of projects is a little fiddly, so my suggestion is to set up an empty template project that you can copy and then change all the project name references in - I use &lt;code&gt;TEMPLATE&lt;/code&gt; as the project name so I can use a little script to clone the project then rename and batch-edit the files with the correct project name.
&lt;/p&gt;</description>
      <category>Arduino</category>
    <category>Tech</category>
    <comments>http://bleaklow.com:80/2010/06/22/configuring_netbeans_to_use_as_an_arduino_ide.html#comments</comments>
    <guid isPermaLink="true">http://bleaklow.com:80/2010/06/22/configuring_netbeans_to_use_as_an_arduino_ide.html</guid>
    <pubDate>Tue, 22 Jun 2010 19:09:00 GMT</pubDate>
  </item>
  </channel>
</rss>

