Thursday, 5 September 2013

ARM GNU Makefile folder dependency timestamp issue

ARM GNU Makefile folder dependency timestamp issue

Hey guys I have a little problem here.I would like to develop a little
kernel for my new raspberry pi and used this course :
http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/ to understand
it. Well when I download a example from this site with more than one
source file it compiles the first correctly and then tell me the
following: make * no rule to build target 'build/', needed by
'build/gpio.o'.Stop.
Let me explain. There is a folder sources which contains all source
files.In the makefile these files are compiled to .o files in the build
folder, but the build folder is ALSO set as dependency when compiling a
assembler file. So when the first file is compilied and the build folder
created, the folders timestamp is outdated and the second compiling file
cant use this directory as a dependency....That is the probleme to solve
but I have no idea how....
Here's the 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 $@
$(BUILD):
mkdir $@
# Rule to clean files.
clean :
-rm -rf $(BUILD)
-rm -f $(TARGET)
-rm -f $(LIST)
-rm -f $(MAP)

No comments:

Post a Comment