2013-03-08 84 views
2

我一直在尝试使用模板为我的avr gcc项目编写makefile。这是我第一次写一个(到目前为止,我刚刚使用默认内置的makefile在AVR Studio中4)Makefile循环依赖+没有这样的文件错误

当我尝试编译我到那里的错误

make: Circular Makefile.out <- Makefile dependency dropped. 
make: Circular all.out <- all dependency dropped. 
avr-gcc -I. -g -mmcu=atmega8 -Os -fpack-struct -fshort-enums -funsigned-bitfields -funsigned-char -Wall -std=gnu99 -DF_CPU=8000000 -Wa,-ahlms=../8_8_LED_DOT_MATRIX_DISPLAY.lst -c ../8_8_LED_DOT_MATRIX_DISPLAY.c -o ../8_8_LED_DOT_MATRIX_DISPLAY.o 
avr-gcc -Wl,-Map,8_8_LED_DOT_MATRIX_DISPLAY .out .map -mmcu=atmega8 -lm -o 8_8_LED_DOT_MATRIX_DISPLAY .out ../8_8_LED_DOT_MATRIX_DISPLAY.o 
avr-gcc: .out: No such file or directory 
avr-gcc: .map: No such file or directory 
avr-gcc: .out: No such file or directory 

这是我的makefile

######### AVR Project Makefile Template ######### 
######          ###### 
###### Copyright (C) 2003-2005,Pat Deegan, ###### 
######   Psychogenic Inc    ###### 
######   All Rights Reserved   ###### 
######          ###### 
###### You are free to use this code as part ###### 
###### of your own applications provided  ###### 
###### you keep this copyright notice intact ###### 
###### and acknowledge its authorship with ###### 
###### the words:        ###### 
######          ###### 
###### "Contains software by Pat Deegan of ###### 
###### Psychogenic Inc (www.psychogenic.com)" ###### 
######          ###### 
###### If you use it as part of a web site ###### 
###### please include a link to our site,  ###### 
###### http://electrons.psychogenic.com or ###### 
###### http://www.psychogenic.com    ###### 
######          ###### 
#################################################### 


##### This Makefile will make compiling Atmel AVR 
##### micro controller projects simple with Linux 
##### or other Unix workstations and the AVR-GCC 
##### tools. 
##### 
##### It supports C, C++ and Assembly source files. 
##### 
##### Customize the values as indicated below and : 
##### make 
##### make disasm 
##### make stats 
##### make hex 
##### make writeflash 
##### make gdbinit 
##### or make clean 
##### 
##### See the http://electrons.psychogenic.com/ 
##### website for detailed instructions 


#################################################### 
#####           ##### 
#####    Configuration    ##### 
#####           ##### 
##### Customize the values in this section for ##### 
##### your project. MCU, PROJECTNAME and  ##### 
##### PRJSRC must be setup for all projects, ##### 
##### the remaining variables are only   ##### 
##### relevant to those needing additional  ##### 
##### include dirs or libraries and those  ##### 
##### who wish to use the avrdude programmer ##### 
#####           ##### 
##### See http://electrons.psychogenic.com/ ##### 
##### for further details.      ##### 
#####           ##### 
#################################################### 


#####   Target Specific Details   ##### 
#####  Customize these for your project  ##### 

# Name of target controller 
# (e.g. 'at90s8515', see the available avr-gcc mmcu 
# options for possible values) 
MCU=atmega8 

# id to use with programmer 
# default: PROGRAMMER_MCU=$(MCU) 
# In case the programer used, e.g avrdude, doesn't 
# accept the same MCU name as avr-gcc (for example 
# for ATmega8s, avr-gcc expects 'atmega8' and 
# avrdude requires 'm8') 
PROGRAMMER_MCU=m8 

# Name of our project 
# (use a single word, e.g. 'myproject') 
PROJECTNAME=8_8_LED_DOT_MATRIX_DISPLAY 

# Source files 
# List C/C++/Assembly source files: 
# (list all files to compile, e.g. 'a.c b.cpp as.S'): 
# Use .cc, .cpp or .C suffix for C++ files, use .S 
# (NOT .s !!!) for assembly source code files. 
PRJSRC=../8_8_LED_DOT_MATRIX_DISPLAY.c 

# additional includes (e.g. -I/path/to/mydir) 
INC= 

# libraries to link in (e.g. -lmylib) 
LIBS= 

# Optimization level, 
# use s (size opt), 1, 2, 3 or 0 (off) 
OPTLEVEL=s 


#################################################### 
#####    Config Done    ##### 
#####           ##### 
##### You shouldn't need to edit anything  ##### 
##### below to use the makefile but may wish ##### 
##### to override a few of the flags   ##### 
##### nonetheless        ##### 
#####           ##### 
#################################################### 


##### Flags #### 

# HEXFORMAT -- format for .hex file output 
HEXFORMAT=ihex 

