Skip to content

Instantly share code, notes, and snippets.

@rjha
Created December 26, 2015 20:53
Show Gist options
  • Save rjha/e7b123d3dc4346b5830c to your computer and use it in GitHub Desktop.
Save rjha/e7b123d3dc4346b5830c to your computer and use it in GitHub Desktop.
Arduino core and libraries inside AVR makefile target
wiznet: spi2
$(BIN)/avr-g++ $(CFLAGS) -I$(LIB)/arduino/SPI -I$(INC) -I$(LIB)/arduino/cores -I$(LIB)/arduino/variants/mega -I$(LIB)/wiznet $(LIB)/wiznet/w5100.cpp -o $(BUILD)/w5500.o -L$(BUILD)
$(BIN)/avr-g++ $(CFLAGS) -I$(INC) -I$(LIB)/arduino/cores -I$(LIB)/arduino/variants/mega -I$(LIB)/wiznet $(LIB)/wiznet/socket.cpp -o $(BUILD)/socket.o -L$(BUILD)
spi2:
$(BIN)/avr-g++ $(CFLAGS) -I$(LIB)/arduino/cores -I$(LIB)/arduino/variants/mega -I$(LIB)/arduino/SPI $(LIB)/arduino/SPI/SPI.cpp -o $(BUILD)/SPI.o -L$(LIB)/arduino/build -larduino
ethernet: wiznet
$(BIN)/avr-g++ $(CFLAGS) -I$(INC) -I$(LIB)/wiznet -I$(LIB)/arduino/cores -I$(LIB)/arduino/variants/mega -I$(LIB)/arduino/Ethernet $(LIB)/arduino/Ethernet/Dns.cpp -o $(BUILD)/Dns.o -L$(BUILD) -L$(LIB)/arduino/build -larduino
$(BIN)/avr-g++ $(CFLAGS) -I$(INC) -I$(LIB)/wiznet -I$(LIB)/arduino/cores -I$(LIB)/arduino/variants/mega -I$(LIB)/arduino/Ethernet $(LIB)/arduino/Ethernet/EthernetClient.cpp -o $(BUILD)/EthernetClient.o -L$(BUILD) -L$(LIB)/arduino/build -larduino
$(BIN)/avr-g++ $(CFLAGS) -I$(INC) -I$(LIB)/wiznet -I$(LIB)/arduino/cores -I$(LIB)/arduino/variants/mega -I$(LIB)/arduino/Ethernet $(LIB)/arduino/Ethernet/EthernetUdp.cpp -o $(BUILD)/EthernetUdp.o -L$(BUILD) -L$(LIB)/arduino/build -larduino
$(BIN)/avr-g++ $(CFLAGS) -I$(INC) -I$(LIB)/wiznet -I$(LIB)/arduino/cores -I$(LIB)/arduino/variants/mega -I$(LIB)/arduino/Ethernet $(LIB)/arduino/Ethernet/EthernetServer.cpp -o $(BUILD)/EthernetServer.o -L$(BUILD) -L$(LIB)/arduino/build -larduino
$(BIN)/avr-g++ $(CFLAGS) -I$(INC) -I$(LIB)/wiznet -I$(LIB)/arduino/cores -I$(LIB)/arduino/variants/mega -I$(LIB)/arduino/Ethernet $(LIB)/arduino/Ethernet/Dhcp.cpp -o $(BUILD)/Dhcp.o -L$(BUILD) -L$(LIB)/arduino/build -larduino
$(BIN)/avr-g++ $(CFLAGS) -I$(INC) -I$(LIB)/wiznet -I$(LIB)/arduino/cores -I$(LIB)/arduino/variants/mega -I$(LIB)/arduino/Ethernet $(LIB)/arduino/Ethernet/Ethernet.cpp -o $(BUILD)/Ethernet.o -L$(BUILD) -L$(LIB)/arduino/build -larduino
webclient: ethernet
$(BIN)/avr-g++ $(CFLAGS) -I$(INC) -I$(LIB)/wiznet -I$(LIB)/arduino/cores -I$(LIB)/arduino/variants/mega -I$(LIB)/arduino/Ethernet $(ROOT)/test/wiznet/webclient.cpp -o $(BUILD)/webclient.o -L$(BUILD) -L$(LIB)/arduino/build -larduino
hex:
$(BIN)/avr-g++ -Os -Wl,--gc-sections,--relax -mmcu=$(MCU) -o $(BUILD)/$(PROG).elf $(BUILD)/*.o -L$(BUILD) -lm -L$(LIB)/arduino/build -larduino
$(BIN)/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 $(BUILD)/$(PROG).elf $(BUILD)/$(PROG).eep
$(BIN)/avr-objcopy -O ihex -R .eeprom $(BUILD)/$(PROG).elf $(BUILD)/$(PROG).hex
$(BIN)/avr-size -C --mcu=$(MCU) $(BUILD)/$(PROG).elf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment