####################################################################### # # 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 # 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 # 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: avrdude -v=3 -dprog=stk500 -dserial=/dev/cu.USA19H1b1P1.1 -dpart=$(MCU_TARGET) --erase --upload --verify if=$(PRG).rom # command to clean up junk (no source files) (invoked by "make clean") clean: rm -f *.o *.rom *.elf *.map *~