8 VPATH := $(TOP_SRCDIR)/threads
9 VPATH := $(VPATH):$(TOP_SRCDIR)/devices
10 VPATH := $(VPATH):$(TOP_SRCDIR)/lib
11 VPATH := $(VPATH):$(TOP_SRCDIR)/filesys
12 VPATH := $(VPATH):$(TOP_SRCDIR)/userprog
14 WARNINGS = -Wall -W -Wstrict-prototypes -Wmissing-prototypes
15 CFLAGS = -g -O3 -MMD $(WARNINGS) $(INCLUDES) $(DEFINES)
16 ASFLAGS = -Wa,--gstabs+ $(INCLUDES) $(DEFINES)
19 THREADS_SRC = start.S # Must be linked first.
20 THREADS_SRC += init.c # Start-up code.
21 THREADS_SRC += thread.c # Thread management core.
22 THREADS_SRC += switch.S # Thread switch routine.
23 THREADS_SRC += interrupt.c # Interrupt core.
24 THREADS_SRC += intr-stubs.S # Interrupt stubs.
25 THREADS_SRC += synch.c # Synchronization.
26 THREADS_SRC += paging.c # Page tables.
27 THREADS_SRC += palloc.c # Page allocator.
28 THREADS_SRC += malloc.c # Subpage allocator.
31 DEVICES_SRC = timer.c # Timer device.
32 DEVICES_SRC += kbd.c # Keyboard device.
33 DEVICES_SRC += vga.c # Video device.
34 DEVICES_SRC += serial.c # Serial port device.
35 DEVICES_SRC += disk.c # IDE disk device.
38 LIB_SRC = debug.c # Debug helpers.
39 LIB_SRC += lib.c # Standard C library.
40 LIB_SRC += random.c # Pseudo-random numbers.
41 LIB_SRC += list.c # Doubly-linked lists.
42 LIB_SRC += bitmap.c # Bitmaps.
45 FILESYS_SRC = filesys.c # Filesystem core.
46 FILESYS_SRC += file.c # Files.
47 FILESYS_SRC += directory.c # Directories.
48 FILESYS_SRC += filehdr.c # File headers (inodes).
51 USERPROG_SRC = addrspace.c # Address spaces.
54 OBJECTS = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(SOURCES)))
58 intr-stubs.S: $(TOP_SRCDIR)/threads/intr-stubs.pl
61 kernel.lds: $(TOP_SRCDIR)/threads/kernel.lds.in
62 $(CPP) -x assembler-with-cpp -P $< -o $@
64 kernel.o: $(OBJECTS) kernel.lds
65 ld -T kernel.lds -o $@ $(OBJECTS) `$(CC) -print-libgcc-file-name`
68 objcopy -O binary -R .note -R .comment -S $< $@.tmp
69 $(TOP_SRCDIR)/pad 4096 < $@.tmp > $@
71 loader.bin: loader.S kernel.bin
72 gcc -c $< -DKERNEL_LOAD_PAGES=`perl -e 'print +(-s "kernel.bin") / 4096;'`
73 ld -N -e start -Ttext 0x7c00 --oformat binary -o $@ loader.o
75 diskimage.bin: loader.bin kernel.bin
76 cat loader.bin kernel.bin > diskimage.bin
80 rm -f kernel.bin.data kernel.bin.pad intr-stubs.S kernel.lds