-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·63 lines (42 loc) · 1.28 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# based on the Makefile by Alex Chadwick
# for generation of raspberry pi kernel images
# The toolchain to use. arm-none-eabi works, but there does exist
# arm-bcm2708-linux-gnueabi.
ARMGNU ?= arm-none-eabi
#source folder
SOURCE = source/
#intermediate folder
BUILD = build/
#final folder
KERNEL = kernel/
#output kernel file
TARGET = kernel.img
#assembler listing file generated
LIST = kernel.list
#map file to generate
MAP = kernel.map
#linker script to use
LINKER = kernel.ld
#the name of the files to be compiled
OBJECTS := $(patsubst $(SOURCE)%.s,$(BUILD)%.o,$(wildcard $(SOURCE)*.s))
all: $(KERNEL) $(TARGET) $(LIST)
rebuild: all
#rule to make listing file
$(LIST) : $(BUILD)output.elf
$(ARMGNU)-objdump -d $(BUILD)output.elf > $(KERNEL)$(LIST)
#rule to make image file
$(TARGET) : $(BUILD)output.elf
$(ARMGNU)-objcopy $(BUILD)output.elf -O binary $(KERNEL)$(TARGET)
#rule to make elf files
$(BUILD)output.elf : $(OBJECTS) $(LINKER)
$(ARMGNU)-ld --no-undefined $(OBJECTS) -Map $(KERNEL)$(MAP) -o $(BUILD)output.elf -T $(LINKER)
#rule to make object files
$(BUILD)%.o: $(SOURCE)%.s $(BUILD)
$(ARMGNU)-as -I $(SOURCE) $< -o $@
$(BUILD):
mkdir $@
$(KERNEL):
mkdir $@
clean :
-rm -rf $(BUILD)
-rm -rf $(KERNEL)