Makefile 930 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. CC = avr-gcc
  2. OBJCPY = avr-objcopy
  3. SIZE = avr-size
  4. MCU = atmega328p
  5. F_CPU = 16000000
  6. U8G2_SRC = ../../../../csrc
  7. CFLAGS = \
  8. -mmcu=$(MCU) \
  9. -DF_CPU=$(F_CPU)UL \
  10. -Os \
  11. -std=gnu99 \
  12. -Werror \
  13. -ffunction-sections \
  14. -fdata-sections \
  15. -I$(U8G2_SRC)/ \
  16. -I../lib/ \
  17. -DAVR_USE_HW_I2C
  18. LDFLAGS = \
  19. -Wl,--gc-sections \
  20. -mmcu=$(MCU)
  21. AVRDUDE=avrdude
  22. PORT=/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A4008fhY-if00-port0
  23. SRC = $(shell ls $(U8G2_SRC)/*.c) $(shell ls ../lib/*.c) $(shell ls ../lib/avr-hw-i2c/*.c) $(shell ls ./*.c)
  24. OBJ = $(SRC:.c=.o)
  25. main.hex: main.elf
  26. $(OBJCPY) -O ihex -R .eeprom -R .fuse -R .lock -R .signature main.elf main.hex
  27. main.elf: $(OBJ)
  28. $(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) -o $@
  29. size: main.elf
  30. $(SIZE) --mcu=$(MCU) --format=avr main.elf
  31. clean:
  32. rm -f $(OBJ) main.elf main.hex
  33. # Example for Arduino Duemilanove
  34. upload: main.hex
  35. $(AVRDUDE) -p$(MCU) -carduino -P$(PORT) -b57600 -D -Uflash:w:main.hex:i