# GAS makefile
# Larry Barello May, 2000
#
	MCU	= at90s1200
#	MCU	= at90s2313
	FORMAT	= ihex
	LIST	= ,-ahlms=$(<:.s=.lst)

	LDFLAGS = -Map=$(<:.o=.map) --cref -v -T$(MCU).x
	AFLAGS	= -c -DMCU=$(MCU) $(MIXED) -Wa,-gstabs,-v

	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 $(FORMAT) $< $@

all:	main.hex

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

main.o:	main.s makefile
	$(AS) $(AFLAGS) $< -o $@

