# AvrX 2.5 GCC Examples makefile # Larry Barello May, 2000 # # Uses GCC tools (make, rm) # # Generic stuff. # DEBUG = --debug RM = rm -f # # MCU - What a mess. IAR uses different mechanisms for C and ASM # and buggers the identifier for the mega parts so the GCCMCU will break # with mega parts. The AVRXMCU goes away when IAR updates their tools for # unified IO headers (ioavr.h) NB: IAR Also needs the linker files changed too. # # MCU = 8515, 8535, mega103, mega163, etc (C compiler input) # AAVRMCU = 0, 1, 2, ... # GCCMCU = at90s8535, atmega103, etc # AVRXMCU = (see define) - matches what ICCAVR will pass in the future... # MCU = 8515 MCU = atmega32 AAVRMCU = 1 GCCMCU = atmega32 AVRXMCU = __AT90S$(MCU)__ # MCU = m103 # AAVRMCU = 3 # GCCMCU = atmega103 # AVRXMCU = __AT90Mega103 # MCU = m128 # AAVRMCU = 5 # GCCMCU = atmega128 # AVRXMCU = __AT90Mega128 #GCC Equates FORMAT = ihex GCCLIB = ../avrx/avrx.a GCCINC = -I. -I../avrx -I$(AVR)/avr/inc LDFLAGS = -Wl,-Map=$(<:.o=.map),--cref,-v AFLAGS = -c -mmcu=$(GCCMCU) -Wa,-gstabs -mmcu=$(GCCMCU) -I$(GCCINC) CFLAGS = -Os -Wall -mmcu=$(GCCMCU) -g BIN = avr-objcopy CC = avr-gcc AS = avr-gcc -x assembler-with-cpp ELFCOF = elfcoff CP = cp OUT = coff #IAR Equates IARLIB = ../avrx/avrx.r90 $(IAR)/avr/lib/dl1s.r90 IARINC = -I. -I../avrx -I$(IAR)/avr/inc AAVRFLAGS = -v1 -b -re -D$(AVRXMCU) XLINKFLAGS = -f lnk8535s -x -z -FINTEL-STANDARD -l $(@:.d90=.map) -o $(@:.d90=.hex) -Oubrof6=.d90 ICCFLAGS = --cpu=$(MCU) --debug -e -z9 -ms -D$(AVRXMCU) -la $(@:.r90=.lst) ICC = iccavr AAVR = aavr XLINK = xlink SRC = Timers.c Messages.c MessagesAndData.c MessageTimers.c MessageTimersAlt.c # IAR Rules (Need more rules to make EEPROM files) %r90: %s $(AAVR) $< $(IARINC) $(AAVRFLAGS) %r90: %c $(ICC) $< $(IARINC) $(ICCFLAGS) -la $(@:.r90=.lst) -o $@ %d90: %r90 $(XLINK) $< $(IARLIB) $(XLINKFLAGS) # GCC Rules %o: %c $(CC) -c $< $(GCCINC) $(CFLAGS) -o $@ %s: %c $(CC) -S $< $(GCCINC) $(CFLAGS) -o $@ %o: %s $(AS) $(AFLAGS) $< -o $@ %elf: %o $(CC) $< $(GCCLIB) $(LDFLAGS) -mmcu=$(GCCMCU) -o $@ #%obj: %elf # $(BIN) -O avrobj $< $@ %hex: %elf $(BIN) -O $(FORMAT) $< $@ %eep: %elf $(BIN) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ %.cof: %.elf $(ELFCOF) $< $(OUT) $@ $*.sym $(CP) $(OUT)\$@ . $(CP) $(OUT)\\*sym . # $(CP) $(OUT)\\*S . all: iar gcc iar: $(SRC:.c=.d90) #gcc: $(SRC:.c=.obj) $(SRC:.c=.hex) $(SRC:.c=.eep) $(SRC:.c=.cof) gcc: $(SRC:.c=.elf) $(SRC:.c=.hex) $(SRC:.c=.eep) clean: $(RM) $(SRC:.c=.d90) $(SRC:.c=.s) $(SRC:.c=.elf) $(SRC:.c=.r90) $(SRC:.c=.o) $(SRC:.c=.lst) $(SRC:.c=.sym) $(RM) $(SRC:.c=.hex) $(SRC:.c=.eep) $(SRC:.c=.hex) $(SRC:.c=.map) $(SRC:.c=.c_sym) $(SRC:.c=.obj) # depends section Messages.o: Messages.c hardware.h makefile MessagesAndData.o: MessagesAndData.c hardware.h makefile MessageTimers.o: MessageTimers.c hardware.h makefile MessageTimersAlt.o: MessageTimersAlt.c hardware.h makefile Timers.o: hardware.h makefile Timers.c Messages.r90: Messages.c hardware.h makefile MessagesAndData.r90: MessagesAndData.c hardware.h makefile MessageTimers.r90: MessageTimers.c hardware.h makefile MessageTimersAlt.r90: MessageTimersAlt.c hardware.h makefile Timers.r90: hardware.h makefile Timers.c Messages.d90: Messages.r90 $(IARLIB) MessagesAndData.d90: MessagesAndData.r90 $(IARLIB) MessageTimers.d90: MessageTimers.r90 $(IARLIB) MessageTimersAlt.d90: MessageTimersAlt.r90 $(IARLIB) Timers.d90: Timers.r90 $(IARLIB) Messages.elf: Messages.o $(GCCLIB) MessagesAndData.elf: MessagesAndData.o $(GCCLIB) MessageTimers.elf: MessageTimers.o $(GCCLIB) MessageTimersAlt.elf: MessageTimersAlt.o $(GCCLIB) Timers.elf: Timers.o $(GCCLIB)