user27414: Im trying to use XCode to compile avr program with arduino libs but seems like something wrong with my Makefile because it throws me warnings like 
# warning "F_CPU not defined for <util/delay.h>"

but I use -D on CC and CXX which should define stuff I thought, here is my Makefile:
TARGET              = firmware
MCU                 = atmega32u4
F_CPU               = 16000000L
USB_VID             = 0x2a03
USB_PID             = 0x8036
USB_PRODUCT         = "USB Device"
USB_MANUFACTURER    = "Unknown"
ARDUINO_VERSION     = 107010

CC   =
CXX  = avr-g++
AR   = avr-ar
COPY = avr-objcopy
SIZE = avr-size
DUDE = avrdude


CFLAGS = -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=$(USB_VID) -DUSB_PID=$(USB_PID) -DUSB_MANUFACTURER=$(USB_MANUFACTURER) -DUSB_PRODUCT=$(USB_PRODUCT)

CXXFLAGS = -c -g -Os -w -fno-exceptions -fno-threadsafe-statics -MMD -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=$(USB_VID) -DUSB_PID=$(USB_PID) -DUSB_MANUFACTURER=$(USB_MANUFACTURER) -DUSB_PRODUCT=$(USB_PRODUCT)
all: compile

compile:

    $(shell $(CXX) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo src/program.cpp -o build/program.cpp.o)

    $(shell $(CC) $(CFLAGS) -I arduino -I arduino/variants/leonardo arduino/hooks.c -o build/hooks.c.o)
    $(shell $(CC) $(CFLAGS) -I arduino -I arduino/variants/leonardo arduino/WInterrupts.c -o build/WInterrupts.c.o)
    $(shell $(CC) $(CFLAGS) -I arduino -I arduino/variants/leonardo arduino/wiring.c -o build/wiring.c.o)
    $(shell $(CC) $(CFLAGS) -I arduino -I arduino/variants/leonardo arduino/wiring_analog.c -o build/wiring_analog.c.o)
    $(shell $(CC) $(CFLAGS) -I arduino -I arduino/variants/leonardo arduino/wiring_digital.c -o build/wiring_digital.c.o)
    $(shell $(CC) $(CFLAGS) -I arduino -I arduino/variants/leonardo arduino/wiring_pulse.c -o build/wiring_pulse.c.o)
    $(shell $(CC) $(CFLAGS) -I arduino -I arduino/variants/leonardo arduino/wiring_shift.c -o build/wiring_shift.c.o)

    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/abi.cpp -o build/abi.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/CDC.cpp -o build/CDC.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/HardwareSerial.cpp -o build/HardwareSerial.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/HardwareSerial0.cpp -o build/HardwareSerial0.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/HardwareSerial1.cpp -o build/HardwareSerial1.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/HardwareSerial2.cpp -o build/HardwareSerial2.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/HardwareSerial3.cpp -o build/HardwareSerial3.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/HID.cpp -o build/HID.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/IPAddress.cpp -o build/IPAddress.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/main.cpp -o build/main.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/new.cpp -o build/new.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/Print.cpp -o build/Print.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/Stream.cpp -o build/Stream.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/Tone.cpp -o build/Tone.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/USBCore.cpp -o build/USBCore.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/WMath.cpp -o build/WMath.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/WString.cpp -o build/WString.cpp.o)

    $(shell $(AR) rcs build/core.a build/hooks.c.o)
    $(shell $(AR) rcs build/core.a build/WInterrupts.c.o)
    $(shell $(AR) rcs build/core.a build/wiring.c.o)
    $(shell $(AR) rcs build/core.a build/wiring_analog.c.o)
    $(shell $(AR) rcs build/core.a build/wiring_digital.c.o)
    $(shell $(AR) rcs build/core.a build/wiring_pulse.c.o)
    $(shell $(AR) rcs build/core.a build/wiring_shift.c.o)
    $(shell $(AR) rcs build/core.a build/abi.cpp.o)
    $(shell $(AR) rcs build/core.a build/CDC.cpp.o)
    $(shell $(AR) rcs build/core.a build/HardwareSerial.cpp.o)
    $(shell $(AR) rcs build/core.a build/HardwareSerial0.cpp.o)
    $(shell $(AR) rcs build/core.a build/HardwareSerial1.cpp.o)
    $(shell $(AR) rcs build/core.a build/HardwareSerial2.cpp.o)
    $(shell $(AR) rcs build/core.a build/HardwareSerial3.cpp.o)
    $(shell $(AR) rcs build/core.a build/HID.cpp.o)
    $(shell $(AR) rcs build/core.a build/IPAddress.cpp.o)
    $(shell $(AR) rcs build/core.a build/main.cpp.o)
    $(shell $(AR) rcs build/core.a build/new.cpp.o)
    $(shell $(AR) rcs build/core.a build/Print.cpp.o)
    $(shell $(AR) rcs build/core.a build/Stream.cpp.o)
    $(shell $(AR) rcs build/core.a build/Tone.cpp.o)
    $(shell $(AR) rcs build/core.a build/USBCore.cpp.o)
    $(shell $(AR) rcs build/core.a build/WMath.cpp.o)
    $(shell $(AR) rcs build/core.a build/WString.cpp.o)

    $(shell $(CC) -w -Os -Wl,--gc-sections -mmcu=$(MCU) -o build/program.cpp.elf build/program.cpp.o build/core.a -Lbuild -lm)

    $(shell $(COPY) -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 build/program.cpp.elf build/program.cpp.eep)
    $(shell $(COPY) -O ihex -R .eeprom build/program.cpp.elf build/program.cpp.hex)


