All pastes #802330 Raw Edit

Miscellany

public text v1 · immutable
#802330 ·published 2007-11-30 02:01 UTC
rendered paste body
#######################################################################
#
# 	This is a generic make file for an avr project
#
#	avr-gcc -c (compile only - don't assemble)
#		-g (provide debugging information)
#		-O3 (optimize - more than O or O2)
#		-Wall (all warnings)
#		-mmcu (target eg. atmega16)
#		-I. (add directory to search for header files)
#		-Wl option (pass option to the linker)
#
########################################################################

PRG				= pwm
MCU_TARGET		= atmega8
AVRDUDE_PGMR	= usbtiny
PORT			= 

# default target when "make" is run w/o arguments
all: $(PRG).rom

# compile sample.c into sample.o
$(PRG).o: $(PRG).c
	avr-gcc -c -g -O3 -Wall -mmcu=$(MCU_TARGET) -I. $(PRG).c -o $(PRG).o

# create some other object files if necessary

# link up filename.o and filename.o into filename.elf
$(PRG).elf: $(PRG).o
	avr-gcc $(PRG).o -Wl,-Map=$(PRG).map,--cref -mmcu=$(MCU_TARGET) -o $(PRG).elf

# copy ROM (FLASH) object out of filename.elf into filename.rom
$(PRG).rom: $(PRG).elf
	avr-objcopy -O ihex $(PRG).elf $(PRG).rom

$(PRG).hex: $(PRG).elf
	avr-objcopy -O ihex $(PRG).elf $(PRG).hex

# command to program chip (optional) (invoked by running "make install")
#install:
#	uisp -v=3 -dprog=stk500 -dserial=/dev/cu.USA19H1b1P1.1 -dpart=$(MCU_TARGET) --erase --upload --verify if=$(PRG).rom

install: $(PRG).hex
	avrdude -C ~/.avrduderc -p m8 -c$(AVRDUDE_PGMR) -P $(PORT) -e -U flash:w:$(PRG).hex


# command to clean up junk (no source files) (invoked by "make clean")
clean:
	rm -f *.o *.rom *.elf *.map *~