Ein Roboter mit bürstenlosem Antrieb, differenzial und NRF24L01 Funk. Großflächig gebaut um ein großes Solarpanel aufzunehmen. https://gitlab.informatik.hs-fulda.de/fdai5253/roboter
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

300 lines
6.3 KiB

  1. PROJECT_NAME = $(PWD:B) ;
  2. PROJECT_DIR = . ;
  3. PROJECT_LIBS = RF24 ;
  4. OUT_DIR = ojam ;
  5. F_CPU = 16000000 ;
  6. MCU = atmega328p ;
  7. PORTS = /dev/tty.usbserial-A600eHIs /dev/tty.usbserial-A40081RP /dev/tty.usbserial-A9007LmI ;
  8. UPLOAD_RATE = 57600 ;
  9. AVRDUDE_PROTOCOL = stk500v1 ;
  10. COM = 33 ;
  11. # Host-specific overrides for locations
  12. if $(OS) = MACOSX
  13. {
  14. ARDUINO_VERSION = 22 ;
  15. OLD_DIR = /opt/arduino-0021 ;
  16. AVR_TOOLS_PATH = $(OLD_DIR)/hardware/tools/avr/bin ;
  17. AVRDUDECONFIG_PATH = $(OLD_DIR)/hardware/tools/avr/etc ;
  18. ARDUINO_DIR = /opt/Arduino ;
  19. ARDUINO_AVR = /usr/lib/avr/include ;
  20. }
  21. # Where is everything?
  22. ARDUINO_VERSION ?= 22 ;
  23. SKETCH_DIR = $(HOME)/Source/Arduino ;
  24. AVR_TOOLS_PATH ?= /usr/bin ;
  25. ARDUINO_DIR ?= /opt/arduino-00$(ARDUINO_VERSION) ;
  26. ARDUINO_AVR ?= $(ARDUINO_DIR)/hardware/tools/avr/avr/include/avr ;
  27. AVRDUDECONFIG_PATH ?= $(ARDUINO_DIR)/hardware/tools ;
  28. ARDUINO_CORE = $(ARDUINO_DIR)/hardware/arduino/cores/arduino ;
  29. ARDUINO_LIB = $(ARDUINO_DIR)/libraries ;
  30. SKETCH_LIB = $(SKETCH_DIR)/libraries ;
  31. AVR_AS = $(AVR_TOOLS_PATH)/avr-as ;
  32. AVR_CC = $(AVR_TOOLS_PATH)/avr-gcc ;
  33. AVR_CXX = $(AVR_TOOLS_PATH)/avr-g++ ;
  34. AVR_LD = $(AVR_TOOLS_PATH)/avr-gcc ;
  35. AVR_OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy ;
  36. AVRDUDE = $(AVR_TOOLS_PATH)/avrdude ;
  37. DEFINES = F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) VERSION_H HAL=1 ;
  38. CTUNING = -ffunction-sections -fdata-sections ;
  39. CXXTUNING = -fno-exceptions -fno-strict-aliasing ;
  40. ASFLAGS = -mmcu=$(MCU) ;
  41. CFLAGS = -Os -Wall -Wextra $(ASFLAGS) $(CTUNING) ;
  42. CXXFLAGS = $(CFLAGS) $(CXXTUNING) ;
  43. LDFLAGS = -Os -lm -Wl,--gc-sections -mmcu=atmega328p ;
  44. # Search everywhere for headers
  45. HDRS = $(PROJECT_DIR) $(ARDUINO_AVR) $(ARDUINO_CORE) [ GLOB $(ARDUINO_LIB) $(SKETCH_LIB) : [^.]* ] ;
  46. HDRS += [ GLOB $(HDRS) : utility ] ;
  47. # Grab everything from the core directory
  48. CORE_MODULES = [ GLOB $(ARDUINO_CORE) : *.c *.cpp ] ;
  49. # Grab everything from libraries. To avoid this "grab everything" behaviour, you
  50. # can specify specific modules to pick up in PROJECT_MODULES
  51. LIB_MODULES = [ GLOB $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) : *.cpp *.c ] ;
  52. # In addition to explicitly-specified program modules, pick up anything from the current
  53. # dir.
  54. PROJECT_MODULES += [ GLOB $(PROJECT_DIR) : *.c *.cpp *.pde ] ;
  55. # Shortcut for the out files
  56. OUT = $(OUT_DIR)/$(PROJECT_NAME) ;
  57. # AvrDude setup
  58. AVRDUDE_FLAGS = -V -F -D -C $(AVRDUDECONFIG_PATH)/avrdude.conf -p $(MCU) -c $(AVRDUDE_PROTOCOL) -b $(UPLOAD_RATE) ;
  59. rule GitVersion
  60. {
  61. Always $(<) ;
  62. Depends all : $(<) ;
  63. }
  64. actions GitVersion
  65. {
  66. echo "const char program_version[] = \"\\" > $(<)
  67. git log -1 --pretty=format:%h >> $(<)
  68. echo "\";" >> $(<)
  69. }
  70. # GitVersion version.h ;
  71. rule AvrAsm
  72. {
  73. Depends $(<) : $(>) ;
  74. Depends $(<) : $(<:D) ;
  75. Clean clean : $(<) ;
  76. CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
  77. CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
  78. }
  79. actions AvrAsm
  80. {
  81. $(AVR_AS) $(ASFLAGS) -o $(<) $(>)
  82. }
  83. rule AvrCc
  84. {
  85. Depends $(<) : $(>) ;
  86. Depends $(<) : $(<:D) ;
  87. Clean clean : $(<) ;
  88. CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
  89. CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
  90. }
  91. actions AvrCc
  92. {
  93. $(AVR_CC) -c -o $(<) $(CCHDRS) $(CCDEFS) $(CFLAGS) $(>)
  94. }
  95. rule AvrC++
  96. {
  97. Depends $(<) : $(>) ;
  98. Depends $(<) : $(<:D) ;
  99. Clean clean : $(<) ;
  100. CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
  101. CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
  102. }
  103. actions AvrC++
  104. {
  105. $(AVR_CXX) -c -o $(<) $(CCHDRS) $(CCDEFS) $(CXXFLAGS) $(>)
  106. }
  107. rule AvrAsmFromC++
  108. {
  109. Depends $(<) : $(>) ;
  110. Depends $(<) : $(<:D) ;
  111. Clean clean : $(<) ;
  112. CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
  113. CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
  114. }
  115. actions AvrAsmFromC++
  116. {
  117. $(AVR_CXX) -S -fverbose-asm -o $(<) $(CCHDRS) $(CCDEFS) $(CXXFLAGS) $(>)
  118. }
  119. rule Pde
  120. {
  121. Depends $(<) : $(>) ;
  122. Depends $(<) : $(<:D) ;
  123. Clean clean : $(<) ;
  124. }
  125. actions Pde
  126. {
  127. echo "#include <WProgram.h>" > $(<)
  128. echo "#line 1 \"$(>)\"" >> $(<)
  129. cat $(>) >> $(<)
  130. }
  131. rule AvrPde
  132. {
  133. local _CPP = $(OUT_DIR)/$(_I:B).cpp ;
  134. Pde $(_CPP) : $(>) ;
  135. AvrC++ $(<) : $(_CPP) ;
  136. }
  137. rule AvrObject
  138. {
  139. switch $(>:S)
  140. {
  141. case .S : AvrAsm $(<) : $(>) ;
  142. case .c : AvrCc $(<) : $(>) ;
  143. case .cpp : AvrC++ $(<) : $(>) ;
  144. case .pde : AvrPde $(<) : $(>) ;
  145. }
  146. }
  147. rule AvrObjects
  148. {
  149. for _I in $(<)
  150. {
  151. AvrObject $(OUT_DIR)/$(_I:B).o : $(_I) ;
  152. }
  153. }
  154. rule AvrMainFromObjects
  155. {
  156. Depends $(<) : $(>) ;
  157. Depends $(<) : $(<:D) ;
  158. MkDir $(<:D) ;
  159. Depends all : $(<) ;
  160. Clean clean : $(<) ;
  161. }
  162. actions AvrMainFromObjects
  163. {
  164. $(AVR_LD) $(LDFLAGS) -o $(<) $(>)
  165. }
  166. rule AvrMain
  167. {
  168. AvrMainFromObjects $(<) : $(OUT_DIR)/$(>:B).o ;
  169. AvrObjects $(>) ;
  170. }
  171. rule AvrHex
  172. {
  173. Depends $(<) : $(>) ;
  174. Depends $(<) : $(<:D) ;
  175. Depends hex : $(<) ;
  176. Clean clean : $(<) ;
  177. }
  178. actions AvrHex
  179. {
  180. $(AVR_OBJCOPY) -O ihex -R .eeprom $(>) $(<)
  181. }
  182. rule AvrUpload
  183. {
  184. Depends $(1) : $(2) ;
  185. Depends $(2) : $(3) ;
  186. NotFile $(1) ;
  187. Always $(1) ;
  188. Always $(2) ;
  189. AvrUploadAction $(2) : $(3) ;
  190. }
  191. actions AvrUploadAction
  192. {
  193. $(AVRDUDE) $(AVRDUDE_FLAGS) -P $(<) $(AVRDUDE_WRITE_FLASH) -U flash:w:$(>):i
  194. }
  195. AvrMain $(OUT).elf : $(CORE_MODULES) $(LIB_MODULES) $(PROJECT_MODULES)
  196. AvrHex $(OUT).hex : $(OUT).elf ;
  197. AvrUpload p6 : /dev/tty.usbserial-A600eHIs : $(OUT).hex ;
  198. AvrUpload p4 : /dev/tty.usbserial-A40081RP : $(OUT).hex ;
  199. AvrUpload p9 : /dev/tty.usbserial-A9007LmI : $(OUT).hex ;
  200. #
  201. # Native
  202. #
  203. OUT_DIR_NATIVE = out_native ;
  204. OUT_NATIVE = $(OUT_DIR_NATIVE)/$(PROJECT_NAME) ;
  205. NATIVE_CORE = $(SKETCH_DIR)/hardware/native ;
  206. HDRS = $(NATIVE_CORE) $(HDRS) ;
  207. NATIVE_CORE_MODULES = [ GLOB $(NATIVE_CORE) : *.c *.cpp ] ;
  208. NATIVE_MODULES = ;
  209. DEFINES += NATIVE ;
  210. rule NativePde
  211. {
  212. local _CPP = $(OUT_DIR_NATIVE)/$(_I:B).cpp ;
  213. Pde $(_CPP) : $(>) ;
  214. C++ $(<) : $(_CPP) ;
  215. }
  216. rule UserObject
  217. {
  218. switch $(>)
  219. {
  220. case *.pde : NativePde $(<) : $(>) ;
  221. }
  222. }
  223. rule Objects
  224. {
  225. for _I in $(<)
  226. {
  227. local _O = $(OUT_DIR_NATIVE)/$(_I:B).o ;
  228. Object $(_O) : $(_I) ;
  229. }
  230. }
  231. rule Main
  232. {
  233. MainFromObjects $(<) : $(OUT_DIR_NATIVE)/$(>:B).o ;
  234. Objects $(>) ;
  235. }
  236. actions C++
  237. {
  238. c++ -c -o $(<) $(CCHDRS) $(CCDEFS) $(>)
  239. }
  240. actions Link
  241. {
  242. c++ -o $(<) $(>)
  243. }
  244. MkDir $(OUT_DIR_NATIVE) ;
  245. Depends $(OUT_NATIVE) : $(OUT_DIR_NATIVE) ;
  246. Main $(OUT_NATIVE) : $(NATIVE_CORE_MODULES) $(NATIVE_MODULES) $(LIB_MODULES) $(PROJECT_MODULES) ;
  247. Depends native : $(OUT_NATIVE) ;