3 include ../Makefile.vars
12 WARNINGS = -Wall -W -Wstrict-prototypes -Wmissing-prototypes
13 INCLUDES = -nostdinc -I../.. -I- -I../../lib -I../../lib/kernel
14 CFLAGS = -g -O3 -MMD -msoft-float $(INCLUDES) $(WARNINGS) $(DEFINES)
15 ASFLAGS = -Wa,--gstabs -MMD $(INCLUDES) $(DEFINES)
18 threads_SRC = threads/init.c # Main program.
19 threads_SRC += threads/thread.c # Thread management core.
20 threads_SRC += threads/switch.S # Thread switch routine.
21 threads_SRC += threads/interrupt.c # Interrupt core.
22 threads_SRC += threads/intr-stubs.S # Interrupt stubs.
23 threads_SRC += threads/synch.c # Synchronization.
24 threads_SRC += threads/paging.c # Page tables.
25 threads_SRC += threads/palloc.c # Page allocator.
26 threads_SRC += threads/malloc.c # Subpage allocator.
27 threads_SRC += threads/start.S # Startup code.
28 threads_SRC += threads/test.c # Test code.
31 devices_SRC = devices/timer.c # Timer device.
32 devices_SRC += devices/kbd.c # Keyboard device.
33 devices_SRC += devices/vga.c # Video device.
34 devices_SRC += devices/serial.c # Serial port device.
35 devices_SRC += devices/disk.c # IDE disk device.
36 devices_SRC += devices/intq.c # Interrupt queue.
38 # Library code shared between kernel and user programs.
39 lib_SRC = lib/debug.c # Debug helpers.
40 lib_SRC += lib/random.c # Pseudo-random numbers.
41 lib_SRC += lib/stdio.c # I/O library.
42 lib_SRC += lib/stdlib.c # Utility functions.
43 lib_SRC += lib/string.c # String functions.
45 # Kernel-specific library code.
46 lib_kernel_SRC += lib/kernel/list.c # Doubly-linked lists.
47 lib_kernel_SRC += lib/kernel/bitmap.c # Bitmaps.
48 lib_kernel_SRC += lib/kernel/hash.c # Hash tables.
49 lib_kernel_SRC += lib/kernel/printf.c # Kernel printf().
52 filesys_SRC = filesys/filesys.c # Filesystem core.
53 filesys_SRC += filesys/file.c # Files.
54 filesys_SRC += filesys/directory.c # Directories.
55 filesys_SRC += filesys/filehdr.c # File headers (inodes).
56 filesys_SRC += filesys/fsutil.c # Utilities.
59 userprog_SRC = userprog/addrspace.c # Address spaces.
60 userprog_SRC += userprog/exception.c # User exception handler.
61 userprog_SRC += userprog/syscall.c # System call handler.
62 userprog_SRC += userprog/gdt.c # GDT initialization.
63 userprog_SRC += userprog/tss.c # TSS management.
65 SOURCES = $(foreach dir,$(SUBDIRS),$($(subst /,_,$(dir))_SRC))
66 OBJECTS = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(SOURCES)))
67 DEPENDS = $(patsubst %.o,%.d,$(OBJECTS))
71 threads/intr-stubs.S: threads/intr-stubs.pl threads/loader.h
74 threads/kernel.lds.s: CPPFLAGS += -P -C
75 threads/kernel.lds.s: threads/kernel.lds.S threads/loader.h
77 kernel.o: threads/kernel.lds.s $(OBJECTS)
78 ld -T $< -o $@ $(OBJECTS) `$(CC) -print-libgcc-file-name`
81 objcopy -O binary -R .note -R .comment -S $< $@.tmp
82 ../../pad 4096 < $@.tmp > $@
85 threads/loader.o: threads/loader.S kernel.bin
86 $(CC) -c $< -o $@ $(ASFLAGS) -DKERNEL_LOAD_PAGES=`perl -e 'print +(-s "kernel.bin") / 4096;'`
88 loader.bin: threads/loader.o
89 ld -N -e start -Ttext 0x7c00 --oformat binary -o $@ $<
91 os.dsk: loader.bin kernel.bin
95 rm -f $(OBJECTS) $(DEPENDS)
96 rm -f threads/intr-stubs.S threads/loader.o
97 rm -f kernel.o kernel.lds.s
98 rm -f kernel.bin loader.bin