Use runtime options instead of conditional compilation for MLFQS,
[pintos-anon] / src / Makefile.build
1 # -*- makefile -*-
2
3 include ../Make.vars
4 include ../../Make.config
5
6 VPATH = ../..
7
8 # Compiler and assembler options.
9 DEFINES += -DKERNEL
10 CPPFLAGS = -nostdinc -I../.. -I- -I../../lib -I../../lib/kernel
11
12 # Core kernel.
13 threads_SRC  = threads/init.c           # Main program.
14 threads_SRC += threads/thread.c         # Thread management core.
15 threads_SRC += threads/switch.S         # Thread switch routine.
16 threads_SRC += threads/interrupt.c      # Interrupt core.
17 threads_SRC += threads/intr-stubs.S     # Interrupt stubs.
18 threads_SRC += threads/synch.c          # Synchronization.
19 threads_SRC += threads/palloc.c         # Page allocator.
20 threads_SRC += threads/malloc.c         # Subpage allocator.
21 threads_SRC += threads/start.S          # Startup code.
22 threads_SRC += threads/test.c           # Test code.
23
24 # Device driver code.
25 devices_SRC  = devices/timer.c          # Timer device.
26 devices_SRC += devices/kbd.c            # Keyboard device.
27 devices_SRC += devices/vga.c            # Video device.
28 devices_SRC += devices/serial.c         # Serial port device.
29 devices_SRC += devices/disk.c           # IDE disk device.
30 devices_SRC += devices/intq.c           # Interrupt queue.
31
32 # Library code shared between kernel and user programs.
33 lib_SRC  = lib/debug.c                  # Debug helpers.
34 lib_SRC += lib/random.c                 # Pseudo-random numbers.
35 lib_SRC += lib/stdio.c                  # I/O library.
36 lib_SRC += lib/stdlib.c                 # Utility functions.
37 lib_SRC += lib/string.c                 # String functions.
38
39 # Kernel-specific library code.
40 lib_kernel_SRC += lib/kernel/list.c     # Doubly-linked lists.
41 lib_kernel_SRC += lib/kernel/bitmap.c   # Bitmaps.
42 lib_kernel_SRC += lib/kernel/hash.c     # Hash tables.
43 lib_kernel_SRC += lib/kernel/console.c  # printf(), putchar().
44
45 # User process code.
46 userprog_SRC  = userprog/process.c      # Process loading.
47 userprog_SRC += userprog/pagedir.c      # Page directories.
48 userprog_SRC += userprog/exception.c    # User exception handler.
49 userprog_SRC += userprog/syscall.c      # System call handler.
50 userprog_SRC += userprog/gdt.c          # GDT initialization.
51 userprog_SRC += userprog/tss.c          # TSS management.
52
53 # No virtual memory code yet.
54 #vm_SRC = vm/filename.c                 # Some file.
55
56 # Filesystem code.
57 filesys_SRC  = filesys/filesys.c        # Filesystem core.
58 filesys_SRC += filesys/file.c           # Files.
59 filesys_SRC += filesys/directory.c      # Directories.
60 filesys_SRC += filesys/inode.c          # File headers.
61 filesys_SRC += filesys/fsutil.c         # Utilities.
62
63 SOURCES = $(foreach dir,$(SUBDIRS),$($(subst /,_,$(dir))_SRC))
64 OBJECTS = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(SOURCES)))
65 DEPENDS = $(patsubst %.o,%.d,$(OBJECTS))
66
67 all: os.dsk
68
69 threads/kernel.lds.s: CPPFLAGS += -P
70 threads/kernel.lds.s: threads/kernel.lds.S threads/loader.h
71
72 kernel.o: threads/kernel.lds.s $(OBJECTS) 
73         $(LD) -T $< -o $@ $(OBJECTS) `$(CC) -print-libgcc-file-name`
74
75 kernel.bin: kernel.o
76         $(OBJCOPY) -O binary -R .note -R .comment -S $< $@.tmp
77         $(DD) if=$@.tmp of=$@ bs=4096 conv=sync
78         $(RM) $@.tmp
79
80 threads/loader.o: threads/loader.S kernel.bin
81         $(CC) -c $< -o $@ $(ASFLAGS) $(CPPFLAGS) $(DEFINES) -DKERNEL_LOAD_PAGES=`perl -e 'print +(-s "kernel.bin") / 4096;'`
82
83 loader.bin: threads/loader.o
84         $(LD) -N -e start -Ttext 0x7c00 --oformat binary -o $@ $<
85
86 os.dsk: loader.bin kernel.bin
87         $(CAT) $^ > $@
88
89 clean:
90         $(RM) -f $(OBJECTS) $(DEPENDS) 
91         $(RM) -f threads/loader.o
92         $(RM) -f kernel.o kernel.lds.s
93         $(RM) -f kernel.bin loader.bin
94
95 Makefile: ../../Makefile.build
96         cp $< $@
97
98 -include $(DEPENDS)