arduino makefile

Hello everyone. I was wondering you someone knows the location of the makefile used by the arduino IDE to build the projects. I have found a couple of makefiles in the arduino folder, but they are not related to the build of a sketch.

diego_P:
Hello everyone. I was wondering you someone knows the location of the makefile used by the arduino IDE to build the projects. I have found a couple of makefiles in the arduino folder, but they are not related to the build of a sketch.

The Arduino IDE doesn't use a makefile - it just uses Java to call the compiler to build any included libraries, Arduino support code (i.e. wiring_xxx to handle "pinMode", "analogRead", "millis()", etc...) and then links it all together and finally calls avr-objcopy to generate the hex file which is then sent to Avrdude to upload to the Arduino board.

However, there is a very nice stand-alone Makefile by Tim Marston that is easily configurable and well documented which will allow you to compile and Arduino sketches from the command line without using the IDE.

Check out this [u]LINK[/u]

Hope this is what you're looking for.

(edit to add): If you run Linux or OSX, you can even setup this makefile to be GENERIC by using $(pwd) to pass the sketch name to the makefile (thereby avoiding the need to "make" a Makefile for each sketch).

Krupski:
The Arduino IDE doesn't use a makefile - it just uses Java to call the compiler to build any included libraries, Arduino support code (i.e. wiring_xxx to handle "pinMode", "analogRead", "millis()", etc...) and then links it all together and finally calls avr-objcopy to generate the hex file which is then sent to Avrdude to upload to the Arduino board.

However, there is a very nice stand-alone Makefile by Tim Marston that is easily configurable and well documented which will allow you to compile and Arduino sketches from the command line without using the IDE.

Check out this [u]LINK[/u]

Hope this is what you're looking for.

(edit to add): If you run Linux or OSX, you can even setup this makefile to be GENERIC by using $(pwd) to pass the sketch name to the makefile (thereby avoiding the need to "make" a Makefile for each sketch).

Thanks for the info. So in order to modify what files the compiler builds, I would need to modify the java files directly? Do you know which file handles the build process?

diego_P:
Thanks for the info. So in order to modify what files the compiler builds, I would need to modify the java files directly? Do you know which file handles the build process?

I’ve done a lot of customizing of my IDE. What specifically do you want to do? Maybe I’ve already done it and could just send you the source?

So in order to modify what files the compiler builds, I would need to modify the java files directly?

In the 1.6 code, there are config files that allow you to change the build process without having to modify Java code.

Krupski:
I've done a lot of customizing of my IDE. What specifically do you want to do? Maybe I've already done it and could just send you the source?

I simply want the Build process to automatically include a library to the sketch like it does with the arduino.h library, so that it does not need to be included by the user in the sketch.

diego_P:
I simply want the Build process to automatically include a library to the sketch like it does with the arduino.h library, so that it does not need to be included by the user in the sketch.

Well, there's no need to hack the IDE at all.

Just include the library(s) you want to be available automatically in your "Arduino.h" file. I have several custom libraries included in my Arduino.h file.

In MOST cases, having extra #includes in your Arduino.h file will not have any effect on your compiled sketch size if you don't use the library in a particular sketch.

Be aware though that if you write a sketch and then give it to someone else or put it online, others won't be able to compile it because THEIR Arduino setup won't have the custom library already included. You would have to add the #include statement(s) in any sketch you place in public.

Hope this helps.

Krupski:
Well, there's no need to hack the IDE at all.

Just include the library(s) you want to be available automatically in your "Arduino.h" file. I have several custom libraries included in my Arduino.h file.

In MOST cases, having extra #includes in your Arduino.h file will not have any effect on your compiled sketch size if you don't use the library in a particular sketch.

Be aware though that if you write a sketch and then give it to someone else or put it online, others won't be able to compile it because THEIR Arduino setup won't have the custom library already included. You would have to add the #include statement(s) in any sketch you place in public.

Hope this helps.

At what part of the Arduino.h file do you include the custom libraries, because I have tried including my libraries in the arduino.h, but the compiler gives me errors. I don't know if it has to do with the fact that in my libraries I use arduino functions that are probably inlcuded by arduino.h

Where do you also put your library files where the arduino.h file is located?

I get this error:

