2013-09-05 71 views
3

嘿家伙我在这里有一个小问题。我想为我的新树莓派开发一个小内核,并使用此课程:http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/ 了解它。那么当我从这个网站上下载一个具有多个源文件的例子时,它会正确编译第一个,然后告诉我以下内容:make *没有规则来构建目标'build /','build/gpio.o' 。停止。ARM GNU Makefile文件夹依赖关系时间戳问题

让我解释一下。有一个包含所有源文件的文件夹源。在makefile中,这些文件被编译为build文件夹中的.o文件,但编译汇编文件时,build文件夹也被设置为依赖项。因此,当第一个文件被编译并且生成了build文件夹时,文件夹时间戳已经过时,第二个编译文件不能使用这个目录作为依赖关系....这是要解决的问题,但我不知道如何....

这里的makefile文件:)

ARMGNU ?= arm-none-eabi 

# The intermediate directory for compiled object files. 
BUILD = build/ 

# The directory in which source files are stored. 
SOURCE = source/ 

# The name of the output file to generate. 
TARGET = kernel.img 

# The name of the assembler listing file to generate. 
LIST = kernel.list 

# The name of the map file to generate. 
MAP = kernel.map 

# The name of the linker script to use. 
LINKER = kernel.ld 

# The names of all object files that must be generated. Deduced from the 
# assembly code files in source. 
OBJECTS := $(patsubst $(SOURCE)%.s,$(BUILD)%.o,$(wildcard $(SOURCE)*.s)) 

# Rule to make everything. 
all: $(TARGET) $(LIST) 

# Rule to remake everything. Does not include clean. 
rebuild: all 

# Rule to make the listing file. 
$(LIST) : $(BUILD)output.elf 
$(ARMGNU)-objdump -d $(BUILD)output.elf > $(LIST) 

# Rule to make the image file. 
$(TARGET) : $(BUILD)output.elf 
$(ARMGNU)-objcopy $(BUILD)output.elf -O binary $(TARGET) 

# Rule to make the elf file. 
$(BUILD)output.elf : $(OBJECTS) $(LINKER) 
$(ARMGNU)-ld --no-undefined $(OBJECTS) -Map $(MAP) -o $(BUILD)output.elf -T  $(LINKER) 

# Rule to make the object files. 
$(BUILD)%.o: $(SOURCE)%.s $(BUILD) 
$(ARMGNU)-as -I $(SOURCE) $< -o [email protected] 

$(BUILD): 
mkdir [email protected] 

# Rule to clean files. 
clean : 
-rm -rf $(BUILD) 
-rm -f $(TARGET) 
-rm -f $(LIST) 
-rm -f $(MAP) 

PS ::

YEEAAYY我有it.Are在这个例子中,页面工作,对天,但现在:) 再看看: OBJDIR:= objdir OBJS:= $(addprefix $(OBJDIR)/,foo.o bar.o baz.o)

$(OBJDIR)/%.o : %.c 
     $(COMPILE.c) $(OUTPUT_OPTION) $< 

all: $(OBJS) 

$(OBJS): | $(OBJDIR) 

$(OBJDIR): 
     mkdir $(OBJDIR)` 

我刚刚删除的$(BUILD)文件夹的依赖性和目标,并写道:

$(OBJECTS): | $(BUILD) 

所以现在的作品完美这里的几行,我改变:

$(BUILD)%.o: $(SOURCE)%.s 
$(ARMGNU)-as -I $(SOURCE) $< -o [email protected] 

$(OBJECTS): | $(BUILD) 
+1

你应该回答你自己的问题,如果你真的找到答案,以便其他人搜索时,他们会看到这个问题已经解决。 – CaptainBli

回答

1

什么你想要做的是制作$(BUILD)order-only prerequisite

$(BUILD)%.o: $(SOURCE)%.s | $(BUILD) 
+0

我之前尝试过,但它不适用于我:(它仍然说没有规则,使目标... –

+0

你得到的错误似乎与你的分析没有关系。显然有一条规则,使'构建'你确定你没有什么奇怪的事情吗? –

+0

我已经看到了它的问题 –