# compiler 
CFLAGS=-I. $(INC) -g -mmcu=$(MCU) -O$(OPTLEVEL) \ 
    -fpack-struct -fshort-enums    \ 
    -funsigned-bitfields -funsigned-char \ 
    -Wall -std=gnu99 -DF_CPU=8000000    \ 
    -Wa,-ahlms=$(firstword     \ 
    $(filter %.lst, $(<:.c=.lst))) 


# assembler 
ASMFLAGS =-I. $(INC) -mmcu=$(MCU)  \ 
    -x assembler-with-cpp   \ 
    -Wa,-gstabs,-ahlms=$(firstword \ 
     $(<:.S=.lst) $(<.s=.lst)) 


# linker 
LDFLAGS=-Wl,-Map,$(TRG).map -mmcu=$(MCU) \ 
    -lm $(LIBS) 

##### executables #### 
CC=avr-gcc 
OBJCOPY=avr-objcopy 
REMOVE=rm -f 

##### automatic target names #### 
TRG=$(PROJECTNAME).out 
HEXROMTRG=$(PROJECTNAME).hex 
HEXTRG=$(HEXROMTRG) $(PROJECTNAME).ee.hex 

# Define all object files. 

# Start by splitting source files by type 
# C 
CFILES=$(filter %.c, $(PRJSRC)) 
# Assembly 
ASMFILES=$(filter %.S, $(PRJSRC)) 


# List all object files we need to create 
OBJDEPS=$(CFILES:.c=.o) \ 
    $(ASMFILES:.S=.o) 



.SUFFIXES : C .o .out .s .S \ 
    .hex .ee.hex .h .hh .hpp 

.PHONY: writeflash clean stats gdbinit stats 

# Make targets: 
# all, disasm, stats, hex, writeflash/install, clean 
all: $(TRG) 

#disasm: $(DUMPTRG) stats 

#stats: $(TRG) 
# $(OBJDUMP) -h $(TRG) 
# $(SIZE) $(TRG) 

hex: $(HEXTRG) 


#writeflash: hex 
#install: writeflash 

#$(DUMPTRG): $(TRG) 
# $(OBJDUMP) -S $< > [email protected] 


$(TRG): $(OBJDEPS) 
    $(CC) $(LDFLAGS) -o $(TRG) $(OBJDEPS) 



#### Generating assembly #### 
# asm from C 
%.s: %.c 
    $(CC) -S $(CFLAGS) $< -o [email protected] 

# asm from (hand coded) asm 
%.s: %.S 
    $(CC) -S $(ASMFLAGS) $< > [email protected] 

# asm from C++ 
#.cpp.s .cc.s .C.s : 
# $(CC) -S $(CFLAGS) $(CPPFLAGS) $< -o [email protected] 



#### Generating object files #### 
# object from C 
.c.o: 
    $(CC) $(CFLAGS) -c $< -o [email protected] 


# object from C++ (.cc, .cpp, .C files) 
#.cc.o .cpp.o .C.o : 
# $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o [email protected] 

# object from asm 
.S.o : 
    $(CC) $(ASMFLAGS) -c $< -o [email protected] 


#### Generating hex files #### 
# hex files from elf 
##### Generating a gdb initialisation file ##### 
.out.hex: 
    $(OBJCOPY) -j .text     \ 
     -j .data      \ 
     -O $(HEXFORMAT) $< [email protected] 

.out.ee.hex: 
    $(OBJCOPY) -j .eeprom     \ 
     --change-section-lma .eeprom=0 \ 
     -O $(HEXFORMAT) $< [email protected] 

#### Cleanup #### 
clean: 
    $(REMOVE) $(TRG) $(TRG).map $(DUMPTRG) 
    $(REMOVE) $(OBJDEPS) 
    $(REMOVE) $(LST) $(GDBINITFILE) 
    $(REMOVE) $(GENASMFILES) 
    $(REMOVE) $(HEXTRG) 



#####     EOF     ##### 

任何帮助我做了什么错在这里?

谢谢!

+0

我的错误,但我应该在electronics.stackexchange.com发布。主持人请将此问题提交到那里 – Ankit 2013-03-08 08:25:14

回答

2

你必须在PROJECTNAME定义尾随的空间,所以TRG变量被设置为8_8_LED_DOT_MATRIX_DISPLAY .out和您的链接命令结束指文件.out(文件.map过,因为似乎是在尾随空间以及TRG的定义)。这是“无此文件”错误和循环依赖关系的罪魁祸首。

的原因循环依赖错误是有点微妙:由于尾随的空间,规则

$(TRG) : $(OBJDEPS) 
    <command> 

结果

% : %.out 
    <command> 

由于您的all目标没有标记为.PHONYmake在检查all是否需要重建时考虑此规则。在另一方面,.out是一个内置的后缀make有一个内置的规则

%.out : % 
    @rm -f [email protected] 
    cp $< [email protected] 

与上述相结合,这导致了all循环依赖。这同样适用于Makefile,因为make总是试图重建它处理的每个文件。

tl; dr:删除PROJECTNAMETRG中的尾部空格。