Index

auto-plow / 7c89af1

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

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
2001 Dec 2018 14:167c89af1Update MakefileJoshua122N

Blob @ auto-plow / Makefile

text/plain2401 bytesdownload raw
1# Raspberry Pi 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
9# Arduino Settings
10F_CPU = 16000000L
11MCU = atmega328p
12
13ARDUINO_CC = avr-gcc
14ARDUINO_CXX = avr-g++
15ARDUINO_AVRDUDE = avrdude
16ARDUINO_OBJCOPY = avr-objcopy
17
18ARDUINO_FLAGS = -c -w -Os -MMD -ffunction-sections -fdata-sections -DF_CPU=$(F_CPU) -DUSB_VID=null -DUSB_PID=null -DARDUINO=106 -mmcu=$(MCU)
19ARDUINO_CFLAGS = $(ARDUINO_FLAGS)
20ARDUINO_CXXFLAGS = $(ARDUINO_FLAGS) -fno-exceptions
21
22ARDUINO_AVRDUDE_CONF = "include/arduino/avrdude.conf"
23ARDUINO_INCLUDE = "include/arduino/"
24
25ARDUINO_CORE_CXX_SRC = $(shell find include/arduino -name '*.cpp')
26ARDUINO_CORE_C_SRC = $(shell find include/arduino -name '*.c')
27ARDUINO_CORE_ASM_SRC = $(shell find include/arduino -name '*.S')
28
29ARD1_SOURCES = $(shell find src/ard1 -name '*.cpp')
30
31ARDUINO_CORE_C = $(ARDUINO_CORE_C_SRC:%.c=%.o)
32ARDUINO_CORE_CXX = $(ARDUINO_CORE_CXX_SRC:%.cpp=%.o)
33ARDUINO_CORE_ASM = $(ARDUINO_CORE_ASM_SRC:%.S=%.o)
34
35ARD1_OBJECTS = $(ARD1_SOURCES:%.cpp=%.o)
36
37ARD1_OUT = bin/ard1.hex
38
39
40
41.PHONY: all ard1-build
42
43all: $(OUT) ard1-build
44
45$(OUT): $(OBJECTS)
46 $(CC) $(CFLAGS) $(OBJECTS) -o $(OUT)
47
48$(OBJECTS): $(SOURCES)
49 $(CC) -c $(CFLAGS) $(SOURCES)
50
51
52ard1-build: $(ARD1_OUT)
53
54%.o: %.c
55 @echo
56 @echo Compiling Arduino C file: $< to $@
57 $(ARDUINO_CC) $(ARDUINO_CFLAGS) -I $(ARDUINO_INCLUDE) $< -o $@
58
59%.o: %.cpp
60 @echo
61 @echo Compiling Arduino C++ file: $< to $@
62 $(ARDUINO_CXX) $(ARDUINO_CXXFLAGS) -I $(ARDUINO_INCLUDE) $< -o $@
63
64%.o: %.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 $(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
78 $(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
79 $(ARDUINO_OBJCOPY) -O ihex -R .eeprom bin/main.elf $@
80 @echo
81 @echo
82 @echo
83 @echo
84 @echo
85 @echo Uploading $(ARD1_OUT) to /dev/ttyACM0
86 $(ARDUINO_AVRDUDE) -C$(ARDUINO_AVRDUDE_CONF) -p$(MCU) -carduino -P/dev/ttyACM0 -b115200 -D -Uflash:w:$(ARD1_OUT):i
87