microcontrollers:avr-libc_makefile_template
Differences
This shows you the differences between two versions of the page.
microcontrollers:avr-libc_makefile_template [2012/01/15 12:32] – created mithat | microcontrollers:avr-libc_makefile_template [2012/01/16 11:10] (current) – mithat | ||
---|---|---|---|
Line 4: | Line 4: | ||
<file make Makefile> | <file make Makefile> | ||
- | PRG = demo | + | PRG |
- | OBJ = demo.o | + | OBJ |
# | # | ||
# | # | ||
Line 59: | Line 59: | ||
OPTIMIZE | OPTIMIZE | ||
- | DEFS | + | DEFS = |
- | LIBS | + | LIBS = |
# You should not have to change anything below here. | # You should not have to change anything below here. | ||
- | CC | + | CC = avr-gcc |
# Override is only needed by avr-lib build system. | # Override is only needed by avr-lib build system. | ||
- | override CFLAGS | + | override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) |
override LDFLAGS | override LDFLAGS | ||
- | OBJCOPY | + | OBJCOPY = avr-objcopy |
- | OBJDUMP | + | OBJDUMP = avr-objdump |
all: $(PRG).elf lst text eeprom | all: $(PRG).elf lst text eeprom | ||
$(PRG).elf: $(OBJ) | $(PRG).elf: $(OBJ) | ||
- | | + | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) |
# dependency: | # dependency: | ||
Line 83: | Line 83: | ||
clean: | clean: | ||
- | | + | rm -rf *.o $(PRG).elf *.eps *.png *.pdf *.bak |
- | rm -rf *.lst *.map $(EXTRA_CLEAN_FILES) | + | rm -rf *.lst *.map $(EXTRA_CLEAN_FILES) |
lst: $(PRG).lst | lst: $(PRG).lst | ||
%.lst: %.elf | %.lst: %.elf | ||
- | | + | $(OBJDUMP) -h -S $< > $@ |
# Rules for building the .text rom images | # Rules for building the .text rom images | ||
Line 100: | Line 100: | ||
%.hex: %.elf | %.hex: %.elf | ||
- | | + | $(OBJCOPY) -j .text -j .data -O ihex $< $@ |
%.srec: %.elf | %.srec: %.elf | ||
- | | + | $(OBJCOPY) -j .text -j .data -O srec $< $@ |
%.bin: %.elf | %.bin: %.elf | ||
- | | + | $(OBJCOPY) -j .text -j .data -O binary $< $@ |
# Rules for building the .eeprom rom images | # Rules for building the .eeprom rom images | ||
Line 117: | Line 117: | ||
%_eeprom.hex: | %_eeprom.hex: | ||
- | | + | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@ \ |
- | || { echo empty $@ not generated; exit 0; } | + | || { echo empty $@ not generated; exit 0; } |
%_eeprom.srec: | %_eeprom.srec: | ||
- | | + | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@ \ |
- | || { echo empty $@ not generated; exit 0; } | + | || { echo empty $@ not generated; exit 0; } |
%_eeprom.bin: | %_eeprom.bin: | ||
- | | + | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@ \ |
- | || { echo empty $@ not generated; exit 0; } | + | || { echo empty $@ not generated; exit 0; } |
# Every thing below here is used by avr-libc' | # Every thing below here is used by avr-libc' | ||
# by the casual user. | # by the casual user. | ||
- | FIG2DEV | + | FIG2DEV = fig2dev |
EXTRA_CLEAN_FILES | EXTRA_CLEAN_FILES | ||
Line 141: | Line 141: | ||
%.eps: %.fig | %.eps: %.fig | ||
- | | + | $(FIG2DEV) -L eps $< $@ |
%.pdf: %.fig | %.pdf: %.fig | ||
- | | + | $(FIG2DEV) -L pdf $< $@ |
%.png: %.fig | %.png: %.fig | ||
- | | + | $(FIG2DEV) -L png $< $@ |
</ | </ |
microcontrollers/avr-libc_makefile_template.1326630776.txt.gz · Last modified: 2012/01/15 12:32 by mithat