Index

auto-plow / 31a2245

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

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
3502 Dec 2018 23:1731a2245Update Makefilejoshuas3122N

Blob @ auto-plow / Makefile

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