xv6-65oo2/Makefile

201 lines
5 KiB
Makefile
Raw Normal View History

2006-07-16 15:35:18 +00:00
OBJS = \
console.o\
2006-09-06 18:40:28 +00:00
file.o\
2006-07-16 15:35:18 +00:00
ide.o\
kalloc.o\
lapic.o\
ioapic.o\
2006-07-16 15:35:18 +00:00
main.o\
mp.o\
picirq.o\
pipe.o\
proc.o\
setjmp.o\
spinlock.o\
string.o\
syscall.o\
2006-09-06 18:18:43 +00:00
sysfile.o\
sysproc.o\
2006-07-16 15:35:18 +00:00
trapasm.o\
trap.o\
vectors.o\
bio.o\
fs.o\
exec.o\
8253pit.o\
kbd.o\
2006-06-12 15:22:12 +00:00
2006-07-11 01:07:40 +00:00
# Cross-compiling (e.g., on Mac OS X)
#TOOLPREFIX = i386-jos-elf-
2006-07-11 01:07:40 +00:00
# Using native tools (e.g., on X86 Linux)
2006-09-07 20:06:15 +00:00
TOOLPREFIX =
2006-07-11 01:07:40 +00:00
CC = $(TOOLPREFIX)gcc
LD = $(TOOLPREFIX)ld
OBJCOPY = $(TOOLPREFIX)objcopy
OBJDUMP = $(TOOLPREFIX)objdump
2007-08-08 08:38:55 +00:00
# On newer gcc you may need to add -fno-stack-protector to $(CFLAGS)
CFLAGS = -fno-builtin -O2 -Wall -MD -ggdb -fno-stack-protector
2006-07-11 01:07:40 +00:00
AS = $(TOOLPREFIX)gas
2006-06-12 15:22:12 +00:00
xv6.img : bootblock kernel fs.img
2006-06-12 15:22:12 +00:00
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 initcode.S
$(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
$(CC) -nostdinc -I. -c initcode.S
$(LD) -N -e start -Ttext 0 -o initcode.out initcode.o
$(OBJCOPY) -S -O binary initcode.out initcode
$(OBJDUMP) -S initcode.o > initcode.asm
2007-08-27 23:32:16 +00:00
$(LD) -Ttext 0x100000 -e main -o kernel $(OBJS) -b binary initcode bootother
2006-06-12 15:22:12 +00:00
$(OBJDUMP) -S kernel > kernel.asm
$(OBJDUMP) -t kernel | awk '/SYMBOL TABLE/ { go=1; next } go {print $$1, $$NF}' >kernel.sym
2006-06-12 15:22:12 +00:00
2006-09-07 14:10:52 +00:00
tags: $(OBJS) bootother.S _init
etags *.S *.c
2006-06-13 15:50:06 +00:00
vectors.S : vectors.pl
perl vectors.pl > vectors.S
ULIB = ulib.o usys.o printf.o umalloc.o
2006-07-11 01:07:40 +00:00
2007-08-24 20:20:23 +00:00
_usertests : usertests.o $(ULIB)
$(LD) -N -e main -Ttext 0 -o _usertests usertests.o $(ULIB)
$(OBJDUMP) -S _usertests > usertests.asm
2006-06-27 14:35:53 +00:00
2006-09-07 13:07:39 +00:00
_echo : echo.o $(ULIB)
$(LD) -N -e main -Ttext 0 -o _echo echo.o $(ULIB)
$(OBJDUMP) -S _echo > echo.asm
2006-07-28 22:33:07 +00:00
2006-09-07 13:07:39 +00:00
_cat : cat.o $(ULIB)
$(LD) -N -e main -Ttext 0 -o _cat cat.o $(ULIB)
$(OBJDUMP) -S _cat > cat.asm
2006-09-07 13:07:39 +00:00
_init : init.o $(ULIB)
$(LD) -N -e main -Ttext 0 -o _init init.o $(ULIB)
$(OBJDUMP) -S _init > init.asm
2007-08-08 07:43:02 +00:00
$(OBJDUMP) -t _init | awk '/SYMBOL TABLE/ { go=1; next } go {print $$1, $$NF}' >init.sym
2007-08-08 08:50:23 +00:00
_kill : kill.o $(ULIB)
$(LD) -N -e main -Ttext 0 -o _kill kill.o $(ULIB)
$(OBJDUMP) -S _kill > kill.asm
2006-09-07 13:07:39 +00:00
_ls : ls.o $(ULIB)
$(LD) -N -e main -Ttext 0 -o _ls ls.o $(ULIB)
$(OBJDUMP) -S _ls > ls.asm
2006-08-12 04:33:50 +00:00
2006-09-07 13:07:39 +00:00
_mkdir : mkdir.o $(ULIB)
$(LD) -N -e main -Ttext 0 -o _mkdir mkdir.o $(ULIB)
$(OBJDUMP) -S _mkdir > mkdir.asm
2006-09-07 13:07:39 +00:00
_rm : rm.o $(ULIB)
$(LD) -N -e main -Ttext 0 -o _rm rm.o $(ULIB)
$(OBJDUMP) -S _rm > rm.asm
2007-08-22 05:54:55 +00:00
_ln : ln.o $(ULIB)
$(LD) -N -e main -Ttext 0 -o _ln ln.o $(ULIB)
$(OBJDUMP) -S _ln > ln.asm
2007-08-08 08:50:23 +00:00
_sh : sh.o $(ULIB)
$(LD) -N -e main -Ttext 0 -o _sh sh.o $(ULIB)
$(OBJDUMP) -S _sh > sh.asm
2007-08-08 08:38:55 +00:00
_zombie: zombie.o $(ULIB)
$(LD) -N -e main -Ttext 0 -o _zombie zombie.o $(ULIB)
$(OBJDUMP) -S _zombie > zombie.asm
2007-08-24 20:20:23 +00:00
_forktest: forktest.o $(ULIB)
# forktest has less library code linked in - needs to be small
# in order to be able to max out the proc table.
$(LD) -N -e main -Ttext 0 -o _forktest forktest.o ulib.o usys.o
$(OBJDUMP) -S _forktest > forktest.asm
mkfs : mkfs.c fs.h
cc -o mkfs mkfs.c
2007-08-24 20:20:23 +00:00
UPROGS=_usertests _echo _cat _init _kill _ln _ls _mkdir _rm _sh _zombie _forktest
2007-08-08 08:38:55 +00:00
fs.img : mkfs README $(UPROGS)
./mkfs fs.img README $(UPROGS)
2006-06-15 19:58:01 +00:00
-include *.d
2006-06-12 15:22:12 +00:00
clean :
2006-09-03 14:38:10 +00:00
rm -f *.ps *.tex *.dvi *.idx *.aux *.log *.ind *.ilg \
2006-08-29 17:50:19 +00:00
*.o *.d *.asm vectors.S parport.out \
2007-08-08 08:38:55 +00:00
bootblock kernel xv6.img fs.img mkfs \
$(UPROGS)
2006-09-07 20:06:15 +00:00
# make a printout
PRINT = \
runoff.list \
README\
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\
2006-09-07 20:06:15 +00:00
proc.h proc.c setjmp.S kalloc.c\
syscall.h trapasm.S traps.h trap.c vectors.pl syscall.c sysproc.c\
buf.h dev.h fcntl.h stat.h file.h fs.h fsvar.h file.c fs.c bio.c ide.c sysfile.c\
pipe.c exec.c\
2006-09-07 20:06:15 +00:00
mp.h ioapic.h mp.c lapic.c ioapic.c picirq.c\
console.c\
string.c\
xv6.pdf : $(PRINT)
./runoff
print : xv6.pdf
# run in emulators
bochs : fs.img xv6.img
if [ ! -e .bochsrc ]; then ln -s dot-bochsrc .bochsrc; fi
bochs -q
qemu : fs.img xv6.img
qemu -parallel stdio -hdb fs.img xv6.img
2006-09-08 14:41:06 +00:00
# CUT HERE
# prepare dist for students
# after running make dist, probably want to
# rename it to rev0 or rev1 or so on and then
# check in that version.
dist :
rm -rf dist
mkdir dist
for i in *.c *.h *.S; \
do \
grep -v PAGEBREAK $$i >dist/$$i; \
done
sed '/CUT HERE/,$$d' Makefile >dist/Makefile
cp README dot-bochsrc *.pl toc.* runoff runoff1 runoff.list dist
dist-test :
rm -rf dist-test
mkdir dist-test
cp dist/* dist-test
cd dist-test; ../m print
cd dist-test; ../m bochs || true
cd dist-test; ../m qemu
# update this rule (change rev0) when it is time to
# make a new revision.
tar :
rm -rf /tmp/xv6
mkdir -p /tmp/xv6
cp dist/* /tmp/xv6
(cd /tmp; tar cf - xv6) | gzip >xv6-rev0.tar.gz