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