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