$(TARGET).bin: compile

    $(shell $(COPY) -O binary build/program.cpp.elf $(TARGET).bin)


clean:


user23841: You are using $(CPPFLAGS) for *.cpp files but only $(CXXFLAGS) are defined.
This should be obvious from command line (if you enable showing executed commands for make)
And also:

CC =
using $(CPP) again only $(CXX) is defined

And don't forget Makefile needs tabs for indenting target commands (here you have four spaces, but it might be just replaced by SE) 

27414: <p>Im trying to use XCode to compile avr program with arduino libs but seems like something wrong with my Makefile because it throws me warnings like </p>

<pre><code># warning "F_CPU not defined for &lt;util/delay.h&gt;"
</code></pre>

<p>but I use -D on CC and CXX which should define stuff I thought, here is my Makefile:</p>

<pre><code>TARGET              = firmware
MCU                 = atmega32u4
F_CPU               = 16000000L
USB_VID             = 0x2a03
USB_PID             = 0x8036
USB_PRODUCT         = "USB Device"
USB_MANUFACTURER    = "Unknown"
ARDUINO_VERSION     = 107010

CC   =
CXX  = avr-g++
AR   = avr-ar
COPY = avr-objcopy
SIZE = avr-size
DUDE = avrdude


CFLAGS = -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=$(USB_VID) -DUSB_PID=$(USB_PID) -DUSB_MANUFACTURER=$(USB_MANUFACTURER) -DUSB_PRODUCT=$(USB_PRODUCT)

CXXFLAGS = -c -g -Os -w -fno-exceptions -fno-threadsafe-statics -MMD -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=$(USB_VID) -DUSB_PID=$(USB_PID) -DUSB_MANUFACTURER=$(USB_MANUFACTURER) -DUSB_PRODUCT=$(USB_PRODUCT)
all: compile

