# AVR-GCC Makefile
#**************************************************************
.SUFFIXES:
.SUFFIXES:	.S .c .o .obj .elf .eep .rom

#--- define some variables based on the AVR base path in $(AVR)
CC	= avr-gcc
AS	= avr-gcc -x assembler-with-cpp
RM	= rm -f
RN	= mv
CP      = cp
BIN	= avr-objcopy
INCDIR	= .
LIBDIR	= $(AVR)/avr/lib
# SHELL   = $(AVR)/bin/sh.exe

#--- default mcu type
MCU = atmega8515

#--- default compiler flags -ahlmsn
CPFLAGS = -g -Os -mcall-prologues -Wall -Wstrict-prototypes -Wa,-adhlmsn=$(<:.c=.lst) -mmcu=$(MCU)

#--- default assembler flags 
ASFLAGS = -mmcu=$(MCU) -Wa,-mmcu=$(MCU),-gstabs

#--- default linker flags
LDFLAGS = -Wl,-Map=$(<:.o=.map),--cref -mmcu=$(MCU)

#--- output format can be srec, ihex
ROMFORMAT 	= srec
EEPROMFORMAT    = ihex


OBJ = avrledtest.o

prog: $(OBJ)	
	$(CC) $(CFLAGS) -o prog $(OBJ) $(LDFLADS)
#--- compile: instructions to create assembler and/or object files from C source
#.c.o:
%o : %c
	$(CC) -c $(CPFLAGS) -I$(INCDIR) $< -o $@

%s : %c
	$(CC) -s $(CPFLAGS) -I$(INCDIR) $< -o $@

#--- link: instructions to create elf output file from object files
%out:	%o
	$(CC) $^ $(LIB) $(LDFLAGS) -o $@

#--- create avrobj file from elf output file
%hex: %out
	$(BIN) -O ihex -R .eeprom $< $@

all: 	avrledtest

	#done with all tardets

clean:
	rm -rf $(BIN) $(OBJ)


avrledtest.out:	avrledtest.o

# avrledtest.o: avrledtest.c



load: avrledtest.hex
	uisp -dlpt=/dev/parport0 --erase  -dprog=dapa
	uisp -dlpt=/dev/parport0 --upload if=avrledtest.hex -dprog=dapa  -v=3 --hash=32
# here is a pre-compiled version in case you have trouble with
# your development environment
