# GAS makefile for uRRC controller chip
#
# Larry Barello copyright 2001, 2002
#
# Source works with both 1200 & 2313
#
	MCU	= at90s1200
#	MCU	= at90s2313

# default build type

	BUILD = OSMC
#	BUILD = LMD18200

	PROG	= c:/progra~1/atmel/avrstu~1/stk500/stk500.exe
	LDFLAGS = -Map=$(<:.o=.map) --cref -v
	AFLAGS	= -c -D$(MCU) -D$(BUILD) -Wa,-gstabs,-v,-ahlms=$(<:.s=.lst)

	RM	= rm -f
	BIN	= avr-objcopy
	AS	= avr-gcc -x assembler-with-cpp
	LD	= avr-ld

	ASRC	= main.s
	OBJ	= $(SRC:.c=.o) $(ASRC:.s=.o)

%o: %s
	$(AS) $(AFLAGS) $< -o $@

%elf:   %o
	$(LD) $< $(LDFLAGS) -o $@

%obj: %elf
	$(BIN) -O avrobj $< $@

%hex: %elf
	$(BIN) -O ihex $< $@

%cof: %elf
	elfcoff.exe main.elf coff main.coff

default: $(BUILD).hex $(BUILD).obj

all:
	make BUILD=LMD18200 clean
	make BUILD=OSMC clean

clean:
	$(RM) *.o *.elf main.obj main.hex $(BUILD).* *.map *.s_sym
	make $(BUILD).hex

burn:	$(BUILD).hex
	$(PROG) -d$(MCU) -if$(BUILD).hex -vf -pf -e -z

$(BUILD).hex: main.hex
	cp main.hex $(BUILD).hex
$(BUILD).obj: main.obj
	cp main.obj $(BUILD).obj

# List dependencies not covered by rules, above.  I.e. changing
# the makefile results in a re-build

main.o:	main.s makefile
