Advertisement
igagis

Untitled

Jan 27th, 2019
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 1.23 KB | None | 0 0
  1. include prorab.mk
  2.  
  3. this_cc := avr-gcc
  4. this_cxx := avr-g++
  5.  
  6. this_name := binaryname
  7.  
  8. #pick all .c and .cpp files from '.' directory, i.e. same dir where makefile resides
  9. this_srcs := $(call prorab-src-dir, .)
  10.  
  11. this_mcu := atmega8a
  12.  
  13. #compiler flags
  14. this_cxxflags += -Wall
  15. this_cxxflags += -Werror
  16. this_cxxflags += -g
  17. this_cxxflags += -mmcu=$(this_mcu)
  18. this_cxxflags += -std=c++11
  19. this_cxxflags += -O3
  20.  
  21. #atmega frequency
  22. this_cpuFreq := 1000000
  23.  
  24. #add F_CPU macro definition
  25. this_cxxflags += -DF_CPU=$(this_cpuFreq)
  26.  
  27. # need to pass correct MCU to linker as well
  28. this_ldflags += -mmcu=$(this_mcu)
  29.  
  30. #this string actually generates all build rules for the binary
  31. $(eval $(prorab-build-app))
  32.  
  33. #here we define additional rules for genearing .hex file and flashing with avrdude
  34. define this_rules :=
  35.  
  36.     $(prorab_this_name).hex: $(prorab_this_name)
  37.     @echo "Generating .hex file..."
  38.     $(prorab_echo)avr-objcopy -j .text -j .data -O ihex $$^ $$@
  39.  
  40.     all: $(prorab_this_name).hex
  41.  
  42.     clean::
  43.     $(prorab_echo)rm -f $(prorab_this_name).hex
  44.  
  45.     .PHONY: flash
  46.  
  47.     flash:: $(prorab_this_name).hex
  48.     @echo "flashing..."
  49.     $(prorab_echo)avrdude -c usbasp -p m8 -U flash:w:$(prorab_this_name).hex:i
  50.  
  51. endef
  52. $(eval $(this_rules))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement