Add PC speaker driver and connect it to '\a' in the VGA console.
[pintos-anon] / src / Makefile.build
1 # -*- makefile -*-
2
3 SRCDIR = ../..
4
5 all: os.dsk
6
7 include ../../Make.config
8 include ../Make.vars
9 include ../../tests/Make.tests
10
11 # Compiler and assembler options.
12 os.dsk: CPPFLAGS += -I$(SRCDIR)/lib/kernel
13
14 # Core kernel.
15 threads_SRC  = threads/init.c           # Main program.
16 threads_SRC += threads/thread.c         # Thread management core.
17 threads_SRC += threads/switch.S         # Thread switch routine.
18 threads_SRC += threads/interrupt.c      # Interrupt core.
19 threads_SRC += threads/intr-stubs.S     # Interrupt stubs.
20 threads_SRC += threads/synch.c          # Synchronization.
21 threads_SRC += threads/palloc.c         # Page allocator.
22 threads_SRC += threads/malloc.c         # Subpage allocator.
23 threads_SRC += threads/start.S          # Startup code.
24
25 # Device driver code.
26 devices_SRC  = devices/pit.c            # Programmable interrupt timer chip.
27 devices_SRC += devices/timer.c          # Periodic timer device.
28 devices_SRC += devices/kbd.c            # Keyboard device.
29 devices_SRC += devices/vga.c            # Video device.
30 devices_SRC += devices/serial.c         # Serial port device.
31 devices_SRC += devices/disk.c           # IDE disk device.
32 devices_SRC += devices/input.c          # Serial and keyboard input.
33 devices_SRC += devices/intq.c           # Interrupt queue.
34 devices_SRC += devices/rtc.c            # Real-time clock.
35 devices_SRC += devices/shutdown.c       # Reboot and power off.
36 devices_SRC += devices/speaker.c        # PC speaker.
37
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.
44 lib_SRC += lib/arithmetic.c             # 64-bit arithmetic for GCC.
45 lib_SRC += lib/ustar.c                  # Unix standard tar format utilities.
46
47 # Kernel-specific library code.
48 lib/kernel_SRC  = lib/kernel/debug.c    # Debug helpers.
49 lib/kernel_SRC += lib/kernel/list.c     # Doubly-linked lists.
50 lib/kernel_SRC += lib/kernel/bitmap.c   # Bitmaps.
51 lib/kernel_SRC += lib/kernel/hash.c     # Hash tables.
52 lib/kernel_SRC += lib/kernel/console.c  # printf(), putchar().
53
54 # User process code.
55 userprog_SRC  = userprog/process.c      # Process loading.
56 userprog_SRC += userprog/pagedir.c      # Page directories.
57 userprog_SRC += userprog/exception.c    # User exception handler.
58 userprog_SRC += userprog/syscall.c      # System call handler.
59 userprog_SRC += userprog/gdt.c          # GDT initialization.
60 userprog_SRC += userprog/tss.c          # TSS management.
61
62 # No virtual memory code yet.
63 #vm_SRC = vm/file.c                     # Some file.
64
65 # Filesystem code.
66 filesys_SRC  = filesys/filesys.c        # Filesystem core.
67 filesys_SRC += filesys/free-map.c       # Free sector bitmap.
68 filesys_SRC += filesys/file.c           # Files.
69 filesys_SRC += filesys/directory.c      # Directories.
70 filesys_SRC += filesys/inode.c          # File headers.
71 filesys_SRC += filesys/fsutil.c         # Utilities.
72
73 SOURCES = $(foreach dir,$(KERNEL_SUBDIRS),$($(dir)_SRC))
74 OBJECTS = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(SOURCES)))
75 DEPENDS = $(patsubst %.o,%.d,$(OBJECTS))
76
77 threads/kernel.lds.s: CPPFLAGS += -P
78 threads/kernel.lds.s: threads/kernel.lds.S threads/loader.h
79
80 kernel.o: threads/kernel.lds.s $(OBJECTS) 
81         $(LD) -T $< -o $@ $(OBJECTS)
82
83 kernel.bin: kernel.o
84         $(OBJCOPY) -O binary -R .note -R .comment -S $< $@.tmp
85         dd if=$@.tmp of=$@ bs=4096 conv=sync
86         rm $@.tmp
87
88 threads/loader.o: threads/loader.S kernel.bin
89         $(CC) -c $< -o $@ $(ASFLAGS) $(CPPFLAGS) $(DEFINES) -DKERNEL_LOAD_PAGES=`perl -e 'print +(-s "kernel.bin") / 4096;'`
90
91 loader.bin: threads/loader.o
92         $(LD) -N -e start -Ttext 0x7c00 --oformat binary -o $@ $<
93
94 os.dsk: loader.bin kernel.bin
95         cat $^ > $@
96
97 clean::
98         rm -f $(OBJECTS) $(DEPENDS) 
99         rm -f threads/loader.o threads/kernel.lds.s threads/loader.d
100         rm -f kernel.o kernel.lds.s
101         rm -f kernel.bin loader.bin os.dsk
102         rm -f bochsout.txt bochsrc.txt
103         rm -f results grade
104
105 Makefile: $(SRCDIR)/Makefile.build
106         cp $< $@
107
108 -include $(DEPENDS)