comparison src/makefile-armgcc4.8.5 @ 12:ad95e7f82f1e

gcc-arm
author mir3636
date Fri, 16 Feb 2018 17:24:12 +0900
parents src/Makefile@83c23a36980d
children
comparison
equal deleted inserted replaced
11:1d371d93ab4f 12:ad95e7f82f1e
1 # specify path to QEMU, installed with MacPorts
2 QEMU = qemu-system-arm
3
4 include makefile.inc
5
6 CC = arm-linux-gnu-gcc
7 AS = arm-linux-gnu-as
8 LD = arm-linux-gnu-ld
9 OBJCOPY = arm-linux-gnu-objcopy
10 OBJDUMP = arm-linux-gnu-objdump
11
12 CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -I. -g -O0
13
14 ASFLAGS =
15
16 LIBGCC = $(shell $(CC) -print-libgcc-file-name)
17
18 LINK_BIN = $(call quiet-command,$(LD) $(LDFLAGS) \
19 -T $(1) -o $(2) $(3) $(LIBS) -b binary $(4), " LINK $(TARGET_DIR)$@")
20
21 LINK_INIT = $(call quiet-command,$(LD) $(LDFLAGS) \
22 $(1) -o $@.out $<, " LINK $(TARGET_DIR)$@")
23 OBJCOPY_INIT = $(call quiet-command,$(OBJCOPY) \
24 -S -O binary --prefix-symbols="_binary_$@" $@.out $@, " OBJCOPY $(TARGET_DIR)$@")
25
26
27 # link the libgcc.a for __aeabi_idiv. ARM has no native support for div
28 LIBS = $(LIBGCC)
29
30 OBJS = \
31 lib/string.o \
32 \
33 arm.o\
34 asm.o\
35 bio.o\
36 buddy.o\
37 console.o\
38 exec.o\
39 file.o\
40 fs.o\
41 log.o\
42 main.o\
43 memide.o\
44 pipe.o\
45 proc.o\
46 spinlock.o\
47 start.o\
48 swtch.o\
49 syscall.o\
50 sysfile.o\
51 sysproc.o\
52 trap_asm.o\
53 trap.o\
54 vm.o \
55 \
56 device/picirq.o \
57 device/timer.o \
58 device/uart.o
59
60 KERN_OBJS = $(OBJS) entry.o
61 kernel.elf: $(addprefix build/,$(KERN_OBJS)) kernel.ld build/initcode build/fs.img
62 cp -f build/initcode initcode
63 cp -f build/fs.img fs.img
64 $(call LINK_BIN, kernel.ld, kernel.elf, \
65 $(addprefix build/,$(KERN_OBJS)), \
66 initcode fs.img)
67 $(OBJDUMP) -S kernel.elf > kernel.asm
68 $(OBJDUMP) -t kernel.elf | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > kernel.sym
69 rm -f initcode fs.img
70
71 qemu: kernel.elf
72 @clear
73 @echo "Press Ctrl-A and then X to terminate QEMU session\n"
74 $(QEMU) -M versatilepb -m 128 -cpu arm1176 -nographic -kernel kernel.elf
75
76 INITCODE_OBJ = initcode.o
77 $(addprefix build/,$(INITCODE_OBJ)): initcode.S
78 $(call build-directory)
79 $(call AS_WITH, -nostdinc -I.)
80
81 #initcode is linked into the kernel, it will be used to craft the first process
82 build/initcode: $(addprefix build/,$(INITCODE_OBJ))
83 $(call LINK_INIT, -N -e start -Ttext 0)
84 $(call OBJCOPY_INIT)
85 $(OBJDUMP) -S $< > initcode.asm
86
87 build/fs.img:
88 make -C tools
89 make -C usr
90
91 clean:
92 rm -rf build
93 rm -f *.o *.d *.asm *.sym vectors.S bootblock entryother \
94 initcode initcode.out kernel xv6.img fs.img kernel.elf memfs
95 make -C tools clean
96 make -C usr clean