Index

auto-plow / fbe2680

A wheelchair motor-propelled battery-powered ESP32-driven remote control snow plow.

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
4213 Jan 2019 17:17f9654fbMove main program from C to C++joshuas3179N

Blob @ auto-plow / Makefile

text/plain2644 bytesdownload raw
1# Driver settings
2CXX = g++ --std=c++17
3CXXFLAGS = -Wall -Wextra -pedantic -Os
4SOURCES = $(shell find src/rpi -name '*.cpp')
5OBJECTS = $(SOURCES:%.cpp=%.o)
6OUT = autoplow
7
8.PHONY: all ard1-build clean
9
10all: $(OUT)
11
12$(OUT): $(OBJECTS)
13 $(CXX) $(CXXFLAGS) $^ -o $@
14
15%.o: %.cpp
16 $(CXX) -c $(CXXFLAGS) $^ -o $@
17
18
19# Arduino settings
20F_CPU = 16000000L
21MCU = atmega328p
22
23ARDUINO_CC = avr-gcc
24ARDUINO_CXX = avr-g++
25ARDUINO_AVRDUDE = avrdude
26ARDUINO_OBJCOPY = avr-objcopy
27
28ARDUINO_FLAGS = -c -w -Os -MMD -ffunction-sections -fdata-sections -DF_CPU=$(F_CPU) -DUSB_VID=null -DUSB_PID=null -DARDUINO=106 -mmcu=$(MCU)
29ARDUINO_CFLAGS = $(ARDUINO_FLAGS)
30ARDUINO_CXXFLAGS = $(ARDUINO_FLAGS) -fno-exceptions
31
32ARDUINO_AVRDUDE_CONF = "include/arduino/avrdude.conf"
33ARDUINO_INCLUDE = "include/arduino/"
34
35ARDUINO_CORE_CXX_SRC = $(shell find include/arduino -name '*.cpp')
36ARDUINO_CORE_C_SRC = $(shell find include/arduino -name '*.c')
37ARDUINO_CORE_ASM_SRC = $(shell find include/arduino -name '*.S')
38
39ARD1_SOURCES = $(shell find src/ard1 -name '*.cpp')
40
41ARDUINO_CORE_C = $(ARDUINO_CORE_C_SRC:%.c=%.ard)
42ARDUINO_CORE_CXX = $(ARDUINO_CORE_CXX_SRC:%.cpp=%.ard)
43ARDUINO_CORE_ASM = $(ARDUINO_CORE_ASM_SRC:%.S=%.ard)
44
45ARD1_OBJECTS = $(ARD1_SOURCES:%.cpp=%.ard)
46
47ARD1_OUT = bin/ard1.hex
48
49
50ard1-build: $(ARD1_OUT)
51
52%.ard: %.c
53 @echo
54 @echo Compiling Arduino C file: $< to $@
55 $(ARDUINO_CC) $(ARDUINO_CFLAGS) -I $(ARDUINO_INCLUDE) $< -o $@
56
57%.ard: %.cpp
58 @echo
59 @echo Compiling Arduino C++ file: $< to $@
60 $(ARDUINO_CXX) $(ARDUINO_CXXFLAGS) -I $(ARDUINO_INCLUDE) $< -o $@
61
62%.ard: %.S
63 @echo
64 @echo Compiling Arduino Assembly file: $< to $@
65 $(ARDUINO_CC) $(ARDUINO_CFLAGS) -I $(ARDUINO_INCLUDE) $< -o $@
66
67
68$(ARD1_OUT): $(ARD1_OBJECTS) $(ARDUINO_CORE_CXX) $(ARDUINO_CORE_C) $(ARDUINO_CORE_ASM)
69 @echo
70 @echo
71 @echo
72 @echo
73 @echo
74 @echo Compiling Arduino objects to $(MCU) hex
75 mkdir -p bin/
76 $(ARDUINO_CC) -Os -Wl,-Map,bin/main.map -mmcu=$(MCU) $(ARD1_OBJECTS) $(ARDUINO_CORE_CXX) $(ARDUINO_CORE_C) $(ARDUINO_CORE_ASM) -o bin/main.elf
77 $(ARDUINO_OBJCOPY) -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 bin/main.elf bin/main.eep
78 $(ARDUINO_OBJCOPY) -O ihex -R .eeprom bin/main.elf $@
79 @echo
80 @echo
81 @echo
82 @echo
83 @echo
84 @echo Uploading $(ARD1_OUT) to /dev/ttyACM0
85 $(ARDUINO_AVRDUDE) -C$(ARDUINO_AVRDUDE_CONF) -p$(MCU) -carduino -P/dev/ttyACM0 -b115200 -D -Uflash:w:$(ARD1_OUT):i
86
87clean:
88 rm -rf include/*.o
89 rm -rf include/*.d
90 rm -rf src/rpi/*.o
91 rm -rf src/rpi/*.d
92 rm -rf src/ard1/*.ard
93 rm -rf src/ard1/*.d
94 rm -rf bin/*.hex
95 rm -rf bin/*.eep
96 rm -rf bin/*.elf
97 rm -rf bin/*.map
98 rm -f autoplow
99 rm -rf bin/
100