compile:

    $(shell $(CXX) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo src/program.cpp -o build/program.cpp.o)

    $(shell $(CC) $(CFLAGS) -I arduino -I arduino/variants/leonardo arduino/hooks.c -o build/hooks.c.o)
    $(shell $(CC) $(CFLAGS) -I arduino -I arduino/variants/leonardo arduino/WInterrupts.c -o build/WInterrupts.c.o)
    $(shell $(CC) $(CFLAGS) -I arduino -I arduino/variants/leonardo arduino/wiring.c -o build/wiring.c.o)
    $(shell $(CC) $(CFLAGS) -I arduino -I arduino/variants/leonardo arduino/wiring_analog.c -o build/wiring_analog.c.o)
    $(shell $(CC) $(CFLAGS) -I arduino -I arduino/variants/leonardo arduino/wiring_digital.c -o build/wiring_digital.c.o)
    $(shell $(CC) $(CFLAGS) -I arduino -I arduino/variants/leonardo arduino/wiring_pulse.c -o build/wiring_pulse.c.o)
    $(shell $(CC) $(CFLAGS) -I arduino -I arduino/variants/leonardo arduino/wiring_shift.c -o build/wiring_shift.c.o)

    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/abi.cpp -o build/abi.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/CDC.cpp -o build/CDC.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/HardwareSerial.cpp -o build/HardwareSerial.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/HardwareSerial0.cpp -o build/HardwareSerial0.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/HardwareSerial1.cpp -o build/HardwareSerial1.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/HardwareSerial2.cpp -o build/HardwareSerial2.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/HardwareSerial3.cpp -o build/HardwareSerial3.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/HID.cpp -o build/HID.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/IPAddress.cpp -o build/IPAddress.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/main.cpp -o build/main.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/new.cpp -o build/new.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/Print.cpp -o build/Print.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/Stream.cpp -o build/Stream.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/Tone.cpp -o build/Tone.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/USBCore.cpp -o build/USBCore.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/WMath.cpp -o build/WMath.cpp.o)
    $(shell $(CPP) $(CPPFLAGS) -I arduino -I arduino/variants/leonardo arduino/WString.cpp -o build/WString.cpp.o)

    $(shell $(AR) rcs build/core.a build/hooks.c.o)
    $(shell $(AR) rcs build/core.a build/WInterrupts.c.o)
    $(shell $(AR) rcs build/core.a build/wiring.c.o)
    $(shell $(AR) rcs build/core.a build/wiring_analog.c.o)
    $(shell $(AR) rcs build/core.a build/wiring_digital.c.o)
    $(shell $(AR) rcs build/core.a build/wiring_pulse.c.o)
    $(shell $(AR) rcs build/core.a build/wiring_shift.c.o)
    $(shell $(AR) rcs build/core.a build/abi.cpp.o)
    $(shell $(AR) rcs build/core.a build/CDC.cpp.o)
    $(shell $(AR) rcs build/core.a build/HardwareSerial.cpp.o)
    $(shell $(AR) rcs build/core.a build/HardwareSerial0.cpp.o)
    $(shell $(AR) rcs build/core.a build/HardwareSerial1.cpp.o)
    $(shell $(AR) rcs build/core.a build/HardwareSerial2.cpp.o)
    $(shell $(AR) rcs build/core.a build/HardwareSerial3.cpp.o)
    $(shell $(AR) rcs build/core.a build/HID.cpp.o)
    $(shell $(AR) rcs build/core.a build/IPAddress.cpp.o)
    $(shell $(AR) rcs build/core.a build/main.cpp.o)
    $(shell $(AR) rcs build/core.a build/new.cpp.o)
    $(shell $(AR) rcs build/core.a build/Print.cpp.o)
    $(shell $(AR) rcs build/core.a build/Stream.cpp.o)
    $(shell $(AR) rcs build/core.a build/Tone.cpp.o)
    $(shell $(AR) rcs build/core.a build/USBCore.cpp.o)
    $(shell $(AR) rcs build/core.a build/WMath.cpp.o)
    $(shell $(AR) rcs build/core.a build/WString.cpp.o)

    $(shell $(CC) -w -Os -Wl,--gc-sections -mmcu=$(MCU) -o build/program.cpp.elf build/program.cpp.o build/core.a -Lbuild -lm)

    $(shell $(COPY) -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 build/program.cpp.elf build/program.cpp.eep)
    $(shell $(COPY) -O ihex -R .eeprom build/program.cpp.elf build/program.cpp.hex)


$(TARGET).bin: compile

    $(shell $(COPY) -O binary build/program.cpp.elf $(TARGET).bin)


clean:
</code></pre>
 23841: <p>You are using <code>$(CPPFLAGS)</code> for <code>*.cpp</code> files but only <code>$(CXXFLAGS)</code> are defined.</p>

<p>This should be obvious from command line (if you enable showing executed commands for <code>make</code>)</p>

<p>And also:</p>

<ul>
<li><code>CC =</code></li>
<li>using <code>$(CPP)</code> again only <code>$(CXX)</code> is defined</li>
</ul>

<p>And don't forget Makefile needs tabs for indenting target commands (here you have four spaces, but it might be just replaced by SE) </p>
