xv6-65oo2/Makefile

169 lines
3.6 KiB
Makefile
Raw Normal View History

2006-07-16 15:35:18 +00:00
OBJS = \
2007-08-28 04:20:40 +00:00
bio.o\
2006-07-16 15:35:18 +00:00
console.o\
2007-08-28 04:20:40 +00:00
exec.o\
2006-09-06 18:40:28 +00:00
file.o\
2007-08-28 04:20:40 +00:00
fs.o\
2006-07-16 15:35:18 +00:00
ide.o\
2007-08-28 04:20:40 +00:00
ioapic.o\
2006-07-16 15:35:18 +00:00
kalloc.o\
2007-08-28 04:20:40 +00:00
kbd.o\
2006-07-16 15:35:18 +00:00
lapic.o\
main.o\
mp.o\
picirq.o\
pipe.o\
proc.o\
spinlock.o\
string.o\
2007-08-28 12:48:33 +00:00
swtch.o\
2006-07-16 15:35:18 +00:00
syscall.o\
2006-09-06 18:18:43 +00:00
sysfile.o\
sysproc.o\
2007-08-28 04:41:20 +00:00
timer.o\
2006-07-16 15:35:18 +00:00
trapasm.o\
trap.o\
vectors.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)
2007-08-28 19:30:29 +00:00
# TOOLPREFIX = i386-jos-elf-
2006-07-11 01:07:40 +00:00
# Using native tools (e.g., on X86 Linux)
2007-08-28 19:30:29 +00:00
TOOLPREFIX =
2006-07-11 01:07:40 +00:00
CC = $(TOOLPREFIX)gcc
2007-08-28 04:20:40 +00:00
AS = $(TOOLPREFIX)gas
2006-07-11 01:07:40 +00:00
LD = $(TOOLPREFIX)ld
OBJCOPY = $(TOOLPREFIX)objcopy
OBJDUMP = $(TOOLPREFIX)objdump
2007-08-28 04:20:40 +00:00
CFLAGS = -fno-builtin -O2 -Wall -MD -ggdb
CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector)
2006-06-12 15:22:12 +00:00
2007-08-28 04:20:40 +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
2007-08-28 04:20:40 +00:00
bootblock: bootasm.S bootmain.c
2006-06-12 15:22:12 +00:00
$(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
2007-08-28 04:20:40 +00:00
bootother: bootother.S
2007-08-28 17:48:44 +00:00
$(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
2007-08-28 04:20:40 +00:00
initcode: initcode.S
2007-08-28 17:48:44 +00:00
$(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-28 04:20:40 +00:00
kernel: $(OBJS) bootother initcode
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
2007-08-28 12:48:33 +00:00
$(OBJDUMP) -t kernel | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > 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
2007-08-28 04:20:40 +00:00
vectors.S: vectors.pl
2006-06-13 15:50:06 +00:00
perl vectors.pl > vectors.S
ULIB = ulib.o usys.o printf.o umalloc.o
2006-07-11 01:07:40 +00:00
2007-08-28 04:20:40 +00:00
_%: %.o $(ULIB)
$(LD) -N -e main -Ttext 0 -o $@ $^
$(OBJDUMP) -S $@ > $*.asm
2007-08-28 12:48:33 +00:00
$(OBJDUMP) -t $@ | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > $*.sym
2007-08-08 08:38:55 +00:00
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
2007-08-28 04:20:40 +00:00
mkfs: mkfs.c fs.h
gcc -Wall -o mkfs mkfs.c
UPROGS=\
_cat\
2007-08-28 04:26:34 +00:00
_echo\
2007-08-28 04:20:40 +00:00
_forktest\
2007-08-28 04:26:34 +00:00
_grep\
2007-08-28 04:20:40 +00:00
_init\
_kill\
_ln\
_ls\
_mkdir\
_rm\
_sh\
_usertests\
_wc\
_zombie\
fs.img: mkfs README $(UPROGS)
2007-08-08 08:38:55 +00:00
./mkfs fs.img README $(UPROGS)
2006-06-15 19:58:01 +00:00
-include *.d
2007-08-28 04:20:40 +00:00
clean:
2006-09-03 14:38:10 +00:00
rm -f *.ps *.tex *.dvi *.idx *.aux *.log *.ind *.ilg \
2007-08-28 04:20:40 +00:00
*.o *.d *.asm *.sym 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
2007-08-28 12:48:33 +00:00
PRINT = runoff.list $(shell grep -v '^\#' runoff.list)
2006-09-07 20:06:15 +00:00
2007-08-28 04:20:40 +00:00
xv6.pdf: $(PRINT)
2006-09-07 20:06:15 +00:00
./runoff
2007-08-28 04:20:40 +00:00
print: xv6.pdf
2006-09-07 20:06:15 +00:00
# run in emulators
bochs : fs.img xv6.img
if [ ! -e .bochsrc ]; then ln -s dot-bochsrc .bochsrc; fi
bochs -q
2007-08-28 04:20:40 +00:00
qemu: fs.img xv6.img
2006-09-07 20:06:15 +00:00
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.
2007-08-28 04:20:40 +00:00
dist:
2006-09-08 14:41:06 +00:00
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
2007-08-28 04:20:40 +00:00
dist-test:
2006-09-08 14:41:06 +00:00
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
2007-08-28 04:20:40 +00:00
# update this rule (change rev1) when it is time to
2006-09-08 14:41:06 +00:00
# make a new revision.
2007-08-28 04:20:40 +00:00
tar:
2006-09-08 14:41:06 +00:00
rm -rf /tmp/xv6
mkdir -p /tmp/xv6
cp dist/* /tmp/xv6
2007-08-28 04:20:40 +00:00
(cd /tmp; tar cf - xv6) | gzip >xv6-rev1.tar.gz
2006-09-08 14:41:06 +00:00