⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 makefile

📁 em公司的RFID源程序,适合EM4094,绝对震撼!
💻
字号:
################################################################################################
################################################################################################
#
# Good Makefile !
#
################################################################################################
# Usage:
#	make all   => compiles source code, generate .cof file for simulations etc.
#	make clean => removes generated files
#
# Important!
#	Don't forget to include PATH statement in autoexec.bat
#
#	example:
#	PATH C:\WINAVR;C:\WINAVR\BIN;C:\WINAVR\UTILS\BIN; 
#
#
# It's recomended to modify only next section!
#
################################################################################################

# Modify only these settings !!!
# MCU name
	MCU = atmega8
#	MCU = at90s8515

# Output format. Can be [srec|ihex].
	FORMAT = ihex

# Target file name (without extension).
	TARGET = main

# Define compiler directory.
	DIRAVR = c:/winavr

################################################################################################
################################################################################################

# Define directories.
	DIRAVRBIN = $(DIRAVR)/bin
	DIRINC = .
	DIRLIB = $(DIRAVR)/avr/lib



# Define programs.
	SHELL = sh
	COMPILE = avr-gcc
	ASSEMBLE = avr-gcc -x assembler-with-cpp
	REMOVE = rm -f
	COPY = cp
	OBJCOPY	= avr-objcopy
	ELFCOFF = objtool
	HEXSIZE = @avr-size --target=$(FORMAT) $(TARGET).hex
	ELFSIZE = @avr-size $(TARGET).elf
	FIN = @echo "Errors: none"
	BEGIN = @echo "-------- begin --------"
	END = @echo "--------  end  --------"

# List C source files here.
	SRC	= $(TARGET).c level4.c level3.c level2.c
#	SRC	= $(TARGET).c
	
# List Assembler source files here.
	ASRC =
#	ASRC = psk_routine.s


# Compiler flags.
	CPFLAGS = -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-ahlms=$(<:.c=.lst)

# Assembler flags.
	ASFLAGS = -Wa,-ahlms=$(<:.s=.lst), -gstabs 

# Linker flags (passed via gcc).
	LDFLAGS = -Wl,-Map=$(TARGET).map,--cref

# Additional library flags (-lm = math library).
	LIBFLAGS = -lm




# Define all project specific object files.
	OBJ	= $(SRC:.c=.o) $(ASRC:.s=.o) 

# Define all listing files.
	LST = $(ASRC:.s=.lst) $(SRC:.c=.lst)

# Add target processor to flags.
	CPFLAGS += -mmcu=$(MCU)
	ASFLAGS += -mmcu=$(MCU)
	LDFLAGS += -mmcu=$(MCU)

  
# Default target.
.PHONY : all
all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep sizeafter fin end
#all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep $(TARGET).cof sizeafter fin end

# Eye candy.
.PHONY : begin
begin:
	$(BEGIN)

.PHONY : fin
fin:
	$(FIN)

.PHONY : end
end:
	$(END)

# Display size of file.
.PHONY : sizebefore
sizebefore:
	@echo "Size before:"
	-$(HEXSIZE)

.PHONY : sizeafter
sizeafter:
	@echo "Size after:"
	$(HEXSIZE)

# Display compiler version information.
.PHONY : gccversion
gccversion : 
	$(COMPILE) --version


# Create AVROBJ format file from ELF output file. (Future release)
%.obj: %.elf
	$(OBJCOPY) -O avrobj -R .eeprom $< $@


# Create COFF format file from ELF output file.
%.cof: %.elf
	$(ELFCOFF) loadelf $< mapfile $*.map writecof $@


# Create final output files (.hex, .eep) from ELF output file.
%.hex: %.elf
	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@

%.eep: %.elf
	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O $(FORMAT) $< $@


# Link: create ELF output file from object files.
.SECONDARY : $(TARGET).elf
%.elf: $(OBJ)
	$(COMPILE) $(LDFLAGS) $(OBJ) $(LIBFLAGS) --output $@


# Compile: create object files from C source files.
%.o : %.c
	$(COMPILE) -c $(CPFLAGS) -I$(DIRINC) $< -o $@


# Assemble: create object files from assembler files.
%.o : %.s
	$(ASSEMBLE) -c $(ASFLAGS) -I$(DIRINC) $< -o $@

# Target: clean project.
.PHONY : clean 
clean: begin clean_list fin end

.PHONY : clean_list
clean_list :
	$(REMOVE) $(TARGET).hex
	$(REMOVE) $(TARGET).eep
	$(REMOVE) $(TARGET).obj
	$(REMOVE) $(TARGET).cof
	$(REMOVE) $(TARGET).elf
	$(REMOVE) $(TARGET).map
	$(REMOVE) $(TARGET).obj
	$(REMOVE) $(TARGET).cof
	$(REMOVE) $(TARGET).a90
	$(REMOVE) $(TARGET).sym
	$(REMOVE) $(TARGET).lnk
	$(REMOVE) $(OBJ)
	$(REMOVE) $(LST)
	$(REMOVE) $(SRC:.c=.s)

# List source file dependencies here:
$(TARGET).o : $(TARGET).c level4.h level3.h level2.h
level4.o : level4.c level4.h level3.h level2.h level1.h
level3.o : level3.c level4.h level3.h level2.h level1.h
level2.o : level2.c level4.h level3.h level2.h level1.h

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -