summaryrefslogtreecommitdiff
path: root/Makefile
blob: 9221deddff4ff4291946016e20825e1bf0e566d3 (plain)
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
OBJS = main.o console.o string.o kalloc.o proc.o trapasm.o trap.o vectors.o \
       syscall.o ide.o picirq.o mp.o spinlock.o fd.o pipe.o

CC = i386-jos-elf-gcc
LD = i386-jos-elf-ld
OBJCOPY = i386-jos-elf-objcopy
OBJDUMP = i386-jos-elf-objdump
CFLAGS = -nostdinc -I. -O2 -Wall -MD

xv6.img : bootblock kernel
	dd if=/dev/zero of=xv6.img count=10000
	dd if=bootblock of=xv6.img conv=notrunc
	dd if=kernel of=xv6.img seek=1 conv=notrunc

bootblock : bootasm.S bootmain.c
	$(CC) -O -nostdinc -I. -c bootmain.c
	$(CC) -nostdinc -I. -c bootasm.S
	$(LD) -N -e start -Ttext 0x7C00 -o bootblock.o bootasm.o bootmain.o
	$(OBJDUMP) -S bootblock.o > bootblock.asm
	$(OBJCOPY) -S -O binary bootblock.o bootblock
	./sign.pl bootblock

kernel : $(OBJS) bootother.S user1 usertests userfs
	$(CC) -nostdinc -I. -c bootother.S
	$(LD) -N -e start -Ttext 0x7000 -o bootother.out bootother.o
	$(OBJCOPY) -S -O binary bootother.out bootother
	$(OBJDUMP) -S bootother.o > bootother.asm
	$(LD) -Ttext 0x100000 -e main -o kernel $(OBJS) -b binary bootother user1 usertests userfs
	$(OBJDUMP) -S kernel > kernel.asm

vectors.S : vectors.pl
	perl vectors.pl > vectors.S

user1 : user1.c ulib.o
	$(CC) -nostdinc -I. -c user1.c
	$(LD) -N -e main -Ttext 0 -o user1 user1.o ulib.o
	$(OBJDUMP) -S user1 > user1.asm

usertests : usertests.c ulib.o
	$(CC) -nostdinc -I. -c usertests.c
	$(LD) -N -e main -Ttext 0 -o usertests usertests.o ulib.o
	$(OBJDUMP) -S usertests > usertests.asm

userfs : userfs.c ulib.o
	$(CC) -nostdinc -I. -c userfs.c
	$(LD) -N -e main -Ttext 0 -o userfs userfs.o ulib.o
	$(OBJDUMP) -S userfs > userfs.asm

ulib.o : ulib.c
	$(CC) -nostdinc -I. -c ulib.c

-include *.d

clean : 
	rm -f *.o bootblock kernel kernel.asm xv6.img *.d user1