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.
30 devices_SRC = devices/timer.c # Timer device.
31 devices_SRC += devices/kbd.c # Keyboard device.
32 devices_SRC += devices/vga.c # Video device.
33 devices_SRC += devices/serial.c # Serial port device.
34 devices_SRC += devices/disk.c # IDE disk device.
35 devices_SRC += devices/intq.c # Interrupt queue.
37 # Library code shared between kernel and user programs.
38 lib_SRC = lib/debug.c # Debug helpers.
39 lib_SRC += lib/random.c # Pseudo-random numbers.
40 lib_SRC += lib/stdio.c # I/O library.
41 lib_SRC += lib/stdlib.c # Utility functions.
42 lib_SRC += lib/string.c # String functions.
44 # Kernel-specific library code.
45 lib_kernel_SRC += lib/kernel/list.c # Doubly-linked lists.
46 lib_kernel_SRC += lib/kernel/bitmap.c # Bitmaps.
47 lib_kernel_SRC += lib/kernel/hash.c # Hash tables.
48 lib_kernel_SRC += lib/kernel/printf.c # Kernel printf().
51 filesys_SRC = filesys/filesys.c # Filesystem core.
52 filesys_SRC += filesys/file.c # Files.
53 filesys_SRC += filesys/directory.c # Directories.
54 filesys_SRC += filesys/filehdr.c # File headers (inodes).
55 filesys_SRC += filesys/fsutil.c # Utilities.
58 userprog_SRC = userprog/addrspace.c # Address spaces.
59 userprog_SRC += userprog/exception.c # User exception handler.
60 userprog_SRC += userprog/syscall.c # System call handler.
61 userprog_SRC += userprog/gdt.c # GDT initialization.
62 userprog_SRC += userprog/tss.c # TSS management.
64 SOURCES = $(foreach dir,$(SUBDIRS),$($(subst /,_,$(dir))_SRC))
65 OBJECTS = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(SOURCES)))
66 DEPENDS = $(patsubst %.o,%.d,$(OBJECTS))
70 threads/intr-stubs.S: threads/intr-stubs.pl threads/loader.h
73 threads/kernel.lds.s: CPPFLAGS += -P -C
74 threads/kernel.lds.s: threads/kernel.lds.S threads/loader.h
76 kernel.o: threads/kernel.lds.s $(OBJECTS)
77 ld -T $< -o $@ $(OBJECTS) `$(CC) -print-libgcc-file-name`
80 objcopy -O binary -R .note -R .comment -S $< $@.tmp
81 ../../pad 4096 < $@.tmp > $@
84 threads/loader.o: threads/loader.S kernel.bin
85 $(CC) -c $< -o $@ $(ASFLAGS) -DKERNEL_LOAD_PAGES=`perl -e 'print +(-s "kernel.bin") / 4096;'`
87 loader.bin: threads/loader.o
88 ld -N -e start -Ttext 0x7c00 --oformat binary -o $@ $<
90 os.dsk: loader.bin kernel.bin
94 rm -f $(OBJECTS) $(DEPENDS)
95 rm -f threads/intr-stubs.S threads/loader.o
96 rm -f kernel.o kernel.lds.s
97 rm -f kernel.bin loader.bin