C:\Users\diego\Desktop\arduino-1.6.0 - Copy\hardware\arduino\avr\cores\arduino\test.h:6:11: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token
class test{

test.h file:

#ifndef TEST_H
#define TEST_H

//#include "Arduino.h"
class test{
    public:
        void functiontest();

};
#endif

test.cpp file:

#include "test.h"

test::functiontest(){
digitalWrite(13, HIGH);
}

diego_P:
At what part of the Arduino.h file do you include the custom libraries, because I have tried including my libraries in the arduino.h, but the compiler gives me errors. I don’t know if it has to do with the fact that in my libraries I use arduino functions that are probably inlcuded by arduino.h

Where do you also put your library files where the arduino.h file is located?

I put my custom libraries in the “arduino-1.0.6/hardware/arduino/cores/arduino” directory and then reference them in the Arduino.h file by putting the name in quotes.

For example, here’s a piece of my “arduino-1.0.6/hardware/arduino/cores/arduino” directory - the filenames in green are custom ones I made:

[b]root@michael:/usr/share/arduino-1.0.6/hardware/arduino/cores/arduino# ls -laF [M-S]*
-rw-r--r-- 1 root root 1683 Jun  2 14:56 [color=green]MemoryFree.cpp[/color]
-rw-r--r-- 1 root root  475 Jun  2 14:51 [color=green]MemoryFree.h[/color]
-rw-r--r-- 1 root root  443 May 11 14:03 new.cpp
-rw-r--r-- 1 root root  634 May 11 14:03 new.h
-rw-r--r-- 1 root root  401 Sep 16  2014 Platform.h
-rw-r--r-- 1 root root 1356 Sep 16  2014 Printable.h
-rw-r--r-- 1 root root 8379 Apr 25 23:55 Print.cpp
-rw-r--r-- 1 root root 3591 Apr 25 22:07 Print.h
-rw-r--r-- 1 root root  971 Sep 16  2014 Server.h
-rw-r--r-- 1 root root 2008 May 28 10:11 [color=green]Stdinout.cpp[/color]
-rw-r--r-- 1 root root 1319 May 28 09:25 [color=green]Stdinout.h[/color]
-rw-r--r-- 1 root root 7302 Apr 25 21:30 Stream.cpp
-rw-r--r-- 1 root root 4044 Sep 16  2014 Stream.h
-rw-r--r-- 1 root root 2308 Sep 16  2014 Streaming.h[/b]

…and here’s how they are included in the Arduino.h file:

[b]#ifdef __cplusplus

#include "WCharacter.h"
#include "WString.h"
#include "HardwareSerial.h"
[color=green]#include "Stdinout.h"[/color] // note "STDIO" is pre-defined in Stdinout.h
[color=green]#include "MemoryFree.h"[/color]
[/b]

You have to have the library code in that directory. You could not, for example, include “LiquidCrystal.h” in the Arduino.h file because you can’t “reach” it. You would have to copy or move the LiquidCrystal library TO the “…cores/arduino” directory, then include it using quotes, not <>.

diego_P:
I get this error:

C:\Users\diego\Desktop\arduino-1.6.0 - Copy\hardware\arduino\avr\cores\arduino\test.h:6:11: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token
class test{

#ifndef TEST_H

#define TEST_H

//#include "Arduino.h"
class test{
   public:
       void functiontest();

};
#endif

Where IS test.h? See my previous post.

Krupski:
Where IS test.h? See my previous post.

It is in the arduino folder where arduino.h is located.

diego_P:
It is in the arduino folder where arduino.h is located.

I just copied your test.h, saved it in the same directory that "Arduino.h" is located and then put #include "test.h" into my Arduino.h file. Worked fine (that is, generated no error).

You do know, I assume, that if you edited your Arduino.h file, you have to kill and restart your Arduino IDE for it to re-read any changes?

Krupski:
I just copied your test.h, saved it in the same directory that "Arduino.h" is located and then put #include "test.h" into my Arduino.h file. Worked fine (that is, generated no error).

You do know, I assume, that if you edited your Arduino.h file, you have to kill and restart your Arduino IDE for it to re-read any changes?

You're completely right. I didn't know you had to close the ide and reopen it. Now it works! Thanks a lot for you help. That was just a quick class to test. If I have any problems with my actual libraries, I will post again.

diego_P:
Thanks a lot for you help.

You are quite welcomed.