title: How to compile arduino core library with makefile?
body: <p>I want to create library files (.a) of the arduino core library, eventually also the other libraries (SPI, ...), with a makefile, but I can't get it to work!  </p>
  
  <p>This is my makefile: </p>
  
  <pre><code>CC=avr-gcc
  CPP=avr-g++
  MCU=-mmcu=atmega328p
  CPU_SPEED=-DF_CPU=16000000UL
  CFLAGS=$(MCU) $(CPU_SPEED) -g2 -gstabs -Os -Wall \
  -ffunction-sections -fdata-sections -fno-exceptions
  INCLUDE=-I./arduinoCORE
  
  CFILES=$(wildcard ./arduinoCORE/*.c)
  CPPFILES=$(wildcard ./arduinoCORE/*.cpp)
  
  OBJ=$(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
  
  default: $(OBJ)
      avr-ar -r libarduinoUNO.a $^
  
  %.o : %.c
      $(CC) $&lt; $(CFLAGS) -c -o $@
  
  %.o : %.cpp
      $(CPP) $&lt; $(CFLAGS) -c -o $@
  </code></pre>
  
  <p>(all header and source files are in arduinoCORE; even pins_arduino.h)  </p>
  
  <p>After <code>$ make</code> in directory above arduinoCORE I get this error message: </p>
  
  <pre><code>avr-g++ arduinoCORE/CDC.cpp -mmcu=atmega328p -DF_CPU=16000000UL -g2 -gstabs -Os -Wall -ffunction-sections -fdata-sections -fno-exceptions -c -o arduinoCORE/CDC.o
  In file included from arduinoCORE/Print.h:27:0,
                   from arduinoCORE/Stream.h:26,
                   from arduinoCORE/HardwareSerial.h:28,
                   from arduinoCORE/Arduino.h:193,
                   from arduinoCORE/Platform.h:15,
                   from arduinoCORE/CDC.cpp:19:
  arduinoCORE/Printable.h:23:17: fatal error: new.h: No such file or directory
   #include &lt;new.h&gt;
                   ^
  compilation terminated.
  
  make: *** [arduinoCORE/CDC.o] Error 1  
  </code></pre>
  
  <p>The problem is, that new.h is actually in arduinoCORE!
  Does anyone know how to manage this?</p>