############################################################################### # Makefile for the project EVBs_061114 ############################################################################### ## General Flags PROJECT = EVB_W5100_DNS MCU = atmega128 TARGET = $(PROJECT)_direct_mode.elf #TARGET = $(PROJECT)_indirect_mode.elf #TARGET = $(PROJECT)_spi_mode.elf CC = avr-gcc.exe ## Options common to compile, link and assembly rules COMMON = -mmcu=$(MCU) ## Compile options common for all C compilation units. CFLAGS = $(COMMON) CFLAGS += -Wall -gdwarf-2 -O0 -fsigned-char CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d -D__COMPILER_VERSION__=2 INCLUDES = -I../mcu -I../iinchip -I../main -I../inet -I../util ## Assembly specific flags ASMFLAGS = $(COMMON) ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2 ## Linker flags LDFLAGS = $(COMMON) LDFLAGS += ## Intel Hex file production flags HEX_FLASH_FLAGS = -R .eeprom HEX_EEPROM_FLAGS = -j .eeprom HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load" HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 ## Objects that must be built in order to link OBJECTS = md5.o socket.o w5100.o main.o delay.o serial.o mcu.o dns.o sockutil.o util.o ## Objects explicitly added by the user LINKONLYOBJECTS = ## Build all: $(TARGET) $(PROJECT)_direct_mode.hex $(PROJECT)_direct_mode.eep size #all: $(TARGET) $(PROJECT)_indirect_mode.hex $(PROJECT)_indirect_mode.eep size #all: $(TARGET) $(PROJECT)_spi_mode.hex $(PROJECT)_spi_mode.eep size ## Compile delay.o: ../mcu/delay.c $(CC) $(INCLUDES) $(CFLAGS) -c $< mcu.o: ../mcu/mcu.c $(CC) $(INCLUDES) $(CFLAGS) -c $< serial.o: ../mcu/serial.c $(CC) $(INCLUDES) $(CFLAGS) -c $< #timer.o: ../mcu/timer.c # $(CC) $(INCLUDES) $(CFLAGS) -c $< main.o: ../main/main.c $(CC) $(INCLUDES) $(CFLAGS) -c $< md5.o: ../iinchip/md5.c $(CC) $(INCLUDES) $(CFLAGS) -c $< socket.o: ../iinchip/socket.c $(CC) $(INCLUDES) $(CFLAGS) -c $< w5100.o: ../iinchip/w5100.c $(CC) $(INCLUDES) $(CFLAGS) -c $< dns.o: ../inet/dns.c $(CC) $(INCLUDES) $(CFLAGS) -c $< sockutil.o: ../util/sockutil.c $(CC) $(INCLUDES) $(CFLAGS) -c $< util.o: ../util/util.c $(CC) $(INCLUDES) $(CFLAGS) -c $< ##Link $(TARGET): $(OBJECTS) $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET) %.hex: $(TARGET) avr-objcopy -O ihex $(HEX_FLASH_FLAGS) $< $@ %.eep: $(TARGET) avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ %.lss: $(TARGET) avr-objdump -h -S $< > $@ size: ${TARGET} @echo @avr-size -C --mcu=${MCU} ${TARGET} ## Clean target .PHONY: clean clean: -rm -rf $(OBJECTS) dep/* -rm -f $(PROJECT)_direct_mode.elf $(PROJECT)_direct_mode.hex $(PROJECT)_direct_mode.eep -rm -f $(PROJECT)_indirect_mode.elf $(PROJECT)_indirect_mode.hex $(PROJECT)_indirect_mode.eep -rm -f $(PROJECT)_spi_mode.elf $(PROJECT)_spi_mode.hex $(PROJECT)_spi_mode.eep ## Other dependencies -include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)