# $Id: Makefile,v 1.4 2010/07/24 20:56:28 simimeie Exp $ # Makefile for HaWo Moodlight CC = avr-gcc OBJDUMP = avr-objdump OBJCOPY = avr-objcopy #AVRDUDE = avrdude AVRDUDE = /opt/avrdude-5.10/bin/avrdude INCDIR = . # There are a few additional defines that en- or disable certain features, # mainly to save space in case you are running out of flash. # You can add them here. # -DJOKECMDS Just some joke commands ADDDEFS = -DJOKECMDS # target mcu (atmega328p or atmega168p) MCU = atmega328p # Since avrdude is generally crappy software (I liked uisp a lot better, too # bad the project is dead :-/), it cannot use the MCU name everybody else # uses, it has to invent its own name for it. So this defines the same # MCU as above, but with the name avrdude understands. AVRDMCU = m328p # Some more settings # Clock Frequency of the AVR. Needed for various calculations. CPUFREQ = 8000000UL # desired baudrate of serial debug console BAUDRATE = 9600UL SRCS = console.c ledframing.c ledpwm.c ircontrol.c timers.c main.c rfm12.c PROG = moodlight # compiler flags CFLAGS = -g -Os -Wall -Wno-pointer-sign -mmcu=$(MCU) $(ADDDEFS) # linker flags LDFLAGS = -g -mmcu=$(MCU) -Wl,-Map,$(PROG).map CFLAGS += -DCPUFREQ=$(CPUFREQ) -DF_CPU=$(CPUFREQ) -DBAUDRATE=$(BAUDRATE) OBJS = $(SRCS:.c=.o) all: compile dump text eeprom @echo -n "Compiled size: " && ls -l ${PROG}.bin compile: $(OBJS) $(CC) $(LDFLAGS) -o $(PROG).elf $(OBJS) dump: compile $(OBJDUMP) -h -S $(PROG).elf > $(PROG).lst %o : %c $(CC) $(CFLAGS) -I$(INCDIR) -c $< -o $@ # Create the flash contents text: compile $(OBJCOPY) -j .text -j .data -O ihex $(PROG).elf $(PROG).hex $(OBJCOPY) -j .text -j .data -O srec $(PROG).elf $(PROG).srec $(OBJCOPY) -j .text -j .data -O binary $(PROG).elf $(PROG).bin # Rules for building the .eeprom rom images eeprom: compile $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $(PROG).elf $(PROG)_eeprom.hex $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $(PROG).elf $(PROG)_eeprom.srec $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $(PROG).elf $(PROG)_eeprom.bin clean: rm -f $(PROG) *~ *.elf *.rom *.bin *.eep *.o *.lst *.map *.srec *.hex upload: uploadflash uploadeeprom uploadflash: $(AVRDUDE) -c stk500v2 -p $(AVRDMCU) -P /dev/ttyS0 -U flash:w:$(PROG).srec:s uploadeeprom: $(AVRDUDE) -c stk500v2 -p $(AVRDMCU) -P /dev/ttyS0 -U eeprom:w:$(PROG)_eeprom.srec:s