]>
cloudbase.mooo.com Git - z180-stamp.git/blob - mk/avr.rules.mk
12 # Define all object files.
13 OBJ
= $(SRC
:.c
=.o
) $(ASRC
:.S
=.o
)
16 # Compiler flags to generate dependency files.
17 GENDEPFLAGS
= -MMD
-MP
-MF .dep
/$(@F
:%.o
=%.d
)
20 # Combine all necessary flags and optional flags.
21 # Add target processor to flags.
22 ALL_CFLAGS
= -mmcu
=$(MCU
) $(CFLAGS
) $(GENDEPFLAGS
)
24 AVRDUDE_WRITE_FLASH
= -U flash
:w
:$(TARGET
).hex
25 AVRDUDE_BASIC
= -p
$(MCU
) -P
$(AVRDUDE_PORT
) -c
$(AVRDUDE_PROGRAMMER
)
26 AVRDUDE_FLAGS
= $(AVRDUDE_BASIC
) $(AVRDUDE_NO_VERIFY
) $(AVRDUDE_VERBOSE
)
28 # Be silent per default, but 'make V=1' will show all compiler calls.
36 .PHONY
: elf hex lss sym size
43 @
$(QP
)printf
" SIZE $(TARGET).elf\n"
44 $(Q
)$(SIZE
) $(TARGET
).elf
49 $(AVRDUDE
) $(AVRDUDE_FLAGS
) $(AVRDUDE_WRITE_FLASH
)
52 $(AVRDUDE
) $(AVRDUDE_FLAGS
) -u
-U hfuse
:w
:$(HFUSE
):m
-U lfuse
:w
:$(LFUSE
):m
55 .SUFFIXES
: .elf .hex .eep .lss .sym
58 @
$(QP
)printf
" OBJCOPY $(*).hex\n"
59 $(Q
)$(OBJCOPY
) -Oihex
-R .eeprom
$< $@
62 # Create extended listing file from ELF output file.
64 @
$(QP
)printf
" OBJDUMP $@\n"
65 $(Q
)$(OBJDUMP
) -h
-S
$< > $@
67 # Create a symbol table from ELF output file.
69 @
$(QP
)printf
" NM $@\n"
74 # Link: create ELF output file from object files.
75 .SECONDARY
: $(TARGET
).elf
78 @
$(QP
)printf
" LD $@\n"
79 $(Q
)$(CC
) $(ALL_CFLAGS
) $^
--output
$@
$(LDFLAGS
)
82 # Compile: create object files from C source files.
84 @
$(QP
)printf
" CC $<\n"
85 $(Q
)$(CC
) -c
$(ALL_CFLAGS
) $< -o
$@
88 # Target: clean project.
89 .PHONY
: clean distclean
91 @
$(QP
)printf
" CLEAN\n"
92 $(Q
)$(RM
) $(TARGET
).elf
$(TARGET
).lss
$(TARGET
).map
$(TARGET
).sym \
93 $(OBJ
) $(SRC
:.c
=.s
) .dep
/*
96 @
$(QP
)printf
" DISTCLEAN\n"
97 $(Q
)$(RM
) $(TARGET
).hex
$(TARGET
).
tar.gz
101 tar cvfz
$(TARGET
).
tar.gz \
103 $(TARGET
).hex
$(TARGET
).eep
105 # Include the dependency files.
106 -include $(shell mkdir .dep
2>/dev
/null
) $(wildcard .dep
/*)