#-------- Makefile 20160922 --------# PRG = main ################ Target file name (without extension). ############################################## SRC = $(PRG).c ################ List C source files here (with extension). ######################################### MCU_TARGET = atmega328 ################ MCU name ########################### atmega8 atmega48 atmega88 atmega168 attiny2313 F_CPU = 8000000 ################ Processor frequency. 8000000etc ##################################################### OPTIMIZE = -Os ###################################################################################################### # Display compiler version information. #gccversion : # @$(CC) --version OBJ = $(SRC:%.c=%.o) DEFS = -DF_CPU=$(F_CPU)UL LIBS = # You should not have to change anything below here. CC = avr-gcc # Override is only needed by avr-lib build system. override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) override LDFLAGS = -Wl,-Map,$(PRG).map OBJCOPY = avr-objcopy OBJDUMP = avr-objdump ############## prog-sizeに必要 SIZE = avr-size ############## size:prog-sizeに必要 all: gccversion $(PRG).elf lst text eeprom size # Display compiler version information. ############################################### gccversion : @$(CC) --version $(PRG).elf: $(OBJ) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) clean: rm -rf *.o $(PRG).elf rm -rf *.lst *.map $(EXTRA_CLEAN_FILES) # rm -rf *.o $(PRG).elf *.eps *.png *.pdf *.bak # rm -rf *.lst *.map $(EXTRA_CLEAN_FILES) lst: $(PRG).lst %.lst: %.elf $(OBJDUMP) -h -S $< > $@ # Rules for building the .text rom images text: hex bin srec hex: $(PRG).hex bin: $(PRG).bin srec: $(PRG).srec %.hex: %.elf $(OBJCOPY) -j .text -j .data -O ihex $< $@ %.srec: %.elf $(OBJCOPY) -j .text -j .data -O srec $< $@ %.bin: %.elf $(OBJCOPY) -j .text -j .data -O binary $< $@ ############## 次の2行:prog-sizeに必要 size: $(PRG).elf $(SIZE) -C --mcu=$(MCU_TARGET) $(PRG).elf # Rules for building the .eeprom rom images eeprom: ehex ebin esrec ehex: $(PRG)_eeprom.hex ebin: $(PRG)_eeprom.bin esrec: $(PRG)_eeprom.srec %_eeprom.hex: %.elf $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@ %_eeprom.srec: %.elf $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@ %_eeprom.bin: %.elf $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@ # Every thing below here is used by avr-libc's build system and can be ignored # by the casual user. JPEGFILES = largedemo-setup.jpg largedemo-wiring.jpg \ largedemo-wiring2.jpg JPEG2PNM = jpegtopnm PNM2EPS = pnmtops JPEGRESOLUTION = 180 EXTRA_CLEAN_FILES = *.hex *.bin *.srec #EXTRA_CLEAN_FILES = *.hex *.bin *.srec *.eps dox: ${JPEGFILES:.jpg=.eps} %.eps: %.jpg $(JPEG2PNM) $< |\ $(PNM2EPS) -noturn -dpi $(JPEGRESOLUTION) -equalpixels \ > $@