1 | # Raspberry Pi settings |
2 | CC = gcc --std=c11 |
3 | CCFLAGS = -Wall -Wextra -pedantic -O3 -g |
4 | SOURCES = $(shell find src/rpi -name '*.c') |
5 | OBJECTS = $(SOURCES:%.c=%.o) |
6 | OUT = autoplow |
7 |
|
8 |
|
9 | # Arduino Settings |
10 | F_CPU = 16000000L |
11 | MCU = atmega328p |
12 | ARDUINO_CC = avr-gcc |
13 | ARDUINO_CXX = avr-g++ |
14 | ARDUINO_AR = avr-ar |
15 | OBJ_COPY = avr-objcopy |
16 | ARDUINO_FLAGS = -c -g -Os -Wall -Wextra -pedantic -MMD -ffunction-sections -fdata-sections -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DUSB_VID=null -DUSB_PID=null -DARDUINO=106 |
17 | ARDUINO_CC_FLAGS = $(ARDUINO_FLAGS) |
18 | ARDUINO_CXX_FLAGS = $(ARDUINO_FLAGS) -fno-exceptions |
19 | ARDUINO_INCLUDE = "include/arduino/" |
20 | ARD1_SOURCES = $(shell find src/ard1 -name '*.cpp') |
21 | ARD1_OUT = bin/ard1.hex |
22 | # ARD2_SOURCES = $(shell find src/ard2 -name '*.cpp') |
23 |
|
24 |
|
25 | .PHONY: all ard1-build ard1-upload |
26 |
|
27 | all: $(OUT) $(OBJECTS) |
28 |
|
29 | $(OUT): $(OBJECTS) |
30 | $(CC) $(CCFLAGS) $(OBJECTS) -o $(OUT) |
31 |
|
32 | ard1-build: $(ARD1_OUT) $(ARD1_SOURCES) |
33 |
|
34 | $(ARD1_OUT): $(ARD1_SOURCES) |
35 | $(ARDUINO_CXX) $(ARDUINO_CXX_FLAGS) -I$(ARDUINO_INCLUDE) $(ARD1_SOURCES) -o $(ARD1_SOURCES:%.cpp=%.o) |
36 | $(ARDUINO_CXX) $(ARDUINO_CXX_FLAGS) -I$(ARDUINO_INCLUDE) ${ARDUINO_INCLUDE}abi.cpp -o $(ARDUINO_INCLUDE)abi.o |
37 | $(ARDUINO_CXX) $(ARDUINO_CXX_FLAGS) -I$(ARDUINO_INCLUDE) ${ARDUINO_INCLUDE}CDC.cpp -o $(ARDUINO_INCLUDE)CDC.o |
38 | $(ARDUINO_CXX) $(ARDUINO_CXX_FLAGS) -I$(ARDUINO_INCLUDE) ${ARDUINO_INCLUDE}HardwareSerial.cpp -o $(ARDUINO_INCLUDE)HardwareSerial.o |
39 | $(ARDUINO_CXX) $(ARDUINO_CXX_FLAGS) -I$(ARDUINO_INCLUDE) ${ARDUINO_INCLUDE}HardwareSerial0.cpp -o $(ARDUINO_INCLUDE)HardwareSerial0.o |
40 | $(ARDUINO_CXX) $(ARDUINO_CXX_FLAGS) -I$(ARDUINO_INCLUDE) ${ARDUINO_INCLUDE}HardwareSerial1.cpp -o $(ARDUINO_INCLUDE)HardwareSerial1.o |
41 | $(ARDUINO_CXX) $(ARDUINO_CXX_FLAGS) -I$(ARDUINO_INCLUDE) ${ARDUINO_INCLUDE}HardwareSerial2.cpp -o $(ARDUINO_INCLUDE)HardwareSerial2.o |
42 | $(ARDUINO_CXX) $(ARDUINO_CXX_FLAGS) -I$(ARDUINO_INCLUDE) ${ARDUINO_INCLUDE}HardwareSerial3.cpp -o $(ARDUINO_INCLUDE)HardwareSerial3.o |
43 | $(ARDUINO_CXX) $(ARDUINO_CXX_FLAGS) -I$(ARDUINO_INCLUDE) ${ARDUINO_INCLUDE}IPAddress.cpp -o $(ARDUINO_INCLUDE)IPAddress.o |
44 | $(ARDUINO_CXX) $(ARDUINO_CXX_FLAGS) -I$(ARDUINO_INCLUDE) ${ARDUINO_INCLUDE}main.cpp -o $(ARDUINO_INCLUDE)main.o |
45 | $(ARDUINO_CXX) $(ARDUINO_CXX_FLAGS) -I$(ARDUINO_INCLUDE) ${ARDUINO_INCLUDE}new.cpp -o $(ARDUINO_INCLUDE)new.o |
46 | $(ARDUINO_CXX) $(ARDUINO_CXX_FLAGS) -I$(ARDUINO_INCLUDE) ${ARDUINO_INCLUDE}PluggableUSB.cpp -o $(ARDUINO_INCLUDE)PluggableUSB.o |
47 | $(ARDUINO_CXX) $(ARDUINO_CXX_FLAGS) -I$(ARDUINO_INCLUDE) ${ARDUINO_INCLUDE}Print.cpp -o $(ARDUINO_INCLUDE)Print.o |
48 | $(ARDUINO_CXX) $(ARDUINO_CXX_FLAGS) -I$(ARDUINO_INCLUDE) ${ARDUINO_INCLUDE}Stream.cpp -o $(ARDUINO_INCLUDE)Stream.o |
49 | $(ARDUINO_CXX) $(ARDUINO_CXX_FLAGS) -I$(ARDUINO_INCLUDE) ${ARDUINO_INCLUDE}Tone.cpp -o $(ARDUINO_INCLUDE)Tone.o |
50 | $(ARDUINO_CXX) $(ARDUINO_CXX_FLAGS) -I$(ARDUINO_INCLUDE) ${ARDUINO_INCLUDE}USBCore.cpp -o $(ARDUINO_INCLUDE)USBCore.o |
51 | $(ARDUINO_CXX) $(ARDUINO_CXX_FLAGS) -I$(ARDUINO_INCLUDE) ${ARDUINO_INCLUDE}WMath.cpp -o $(ARDUINO_INCLUDE)WMath.o |
52 | $(ARDUINO_CXX) $(ARDUINO_CXX_FLAGS) -I$(ARDUINO_INCLUDE) ${ARDUINO_INCLUDE}WString.cpp -o $(ARDUINO_INCLUDE)WString.o |
53 | $(ARDUINO_CC) $(ARDUINO_CC_FLAGS) -I$(ARDUINO_INCLUDE) ${ARDUINO_INCLUDE}hooks.c -o $(ARDUINO_INCLUDE)hooks.o |
54 | $(ARDUINO_CC) $(ARDUINO_CC_FLAGS) -I$(ARDUINO_INCLUDE) ${ARDUINO_INCLUDE}WInterrupts.c -o $(ARDUINO_INCLUDE)WInterrupts.o |
55 | $(ARDUINO_CC) $(ARDUINO_CC_FLAGS) -I$(ARDUINO_INCLUDE) ${ARDUINO_INCLUDE}wiring.c -o $(ARDUINO_INCLUDE)wiring.o |
56 | $(ARDUINO_CC) $(ARDUINO_CC_FLAGS) -I$(ARDUINO_INCLUDE) ${ARDUINO_INCLUDE}wiring_analog.c -o $(ARDUINO_INCLUDE)wiring_analog.o |
57 | $(ARDUINO_CC) $(ARDUINO_CC_FLAGS) -I$(ARDUINO_INCLUDE) ${ARDUINO_INCLUDE}wiring_digital.c -o $(ARDUINO_INCLUDE)wiring_digital.o |
58 | $(ARDUINO_CC) $(ARDUINO_CC_FLAGS) -I$(ARDUINO_INCLUDE) ${ARDUINO_INCLUDE}wiring_pulse.c -o $(ARDUINO_INCLUDE)wiring_pulse.o |
59 | $(ARDUINO_CC) $(ARDUINO_CC_FLAGS) -I$(ARDUINO_INCLUDE) ${ARDUINO_INCLUDE}wiring_shift.c -o $(ARDUINO_INCLUDE)wiring_shift.o |
60 | $(AR) rcs core.a WInterrupts.c.o |
61 | $(AR) rcs core.a wiring.c.o |
62 | $(AR) rcs core.a wiring_analog.c.o |
63 | $(AR) rcs core.a wiring_digital.c.o |
64 | $(AR) rcs core.a wiring_pulse.c.o |
65 | $(AR) rcs core.a wiring_shift.c.o |
66 | $(AR) rcs core.a CDC.cpp.o |
67 | $(AR) rcs core.a HardwareSerial.cpp.o |
68 | $(AR) rcs core.a HID.cpp.o |
69 | $(AR) rcs core.a IPAddress.cpp.o |
70 | $(AR) rcs core.a main.cpp.o |
71 | $(AR) rcs core.a new.cpp.o |
72 | $(AR) rcs core.a Print.cpp.o |
73 | $(AR) rcs core.a Stream.cpp.o |
74 | $(AR) rcs core.a Tone.cpp.o |
75 | $(AR) rcs core.a USBCore.cpp.o |
76 | $(AR) rcs core.a WMath.cpp.o |
77 | $(AR) rcs core.a WString.cpp.o |
78 | $(ARDUINO_CC) -Os -Wl,--gc-sections -mmcu=$(MCU) -o $(ARD1_SOURCES).elf $(ARD1_SOURCES).o core.a -lm |
79 | $(OBJ_COPY) -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 $(ARD1_SOURCES).elf $(ARD1_SOURCES).eep |
80 | $(OBJ_COPY) -O ihex -R .eeprom $(ARD1_SOURCES).elf $(ARD1_OUT).hex |
81 |
|