Skip to content
Snippets Groups Projects
Makefile 3.35 KiB
Newer Older
rsc's avatar
rsc committed
OBJS = \
	console.o\
	fd.o\
	ide.o\
	kalloc.o\
	lapic.o\
rsc's avatar
rsc committed
	main.o\
	mp.o\
	picirq.o\
	pipe.o\
	proc.o\
	setjmp.o\
	spinlock.o\
	string.o\
	syscall.o\
	trapasm.o\
	trap.o\
	vectors.o\
rtm's avatar
rtm committed
	bio.o\
	fs.o\
rtm's avatar
rtm committed

# Cross-compiling (e.g., on Mac OS X)
TOOLPREFIX = i386-jos-elf-

# Using native tools (e.g., on X86 Linux)
# TOOLPREFIX = 

CC = $(TOOLPREFIX)gcc
LD = $(TOOLPREFIX)ld
OBJCOPY = $(TOOLPREFIX)objcopy
OBJDUMP = $(TOOLPREFIX)objdump
rsc's avatar
rsc committed
CFLAGS = -fno-builtin -O2 -Wall -MD
AS = $(TOOLPREFIX)gas
rtm's avatar
rtm committed

rtm's avatar
rtm committed
xv6.img : bootblock kernel fs.img
rtm's avatar
rtm committed
	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 init
	$(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 main0 -o kernel $(OBJS) -b binary bootother init
rtm's avatar
rtm committed
	$(OBJDUMP) -S kernel > kernel.asm

kaashoek's avatar
kaashoek committed
tags: $(OBJS) bootother.S init
	etags *.S *.c

kaashoek's avatar
kaashoek committed
PRINT =	\
rsc's avatar
 
rsc committed
	runoff.list \
kaashoek's avatar
kaashoek committed
	README\
kaashoek's avatar
kaashoek committed
	types.h param.h defs.h x86.h asm.h elf.h mmu.h spinlock.h\
	bootasm.S bootother.S main.c init.c spinlock.c\
	proc.h proc.c setjmp.S kalloc.c\
	syscall.h trapasm.S traps.h trap.c vectors.pl syscall.c\
	buf.h dev.h fcntl.h stat.h fd.h fs.h fsvar.h fd.c fs.c bio.c ide.c\
	pipe.c\
	mp.h ioapic.h mp.c lapic.c ioapic.c picirq.c\
	console.c\
	string.c\

rsc's avatar
 
rsc committed
# make a printout
xv6.pdf : $(PRINT)
	./runoff

print : xv6.pdf
kaashoek's avatar
kaashoek committed

rtm's avatar
rtm committed
vectors.S : vectors.pl
	perl vectors.pl > vectors.S

kaashoek's avatar
kaashoek committed
ULIB = ulib.o usys.o printf.o umalloc.o
rsc's avatar
rsc committed
user1 : user1.o $(ULIB)
	$(LD) -N -e main -Ttext 0 -o user1 user1.o $(ULIB)
rtm's avatar
rtm committed
	$(OBJDUMP) -S user1 > user1.asm
rtm's avatar
rtm committed

rsc's avatar
rsc committed
usertests : usertests.o $(ULIB)
	$(LD) -N -e main -Ttext 0 -o usertests usertests.o $(ULIB)
rtm's avatar
rtm committed
	$(OBJDUMP) -S usertests > usertests.asm

fstests : fstests.o $(ULIB)
	$(LD) -N -e main -Ttext 0 -o fstests fstests.o $(ULIB)
	$(OBJDUMP) -S fstests > fstests.asm

rtm's avatar
rtm committed
echo : echo.o $(ULIB)
	$(LD) -N -e main -Ttext 0 -o echo echo.o $(ULIB)
	$(OBJDUMP) -S echo > echo.asm

cat : cat.o $(ULIB)
	$(LD) -N -e main -Ttext 0 -o cat cat.o $(ULIB)
	$(OBJDUMP) -S cat > cat.asm

rsc's avatar
rsc committed
userfs : userfs.o $(ULIB)
	$(LD) -N -e main -Ttext 0 -o userfs userfs.o $(ULIB)
	$(OBJDUMP) -S userfs > userfs.asm

init : init.o $(ULIB)
	$(LD) -N -e main -Ttext 0 -o init init.o $(ULIB)
	$(OBJDUMP) -S init > init.asm

sh : sh.o $(ULIB)
	$(LD) -N -e main -Ttext 0 -o sh sh.o $(ULIB)
	$(OBJDUMP) -S sh > sh.asm

kaashoek's avatar
kaashoek committed
ls : ls.o $(ULIB)
	$(LD) -N -e main -Ttext 0 -o ls ls.o $(ULIB)
	$(OBJDUMP) -S ls > ls.asm

mkdir : mkdir.o $(ULIB)
	$(LD) -N -e main -Ttext 0 -o mkdir mkdir.o $(ULIB)
	$(OBJDUMP) -S mkdir > mkdir.asm

rm : rm.o $(ULIB)
	$(LD) -N -e main -Ttext 0 -o rm rm.o $(ULIB)
	$(OBJDUMP) -S rm > rm.asm

rtm's avatar
rtm committed
mkfs : mkfs.c fs.h
	cc -o mkfs mkfs.c

kaashoek's avatar
kaashoek committed
fs.img : mkfs userfs usertests echo cat README init sh ls mkdir rm fstests
	./mkfs fs.img userfs usertests echo cat README init sh ls mkdir rm fstests
rtm's avatar
rtm committed

rtm's avatar
rtm committed
-include *.d

rtm's avatar
rtm committed
clean : 
kaashoek's avatar
kaashoek committed
	rm -f *.ps *.tex *.dvi *.idx *.aux *.log *.ind *.ilg \
kaashoek's avatar
kaashoek committed
	*.o *.d *.asm vectors.S parport.out \
	bootblock kernel xv6.img user1 userfs usertests \
	fs.img mkfs echo init fstests